add more towers, change some things

This commit is contained in:
koneko 2025-02-12 23:37:51 +01:00
parent 4d98b82f3a
commit 9c053ece61
34 changed files with 332 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -4,6 +4,7 @@
"behaviour": "BasicTowerBehaviour", "behaviour": "BasicTowerBehaviour",
"sprite": "basic_tower", "sprite": "basic_tower",
"texture": null, "texture": null,
"projectile": "white",
"projectileTextures": [], "projectileTextures": [],
"projectileTexturesArrayLength": 5, "projectileTexturesArrayLength": 5,
"description": "The building block of society, nothing more basic exists.", "description": "The building block of society, nothing more basic exists.",
@ -22,6 +23,121 @@
"behaviour": "CircleTowerBehaviour", "behaviour": "CircleTowerBehaviour",
"sprite": "circle_tower", "sprite": "circle_tower",
"texture": null, "texture": null,
"projectile": "blue",
"projectileTextures": [],
"projectileTexturesArrayLength": 4,
"description": "If you feel a little circular.",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Electric Tower",
"behaviour": "ElectricTowerBehaviour",
"sprite": "electric_tower",
"texture": null,
"projectile": "yellow",
"projectileTextures": [],
"projectileTexturesArrayLength": 4,
"description": "Think of something",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Quick Tower",
"behaviour": "QuickTowerBehaviour",
"sprite": "quick_tower",
"texture": null,
"projectile": "blue",
"projectileTextures": [],
"projectileTexturesArrayLength": 4,
"description": "",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Strong Tower",
"behaviour": "StrongTowerBehaviour",
"sprite": "strong_tower",
"texture": null,
"projectile": "white",
"projectileTextures": [],
"projectileTexturesArrayLength": 5,
"description": "",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Rail Tower",
"behaviour": "RailTowerBehaviour",
"sprite": "rail_tower",
"texture": null,
"projectile": "red",
"projectileTextures": [],
"projectileTexturesArrayLength": 4,
"description": "If you feel a little circular.",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Trapper Tower",
"behaviour": "TrapperTowerBehaviour",
"sprite": "trapper_tower",
"texture": null,
"projectile": "stone",
"projectileTextures": [],
"projectileTexturesArrayLength": 2,
"description": "If you feel a little circular.",
"stats": {
"damage": 2,
"cooldown": 2000,
"gemSlotsAmount": 3,
"cost": 125,
"range": 2.5,
"timeToLive": 12,
"pierce": 30
}
},
{
"name": "Advanced Tower",
"behaviour": "AdvancedTowerBehaviour",
"sprite": "advanced_tower",
"texture": null,
"projectile": "red",
"projectileTextures": [], "projectileTextures": [],
"projectileTexturesArrayLength": 4, "projectileTexturesArrayLength": 4,
"description": "If you feel a little circular.", "description": "If you feel a little circular.",

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -17,6 +17,7 @@ export default class GameAssets {
public static RedBackground: PIXI.Texture; public static RedBackground: PIXI.Texture;
public static GreenBackground: PIXI.Texture; public static GreenBackground: PIXI.Texture;
public static BlueBackground: PIXI.Texture; public static BlueBackground: PIXI.Texture;
public static YellowBackground: PIXI.Texture;
public static Button01Texture: PIXI.Texture; public static Button01Texture: PIXI.Texture;
public static Button02Texture: PIXI.Texture; public static Button02Texture: PIXI.Texture;
public static ButtonSmallTexture: PIXI.Texture; public static ButtonSmallTexture: PIXI.Texture;
@ -105,6 +106,7 @@ export default class GameAssets {
this.Load('./assets/gui/frame_red.png').then((texture) => (this.RedBackground = texture)), this.Load('./assets/gui/frame_red.png').then((texture) => (this.RedBackground = texture)),
this.Load('./assets/gui/frame_green.png').then((texture) => (this.GreenBackground = texture)), this.Load('./assets/gui/frame_green.png').then((texture) => (this.GreenBackground = texture)),
this.Load('./assets/gui/frame_blue.png').then((texture) => (this.BlueBackground = texture)), this.Load('./assets/gui/frame_blue.png').then((texture) => (this.BlueBackground = texture)),
this.Load('./assets/gui/frame_yellow.png').then((texture) => (this.YellowBackground = texture)),
this.Load('./assets/gui/banner_01.png').then((texture) => (this.BannerGemsmith = texture)), this.Load('./assets/gui/banner_01.png').then((texture) => (this.BannerGemsmith = texture)),
this.Load('./assets/gui/note.png').then((texture) => (this.EndScreenDialog = texture)), this.Load('./assets/gui/note.png').then((texture) => (this.EndScreenDialog = texture)),
this.Load('./assets/gui/main_background.jpg').then((texture) => (this.MainBackground = texture)), this.Load('./assets/gui/main_background.jpg').then((texture) => (this.MainBackground = texture)),
@ -186,7 +188,7 @@ export default class GameAssets {
for (let idx = 0; idx < this.Towers.length; idx++) { for (let idx = 0; idx < this.Towers.length; idx++) {
const tower = this.Towers[idx]; const tower = this.Towers[idx];
for (let i = 0; i < tower.projectileTexturesArrayLength; i++) { for (let i = 0; i < tower.projectileTexturesArrayLength; i++) {
const projTexture = await this.Load(`./assets/projectiles/${tower.sprite}/${i}.png`); const projTexture = await this.Load(`./assets/projectiles/${tower.projectile}/${i}.png`);
tower.projectileTextures[i] = projTexture; tower.projectileTextures[i] = projTexture;
} }
tower.texture = await this.Load(`./assets/towers/${tower.sprite}.png`); tower.texture = await this.Load(`./assets/towers/${tower.sprite}.png`);

View File

@ -56,6 +56,7 @@ export type TowerDefinition = {
behaviour: string; behaviour: string;
sprite: string; sprite: string;
description: string; description: string;
projectile: string;
texture: PIXI.Texture; texture: PIXI.Texture;
projectileTextures: PIXI.Texture[]; projectileTextures: PIXI.Texture[];
projectileTexturesArrayLength: number; projectileTexturesArrayLength: number;
@ -123,4 +124,10 @@ export enum GemType {
export enum TowerType { export enum TowerType {
Basic = 0, Basic = 0,
Circle = 1, Circle = 1,
Electric = 2,
Quick = 3,
Strong = 4,
Rail = 5,
Trapper = 6,
Advanced = 7,
} }

View File

@ -7,7 +7,16 @@ import { TowerBehaviours } from './TowerManager';
import Projectile, { calculateAngleToPoint } from './Projectile'; import Projectile, { calculateAngleToPoint } from './Projectile';
import Creep from './Creep'; import Creep from './Creep';
import Gem from './Gem'; import Gem from './Gem';
import { BasicTowerBehaviour, CircleTowerBehaviour } from './TowerBehaviours'; import {
AdvancedTowerBehaviour,
BasicTowerBehaviour,
CircleTowerBehaviour,
ElectricTowerBehaviour,
QuickTowerBehaviour,
RailTowerBehaviour,
StrongTowerBehaviour,
TrapperTowerBehaviour,
} from './TowerBehaviours';
export function distance(x1, y1, x2, y2) { export function distance(x1, y1, x2, y2) {
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
@ -143,6 +152,12 @@ export class Tower extends GameObject {
} }
if (this.behaviour == TowerBehaviours.BasicTowerBehaviour) BasicTowerBehaviour(this, elapsedMS); if (this.behaviour == TowerBehaviours.BasicTowerBehaviour) BasicTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.CircleTowerBehaviour) CircleTowerBehaviour(this, elapsedMS); if (this.behaviour == TowerBehaviours.CircleTowerBehaviour) CircleTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.ElectricTowerBehaviour) ElectricTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.QuickTowerBehaviour) QuickTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.StrongTowerBehaviour) StrongTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.RailTowerBehaviour) RailTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.TrapperTowerBehaviour) TrapperTowerBehaviour(this, elapsedMS);
if (this.behaviour == TowerBehaviours.AdvancedTowerBehaviour) AdvancedTowerBehaviour(this, elapsedMS);
} }
public destroy(): void { public destroy(): void {

View File

@ -112,3 +112,111 @@ export function CircleTowerBehaviour(tower: Tower, elapsedMS: number) {
} }
} }
} }
export function ElectricTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}
export function QuickTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}
export function StrongTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}
export function RailTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}
export function TrapperTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}
export function AdvancedTowerBehaviour(tower: Tower, elapsedMS: number) {
computeGemImprovements(tower);
projectileCheck(tower, elapsedMS);
if (tower.millisecondsUntilNextShot > 0)
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
let creepsInRange = tower.GetCreepsInRange();
if (creepsInRange.length > 0) {
let focus = creepsInRange[0];
if (tower.millisecondsUntilNextShot <= 0) {
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
tower.millisecondsUntilNextShot = tower.computedCooldown;
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
}
}
}

