diff --git a/src/classes/game/Projectile.ts b/src/classes/game/Projectile.ts index 6ebf97d..27d7063 100644 --- a/src/classes/game/Projectile.ts +++ b/src/classes/game/Projectile.ts @@ -64,7 +64,7 @@ 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.pierce <= 0 || this.timeToLive <= 0) + if (this.x > 1720 || this.x < 0 || this.y > 2000 || this.y < 0 || this.pierce <= 0 || this.timeToLive <= 0) return this.destroy(); this.timeToLive -= Engine.GameScene.gameSpeedMultiplier; Engine.Grid.creeps.forEach((creep) => { @@ -105,6 +105,54 @@ export default class Projectile extends GameObject { } } +export class RailProjectile extends Projectile { + public visuals: PIXI.Sprite[] = []; + public counter: number = 0; + constructor( + x, + y, + textures, + angle, + damage, + tint, + timeToLive, + pierce, + gemResistanceModifications: CreepResistancesDefinition + ) { + super(x, y, textures, angle, damage, tint, timeToLive, pierce, gemResistanceModifications); + this.pierce = 1000; + this.timeToLive = 2000; + } + + public destroy(): void { + super.destroy(); + this.visuals.forEach((visual) => visual.destroy()); + this.visuals = []; + } + public update(elapsedMS) { + super.update(elapsedMS); + if (this.counter == 2) { + this.counter = 0; + let newVisual = new PIXI.Sprite({ + x: this.x, + y: this.y, + rotation: this.angle, + texture: this.sprite.texture, + scale: 0.25, + }); + newVisual.anchor.set(0.5, 0.5); + this.visuals.push(newVisual); + this.visuals.forEach((visual) => { + visual.width -= 4; + visual.height -= 4; + visual.alpha -= 0.05; + if (visual.width <= 0 && visual.height <= 0) visual.destroy(); + }); + Engine.GameScene.stage.addChild(newVisual); + } else this.counter++; + } +} + export class VisualLightning extends GameObject { public deleteMe: boolean = false; private c: Creep; diff --git a/src/classes/game/Tower.ts b/src/classes/game/Tower.ts index 3443383..154545f 100644 --- a/src/classes/game/Tower.ts +++ b/src/classes/game/Tower.ts @@ -4,7 +4,7 @@ import GameObject from '../GameObject'; import { CreepResistancesDefinition, TowerDefinition } from '../Definitions'; import { Cell } from './Grid'; import { TowerBehaviours } from './TowerManager'; -import Projectile from './Projectile'; +import Projectile, { RailProjectile } from './Projectile'; import Gem from './Gem'; import { DebuffTowerBehaviour, @@ -132,18 +132,34 @@ export class Tower extends GameObject { } combinedTint = color; } - let proj = new Projectile( - x, - y, - this.definition.projectileTextures, - angle, - this.computedDamageToDeal, - combinedTint, - this.computedTimeToLive, - this.computedPierce, - this.totalGemResistanceModifications - ); - const time = new Date().toISOString(); + + let proj; + if (this.behaviour == TowerBehaviours.RailTowerBehaviour) { + proj = new RailProjectile( + x, + y, + this.definition.projectileTextures, + angle, + this.computedDamageToDeal, + combinedTint, + this.computedTimeToLive, + this.computedPierce, + this.totalGemResistanceModifications + ); + } else { + proj = new Projectile( + x, + y, + this.definition.projectileTextures, + angle, + this.computedDamageToDeal, + combinedTint, + this.computedTimeToLive, + this.computedPierce, + this.totalGemResistanceModifications + ); + } + // const time = new Date().toISOString(); // console.log(`${time} ${this.definition.name} shot at ${angle} degrees`); this.projectiles.push(proj); return proj;