statistics
This commit is contained in:
parent
547cccd071
commit
aec0821dbb
@ -4,16 +4,15 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
<link href="https://fonts.googleapis.com/css?family=Aclonica" rel="stylesheet" />
|
<title>Bastion: The Watchers Lament</title>
|
||||||
<title>Bastion: The Watcher's Lament</title>
|
<meta property="og:title" content="Bastion: The Watchers Lament" />
|
||||||
<meta property="og:title" content="Bastion: The Watcher's Lament" />
|
|
||||||
<meta
|
<meta
|
||||||
property="og:description"
|
property="og:description"
|
||||||
content="A free, open source, browser based, tower defense game inspired by GemCraft: Frostborn Wrath. Playable NOW on PC!"
|
content="A free, open source, browser based, tower defense game inspired by GemCraft: Frostborn Wrath. Playable NOW on PC!"
|
||||||
/>
|
/>
|
||||||
<meta property="og:image" content="https://bastion.overflow.fun/faivcon.png" />
|
<meta property="og:image" content="https://bastion.overflow.fun/favicon.png" />
|
||||||
<meta property="og:url" content="https://bastion.overflow.fun" />
|
<meta property="og:url" content="https://bastion.overflow.fun" />
|
||||||
<meta name="twitter:title" content="Bastion: The Watcher's Lament" />
|
<meta name="twitter:title" content="Bastion: The Watchers Lament" />
|
||||||
<meta
|
<meta
|
||||||
name="twitter:description"
|
name="twitter:description"
|
||||||
content="A free, open source, browser based, tower defense game inspired by GemCraft: Frostborn Wrath. Playable NOW on PC!"
|
content="A free, open source, browser based, tower defense game inspired by GemCraft: Frostborn Wrath. Playable NOW on PC!"
|
||||||
|
@ -10,9 +10,9 @@ export default class MissionStats extends GameObject {
|
|||||||
private gold: number = 0;
|
private gold: number = 0;
|
||||||
private goldEarned: number = 0;
|
private goldEarned: number = 0;
|
||||||
private goldSpent: number = 0;
|
private goldSpent: number = 0;
|
||||||
private wavesSurvived: number = 0;
|
public damageDealt: number = 0;
|
||||||
private damageDealt: number = 0;
|
public wavesSurvived: number = 0;
|
||||||
private creepsKilled: number = 0;
|
public creepsKilled: number = 0;
|
||||||
private goldText: PIXI.Text;
|
private goldText: PIXI.Text;
|
||||||
private healthText: PIXI.Text;
|
private healthText: PIXI.Text;
|
||||||
private waveText: PIXI.Text;
|
private waveText: PIXI.Text;
|
||||||
@ -44,11 +44,13 @@ export default class MissionStats extends GameObject {
|
|||||||
public earnGold(gold: number) {
|
public earnGold(gold: number) {
|
||||||
this.gold += gold;
|
this.gold += gold;
|
||||||
this.goldText.text = this.gold;
|
this.goldText.text = this.gold;
|
||||||
|
this.goldEarned += gold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public spendGold(amount: number) {
|
public spendGold(amount: number) {
|
||||||
this.gold -= amount;
|
this.gold -= amount;
|
||||||
this.goldText.text = this.gold;
|
this.goldText.text = this.gold;
|
||||||
|
this.goldSpent += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public giveGem(gem: Gem, noNotify?) {
|
public giveGem(gem: Gem, noNotify?) {
|
||||||
@ -82,6 +84,7 @@ export default class MissionStats extends GameObject {
|
|||||||
super();
|
super();
|
||||||
this.hp = initialHP;
|
this.hp = initialHP;
|
||||||
this.gold = initialGold;
|
this.gold = initialGold;
|
||||||
|
this.goldEarned = initialGold;
|
||||||
this.container.x = 0;
|
this.container.x = 0;
|
||||||
this.container.y = 20;
|
this.container.y = 20;
|
||||||
Engine.GameMaster.currentScene.stage.addChild(this.container);
|
Engine.GameMaster.currentScene.stage.addChild(this.container);
|
||||||
@ -161,20 +164,25 @@ export default class MissionStats extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private calculateScore() {
|
private calculateScore() {
|
||||||
const uniqueGems = [];
|
const gems = [];
|
||||||
for (const gem of this.inventory) {
|
for (const gem of this.inventory) {
|
||||||
if (!uniqueGems.includes(gem.definition.name)) {
|
gems.push(gem.definition.name);
|
||||||
uniqueGems.push(gem.definition.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Engine.TowerManager.towers.forEach((tower) => {
|
||||||
|
tower.slottedGems.forEach((gem) => {
|
||||||
|
gems.push(gem.definition.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
this.damageDealt * 2 +
|
this.damageDealt * 2 +
|
||||||
this.hp * 10 +
|
this.hp * 10 +
|
||||||
(this.goldEarned - this.goldSpent) * 3 +
|
(this.goldEarned - this.goldSpent) * 3 +
|
||||||
this.wavesSurvived * 100 +
|
this.wavesSurvived * 100 +
|
||||||
uniqueGems.length * 100
|
gems.length * 100 +
|
||||||
|
1000
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Because it's a game object, must have this.
|
||||||
public update() {}
|
public update() {}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import Creep, { CreepEffects } from './Creep';
|
|||||||
import Projectile, { calculateAngleToPoint, TrapProjectile, VisualLightning } from './Projectile';
|
import Projectile, { calculateAngleToPoint, TrapProjectile, VisualLightning } from './Projectile';
|
||||||
import { distance, Tower } from './Tower';
|
import { distance, Tower } from './Tower';
|
||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
|
import { TowerBehaviours } from './TowerManager';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the projectiles of the tower and updates or removes them based on their state.
|
* Checks the projectiles of the tower and updates or removes them based on their state.
|
||||||
@ -72,7 +73,9 @@ export function computeGemImprovements(tower: Tower) {
|
|||||||
tower.computedDamageToDeal = tower.definition.stats.damage + gemDamage;
|
tower.computedDamageToDeal = tower.definition.stats.damage + gemDamage;
|
||||||
tower.computedCooldown = 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;
|
||||||
|
if (tower.behaviour != TowerBehaviours.TrapperTowerBehaviour)
|
||||||
tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp;
|
tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp;
|
||||||
|
else tower.computedTimeToLive = tower.definition.stats.timeToLive + gemTimeToLiveUp * 10;
|
||||||
tower.computedPierce = tower.definition.stats.pierce + gemPierceUp;
|
tower.computedPierce = tower.definition.stats.pierce + gemPierceUp;
|
||||||
|
|
||||||
// Buff tower
|
// Buff tower
|
||||||
|
@ -28,7 +28,7 @@ export default class TowerManager {
|
|||||||
height: 64,
|
height: 64,
|
||||||
alpha: 0.8,
|
alpha: 0.8,
|
||||||
});
|
});
|
||||||
private towers: Tower[] = [];
|
public towers: Tower[] = [];
|
||||||
constructor() {
|
constructor() {
|
||||||
// TODO: Unsubscribe from events once the scene is destroyed
|
// TODO: Unsubscribe from events once the scene is destroyed
|
||||||
Engine.TowerManager = this;
|
Engine.TowerManager = this;
|
||||||
|
17
src/main.ts
17
src/main.ts
@ -48,6 +48,23 @@ import DebrisManager from './classes/game/DebrisManager';
|
|||||||
window.addEventListener('resize', resize);
|
window.addEventListener('resize', resize);
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
|
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
||||||
|
if (isMobile) {
|
||||||
|
let ttxt = new PIXI.Text({
|
||||||
|
text: 'Bastion: The Watchers Lament is currently unsupported on mobile.\nPlease play it on your computer instead.',
|
||||||
|
style: new PIXI.TextStyle({
|
||||||
|
fill: 0x333333,
|
||||||
|
fontSize: 50,
|
||||||
|
textBaseline: 'middle',
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
ttxt.x = Engine.app.canvas.width / 2;
|
||||||
|
ttxt.y = Engine.app.canvas.height / 2 + 50;
|
||||||
|
ttxt.anchor.set(0.5, 0.5);
|
||||||
|
Engine.app.stage.addChild(ttxt);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
await Assets.LoadAssets();
|
await Assets.LoadAssets();
|
||||||
GameUIConstants.init();
|
GameUIConstants.init();
|
||||||
KeyboardManager.init();
|
KeyboardManager.init();
|
||||||
|
@ -85,6 +85,8 @@ export class GameScene extends Scene {
|
|||||||
this.isWaveManagerFinished = true;
|
this.isWaveManagerFinished = true;
|
||||||
});
|
});
|
||||||
this.events.on(CreepEvents.Died, (playerAward, creepThatDied) => {
|
this.events.on(CreepEvents.Died, (playerAward, creepThatDied) => {
|
||||||
|
this.MissionStats.damageDealt += playerAward;
|
||||||
|
this.MissionStats.creepsKilled++;
|
||||||
this.MissionStats.earnGold(playerAward);
|
this.MissionStats.earnGold(playerAward);
|
||||||
});
|
});
|
||||||
this.towerPanel = new TowerPanel(GameUIConstants.SidebarRect);
|
this.towerPanel = new TowerPanel(GameUIConstants.SidebarRect);
|
||||||
@ -185,6 +187,7 @@ export class GameScene extends Scene {
|
|||||||
this.isWaveManagerFinished = false;
|
this.isWaveManagerFinished = false;
|
||||||
this.setRoundMode(RoundMode.Purchase);
|
this.setRoundMode(RoundMode.Purchase);
|
||||||
this.changeRoundButton.buttonIcon.texture = GameAssets.PlayIconTexture;
|
this.changeRoundButton.buttonIcon.texture = GameAssets.PlayIconTexture;
|
||||||
|
this.MissionStats.wavesSurvived++;
|
||||||
Engine.NotificationManager.Notify(
|
Engine.NotificationManager.Notify(
|
||||||
`Round ${this.currentRound + 1}/${this.mission.rounds.length} completed.`,
|
`Round ${this.currentRound + 1}/${this.mission.rounds.length} completed.`,
|
||||||
'info'
|
'info'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user