i have to think more about it

This commit is contained in:
koneko 2025-01-22 13:10:58 +01:00
parent c57e84633b
commit 2f3bb621c7
7 changed files with 22 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

@ -102,7 +102,7 @@
"creeps": [0, 0, 0, 0, 0]
}
],
"offeredGems": [0, 1, 2, 3]
"offeredGems": [0, 0, 0, 0]
},
{
"waves": [

View File

@ -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)),

View File

@ -85,7 +85,7 @@ export type GenericGemImprovement = {
attackSpeedUp: number;
rangeUp: number;
timeToLiveUp: number;
pieceUp: number;
pierceUp: number;
};
export type PathDefinition = [[row: number, column: number]];

View File

@ -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];
}
}

View File

@ -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();

View File

@ -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