get gems when finishing rounds
This commit is contained in:
parent
2f3bb621c7
commit
5ea6017547
@ -11,16 +11,16 @@ List of things to implement following the "release" of the minimum viable produc
|
|||||||
|
|
||||||
## Towers
|
## Towers
|
||||||
|
|
||||||
- [ ] Extend projectile into seperate defintion + json file
|
- [x] Extend projectile into seperate defintion + json file
|
||||||
- [ ] Make tower react with slotted gems
|
- [ ] Make tower react with slotted gems
|
||||||
- [ ] Alter damage based on attunement from slotted gems
|
- [ ] Alter damage based on attunement from slotted gems
|
||||||
- [ ] Tower info on click
|
- [x] Tower info on click
|
||||||
- [x] Animate projectiles
|
- [x] Animate projectiles
|
||||||
- [x] Better mouseover tracking when placing tower and showing radius
|
- [x] Better mouseover tracking when placing tower and showing radius
|
||||||
|
|
||||||
## Gems
|
## Gems
|
||||||
|
|
||||||
- [ ] Create Gem definitions
|
- [x] Create Gem definitions
|
||||||
- [ ] Make gems affect towers
|
- [ ] Make gems affect towers
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"textureArrayLength": 12,
|
"textureArrayLength": 12,
|
||||||
"stats": {
|
"stats": {
|
||||||
"health": 5,
|
"health": 5,
|
||||||
"speed": 2.4,
|
"speed": 6,
|
||||||
"special": null,
|
"special": null,
|
||||||
"resistance": {
|
"resistance": {
|
||||||
"physical": 0,
|
"physical": 0,
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "Fire Gem",
|
"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.",
|
||||||
"type": "Fire",
|
"type": "Fire",
|
||||||
"totalLevels": 2,
|
"totalLevels": 2,
|
||||||
"textures": [],
|
"textures": [],
|
||||||
"cantCombineWith": [],
|
"cantCombineWith": [],
|
||||||
"specialCombine": ["Yeti"],
|
"specialCombine": [],
|
||||||
"genericImprovements": [
|
"genericImprovements": [
|
||||||
{
|
{
|
||||||
"damageUp": 2,
|
"damageUp": 2,
|
||||||
@ -21,6 +22,22 @@
|
|||||||
"timeToLiveUp": 0,
|
"timeToLiveUp": 0,
|
||||||
"pierceUp": 1
|
"pierceUp": 1
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"gemResistanceModifications": [
|
||||||
|
{
|
||||||
|
"physical": 0,
|
||||||
|
"divine": 0,
|
||||||
|
"fire": 0.5,
|
||||||
|
"ice": 0,
|
||||||
|
"frostfire": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"physical": 0,
|
||||||
|
"divine": 0,
|
||||||
|
"fire": 0.5,
|
||||||
|
"ice": 0,
|
||||||
|
"frostfire": 0
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -125,7 +125,7 @@ export default class GameAssets {
|
|||||||
const gem = this.Gems[idx];
|
const gem = this.Gems[idx];
|
||||||
for (let i = 1; i <= gem.totalLevels; i++) {
|
for (let i = 1; i <= gem.totalLevels; i++) {
|
||||||
const texture = await this.Load(`./assets/gems/${gem.type}/${i}.png`);
|
const texture = await this.Load(`./assets/gems/${gem.type}/${i}.png`);
|
||||||
gem.textures[i] = texture;
|
gem.textures[i - 1] = texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 7; i++) {
|
||||||
|
@ -72,12 +72,14 @@ export type TowerStatsDefinition = {
|
|||||||
|
|
||||||
export type GemDefinition = {
|
export type GemDefinition = {
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
type: GemType;
|
type: GemType;
|
||||||
totalLevels: number;
|
totalLevels: number;
|
||||||
textures: PIXI.Texture[];
|
textures: PIXI.Texture[];
|
||||||
cantCombineWith: GemType[];
|
cantCombineWith: GemType[];
|
||||||
specialCombine: GemType[];
|
specialCombine: GemType[];
|
||||||
genericImprovements: GenericGemImprovement[];
|
genericImprovements: GenericGemImprovement[];
|
||||||
|
gemResistanceModifications: CreepResistancesDefinition[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GenericGemImprovement = {
|
export type GenericGemImprovement = {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
import { GemType } from '../Definitions';
|
import { GemType, GemDefinition } from '../Definitions';
|
||||||
import GameAssets from '../Assets';
|
import GameAssets from '../Assets';
|
||||||
export default class Gem {
|
export default class Gem {
|
||||||
public texture: PIXI.Texture;
|
public texture: PIXI.Texture;
|
||||||
public type: GemType;
|
|
||||||
public level: number = 1;
|
public level: number = 1;
|
||||||
|
public gemDefinition: GemDefinition;
|
||||||
constructor(gemType: GemType) {
|
constructor(gemType: GemType) {
|
||||||
this.texture = GameAssets.Gems[gemType].textures[0];
|
this.gemDefinition = GameAssets.Gems[gemType];
|
||||||
|
this.texture = this.gemDefinition.textures[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import GameObject from '../GameObject';
|
|||||||
import * as PIXI from 'pixi.js';
|
import * as PIXI from 'pixi.js';
|
||||||
import { FadeInOut } from './AnimationManager';
|
import { FadeInOut } from './AnimationManager';
|
||||||
|
|
||||||
export type NotificationType = 'info' | 'warn' | 'danger' | 'reward';
|
export type NotificationType = 'info' | 'warn' | 'danger' | 'reward' | 'gemaward';
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
public textObj: PIXI.Text;
|
public textObj: PIXI.Text;
|
||||||
@ -20,6 +20,8 @@ class Notification {
|
|||||||
fill = 0xfc0a0a;
|
fill = 0xfc0a0a;
|
||||||
} else if (type == 'reward') {
|
} else if (type == 'reward') {
|
||||||
fill = 0xd65afc;
|
fill = 0xd65afc;
|
||||||
|
} else if (type == 'gemaward') {
|
||||||
|
fill = 0xffff00;
|
||||||
}
|
}
|
||||||
this.ticksToFadeAway = ticksToFadeAway;
|
this.ticksToFadeAway = ticksToFadeAway;
|
||||||
this.textObj = new PIXI.Text({
|
this.textObj = new PIXI.Text({
|
||||||
|
@ -42,7 +42,7 @@ export class Tower extends GameObject {
|
|||||||
texture: texture,
|
texture: texture,
|
||||||
height: Engine.GridCellSize,
|
height: Engine.GridCellSize,
|
||||||
width: Engine.GridCellSize,
|
width: Engine.GridCellSize,
|
||||||
zIndex: 10,
|
zIndex: 130,
|
||||||
});
|
});
|
||||||
this.container.addChild(this.sprite);
|
this.container.addChild(this.sprite);
|
||||||
this.parent.container.addChild(this.container);
|
this.parent.container.addChild(this.container);
|
||||||
@ -53,7 +53,8 @@ export class Tower extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onParentCellEnter = (e) => {
|
private onParentCellEnter = (e) => {
|
||||||
if (!Engine.TowerManager.isPlacingTower) this.parent.showRangePreview(false, this.definition.stats.range);
|
if (!Engine.TowerManager.isPlacingTower && Engine.Grid.gridInteractionEnabled)
|
||||||
|
this.parent.showRangePreview(false, this.definition.stats.range);
|
||||||
};
|
};
|
||||||
|
|
||||||
private onParentCellLeave = (e) => {
|
private onParentCellLeave = (e) => {
|
||||||
|
@ -2,6 +2,7 @@ import * as PIXI from 'pixi.js';
|
|||||||
import GuiObject from '../GuiObject';
|
import GuiObject from '../GuiObject';
|
||||||
import GameAssets from '../Assets';
|
import GameAssets from '../Assets';
|
||||||
import { Engine } from '../Bastion';
|
import { Engine } from '../Bastion';
|
||||||
|
import Gem from '../game/Gem';
|
||||||
|
|
||||||
// ! TODO NEXT!
|
// ! TODO NEXT!
|
||||||
|
|
||||||
@ -14,12 +15,17 @@ export default class Tooltip extends GuiObject {
|
|||||||
private damageText: PIXI.Text;
|
private damageText: PIXI.Text;
|
||||||
private gemAmount: PIXI.Text;
|
private gemAmount: PIXI.Text;
|
||||||
private gemAmountSprite: PIXI.Sprite;
|
private gemAmountSprite: PIXI.Sprite;
|
||||||
|
private title: PIXI.Sprite;
|
||||||
|
private costSprite: PIXI.Sprite;
|
||||||
|
private damageSprite: PIXI.Sprite;
|
||||||
|
private gemDescriptionText: PIXI.Text;
|
||||||
|
|
||||||
constructor(bounds: PIXI.Rectangle) {
|
constructor(bounds: PIXI.Rectangle) {
|
||||||
super(false);
|
super(false);
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
this.container.x = -500;
|
this.container.x = -500;
|
||||||
this.container.y = -500;
|
this.container.y = -500;
|
||||||
|
this.container.zIndex = 150;
|
||||||
this.tooltipSprite = new PIXI.NineSliceSprite({
|
this.tooltipSprite = new PIXI.NineSliceSprite({
|
||||||
texture: GameAssets.Frame04Texture,
|
texture: GameAssets.Frame04Texture,
|
||||||
leftWidth: 200,
|
leftWidth: 200,
|
||||||
@ -43,16 +49,16 @@ export default class Tooltip extends GuiObject {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
this.titleText.anchor.set(0.5, 0);
|
this.titleText.anchor.set(0.5, 0);
|
||||||
let title = new PIXI.Sprite({
|
this.title = new PIXI.Sprite({
|
||||||
x: this.tooltipSprite.width / 2,
|
x: this.tooltipSprite.width / 2,
|
||||||
y: -20,
|
y: -20,
|
||||||
width: 250,
|
width: 250,
|
||||||
height: 40,
|
height: 40,
|
||||||
texture: GameAssets.TitleTexture,
|
texture: GameAssets.TitleTexture,
|
||||||
});
|
});
|
||||||
title.anchor.set(0.5, 0);
|
this.title.anchor.set(0.5, 0);
|
||||||
|
|
||||||
const costSprite = new PIXI.Sprite({
|
this.costSprite = new PIXI.Sprite({
|
||||||
texture: GameAssets.GoldTexture,
|
texture: GameAssets.GoldTexture,
|
||||||
x: 10,
|
x: 10,
|
||||||
y: 20,
|
y: 20,
|
||||||
@ -88,7 +94,7 @@ export default class Tooltip extends GuiObject {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const damageSprite = new PIXI.Sprite({
|
this.damageSprite = new PIXI.Sprite({
|
||||||
texture: GameAssets.SwordsTexture,
|
texture: GameAssets.SwordsTexture,
|
||||||
x: 22,
|
x: 22,
|
||||||
y: 70,
|
y: 70,
|
||||||
@ -117,26 +123,64 @@ export default class Tooltip extends GuiObject {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
this.gemDescriptionText = new PIXI.Text({
|
||||||
|
x: 10,
|
||||||
|
y: 20,
|
||||||
|
text: '',
|
||||||
|
style: {
|
||||||
|
fontSize: 18,
|
||||||
|
wordWrap: true,
|
||||||
|
wordWrapWidth: this.tooltipSprite.width - 30,
|
||||||
|
fill: 'white',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
fontStyle: 'italic',
|
||||||
|
stroke: {
|
||||||
|
color: 0x000000,
|
||||||
|
width: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.container.addChild(this.tooltipSprite);
|
this.container.addChild(this.tooltipSprite);
|
||||||
this.container.addChild(title);
|
this.container.addChild(this.title);
|
||||||
this.container.addChild(costSprite);
|
this.container.addChild(this.costSprite);
|
||||||
this.container.addChild(damageSprite);
|
this.container.addChild(this.damageSprite);
|
||||||
this.container.addChild(this.gemAmountSprite);
|
this.container.addChild(this.gemAmountSprite);
|
||||||
this.container.addChild(this.costText);
|
this.container.addChild(this.costText);
|
||||||
this.container.addChild(this.titleText);
|
this.container.addChild(this.titleText);
|
||||||
this.container.addChild(this.damageText);
|
this.container.addChild(this.damageText);
|
||||||
this.container.addChild(this.gemAmount);
|
this.container.addChild(this.gemAmount);
|
||||||
|
|
||||||
Engine.GameMaster.currentScene.stage.addChild(this.container);
|
this.container.addChild(this.gemDescriptionText);
|
||||||
|
Engine.app.stage.addChildAt(this.container, 0);
|
||||||
}
|
}
|
||||||
public SetContent(title, damage: number, cost: number, gemSlotsAmount: number) {
|
public SetContentTower(title, damage: number, cost: number, gemSlotsAmount: number) {
|
||||||
|
this.costSprite.alpha = 1;
|
||||||
|
this.damageSprite.alpha = 1;
|
||||||
|
this.gemAmountSprite.alpha = 1;
|
||||||
|
this.costText.alpha = 1;
|
||||||
|
this.damageText.alpha = 1;
|
||||||
|
this.gemAmount.alpha = 1;
|
||||||
|
this.gemDescriptionText.alpha = 0;
|
||||||
|
|
||||||
this.titleText.text = title;
|
this.titleText.text = title;
|
||||||
this.gemAmount.text = `Has ${gemSlotsAmount} Gem slots.`;
|
this.gemAmount.text = `Has ${gemSlotsAmount} Gem slots.`;
|
||||||
this.gemAmountSprite.texture = GameAssets.GemAmountIcons[gemSlotsAmount];
|
this.gemAmountSprite.texture = GameAssets.GemAmountIcons[gemSlotsAmount];
|
||||||
this.costText.text = `Costs ${cost} gold.`;
|
this.costText.text = `Costs ${cost} gold.`;
|
||||||
this.damageText.text = `Deals ${damage} base damage.`;
|
this.damageText.text = `Deals ${damage} base damage.`;
|
||||||
}
|
}
|
||||||
|
public SetContentGem(gem: Gem) {
|
||||||
|
this.costSprite.alpha = 0;
|
||||||
|
this.damageSprite.alpha = 0;
|
||||||
|
this.gemAmountSprite.alpha = 0;
|
||||||
|
this.costText.alpha = 0;
|
||||||
|
this.damageText.alpha = 0;
|
||||||
|
this.gemAmount.alpha = 0;
|
||||||
|
this.gemDescriptionText.alpha = 1;
|
||||||
|
|
||||||
|
this.titleText.text = `Lv. ${gem.level} ` + gem.gemDefinition.name;
|
||||||
|
this.gemDescriptionText.text = gem.gemDefinition.description;
|
||||||
|
}
|
||||||
public Show(x, y) {
|
public Show(x, y) {
|
||||||
this.container.alpha = 1;
|
this.container.alpha = 1;
|
||||||
if (x + this.container.width > Engine.app.canvas.width) {
|
if (x + this.container.width > Engine.app.canvas.width) {
|
||||||
|
@ -7,33 +7,43 @@ import Button, { ButtonTexture } from './Button';
|
|||||||
import { Tower } from '../game/Tower';
|
import { Tower } from '../game/Tower';
|
||||||
import Gem from '../game/Gem';
|
import Gem from '../game/Gem';
|
||||||
|
|
||||||
class VisualGemSlot extends GuiObject {
|
export class VisualGemSlot extends GuiObject {
|
||||||
public iconSprite: PIXI.Sprite;
|
public iconSprite: PIXI.Sprite;
|
||||||
private background: PIXI.Sprite;
|
private background: PIXI.Sprite;
|
||||||
|
private gem: Gem;
|
||||||
private i: number = 0;
|
private i: number = 0;
|
||||||
constructor(index: number, parent: PIXI.Container, gem: Gem | null) {
|
constructor(index: number, parent: PIXI.Container, gem: Gem | null) {
|
||||||
super(true);
|
super(true);
|
||||||
let gtexture;
|
let gtexture;
|
||||||
if (gem == null) {
|
|
||||||
gtexture = GameAssets.PlusIconTexture;
|
|
||||||
} else {
|
|
||||||
gtexture = gem.texture;
|
|
||||||
}
|
|
||||||
this.container.x = 10;
|
this.container.x = 10;
|
||||||
this.container.y = index * Engine.GridCellSize + 300;
|
this.container.y = index * Engine.GridCellSize + 300;
|
||||||
this.background = new PIXI.Sprite({
|
this.background = new PIXI.Sprite({
|
||||||
texture: GameAssets.FrameInventory,
|
texture: GameAssets.FrameInventory,
|
||||||
});
|
});
|
||||||
|
this.gem = gem;
|
||||||
|
if (gem == null) {
|
||||||
|
gtexture = GameAssets.PlusIconTexture;
|
||||||
|
} else {
|
||||||
|
gtexture = gem.texture;
|
||||||
|
}
|
||||||
this.iconSprite = new PIXI.Sprite({
|
this.iconSprite = new PIXI.Sprite({
|
||||||
texture: gtexture,
|
texture: gtexture,
|
||||||
|
zIndex: 10,
|
||||||
});
|
});
|
||||||
this.background.width = Engine.GridCellSize;
|
this.background.width = Engine.GridCellSize;
|
||||||
this.background.height = Engine.GridCellSize;
|
this.background.height = Engine.GridCellSize;
|
||||||
|
if (gem == null) {
|
||||||
this.iconSprite.x = Engine.GridCellSize / 2;
|
this.iconSprite.x = Engine.GridCellSize / 2;
|
||||||
this.iconSprite.y = Engine.GridCellSize / 2;
|
this.iconSprite.y = Engine.GridCellSize / 2;
|
||||||
this.iconSprite.width = Engine.GridCellSize / 2;
|
this.iconSprite.width = Engine.GridCellSize / 2;
|
||||||
this.iconSprite.height = Engine.GridCellSize / 2;
|
this.iconSprite.height = Engine.GridCellSize / 2;
|
||||||
this.iconSprite.anchor.set(0.5, 0.5);
|
this.iconSprite.anchor.set(0.5, 0.5);
|
||||||
|
} else {
|
||||||
|
this.iconSprite.x = 4;
|
||||||
|
this.iconSprite.y = 4;
|
||||||
|
this.iconSprite.width = Engine.GridCellSize - 8;
|
||||||
|
this.iconSprite.height = Engine.GridCellSize - 8;
|
||||||
|
}
|
||||||
this.container.addChild(this.background);
|
this.container.addChild(this.background);
|
||||||
this.container.addChild(this.iconSprite);
|
this.container.addChild(this.iconSprite);
|
||||||
parent.addChild(this.container);
|
parent.addChild(this.container);
|
||||||
|
@ -47,7 +47,8 @@ class TowerButton extends GuiObject {
|
|||||||
Engine.GameScene.events.on(TowerEvents.TowerPlacedEvent, (name) => {
|
Engine.GameScene.events.on(TowerEvents.TowerPlacedEvent, (name) => {
|
||||||
this.resetTint();
|
this.resetTint();
|
||||||
});
|
});
|
||||||
this.container.onmousemove = (e) => {
|
this.container.onpointermove = (e) => {
|
||||||
|
if (Engine.Grid.gridInteractionEnabled == false) return;
|
||||||
if (Engine.TowerManager.isPlacingTower) return;
|
if (Engine.TowerManager.isPlacingTower) return;
|
||||||
this.ShowTooltip();
|
this.ShowTooltip();
|
||||||
};
|
};
|
||||||
@ -63,7 +64,7 @@ class TowerButton extends GuiObject {
|
|||||||
definition = item;
|
definition = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Engine.GameScene.tooltip.SetContent(
|
Engine.GameScene.tooltip.SetContentTower(
|
||||||
this.towerName,
|
this.towerName,
|
||||||
definition.stats.damage,
|
definition.stats.damage,
|
||||||
definition.stats.cost,
|
definition.stats.cost,
|
||||||
@ -72,6 +73,7 @@ class TowerButton extends GuiObject {
|
|||||||
Engine.GameScene.tooltip.Show(Engine.MouseX, Engine.MouseY);
|
Engine.GameScene.tooltip.Show(Engine.MouseX, Engine.MouseY);
|
||||||
}
|
}
|
||||||
public onClick(e: PIXI.FederatedPointerEvent): void {
|
public onClick(e: PIXI.FederatedPointerEvent): void {
|
||||||
|
if (Engine.Grid.gridInteractionEnabled == false) return;
|
||||||
if (Engine.TowerManager.isPlacingTower && Engine.TowerManager.selectedTower.name != this.towerName) {
|
if (Engine.TowerManager.isPlacingTower && Engine.TowerManager.selectedTower.name != this.towerName) {
|
||||||
Engine.GameScene.sidebar.towerTab.resetTint();
|
Engine.GameScene.sidebar.towerTab.resetTint();
|
||||||
Engine.TowerManager.ResetChooseTower();
|
Engine.TowerManager.ResetChooseTower();
|
||||||
|
@ -13,11 +13,13 @@ import TowerManager from '../classes/game/TowerManager';
|
|||||||
import { MissionPickerScene } from './MissionPicker';
|
import { MissionPickerScene } from './MissionPicker';
|
||||||
import GameUIConstants from '../classes/GameUIConstants';
|
import GameUIConstants from '../classes/GameUIConstants';
|
||||||
import Tooltip from '../classes/gui/Tooltip';
|
import Tooltip from '../classes/gui/Tooltip';
|
||||||
import TowerPanel from '../classes/gui/TowerPanel';
|
import TowerPanel, { VisualGemSlot } from '../classes/gui/TowerPanel';
|
||||||
|
import Gem from '../classes/game/Gem';
|
||||||
|
|
||||||
enum RoundMode {
|
enum RoundMode {
|
||||||
Purchase = 0,
|
Purchase = 0,
|
||||||
Combat = 1,
|
Combat = 1,
|
||||||
|
OfferingGems = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GameScene extends Scene {
|
export class GameScene extends Scene {
|
||||||
@ -31,6 +33,13 @@ export class GameScene extends Scene {
|
|||||||
public sidebar: Sidebar;
|
public sidebar: Sidebar;
|
||||||
public tooltip: Tooltip;
|
public tooltip: Tooltip;
|
||||||
public towerPanel: TowerPanel;
|
public towerPanel: TowerPanel;
|
||||||
|
public dimGraphics: PIXI.Graphics = new PIXI.Graphics({
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
zIndex: 120,
|
||||||
|
});
|
||||||
|
private offerGemsSprite: PIXI.NineSliceSprite;
|
||||||
|
private visualGems: VisualGemSlot[] = [];
|
||||||
private currentRound: number = 0;
|
private currentRound: number = 0;
|
||||||
private isWaveManagerFinished: boolean = false;
|
private isWaveManagerFinished: boolean = false;
|
||||||
private playerWon: boolean = false;
|
private playerWon: boolean = false;
|
||||||
@ -47,13 +56,6 @@ export class GameScene extends Scene {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
public init() {
|
public init() {
|
||||||
this.ticker = new PIXI.Ticker();
|
|
||||||
this.ticker.maxFPS = 60;
|
|
||||||
this.ticker.minFPS = 30;
|
|
||||||
this.ticker.add(() => {
|
|
||||||
if (this.update) this.update(this.ticker.elapsedMS);
|
|
||||||
});
|
|
||||||
this.ticker.start();
|
|
||||||
new Grid(this.mission.gameMap, this.missionIndex);
|
new Grid(this.mission.gameMap, this.missionIndex);
|
||||||
new TowerManager();
|
new TowerManager();
|
||||||
new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
|
new WaveManager(this.mission.rounds, this.mission.gameMap.paths);
|
||||||
@ -76,10 +78,11 @@ export class GameScene extends Scene {
|
|||||||
});
|
});
|
||||||
this.towerPanel = new TowerPanel(GameUIConstants.SidebarRect);
|
this.towerPanel = new TowerPanel(GameUIConstants.SidebarRect);
|
||||||
this.sidebar = new Sidebar(GameUIConstants.SidebarRect);
|
this.sidebar = new Sidebar(GameUIConstants.SidebarRect);
|
||||||
this.tooltip = new Tooltip(new PIXI.Rectangle(0, 0, 350, 160));
|
|
||||||
this.changeRoundButton = new Button(GameUIConstants.ChangeRoundButtonRect, '', ButtonTexture.Button01, true);
|
this.changeRoundButton = new Button(GameUIConstants.ChangeRoundButtonRect, '', ButtonTexture.Button01, true);
|
||||||
this.changeRoundButton.container.removeFromParent();
|
this.changeRoundButton.container.removeFromParent();
|
||||||
this.sidebar.container.addChild(this.changeRoundButton.container);
|
this.sidebar.container.addChild(this.changeRoundButton.container);
|
||||||
|
Engine.GameMaster.currentScene.stage.addChildAt(this.dimGraphics, 0);
|
||||||
|
this.tooltip = new Tooltip(new PIXI.Rectangle(0, 0, 350, 160));
|
||||||
// Added custom button logic to still keep all the regular events for the button, just have an icon instead of text.
|
// Added custom button logic to still keep all the regular events for the button, just have an icon instead of text.
|
||||||
// TODO: maybe make this better? add like a seperate class for icon buttons or smth
|
// TODO: maybe make this better? add like a seperate class for icon buttons or smth
|
||||||
this.changeRoundButton.CustomButtonLogic = () => {
|
this.changeRoundButton.CustomButtonLogic = () => {
|
||||||
@ -98,12 +101,19 @@ export class GameScene extends Scene {
|
|||||||
if (this.roundMode == RoundMode.Combat)
|
if (this.roundMode == RoundMode.Combat)
|
||||||
return Engine.NotificationManager.Notify('Wave is already in progress.', 'warn');
|
return Engine.NotificationManager.Notify('Wave is already in progress.', 'warn');
|
||||||
if (this.isGameOver) return Engine.NotificationManager.Notify('No more waves.', 'danger');
|
if (this.isGameOver) return Engine.NotificationManager.Notify('No more waves.', 'danger');
|
||||||
|
if (this.roundMode == RoundMode.OfferingGems) return;
|
||||||
this.setRoundMode(RoundMode.Combat);
|
this.setRoundMode(RoundMode.Combat);
|
||||||
this.changeRoundButton.buttonIcon.texture = GameAssets.ExclamationIconTexture;
|
this.changeRoundButton.buttonIcon.texture = GameAssets.ExclamationIconTexture;
|
||||||
this.events.emit(WaveManagerEvents.NewWave, `${this.currentRound + 1}`);
|
this.events.emit(WaveManagerEvents.NewWave, `${this.currentRound + 1}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.MissionStats = new MissionStats(100, 200);
|
this.MissionStats = new MissionStats(100, 200);
|
||||||
|
this.ticker = new PIXI.Ticker();
|
||||||
|
this.ticker.maxFPS = 60;
|
||||||
|
this.ticker.minFPS = 30;
|
||||||
|
this.ticker.add(() => {
|
||||||
|
if (this.update) this.update(this.ticker.elapsedMS);
|
||||||
|
});
|
||||||
|
this.ticker.start();
|
||||||
}
|
}
|
||||||
public update(elapsedMS) {
|
public update(elapsedMS) {
|
||||||
if (this.isGameOver) {
|
if (this.isGameOver) {
|
||||||
@ -116,6 +126,7 @@ export class GameScene extends Scene {
|
|||||||
Engine.WaveManager.update(elapsedMS);
|
Engine.WaveManager.update(elapsedMS);
|
||||||
Engine.Grid.update(elapsedMS);
|
Engine.Grid.update(elapsedMS);
|
||||||
Engine.TowerManager.update(elapsedMS);
|
Engine.TowerManager.update(elapsedMS);
|
||||||
|
// Means the round is finished.
|
||||||
if (this.isWaveManagerFinished && Engine.Grid.creeps.length == 0) {
|
if (this.isWaveManagerFinished && Engine.Grid.creeps.length == 0) {
|
||||||
this.isWaveManagerFinished = false;
|
this.isWaveManagerFinished = false;
|
||||||
this.setRoundMode(RoundMode.Purchase);
|
this.setRoundMode(RoundMode.Purchase);
|
||||||
@ -124,16 +135,13 @@ export class GameScene extends Scene {
|
|||||||
`Round ${this.currentRound + 1}/${this.mission.rounds.length} completed.`,
|
`Round ${this.currentRound + 1}/${this.mission.rounds.length} completed.`,
|
||||||
'info'
|
'info'
|
||||||
);
|
);
|
||||||
if (this.currentRound + 2 == this.mission.rounds.length) {
|
|
||||||
Engine.NotificationManager.Notify(`Final round.`, 'danger');
|
|
||||||
}
|
|
||||||
if (this.currentRound + 1 == this.mission.rounds.length) {
|
if (this.currentRound + 1 == this.mission.rounds.length) {
|
||||||
Engine.NotificationManager.Notify(`Mission victory!!`, 'reward');
|
Engine.NotificationManager.Notify(`Mission victory!!`, 'reward');
|
||||||
this.changeRoundButton.buttonIcon.texture = GameAssets.HomeIconTexture;
|
this.changeRoundButton.buttonIcon.texture = GameAssets.HomeIconTexture;
|
||||||
this.playerWon = true;
|
this.playerWon = true;
|
||||||
} else {
|
} else {
|
||||||
this.currentRound++;
|
|
||||||
this.OfferPlayerGems();
|
this.OfferPlayerGems();
|
||||||
|
this.currentRound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,14 +153,59 @@ export class GameScene extends Scene {
|
|||||||
this.ShowScoreScreen(false);
|
this.ShowScoreScreen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public DarkenScreen() {
|
||||||
|
this.dimGraphics.rect(0, 0, Engine.app.canvas.width, Engine.app.canvas.height);
|
||||||
|
this.dimGraphics.fill({ color: 0x000000, alpha: 0.5 });
|
||||||
|
}
|
||||||
private OfferPlayerGems() {
|
private OfferPlayerGems() {
|
||||||
Engine.Grid.gridInteractionEnabled = false;
|
Engine.Grid.gridInteractionEnabled = false;
|
||||||
|
Engine.GameScene.sidebar.towerTab.resetTint();
|
||||||
|
Engine.TowerManager.ResetChooseTower();
|
||||||
|
this.setRoundMode(RoundMode.OfferingGems);
|
||||||
|
let gemsToOffer = this.mission.rounds[this.currentRound].offeredGems;
|
||||||
|
this.DarkenScreen();
|
||||||
|
this.offerGemsSprite = new PIXI.NineSliceSprite({
|
||||||
|
width: 400,
|
||||||
|
height: 200,
|
||||||
|
texture: GameAssets.Frame01Texture,
|
||||||
|
leftWidth: 100,
|
||||||
|
topHeight: 100,
|
||||||
|
rightWidth: 100,
|
||||||
|
bottomHeight: 100,
|
||||||
|
zIndex: this.dimGraphics.zIndex + 1,
|
||||||
|
x: Engine.app.canvas.width / 2 - 200,
|
||||||
|
y: Engine.app.canvas.height / 2 - 100,
|
||||||
|
});
|
||||||
|
Engine.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite, 0);
|
||||||
|
gemsToOffer.forEach((gType, index) => {
|
||||||
|
let _Gem = new Gem(gType);
|
||||||
|
let vGem = new VisualGemSlot(0, Engine.app.stage, _Gem);
|
||||||
|
this.visualGems.push(vGem);
|
||||||
|
vGem.container.x = this.offerGemsSprite.x + 69 * (index + 1);
|
||||||
|
vGem.container.y = this.offerGemsSprite.y + 50;
|
||||||
|
vGem.container.onpointermove = () => {
|
||||||
|
Engine.GameScene.tooltip.SetContentGem(_Gem);
|
||||||
|
Engine.GameScene.tooltip.Show(Engine.MouseX, Engine.MouseY);
|
||||||
|
};
|
||||||
|
vGem.container.onpointerleave = () => {
|
||||||
|
Engine.GameScene.tooltip.Hide();
|
||||||
|
};
|
||||||
|
vGem.onClick = () => {
|
||||||
|
Engine.GameScene.tooltip.Hide();
|
||||||
|
this.PlayerPickedGem(_Gem);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private PlayerPickedGem(gem: Gem) {
|
||||||
|
this.offerGemsSprite.destroy();
|
||||||
|
this.dimGraphics.clear();
|
||||||
|
this.visualGems.forEach((item) => item.destroy());
|
||||||
Engine.Grid.gridInteractionEnabled = true;
|
Engine.Grid.gridInteractionEnabled = true;
|
||||||
|
Engine.NotificationManager.Notify(gem.gemDefinition.name + ' added to your inventory.', 'gemaward');
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShowScoreScreen(lost) {
|
private ShowScoreScreen(lost) {
|
||||||
// TODO: show to player for real
|
// TODO: show to player for real (see how this.OfferPlayerGems() does it)
|
||||||
if (lost) {
|
if (lost) {
|
||||||
console.log('LOSE!');
|
console.log('LOSE!');
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user