View File

@ -9,6 +9,12 @@ import { GridEvents, TowerEvents } from '../Events';
export enum TowerBehaviours { export enum TowerBehaviours {
BasicTowerBehaviour = 'BasicTowerBehaviour', BasicTowerBehaviour = 'BasicTowerBehaviour',
CircleTowerBehaviour = 'CircleTowerBehaviour', CircleTowerBehaviour = 'CircleTowerBehaviour',
ElectricTowerBehaviour = 'ElectricTowerBehaviour',
QuickTowerBehaviour = 'QuickTowerBehaviour',
StrongTowerBehaviour = 'StrongTowerBehaviour',
RailTowerBehaviour = 'RailTowerBehaviour',
TrapperTowerBehaviour = 'TrapperTowerBehaviour',
AdvancedTowerBehaviour = 'AdvancedTowerBehaviour',
} }
export default class TowerManager { export default class TowerManager {

View File

@ -122,10 +122,82 @@ export default class TowerTab extends GuiObject {
70, 70,
this.container, this.container,
GameAssets.RedBackground, GameAssets.RedBackground,
'Basic Tower', GameAssets.Towers[0].name,
GameAssets.Towers[0].texture GameAssets.Towers[0].texture
) )
); );
this.towerButtons.push(
new TowerButton(
1,
0,
70,
70,
this.container,
GameAssets.RedBackground,
GameAssets.Towers[1].name,
GameAssets.Towers[1].texture
)
);
this.towerButtons.push(
new TowerButton(
2,
0,
70,
70,
this.container,
GameAssets.BlueBackground,
GameAssets.Towers[2].name,
GameAssets.Towers[2].texture
)
);
this.towerButtons.push(
new TowerButton(
3,
0,
70,
70,
this.container,
GameAssets.BlueBackground,
GameAssets.Towers[3].name,
GameAssets.Towers[3].texture
)
);
this.towerButtons.push(
new TowerButton(
0,
1,
70,
70,
this.container,
GameAssets.GreenBackground,
GameAssets.Towers[4].name,
GameAssets.Towers[4].texture
)
);
this.towerButtons.push(
new TowerButton(
1,
1,
70,
70,
this.container,
GameAssets.GreenBackground,
GameAssets.Towers[5].name,
GameAssets.Towers[5].texture
)
);
this.towerButtons.push(
new TowerButton(
2,
1,
70,
70,
this.container,
GameAssets.YellowBackground,
GameAssets.Towers[6].name,
GameAssets.Towers[6].texture
)
);
this.towerButtons.push( this.towerButtons.push(
new TowerButton( new TowerButton(
3, 3,
@ -133,9 +205,9 @@ export default class TowerTab extends GuiObject {
70, 70,
70, 70,
this.container, this.container,
GameAssets.GreenBackground, GameAssets.YellowBackground,
'Circle Tower', GameAssets.Towers[7].name,
GameAssets.Towers[1].texture GameAssets.Towers[7].texture
) )
); );
} }