diff options
Diffstat (limited to 'client/src/akkamon/scenes/BattleScene.ts')
| -rw-r--r-- | client/src/akkamon/scenes/BattleScene.ts | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/client/src/akkamon/scenes/BattleScene.ts b/client/src/akkamon/scenes/BattleScene.ts index c2746d8..8ff430f 100644 --- a/client/src/akkamon/scenes/BattleScene.ts +++ b/client/src/akkamon/scenes/BattleScene.ts @@ -1,8 +1,9 @@ import { client } from '../../app'; +import type { Mon } from '../client/IncomingEvents'; import { baseStack, Queue, queueFromArray } from '../DataWrappers'; import type { BasePhaserScene, GConstructor } from '../PhaserTypes'; -import type { BattleUIEvent, DialogueUIEvent } from '../render/BattleEngine'; -import { BattleDialogue } from '../render/battleUI'; +import type { BattleUIEvent, DialogueUIEvent, InstantUIEvent } from '../render/BattleEngine'; +import { BattleDialogue, MonInterface, OpponentInterface, PlayerInterface } from '../render/battleUI'; import { Direction } from '../render/Direction'; import type { AkkamonMenu, Dialogue, Menu, MenuText, Picker } from './UIElement'; import type { WorldScene } from './WorldScene'; @@ -14,6 +15,9 @@ export default class BattleScene extends Phaser.Scene { dialogueBox?: BattleDialogue; busy = false; + playerSprites: Phaser.GameObjects.Image[] = []; + monInterfaces: Map<string, MonInterface> = new Map(); + constructor() { super('BattleScene') } @@ -61,10 +65,12 @@ export default class BattleScene extends Phaser.Scene { client.setBattleControls(input, menu); } - pushEvents(events: DialogueUIEvent[], endBehavior: () => void, before?: BattleUIEvent) { + pushEvents(events: DialogueUIEvent[], endBehavior: () => void, before?: InstantUIEvent) { this.toggleVisible(false); this.menuTakesUIControl(this.input, this.dialogueBox!); if (before) { + this.busy = true; + before.callback(); } this.dialogueBox!.pushEvents( events, @@ -85,4 +91,63 @@ export default class BattleScene extends Phaser.Scene { isBusy() { return this.busy; } + + showPlayerSpritesAndBalls() { + this.showPlayerSprites(); + this.showBalls(); + } + + showPlayerSprites() { + let playerBack = this.add.image(0,0, "playerBack") + .setOrigin(0, 1) + .setPosition(0 + 100, (1 - 0.28) * this.cameras.main.displayHeight - 20) + .setDisplaySize(200, 200) + + let opponentFront = this.add.image(0,0, "opponentFront") + .setOrigin(1, 0.5) + .setPosition(this.cameras.main.displayWidth - 100, 150) + .setDisplaySize(200, 200) + + this.playerSprites.push(playerBack); + this.playerSprites.push(opponentFront); + } + + showBalls() { + + } + + removePlayerSprites() { + for (let sprite of this.playerSprites) { + sprite.destroy(); + } + } + + showPlayerMonInterface(trainer: string, monObj: Mon) { + this.monInterfaces.set(trainer, + new PlayerInterface( + this, + monObj, + "hp-player", + {x: this.cameras.main.displayWidth - 20, y: (1 - 0.28) * this.cameras.main.displayHeight - 400 * 0.4 / 1.5}, + {x: 1, y: 0.5}, + 0.4 + )); + } + + showOpponentMonInterface(trainer: string, monObj: Mon) { + this.monInterfaces.set(trainer, + new OpponentInterface( + this, + monObj, + "hp-opponent", + {x: 30, y: 30}, + {x: 0, y: 0}, + 0.28 + )); + + } + + clearDialogue() { + this.dialogueBox!.clearText(); + } } |
