From 1e63f99765ed0575ba12b721821e86a601fb3809 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:06:03 -0400 Subject: [PATCH] Added trainer team bar --- src/battle-scene.ts | 6 +++++ src/ui/trainer-team-bar.ts | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/ui/trainer-team-bar.ts diff --git a/src/battle-scene.ts b/src/battle-scene.ts index ba0720baab2..4cc837cada8 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -54,6 +54,7 @@ import {InputsController} from "./inputs-controller"; import {UiInputs} from "./ui-inputs"; import { NewArenaEvent } from "./events/battle-scene"; import ArenaFlyout from "./ui/arena-flyout"; +import TeamBar from "./ui/trainer-team-bar"; import { EaseType } from "#enums/ease-type"; import { Abilities } from "#enums/abilities"; import { BattleSpec } from "#enums/battle-spec"; @@ -220,6 +221,7 @@ export default class BattleScene extends SceneBase { private modifierBar: ModifierBar; private enemyModifierBar: ModifierBar; public arenaFlyout: ArenaFlyout; + public trainerBar: TeamBar; private fieldOverlay: Phaser.GameObjects.Rectangle; private shopOverlay: Phaser.GameObjects.Rectangle; @@ -473,6 +475,9 @@ export default class BattleScene extends SceneBase { this.arenaFlyout = new ArenaFlyout(this); this.fieldUI.add(this.arenaFlyout); this.fieldUI.moveBelow(this.arenaFlyout, this.fieldOverlay); + this.trainerBar = new TeamBar(this); + this.fieldUI.add(this.trainerBar); + this.fieldUI.moveBelow(this.trainerBar, this.fieldOverlay); this.updateUIPositions(); @@ -1396,6 +1401,7 @@ export default class BattleScene extends SceneBase { } processInfoButton(pressed: boolean): void { this.arenaFlyout.toggleFlyout(pressed); + this.trainerBar.toggleFlyout(pressed); } showFieldOverlay(duration: integer): Promise { diff --git a/src/ui/trainer-team-bar.ts b/src/ui/trainer-team-bar.ts new file mode 100644 index 00000000000..7051ad5434e --- /dev/null +++ b/src/ui/trainer-team-bar.ts @@ -0,0 +1,54 @@ +import BattleScene from "../battle-scene"; +import {addTextObject, TextStyle} from "./text"; +import i18next from "i18next"; +import * as Utils from "#app/utils"; +import { EnemyPokemon } from "#app/field/pokemon.js"; + +export default class TeamBar extends Phaser.GameObjects.Container { + // Public vars + public party: EnemyPokemon[]; + public gamescene: BattleScene; + + // Private vars + private bg: Phaser.GameObjects.NineSlice; + private teamIcons: Array; + private tween: Phaser.Tweens.Tween; + private components: any[] = []; + + // Constructor + constructor(scene: Phaser.Scene) { + super(scene, -150, 0); + this.gamescene = scene as BattleScene; + this.components = [this] + this.bg = this.scene.add.nineslice(-5, -5, "ability_bar_left", null, 200, 100, 0, 0, 10, 10); + this.bg.setOrigin(0, 0); + this.add(this.bg); + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 6; j++) { + if (i == 0) this.teamIcons[j] = [] + this.teamIcons[j][i] = this.scene.add.sprite(0, 0, "pb_tray_ball", "empty") + this.teamIcons[j][i].setOrigin(0, 0); + //this.teamIcons[j][i].setVisible(false); + this.add(this.teamIcons[j][i]) + this.components.push(this.teamIcons[j][i]) + } + } + } + + /* + Show or hide the BGM bar. + @param {boolean} visible Whether to show or hide the BGM bar. + */ + public toggleFlyout(visible: boolean): void { + this.scene.tweens.add({ + targets: this, + x: visible ? 0 : -200, + alpha: visible ? 1 : 0, + duration: 500, + ease: "Sine.easeInOut" + //onComplete: () => { + // + //} + }); + } +} \ No newline at end of file