diff --git a/public/assets/creeps/basic/0.png b/public/assets/creeps/basic/0.png index aca768d..05b90b7 100644 Binary files a/public/assets/creeps/basic/0.png and b/public/assets/creeps/basic/0.png differ diff --git a/public/assets/creeps/basic/1.png b/public/assets/creeps/basic/1.png index b060a5a..d978a9a 100644 Binary files a/public/assets/creeps/basic/1.png and b/public/assets/creeps/basic/1.png differ diff --git a/public/assets/creeps/basic/10.png b/public/assets/creeps/basic/10.png index 84e98db..48b4f7d 100644 Binary files a/public/assets/creeps/basic/10.png and b/public/assets/creeps/basic/10.png differ diff --git a/public/assets/creeps/basic/11.png b/public/assets/creeps/basic/11.png index b060a5a..d978a9a 100644 Binary files a/public/assets/creeps/basic/11.png and b/public/assets/creeps/basic/11.png differ diff --git a/public/assets/creeps/basic/2.png b/public/assets/creeps/basic/2.png index 84e98db..48b4f7d 100644 Binary files a/public/assets/creeps/basic/2.png and b/public/assets/creeps/basic/2.png differ diff --git a/public/assets/creeps/basic/3.png b/public/assets/creeps/basic/3.png index 80bb092..06a46df 100644 Binary files a/public/assets/creeps/basic/3.png and b/public/assets/creeps/basic/3.png differ diff --git a/public/assets/creeps/basic/4.png b/public/assets/creeps/basic/4.png index 4c7cd40..139737c 100644 Binary files a/public/assets/creeps/basic/4.png and b/public/assets/creeps/basic/4.png differ diff --git a/public/assets/creeps/basic/5.png b/public/assets/creeps/basic/5.png index 4f35905..fac6dd7 100644 Binary files a/public/assets/creeps/basic/5.png and b/public/assets/creeps/basic/5.png differ diff --git a/public/assets/creeps/basic/6.png b/public/assets/creeps/basic/6.png index 65a8abd..db9bc87 100644 Binary files a/public/assets/creeps/basic/6.png and b/public/assets/creeps/basic/6.png differ diff --git a/public/assets/creeps/basic/7.png b/public/assets/creeps/basic/7.png index 4f35905..fac6dd7 100644 Binary files a/public/assets/creeps/basic/7.png and b/public/assets/creeps/basic/7.png differ diff --git a/public/assets/creeps/basic/8.png b/public/assets/creeps/basic/8.png index 4c7cd40..139737c 100644 Binary files a/public/assets/creeps/basic/8.png and b/public/assets/creeps/basic/8.png differ diff --git a/public/assets/creeps/basic/9.png b/public/assets/creeps/basic/9.png index 80bb092..06a46df 100644 Binary files a/public/assets/creeps/basic/9.png and b/public/assets/creeps/basic/9.png differ diff --git a/public/assets/creeps/cloaker/0.png b/public/assets/creeps/cloaker/0.png new file mode 100644 index 0000000..bcbc3af Binary files /dev/null and b/public/assets/creeps/cloaker/0.png differ diff --git a/public/assets/creeps/cloaker/1.png b/public/assets/creeps/cloaker/1.png new file mode 100644 index 0000000..200bc9e Binary files /dev/null and b/public/assets/creeps/cloaker/1.png differ diff --git a/public/assets/creeps/cloaker/10.png b/public/assets/creeps/cloaker/10.png new file mode 100644 index 0000000..3df93f8 Binary files /dev/null and b/public/assets/creeps/cloaker/10.png differ diff --git a/public/assets/creeps/cloaker/11.png b/public/assets/creeps/cloaker/11.png new file mode 100644 index 0000000..2512c1c Binary files /dev/null and b/public/assets/creeps/cloaker/11.png differ diff --git a/public/assets/creeps/cloaker/2.png b/public/assets/creeps/cloaker/2.png new file mode 100644 index 0000000..5e0d41c Binary files /dev/null and b/public/assets/creeps/cloaker/2.png differ diff --git a/public/assets/creeps/cloaker/3.png b/public/assets/creeps/cloaker/3.png new file mode 100644 index 0000000..779efea Binary files /dev/null and b/public/assets/creeps/cloaker/3.png differ diff --git a/public/assets/creeps/cloaker/4.png b/public/assets/creeps/cloaker/4.png new file mode 100644 index 0000000..95924e0 Binary files /dev/null and b/public/assets/creeps/cloaker/4.png differ diff --git a/public/assets/creeps/cloaker/5.png b/public/assets/creeps/cloaker/5.png new file mode 100644 index 0000000..56ce34e Binary files /dev/null and b/public/assets/creeps/cloaker/5.png differ diff --git a/public/assets/creeps/cloaker/6.png b/public/assets/creeps/cloaker/6.png new file mode 100644 index 0000000..da52a20 Binary files /dev/null and b/public/assets/creeps/cloaker/6.png differ diff --git a/public/assets/creeps/cloaker/7.png b/public/assets/creeps/cloaker/7.png new file mode 100644 index 0000000..4baad15 Binary files /dev/null and b/public/assets/creeps/cloaker/7.png differ diff --git a/public/assets/creeps/cloaker/8.png b/public/assets/creeps/cloaker/8.png new file mode 100644 index 0000000..5030dca Binary files /dev/null and b/public/assets/creeps/cloaker/8.png differ diff --git a/public/assets/creeps/cloaker/9.png b/public/assets/creeps/cloaker/9.png new file mode 100644 index 0000000..4ac8690 Binary files /dev/null and b/public/assets/creeps/cloaker/9.png differ diff --git a/public/assets/creeps/demon/0.png b/public/assets/creeps/demon/0.png new file mode 100644 index 0000000..4981186 Binary files /dev/null and b/public/assets/creeps/demon/0.png differ diff --git a/public/assets/creeps/demon/1.png b/public/assets/creeps/demon/1.png new file mode 100644 index 0000000..c082f4d Binary files /dev/null and b/public/assets/creeps/demon/1.png differ diff --git a/public/assets/creeps/demon/2.png b/public/assets/creeps/demon/2.png new file mode 100644 index 0000000..284d170 Binary files /dev/null and b/public/assets/creeps/demon/2.png differ diff --git a/public/assets/creeps/demon/3.png b/public/assets/creeps/demon/3.png new file mode 100644 index 0000000..22e9cc8 Binary files /dev/null and b/public/assets/creeps/demon/3.png differ diff --git a/public/assets/creeps/demon/4.png b/public/assets/creeps/demon/4.png new file mode 100644 index 0000000..14e592a Binary files /dev/null and b/public/assets/creeps/demon/4.png differ diff --git a/public/assets/creeps/demon/5.png b/public/assets/creeps/demon/5.png new file mode 100644 index 0000000..0590e06 Binary files /dev/null and b/public/assets/creeps/demon/5.png differ diff --git a/public/assets/creeps/demon/6.png b/public/assets/creeps/demon/6.png new file mode 100644 index 0000000..d59ee3e Binary files /dev/null and b/public/assets/creeps/demon/6.png differ diff --git a/public/assets/creeps/demon/7.png b/public/assets/creeps/demon/7.png new file mode 100644 index 0000000..f40d8ab Binary files /dev/null and b/public/assets/creeps/demon/7.png differ diff --git a/public/assets/creeps/maker/1.png b/public/assets/creeps/maker/1.png new file mode 100644 index 0000000..042a582 Binary files /dev/null and b/public/assets/creeps/maker/1.png differ diff --git a/public/assets/creeps/quick/10.png b/public/assets/creeps/maker/10.png similarity index 98% rename from public/assets/creeps/quick/10.png rename to public/assets/creeps/maker/10.png index aa2c1c5..55fa573 100644 Binary files a/public/assets/creeps/quick/10.png and b/public/assets/creeps/maker/10.png differ diff --git a/public/assets/creeps/quick/11.png b/public/assets/creeps/maker/11.png similarity index 98% rename from public/assets/creeps/quick/11.png rename to public/assets/creeps/maker/11.png index ebf3fbf..042a582 100644 Binary files a/public/assets/creeps/quick/11.png and b/public/assets/creeps/maker/11.png differ diff --git a/public/assets/creeps/maker/2.png b/public/assets/creeps/maker/2.png new file mode 100644 index 0000000..55fa573 Binary files /dev/null and b/public/assets/creeps/maker/2.png differ diff --git a/public/assets/creeps/maker/3.png b/public/assets/creeps/maker/3.png new file mode 100644 index 0000000..59275bc Binary files /dev/null and b/public/assets/creeps/maker/3.png differ diff --git a/public/assets/creeps/maker/4.png b/public/assets/creeps/maker/4.png new file mode 100644 index 0000000..e120c5c Binary files /dev/null and b/public/assets/creeps/maker/4.png differ diff --git a/public/assets/creeps/maker/5.png b/public/assets/creeps/maker/5.png new file mode 100644 index 0000000..510cbc1 Binary files /dev/null and b/public/assets/creeps/maker/5.png differ diff --git a/public/assets/creeps/maker/6.png b/public/assets/creeps/maker/6.png new file mode 100644 index 0000000..3ded504 Binary files /dev/null and b/public/assets/creeps/maker/6.png differ diff --git a/public/assets/creeps/maker/7.png b/public/assets/creeps/maker/7.png new file mode 100644 index 0000000..510cbc1 Binary files /dev/null and b/public/assets/creeps/maker/7.png differ diff --git a/public/assets/creeps/quick/8.png b/public/assets/creeps/maker/8.png similarity index 98% rename from public/assets/creeps/quick/8.png rename to public/assets/creeps/maker/8.png index fa89fb3..e120c5c 100644 Binary files a/public/assets/creeps/quick/8.png and b/public/assets/creeps/maker/8.png differ diff --git a/public/assets/creeps/quick/9.png b/public/assets/creeps/maker/9.png similarity index 98% rename from public/assets/creeps/quick/9.png rename to public/assets/creeps/maker/9.png index d5778d8..59275bc 100644 Binary files a/public/assets/creeps/quick/9.png and b/public/assets/creeps/maker/9.png differ diff --git a/public/assets/creeps/quick/0.png b/public/assets/creeps/quick/0.png index 946b183..516c3c1 100644 Binary files a/public/assets/creeps/quick/0.png and b/public/assets/creeps/quick/0.png differ diff --git a/public/assets/creeps/quick/1.png b/public/assets/creeps/quick/1.png index ebf3fbf..409cd58 100644 Binary files a/public/assets/creeps/quick/1.png and b/public/assets/creeps/quick/1.png differ diff --git a/public/assets/creeps/quick/2.png b/public/assets/creeps/quick/2.png index aa2c1c5..90d2e95 100644 Binary files a/public/assets/creeps/quick/2.png and b/public/assets/creeps/quick/2.png differ diff --git a/public/assets/creeps/quick/3.png b/public/assets/creeps/quick/3.png index d5778d8..83250d4 100644 Binary files a/public/assets/creeps/quick/3.png and b/public/assets/creeps/quick/3.png differ diff --git a/public/assets/creeps/quick/4.png b/public/assets/creeps/quick/4.png index fa89fb3..f3f6d65 100644 Binary files a/public/assets/creeps/quick/4.png and b/public/assets/creeps/quick/4.png differ diff --git a/public/assets/creeps/quick/5.png b/public/assets/creeps/quick/5.png index 5851161..046d3a4 100644 Binary files a/public/assets/creeps/quick/5.png and b/public/assets/creeps/quick/5.png differ diff --git a/public/assets/creeps/quick/6.png b/public/assets/creeps/quick/6.png index 195f03a..8038456 100644 Binary files a/public/assets/creeps/quick/6.png and b/public/assets/creeps/quick/6.png differ diff --git a/public/assets/creeps/quick/7.png b/public/assets/creeps/quick/7.png index 5851161..65f4bbe 100644 Binary files a/public/assets/creeps/quick/7.png and b/public/assets/creeps/quick/7.png differ diff --git a/public/assets/creeps/tank/0.png b/public/assets/creeps/tank/0.png index a8aed52..f409430 100644 Binary files a/public/assets/creeps/tank/0.png and b/public/assets/creeps/tank/0.png differ diff --git a/public/assets/creeps/tank/1.png b/public/assets/creeps/tank/1.png index fbb5014..469e13d 100644 Binary files a/public/assets/creeps/tank/1.png and b/public/assets/creeps/tank/1.png differ diff --git a/public/assets/creeps/tank/10.png b/public/assets/creeps/tank/10.png index a652962..c67f03f 100644 Binary files a/public/assets/creeps/tank/10.png and b/public/assets/creeps/tank/10.png differ diff --git a/public/assets/creeps/tank/11.png b/public/assets/creeps/tank/11.png index fbb5014..469e13d 100644 Binary files a/public/assets/creeps/tank/11.png and b/public/assets/creeps/tank/11.png differ diff --git a/public/assets/creeps/tank/2.png b/public/assets/creeps/tank/2.png index a652962..c67f03f 100644 Binary files a/public/assets/creeps/tank/2.png and b/public/assets/creeps/tank/2.png differ diff --git a/public/assets/creeps/tank/3.png b/public/assets/creeps/tank/3.png index f6da5a0..ea50556 100644 Binary files a/public/assets/creeps/tank/3.png and b/public/assets/creeps/tank/3.png differ diff --git a/public/assets/creeps/tank/4.png b/public/assets/creeps/tank/4.png index 7df3630..ee42532 100644 Binary files a/public/assets/creeps/tank/4.png and b/public/assets/creeps/tank/4.png differ diff --git a/public/assets/creeps/tank/5.png b/public/assets/creeps/tank/5.png index 027af78..88404b0 100644 Binary files a/public/assets/creeps/tank/5.png and b/public/assets/creeps/tank/5.png differ diff --git a/public/assets/creeps/tank/6.png b/public/assets/creeps/tank/6.png index edac5a5..1e04a28 100644 Binary files a/public/assets/creeps/tank/6.png and b/public/assets/creeps/tank/6.png differ diff --git a/public/assets/creeps/tank/7.png b/public/assets/creeps/tank/7.png index 537912d..88404b0 100644 Binary files a/public/assets/creeps/tank/7.png and b/public/assets/creeps/tank/7.png differ diff --git a/public/assets/creeps/tank/8.png b/public/assets/creeps/tank/8.png index 3ba4085..ee42532 100644 Binary files a/public/assets/creeps/tank/8.png and b/public/assets/creeps/tank/8.png differ diff --git a/public/assets/creeps/tank/9.png b/public/assets/creeps/tank/9.png index 9e6e707..6531367 100644 Binary files a/public/assets/creeps/tank/9.png and b/public/assets/creeps/tank/9.png differ diff --git a/public/assets/json/Creeps.json b/public/assets/json/Creeps.json index e844c16..7eab6fa 100644 --- a/public/assets/json/Creeps.json +++ b/public/assets/json/Creeps.json @@ -5,7 +5,7 @@ "textureArrayLength": 12, "stats": { "health": 5, - "speed": 2.4, + "speed": 4, "special": null, "resistance": { "physical": 0, @@ -19,9 +19,9 @@ { "name": "quick", "textures": [], - "textureArrayLength": 12, + "textureArrayLength": 8, "stats": { - "health": 3, + "health": 2, "speed": 6, "special": null, "resistance": { @@ -38,8 +38,8 @@ "textures": [], "textureArrayLength": 12, "stats": { - "health": 10, - "speed": 2.4, + "health": 12, + "speed": 2, "special": null, "resistance": { "physical": 0, diff --git a/public/assets/json/Gems.json b/public/assets/json/Gems.json index aab44ba..d41a211 100644 --- a/public/assets/json/Gems.json +++ b/public/assets/json/Gems.json @@ -2,6 +2,7 @@ { "name": "Fire Gem", "description": "Forged from molten lava, the Fire Gem imbues your tower's attacks and adds 50% extra fire damage. It can be merged with any gem and is common. This text shouldn't be long.", + "color": "red", "type": "Fire", "totalLevels": 2, "textures": [], @@ -11,7 +12,7 @@ "genericImprovements": [ { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -19,7 +20,7 @@ }, { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -46,6 +47,7 @@ { "name": "Yeti Gem", "description": "Yeti gem description. Something something, write this while drunk or something.", + "color": "dodgerblue", "type": "Yeti", "totalLevels": 2, "textures": [], @@ -55,7 +57,7 @@ "genericImprovements": [ { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -63,7 +65,7 @@ }, { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -90,6 +92,7 @@ { "name": "Titalium Gem", "description": "Titalium gem description. Something something zombie creeps working for you something something.", + "color": "pink", "type": "Titalium", "totalLevels": 3, "textures": [], @@ -99,7 +102,7 @@ "genericImprovements": [ { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -107,7 +110,7 @@ }, { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0, "timeToLiveUp": 0, "pierceUp": 1, @@ -115,7 +118,7 @@ }, { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0, "timeToLiveUp": 0, "pierceUp": 1, @@ -149,6 +152,7 @@ { "name": "Soulforge Gem", "description": "Soulforge gem description, have to write later.", + "color": "gray", "type": "Soulforge", "totalLevels": 2, "textures": [], @@ -158,7 +162,7 @@ "genericImprovements": [ { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, @@ -166,7 +170,7 @@ }, { "damageUp": 2, - "attackSpeedUp": 100, + "attackSpeedUp": 10, "rangeUp": 0.5, "timeToLiveUp": 0, "pierceUp": 1, diff --git a/public/assets/json/Towers.json b/public/assets/json/Towers.json index 1a609f7..34a088b 100644 --- a/public/assets/json/Towers.json +++ b/public/assets/json/Towers.json @@ -9,26 +9,30 @@ "description": "The building block of society, nothing more basic exists.", "stats": { "damage": 2, - "cooldown": 60, + "cooldown": 120, "gemSlotsAmount": 2, "cost": 100, - "range": 3 + "range": 3, + "timeToLive": 120, + "pierce": 1 } }, { "name": "Circle Tower", - "behaviour": "BasicTowerBehaviour", + "behaviour": "CircleTowerBehaviour", "sprite": "circle_tower", "texture": null, "projectileTextures": [], "projectileTexturesArrayLength": 4, "description": "If you feel a little circular.", "stats": { - "damage": 6, - "cooldown": 180, + "damage": 2, + "cooldown": 120, "gemSlotsAmount": 3, "cost": 125, - "range": 3 + "range": 2, + "timeToLive": 8, + "pierce": 30 } } ] diff --git a/src/classes/Bastion.ts b/src/classes/Bastion.ts index 179cf49..b277cf9 100644 --- a/src/classes/Bastion.ts +++ b/src/classes/Bastion.ts @@ -36,7 +36,7 @@ export class Engine { Engine.NotificationManager.Notify('Loaded testing suite.', 'danger'); Engine.TowerManager.ToggleChoosingTowerLocation('RESET'); - Engine.TowerManager.PlaceTower(GameAssets.Towers[1], 8, 10, GameAssets.Towers[0].behaviour, true); + Engine.TowerManager.PlaceTower(GameAssets.Towers[1], 6, 10, GameAssets.Towers[1].behaviour, true); for (let i = 0; i < 29; i++) { this.GameScene.MissionStats.giveGem(new Gem(i % 4), true); } diff --git a/src/classes/Definitions.ts b/src/classes/Definitions.ts index 0d44771..b33ec4f 100644 --- a/src/classes/Definitions.ts +++ b/src/classes/Definitions.ts @@ -68,11 +68,14 @@ export type TowerStatsDefinition = { gemSlotsAmount: number; cost: number; range: number; + timeToLive: number; + pierce: number; }; export type GemDefinition = { name: string; description: string; + color: PIXI.ColorSource; type: GemType; totalLevels: number; textures: PIXI.Texture[]; diff --git a/src/classes/GameObject.ts b/src/classes/GameObject.ts index 7b7963b..11a576b 100644 --- a/src/classes/GameObject.ts +++ b/src/classes/GameObject.ts @@ -24,6 +24,7 @@ export default abstract class GameObject { } public copyContainerToBB() { + if (this.container == null) return null; this.bb.x = this.container.x; this.bb.y = this.container.y; this.bb.width = this.container.width; diff --git a/src/classes/game/Projectile.ts b/src/classes/game/Projectile.ts index 62300e5..8be5852 100644 --- a/src/classes/game/Projectile.ts +++ b/src/classes/game/Projectile.ts @@ -19,12 +19,16 @@ export default class Projectile extends GameObject { public angle: number; public speed: number; public damage: number; - public timeToLive: number = 1; + public pierce: number = 1; + public timeToLive: number; public parent: Tower; - constructor(x, y, textures, angle, damage, tint, tower) { + private collidedCreepIDs = []; + constructor(x, y, textures, angle, damage, tint, tower: Tower) { super(); this.x = x; this.y = y; + this.timeToLive = tower.computedTimeToLive; + this.pierce = tower.computedPierce; this.parent = tower; this.damage = damage; this.sprite = new PIXI.AnimatedSprite({ textures: textures, scale: 0.25, rotation: angle }); @@ -46,13 +50,19 @@ export default class Projectile extends GameObject { public update(elapsedMS) { if (this.deleteMe) return; - if (this.x > 2000 || this.x < 0 || this.y > 2000 || this.y < 0 || this.timeToLive <= 0) return this.destroy(); + if (this.x > 2000 || this.x < 0 || this.y > 2000 || this.y < 0 || this.pierce <= 0 || this.timeToLive <= 0) + return this.destroy(); + this.timeToLive--; Engine.Grid.creeps.forEach((creep) => { - if (this.timeToLive <= 0) return; - if (creep.container && this.checkCollision(creep)) { - this.timeToLive--; - this.onCollide(creep); - return; + if (this.pierce <= 0) return; + if (creep && creep.container && this.checkCollision(creep)) { + let exists = this.collidedCreepIDs.find((c) => creep.id == c.id); + if (!exists) { + this.collidedCreepIDs.push(creep); + this.pierce--; + this.onCollide(creep); + return; + } } }); this.x += Math.cos(this.angle) * this.speed * elapsedMS; @@ -67,7 +77,8 @@ export default class Projectile extends GameObject { } public checkCollision(creep: Creep) { - if (creep == null) return; + console.debug(creep); + if (creep == null || creep.container == null || creep.container._position == null) return; let mybb = this.copyContainerToBB(); let otherbb = creep.copyContainerToBB(); return mybb.getBounds().intersects(otherbb.getBounds()); diff --git a/src/classes/game/Tower.ts b/src/classes/game/Tower.ts index 620543f..a253d1e 100644 --- a/src/classes/game/Tower.ts +++ b/src/classes/game/Tower.ts @@ -1,13 +1,13 @@ import { Engine } from '../Bastion'; import * as PIXI from 'pixi.js'; import GameObject from '../GameObject'; -import { TowerDefinition } from '../Definitions'; +import { GemType, TowerDefinition } from '../Definitions'; import { Cell } from './Grid'; import { TowerBehaviours } from './TowerManager'; import Projectile, { calculateAngleToPoint } from './Projectile'; import Creep from './Creep'; import Gem from './Gem'; -import { BasicTowerBehaviour } from './TowerBehaviours'; +import { BasicTowerBehaviour, CircleTowerBehaviour } from './TowerBehaviours'; export function distance(x1, y1, x2, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); @@ -25,6 +25,10 @@ export class Tower extends GameObject { public ticksUntilNextShot: number; public graphics: PIXI.Graphics = new PIXI.Graphics(); public computedDamageToDeal: number; + public computedAttackSpeed: number; + public computedRange: number; + public computedTimeToLive: number; + public computedPierce: number; public parent: Cell; constructor(row, column, texture, definition, behaviour) { @@ -56,14 +60,13 @@ export class Tower extends GameObject { Engine.Grid.gridInteractionEnabled && !Engine.GameScene.towerPanel.isShown ) - this.parent.showRangePreview(false, this.definition.stats.range); + this.parent.showRangePreview(false, this.computedRange); }; private onParentCellLeave = (e) => { this.graphics.clear(); }; public SlotGem(gem: Gem, index: number) { - console.log('ATTEMPTING TO SLOT ', gem, index); this.slottedGems[index] = gem; Engine.GameScene.towerPanel.Hide(); Engine.GameScene.towerPanel.Show(this); @@ -92,25 +95,37 @@ export class Tower extends GameObject { const y = creep.y; const towerX = this.column * Engine.GridCellSize + Engine.GridCellSize / 2; const towerY = this.row * Engine.GridCellSize + Engine.GridCellSize / 2; - const radius = this.definition.stats.range * Engine.GridCellSize; + const radius = this.computedRange * Engine.GridCellSize; const d = distance(towerX, towerY, x, y); return d < radius + (Engine.GridCellSize * 2) / 3; }); } - public Shoot(creep: Creep) { + public Shoot(angle) { let x = this.column * Engine.GridCellSize + Engine.GridCellSize / 2; let y = this.row * Engine.GridCellSize + Engine.GridCellSize / 2; - let angle = calculateAngleToPoint(x, y, creep.x, creep.y); - let tint = 0xffffff; + let combinedTint = 0xffffff; this.slottedGems.forEach((gem) => { - if (gem.definition.type.toString() == 'Fire') tint = 0xff0000; + let rgb = new PIXI.Color(gem.definition.color).toRgb(); + combinedTint = + ((combinedTint & 0xff0000) + (rgb.r << 16)) | + ((combinedTint & 0x00ff00) + (rgb.g << 8)) | + ((combinedTint & 0x0000ff) + rgb.b); }); - this.projectiles.push( - new Projectile(x, y, this.definition.projectileTextures, angle, this.computedDamageToDeal, tint, this) + let proj = new Projectile( + x, + y, + this.definition.projectileTextures, + angle, + this.computedDamageToDeal, + combinedTint, + this ); + this.projectiles.push(proj); + return proj; } public update(elapsedMS: any): void { if (this.behaviour == TowerBehaviours.BasicTowerBehaviour) BasicTowerBehaviour(this, elapsedMS); + if (this.behaviour == TowerBehaviours.CircleTowerBehaviour) CircleTowerBehaviour(this, elapsedMS); } public destroy(): void { diff --git a/src/classes/game/TowerBehaviours.ts b/src/classes/game/TowerBehaviours.ts index 7f7d8d4..fbc321c 100644 --- a/src/classes/game/TowerBehaviours.ts +++ b/src/classes/game/TowerBehaviours.ts @@ -1,3 +1,5 @@ +import { Engine } from '../Bastion'; +import { calculateAngleToPoint } from './Projectile'; import { Tower } from './Tower'; /** @@ -26,10 +28,24 @@ function projectileCheck(tower: Tower, elapsedMS: number) { */ export function computeGemImprovements(tower: Tower) { let gemDamage = 0; + let gemAttackSpeedUp = 0; + let gemRangeUp = 0; + let gemTimeToLiveUp = 0; + let gemPierceUp = 0; + tower.slottedGems.forEach((gem) => { - gemDamage += gem.currentGemImprovement().damageUp; + let ccurrentGemImprovements = gem.currentGemImprovement(); + gemDamage += ccurrentGemImprovements.damageUp; + gemAttackSpeedUp += ccurrentGemImprovements.attackSpeedUp; + gemRangeUp += ccurrentGemImprovements.rangeUp; + gemTimeToLiveUp += ccurrentGemImprovements.timeToLiveUp; + gemPierceUp += ccurrentGemImprovements.pierceUp; }); tower.computedDamageToDeal = tower.definition.stats.damage + gemDamage; + tower.computedAttackSpeed = tower.definition.stats.cooldown - gemAttackSpeedUp; + tower.computedRange = tower.definition.stats.range + gemRangeUp; + tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp; + tower.computedPierce = tower.definition.stats.pierce + gemPierceUp; } /** @@ -46,9 +62,34 @@ export function BasicTowerBehaviour(tower: Tower, elapsedMS: number) { let creepsInRange = tower.GetCreepsInRange(); if (creepsInRange.length > 0) { let focus = creepsInRange[0]; - if (tower.ticksUntilNextShot == 0) { - tower.ticksUntilNextShot = tower.definition.stats.cooldown; - tower.Shoot(focus); + if (tower.ticksUntilNextShot <= 0) { + let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2; + let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2; + tower.ticksUntilNextShot = tower.computedAttackSpeed; + tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y)); + } + } +} + +export function CircleTowerBehaviour(tower: Tower, elapsedMS: number) { + if (tower.ticksUntilNextShot % 2 == 0) computeGemImprovements(tower); + projectileCheck(tower, elapsedMS); + if (tower.ticksUntilNextShot > 0) tower.ticksUntilNextShot--; + let creepsInRange = tower.GetCreepsInRange(); + if (creepsInRange.length > 0) { + let focus = creepsInRange[0]; + if (tower.ticksUntilNextShot <= 0) { + tower.ticksUntilNextShot = tower.computedAttackSpeed; + let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2; + let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2; + tower.Shoot(calculateAngleToPoint(x, y, x, y + 10)); // Up + tower.Shoot(calculateAngleToPoint(x, y, x + 10, y)); // Right + tower.Shoot(calculateAngleToPoint(x, y, x - 10, y)); // Left + tower.Shoot(calculateAngleToPoint(x, y, x, y - 10)); // Down + tower.Shoot(calculateAngleToPoint(x, y, x + 10, y + 10)); // Up right + tower.Shoot(calculateAngleToPoint(x, y, x - 10, y + 10)); // Up left + tower.Shoot(calculateAngleToPoint(x, y, x - 10, y - 10)); // Down left + tower.Shoot(calculateAngleToPoint(x, y, x + 10, y - 10)); // Down right } } } diff --git a/src/classes/game/TowerManager.ts b/src/classes/game/TowerManager.ts index 1e425d9..967f547 100644 --- a/src/classes/game/TowerManager.ts +++ b/src/classes/game/TowerManager.ts @@ -8,6 +8,7 @@ import { GridEvents, TowerEvents } from '../Events'; export enum TowerBehaviours { BasicTowerBehaviour = 'BasicTowerBehaviour', + CircleTowerBehaviour = 'CircleTowerBehaviour', } export default class TowerManager { diff --git a/src/classes/gui/TowerPanel.ts b/src/classes/gui/TowerPanel.ts index c090ebf..ddfde88 100644 --- a/src/classes/gui/TowerPanel.ts +++ b/src/classes/gui/TowerPanel.ts @@ -246,14 +246,14 @@ export default class TowerPanel extends GuiObject { } else { this.ShowLeft(); } - tower.parent.showRangePreview(false, tower.definition.stats.range); + tower.parent.showRangePreview(false, tower.computedRange); } private SetContent(tower: Tower) { this.titleText.text = tower.definition.name; this.damageText.text = 'Deals ' + tower.computedDamageToDeal + ' damage'; this.totalDamage.text = 'Damage dealt: ' + tower.damageDealt + ' damage'; this.attackSpeedText.x = this.damageText.width + 10; - this.attackSpeedText.text = ` every ${Math.floor(tower.definition.stats.cooldown / 60)}s`; + this.attackSpeedText.text = ` every ${Math.floor((tower.computedAttackSpeed / 60) * 100) / 100}s`; } private ShowLeft() { this.towerPanel.x = -100; @@ -270,7 +270,7 @@ export default class TowerPanel extends GuiObject { public Hide() { this.isShown = false; this.container.alpha = 0; - this.container.x = GameUIConstants.SidebarRect.x + 10; + this.container.x = -1000; Engine.Grid.rangePreview.clear(); } }