Fix issues

work
This commit is contained in:
Koneko 2025-01-13 15:22:22 +01:00 committed by GitHub
commit b214b40e63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 13 deletions

View File

@ -0,0 +1,15 @@
import * as PIXI from 'pixi.js';
import { Engine } from './Bastion';
export default class GameUIConstants {
public static SidebarRect;
public static ChangeRoundButtonRect;
public static init() {
GameUIConstants.SidebarRect = new PIXI.Rectangle(
Engine.app.canvas.width - 360,
0,
360,
Engine.app.canvas.height
);
GameUIConstants.ChangeRoundButtonRect = new PIXI.Rectangle(50, Engine.app.canvas.height - 100, 310, 100);
}
}

View File

@ -97,11 +97,6 @@ export class Grid extends GameObject {
Engine.GameMaster.currentScene.stage.addChild(this.container); Engine.GameMaster.currentScene.stage.addChild(this.container);
let background = new PIXI.Sprite(GameAssets.MissionBackgrounds[missionIndex]); let background = new PIXI.Sprite(GameAssets.MissionBackgrounds[missionIndex]);
background.x = 0;
background.y = 0;
background.width = this.bb.width;
background.height = this.bb.height;
this.container.addChild(background); this.container.addChild(background);
for (let y = 0; y < this.gameMap.columns; y++) { for (let y = 0; y < this.gameMap.columns; y++) {

View File

@ -78,7 +78,7 @@ export class Tower extends GameObject {
const towerY = this.row * Engine.GridCellSize + Engine.GridCellSize / 2; const towerY = this.row * Engine.GridCellSize + Engine.GridCellSize / 2;
const radius = this.definition.stats.range * Engine.GridCellSize; const radius = this.definition.stats.range * Engine.GridCellSize;
const d = distance(towerX, towerY, x, y); const d = distance(towerX, towerY, x, y);
return d < radius; return d < radius + Engine.GridCellSize;
}); });
} }
public Shoot(creep: Creep) { public Shoot(creep: Creep) {

View File

@ -3,9 +3,9 @@ import GameMaster, { Engine } from './classes/Bastion';
import Assets from './classes/Assets'; import Assets from './classes/Assets';
import { MainScene } from './scenes/Main'; import { MainScene } from './scenes/Main';
import { GameScene } from './scenes/Game'; import { GameScene } from './scenes/Game';
import { log } from './utils';
import { AnimationManager } from './classes/game/AnimationManager'; import { AnimationManager } from './classes/game/AnimationManager';
import NotificationManager from './classes/game/NotificationManager'; import NotificationManager from './classes/game/NotificationManager';
import GameUIConstants from './classes/GameUIConstants';
(async () => { (async () => {
const app = new PIXI.Application(); const app = new PIXI.Application();
@ -46,6 +46,7 @@ import NotificationManager from './classes/game/NotificationManager';
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
resize(); resize();
await Assets.LoadAssets(); await Assets.LoadAssets();
GameUIConstants.init();
new GameMaster(); new GameMaster();
Engine.AnimationManager = new AnimationManager(); Engine.AnimationManager = new AnimationManager();
Engine.NotificationManager = new NotificationManager(); Engine.NotificationManager = new NotificationManager();

View File

@ -11,6 +11,7 @@ import * as PIXI from 'pixi.js';
import MissionStats from '../classes/game/MissionStats'; import MissionStats from '../classes/game/MissionStats';
import TowerManager from '../classes/game/TowerManager'; import TowerManager from '../classes/game/TowerManager';
import { MissionPickerScene } from './MissionPicker'; import { MissionPickerScene } from './MissionPicker';
import GameUIConstants from '../classes/GameUIConstants';
enum RoundMode { enum RoundMode {
Purchase = 0, Purchase = 0,
@ -49,10 +50,6 @@ export class GameScene extends Scene {
if (this.update) this.update(this.ticker.elapsedMS); if (this.update) this.update(this.ticker.elapsedMS);
}); });
this.ticker.start(); this.ticker.start();
console.log(Engine.GridCellSize * (Engine.GridColumns + 5) - 360);
console.log(Engine.app.canvas.width - 360);
const SidebarRect = new PIXI.Rectangle(Engine.app.canvas.width - 360, 0, 360, Engine.app.canvas.height);
const changeRoundButtonRect = new PIXI.Rectangle(50, Engine.app.canvas.height - 100, 310, 100);
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);
@ -73,8 +70,13 @@ export class GameScene extends Scene {
this.events.on(CreepEvents.Died, (playerAward, creepThatDied) => { this.events.on(CreepEvents.Died, (playerAward, creepThatDied) => {
this.MissionStats.earnGold(playerAward); this.MissionStats.earnGold(playerAward);
}); });
this.sidebar = new Sidebar(SidebarRect); this.sidebar = new Sidebar(GameUIConstants.SidebarRect);
this.changeRoundButton = new Button(changeRoundButtonRect, 'Start', ButtonTexture.Button01, true); this.changeRoundButton = new Button(
GameUIConstants.ChangeRoundButtonRect,
'Start',
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);
this.changeRoundButton.onClick = () => { this.changeRoundButton.onClick = () => {