From 2f3bb621c7167d5d379ddbde5116c1eaddb57401 Mon Sep 17 00:00:00 2001 From: koneko <67551503+koneko@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:10:58 +0100 Subject: [PATCH] i have to think more about it --- public/assets/gui/{m_frame.png => gem_frame.png} | Bin public/assets/missions/mission_01.json | 2 +- src/classes/Assets.ts | 2 ++ src/classes/Definitions.ts | 2 +- src/classes/game/Gem.ts | 6 ++++-- src/classes/game/Grid.ts | 6 ++++-- src/scenes/Game.ts | 12 ++++++++++-- 7 files changed, 22 insertions(+), 8 deletions(-) rename public/assets/gui/{m_frame.png => gem_frame.png} (100%) diff --git a/public/assets/gui/m_frame.png b/public/assets/gui/gem_frame.png similarity index 100% rename from public/assets/gui/m_frame.png rename to public/assets/gui/gem_frame.png diff --git a/public/assets/missions/mission_01.json b/public/assets/missions/mission_01.json index 496c2b2..13567fd 100644 --- a/public/assets/missions/mission_01.json +++ b/public/assets/missions/mission_01.json @@ -102,7 +102,7 @@ "creeps": [0, 0, 0, 0, 0] } ], - "offeredGems": [0, 1, 2, 3] + "offeredGems": [0, 0, 0, 0] }, { "waves": [ diff --git a/src/classes/Assets.ts b/src/classes/Assets.ts index 3085c6e..d4bb42a 100644 --- a/src/classes/Assets.ts +++ b/src/classes/Assets.ts @@ -22,6 +22,7 @@ export default class GameAssets { public static WaveTexture: PIXI.Texture; public static SwordsTexture: PIXI.Texture; public static TitleTexture: PIXI.Texture; + public static GemFrame: PIXI.Texture; public static PlayIconTexture: PIXI.Texture; public static PauseIconTexture: PIXI.Texture; @@ -92,6 +93,7 @@ export default class GameAssets { this.Load('./assets/gui/frame_red.png').then((texture) => (this.RedBackground = texture)), this.Load('./assets/gui/frame_green.png').then((texture) => (this.GreenBackground = texture)), this.Load('./assets/gui/frame_blue.png').then((texture) => (this.BlueBackground = texture)), + this.Load('./assets/gui/gem_frame.png').then((texture) => (this.GemFrame = texture)), this.Load('./assets/gui/heart.png').then((texture) => (this.HealthTexture = texture)), this.Load('./assets/gui/money.png').then((texture) => (this.GoldTexture = texture)), this.Load('./assets/gui/wave.png').then((texture) => (this.WaveTexture = texture)), diff --git a/src/classes/Definitions.ts b/src/classes/Definitions.ts index 4732c34..4985101 100644 --- a/src/classes/Definitions.ts +++ b/src/classes/Definitions.ts @@ -85,7 +85,7 @@ export type GenericGemImprovement = { attackSpeedUp: number; rangeUp: number; timeToLiveUp: number; - pieceUp: number; + pierceUp: number; }; export type PathDefinition = [[row: number, column: number]]; diff --git a/src/classes/game/Gem.ts b/src/classes/game/Gem.ts index ec292ec..b3877ed 100644 --- a/src/classes/game/Gem.ts +++ b/src/classes/game/Gem.ts @@ -1,9 +1,11 @@ import * as PIXI from 'pixi.js'; import { GemType } from '../Definitions'; +import GameAssets from '../Assets'; export default class Gem { public texture: PIXI.Texture; public type: GemType; public level: number = 1; - // TODO: create and load from Gems.json and also load gem textures - constructor(gemType) {} + constructor(gemType: GemType) { + this.texture = GameAssets.Gems[gemType].textures[0]; + } } diff --git a/src/classes/game/Grid.ts b/src/classes/game/Grid.ts index 8169204..2cb94f5 100644 --- a/src/classes/game/Grid.ts +++ b/src/classes/game/Grid.ts @@ -47,13 +47,16 @@ export class Cell extends GameObject { this.container.addChild(this.clickDetector); this.container.addChild(this.g); this.clickDetector.on('pointerup', (e) => { + if (!Engine.Grid.gridInteractionEnabled) return; if (Engine.TowerManager.isPlacingTower) Engine.Grid.onGridCellClicked(row, column); else this.OpenSelectedTowerPanel(); }); this.clickDetector.on('pointerenter', (e) => { + if (!Engine.Grid.gridInteractionEnabled) return; Engine.GameScene.events.emit(GridEvents.CellMouseOver, this); }); this.clickDetector.on('pointerleave', (e) => { + if (!Engine.Grid.gridInteractionEnabled) return; Engine.GameScene.events.emit(GridEvents.CellMouseLeave, this); Engine.Grid.rangePreview.clear(); }); @@ -84,8 +87,6 @@ export class Cell extends GameObject { if (this.hasTowerPlaced) { const tower = Engine.TowerManager.GetTowerByRowAndCol(this.row, this.column); Engine.GameScene.towerPanel.Show(tower); - } else { - // TODO: hide the sidepanel somehow } } public checkIfCantPlace() { @@ -117,6 +118,7 @@ export class Grid extends GameObject { public rangePreview: PIXI.Graphics; public creeps: Creep[] = []; public gridShown: boolean = false; + public gridInteractionEnabled = true; constructor(map: GameMapDefinition, missionIndex) { super(); diff --git a/src/scenes/Game.ts b/src/scenes/Game.ts index edc0708..7cf6f4e 100644 --- a/src/scenes/Game.ts +++ b/src/scenes/Game.ts @@ -124,14 +124,17 @@ export class GameScene extends Scene { `Round ${this.currentRound + 1}/${this.mission.rounds.length} completed.`, 'info' ); - if (this.currentRound == this.mission.rounds.length) { + if (this.currentRound + 2 == this.mission.rounds.length) { Engine.NotificationManager.Notify(`Final round.`, 'danger'); } if (this.currentRound + 1 == this.mission.rounds.length) { Engine.NotificationManager.Notify(`Mission victory!!`, 'reward'); this.changeRoundButton.buttonIcon.texture = GameAssets.HomeIconTexture; this.playerWon = true; - } else this.currentRound++; + } else { + this.currentRound++; + this.OfferPlayerGems(); + } } if (this.MissionStats.getHP() <= 0) { @@ -142,6 +145,11 @@ export class GameScene extends Scene { this.ShowScoreScreen(false); } } + private OfferPlayerGems() { + Engine.Grid.gridInteractionEnabled = false; + + Engine.Grid.gridInteractionEnabled = true; + } private ShowScoreScreen(lost) { // TODO: show to player for real