Implementing fast-forward
This commit is contained in:
parent
5e8b91ed81
commit
1d7b4070f6
@ -9,7 +9,7 @@
|
|||||||
"description": "The building block of society, nothing more basic exists.",
|
"description": "The building block of society, nothing more basic exists.",
|
||||||
"stats": {
|
"stats": {
|
||||||
"damage": 2,
|
"damage": 2,
|
||||||
"cooldown": 120,
|
"cooldown": 2000,
|
||||||
"gemSlotsAmount": 2,
|
"gemSlotsAmount": 2,
|
||||||
"cost": 100,
|
"cost": 100,
|
||||||
"range": 4,
|
"range": 4,
|
||||||
@ -27,7 +27,7 @@
|
|||||||
"description": "If you feel a little circular.",
|
"description": "If you feel a little circular.",
|
||||||
"stats": {
|
"stats": {
|
||||||
"damage": 2,
|
"damage": 2,
|
||||||
"cooldown": 120,
|
"cooldown": 2000,
|
||||||
"gemSlotsAmount": 3,
|
"gemSlotsAmount": 3,
|
||||||
"cost": 125,
|
"cost": 125,
|
||||||
"range": 2.5,
|
"range": 2.5,
|
||||||
|
@ -39,7 +39,7 @@ export default class Projectile extends GameObject {
|
|||||||
super();
|
super();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.timeToLive = timeToLive * (0.9 / 0.1);
|
this.timeToLive = timeToLive;
|
||||||
this.pierce = pierce;
|
this.pierce = pierce;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.gemResistanceModifications = gemResistanceModifications;
|
this.gemResistanceModifications = gemResistanceModifications;
|
||||||
@ -53,7 +53,7 @@ export default class Projectile extends GameObject {
|
|||||||
Engine.GameMaster.currentScene.stage.addChild(this.container);
|
Engine.GameMaster.currentScene.stage.addChild(this.container);
|
||||||
|
|
||||||
this.angle = angle;
|
this.angle = angle;
|
||||||
this.speed = 0.1;
|
this.speed = 0.9;
|
||||||
}
|
}
|
||||||
public destroy(): void {
|
public destroy(): void {
|
||||||
super.destroy();
|
super.destroy();
|
||||||
@ -95,7 +95,7 @@ export default class Projectile extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public checkCollision(creep: Creep) {
|
public checkCollision(creep: Creep) {
|
||||||
console.debug(creep);
|
//console.debug(creep);
|
||||||
if (creep == null || creep.container == null || creep.container._position == null) return;
|
if (creep == null || creep.container == null || creep.container._position == null) return;
|
||||||
let mybb = this.copyContainerToBB();
|
let mybb = this.copyContainerToBB();
|
||||||
let otherbb = creep.copyContainerToBB();
|
let otherbb = creep.copyContainerToBB();
|
||||||
|
@ -24,10 +24,10 @@ export class Tower extends GameObject {
|
|||||||
public projectiles: Projectile[] = [];
|
public projectiles: Projectile[] = [];
|
||||||
public behaviour: string;
|
public behaviour: string;
|
||||||
public sprite: PIXI.Sprite;
|
public sprite: PIXI.Sprite;
|
||||||
public ticksUntilNextShot: number;
|
public millisecondsUntilNextShot: number;
|
||||||
public graphics: PIXI.Graphics = new PIXI.Graphics();
|
public graphics: PIXI.Graphics = new PIXI.Graphics();
|
||||||
public computedDamageToDeal: number;
|
public computedDamageToDeal: number;
|
||||||
public computedAttackSpeed: number;
|
public computedCooldown: number;
|
||||||
public computedRange: number;
|
public computedRange: number;
|
||||||
public computedTimeToLive: number;
|
public computedTimeToLive: number;
|
||||||
public computedPierce: number;
|
public computedPierce: number;
|
||||||
@ -40,7 +40,7 @@ export class Tower extends GameObject {
|
|||||||
this.column = column;
|
this.column = column;
|
||||||
this.behaviour = behaviour;
|
this.behaviour = behaviour;
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
this.ticksUntilNextShot = 0;
|
this.millisecondsUntilNextShot = 0;
|
||||||
this.parent = Engine.Grid.getCellByRowAndCol(row, column);
|
this.parent = Engine.Grid.getCellByRowAndCol(row, column);
|
||||||
this.sprite = new PIXI.Sprite({
|
this.sprite = new PIXI.Sprite({
|
||||||
texture: texture,
|
texture: texture,
|
||||||
@ -127,6 +127,8 @@ export class Tower extends GameObject {
|
|||||||
this.computedPierce,
|
this.computedPierce,
|
||||||
this.totalGemResistanceModifications
|
this.totalGemResistanceModifications
|
||||||
);
|
);
|
||||||
|
const time = new Date().toISOString();
|
||||||
|
console.log(`${time} ${this.definition.name} shot at ${angle} degrees`);
|
||||||
this.projectiles.push(proj);
|
this.projectiles.push(proj);
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ export function computeGemImprovements(tower: Tower) {
|
|||||||
tower.totalGemResistanceModifications.frostfire += gemResMod.frostfire;
|
tower.totalGemResistanceModifications.frostfire += gemResMod.frostfire;
|
||||||
});
|
});
|
||||||
tower.computedDamageToDeal = tower.definition.stats.damage + gemDamage;
|
tower.computedDamageToDeal = tower.definition.stats.damage + gemDamage;
|
||||||
tower.computedAttackSpeed = tower.definition.stats.cooldown - gemAttackSpeedUp;
|
tower.computedCooldown = tower.definition.stats.cooldown - gemAttackSpeedUp;
|
||||||
tower.computedRange = tower.definition.stats.range + gemRangeUp;
|
tower.computedRange = tower.definition.stats.range + gemRangeUp;
|
||||||
tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp;
|
tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp;
|
||||||
tower.computedPierce = tower.definition.stats.pierce + gemPierceUp;
|
tower.computedPierce = tower.definition.stats.pierce + gemPierceUp;
|
||||||
@ -73,30 +73,32 @@ export function computeGemImprovements(tower: Tower) {
|
|||||||
* @param elapsedMS - The elapsed time in milliseconds since the last update.
|
* @param elapsedMS - The elapsed time in milliseconds since the last update.
|
||||||
*/
|
*/
|
||||||
export function BasicTowerBehaviour(tower: Tower, elapsedMS: number) {
|
export function BasicTowerBehaviour(tower: Tower, elapsedMS: number) {
|
||||||
if (tower.ticksUntilNextShot % 2 == 0) computeGemImprovements(tower);
|
computeGemImprovements(tower);
|
||||||
projectileCheck(tower, elapsedMS);
|
projectileCheck(tower, elapsedMS);
|
||||||
if (tower.ticksUntilNextShot > 0) tower.ticksUntilNextShot -= Engine.GameScene.gameSpeedMultiplier;
|
if (tower.millisecondsUntilNextShot > 0)
|
||||||
|
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
|
||||||
let creepsInRange = tower.GetCreepsInRange();
|
let creepsInRange = tower.GetCreepsInRange();
|
||||||
if (creepsInRange.length > 0) {
|
if (creepsInRange.length > 0) {
|
||||||
let focus = creepsInRange[0];
|
let focus = creepsInRange[0];
|
||||||
if (tower.ticksUntilNextShot <= 0) {
|
if (tower.millisecondsUntilNextShot <= 0) {
|
||||||
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
|
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
|
||||||
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
|
let y = tower.row * Engine.GridCellSize + Engine.GridCellSize / 2;
|
||||||
tower.ticksUntilNextShot = tower.computedAttackSpeed / Engine.GameScene.gameSpeedMultiplier;
|
tower.millisecondsUntilNextShot = tower.computedCooldown;
|
||||||
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
|
tower.Shoot(calculateAngleToPoint(x, y, focus.x, focus.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CircleTowerBehaviour(tower: Tower, elapsedMS: number) {
|
export function CircleTowerBehaviour(tower: Tower, elapsedMS: number) {
|
||||||
if (tower.ticksUntilNextShot % 2 == 0) computeGemImprovements(tower);
|
computeGemImprovements(tower);
|
||||||
projectileCheck(tower, elapsedMS);
|
projectileCheck(tower, elapsedMS);
|
||||||
if (tower.ticksUntilNextShot > 0) tower.ticksUntilNextShot -= Engine.GameScene.gameSpeedMultiplier;
|
if (tower.millisecondsUntilNextShot > 0)
|
||||||
|
tower.millisecondsUntilNextShot -= elapsedMS * Engine.GameScene.gameSpeedMultiplier;
|
||||||
let creepsInRange = tower.GetCreepsInRange();
|
let creepsInRange = tower.GetCreepsInRange();
|
||||||
if (creepsInRange.length > 0) {
|
if (creepsInRange.length > 0) {
|
||||||
let focus = creepsInRange[0];
|
let focus = creepsInRange[0];
|
||||||
if (tower.ticksUntilNextShot <= 0) {
|
if (tower.millisecondsUntilNextShot <= 0) {
|
||||||
tower.ticksUntilNextShot = tower.computedAttackSpeed / Engine.GameScene.gameSpeedMultiplier;
|
tower.millisecondsUntilNextShot = tower.computedCooldown;
|
||||||
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
|
let x = tower.column * Engine.GridCellSize + Engine.GridCellSize / 2;
|
||||||
let y = tower.row * 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, y + 10)); // Up
|
||||||
|
@ -341,7 +341,7 @@ export default class TowerPanel extends GuiObject {
|
|||||||
this.damageText.text = 'Deals ' + tower.computedDamageToDeal + ' damage';
|
this.damageText.text = 'Deals ' + tower.computedDamageToDeal + ' damage';
|
||||||
this.totalDamage.text = 'Damage dealt: ' + tower.damageDealt + ' damage';
|
this.totalDamage.text = 'Damage dealt: ' + tower.damageDealt + ' damage';
|
||||||
this.attackSpeedText.x = this.damageText.width + 10;
|
this.attackSpeedText.x = this.damageText.width + 10;
|
||||||
this.attackSpeedText.text = ` every ${Math.floor((tower.computedAttackSpeed / 60) * 100) / 100}s`;
|
this.attackSpeedText.text = ` every ${Math.floor((tower.computedCooldown / 60) * 100) / 100}s`;
|
||||||
|
|
||||||
this.fireResDamage.text = `+${tower.totalGemResistanceModifications.fire * 100}% Fire damage`;
|
this.fireResDamage.text = `+${tower.totalGemResistanceModifications.fire * 100}% Fire damage`;
|
||||||
this.iceResDamage.text = `+${tower.totalGemResistanceModifications.ice * 100}% Ice damage`;
|
this.iceResDamage.text = `+${tower.totalGemResistanceModifications.ice * 100}% Ice damage`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user