basic railgun
This commit is contained in:
parent
abde1a6519
commit
a33912d59d
@ -64,7 +64,7 @@ export default class Projectile extends GameObject {
|
|||||||
|
|
||||||
public update(elapsedMS) {
|
public update(elapsedMS) {
|
||||||
if (this.deleteMe) return;
|
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();
|
return this.destroy();
|
||||||
this.timeToLive -= Engine.GameScene.gameSpeedMultiplier;
|
this.timeToLive -= Engine.GameScene.gameSpeedMultiplier;
|
||||||
Engine.Grid.creeps.forEach((creep) => {
|
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 {
|
export class VisualLightning extends GameObject {
|
||||||
public deleteMe: boolean = false;
|
public deleteMe: boolean = false;
|
||||||
private c: Creep;
|
private c: Creep;
|
||||||
|
@ -4,7 +4,7 @@ import GameObject from '../GameObject';
|
|||||||
import { CreepResistancesDefinition, TowerDefinition } from '../Definitions';
|
import { CreepResistancesDefinition, TowerDefinition } from '../Definitions';
|
||||||
import { Cell } from './Grid';
|
import { Cell } from './Grid';
|
||||||
import { TowerBehaviours } from './TowerManager';
|
import { TowerBehaviours } from './TowerManager';
|
||||||
import Projectile from './Projectile';
|
import Projectile, { RailProjectile } from './Projectile';
|
||||||
import Gem from './Gem';
|
import Gem from './Gem';
|
||||||
import {
|
import {
|
||||||
DebuffTowerBehaviour,
|
DebuffTowerBehaviour,
|
||||||
@ -132,18 +132,34 @@ export class Tower extends GameObject {
|
|||||||
}
|
}
|
||||||
combinedTint = color;
|
combinedTint = color;
|
||||||
}
|
}
|
||||||
let proj = new Projectile(
|
|
||||||
x,
|
let proj;
|
||||||
y,
|
if (this.behaviour == TowerBehaviours.RailTowerBehaviour) {
|
||||||
this.definition.projectileTextures,
|
proj = new RailProjectile(
|
||||||
angle,
|
x,
|
||||||
this.computedDamageToDeal,
|
y,
|
||||||
combinedTint,
|
this.definition.projectileTextures,
|
||||||
this.computedTimeToLive,
|
angle,
|
||||||
this.computedPierce,
|
this.computedDamageToDeal,
|
||||||
this.totalGemResistanceModifications
|
combinedTint,
|
||||||
);
|
this.computedTimeToLive,
|
||||||
const time = new Date().toISOString();
|
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`);
|
// console.log(`${time} ${this.definition.name} shot at ${angle} degrees`);
|
||||||
this.projectiles.push(proj);
|
this.projectiles.push(proj);
|
||||||
return proj;
|
return proj;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user