diff --git a/assets/_Game/Scripts/Booster/BoosterBase.ts b/assets/_Game/Scripts/Booster/BoosterBase.ts index 71b9c1c..e3bf661 100644 --- a/assets/_Game/Scripts/Booster/BoosterBase.ts +++ b/assets/_Game/Scripts/Booster/BoosterBase.ts @@ -1,4 +1,4 @@ -import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip } from 'cc'; +import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip, CCString } from 'cc'; import ObjectPool from '../Pool/ObjectPool'; import { EventManger } from '../Manager/EventManger'; import GameEvent from '../Events/GameEvent'; @@ -15,6 +15,8 @@ export class BoosterBase extends Component implements IPoolable { protected _collectSound: AudioClip; @property({ type: Animation, visible: true }) private _animation: Animation; + @property() + public readonly displayName: string = 'CHEESE'; @property(CCFloat) protected time: number = 10; diff --git a/assets/_Game/Scripts/Booster/CumulativeBooster.ts b/assets/_Game/Scripts/Booster/CumulativeBooster.ts index 852c1a1..9abc526 100644 --- a/assets/_Game/Scripts/Booster/CumulativeBooster.ts +++ b/assets/_Game/Scripts/Booster/CumulativeBooster.ts @@ -7,6 +7,6 @@ const { ccclass, property } = _decorator; @ccclass('CumulativeBooster') export class CumulativeBooster extends BoosterBase { protected boosterActive(): void { - GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time); + GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time, this.displayName); } } diff --git a/assets/_Game/Scripts/Events/GameEvent.ts b/assets/_Game/Scripts/Events/GameEvent.ts index e5befa1..e7bc2fc 100644 --- a/assets/_Game/Scripts/Events/GameEvent.ts +++ b/assets/_Game/Scripts/Events/GameEvent.ts @@ -25,7 +25,7 @@ export interface GameEventCallbackMap { [GameEvent.TimeUpdate]: (time: number) => void; [GameEvent.GameStateChange]: (state: GameState) => void; [GameEvent.ObjectRelease]: (obj: Node) => void; - [GameEvent.BoosterActive]: (boosterType: BoosterType) => void; + [GameEvent.BoosterActive]: (boosterType: BoosterType, displayName: string) => void; [GameEvent.BoosterDisable]: (boosterType: BoosterType) => void; [GameEvent.ControlTouchStart]: (touchSide: ControllerSide) => void; [GameEvent.ControlTouchEnd]: (touchSide: ControllerSide) => void; @@ -39,7 +39,7 @@ export interface GameEventArgMap { [GameEvent.TimeUpdate]: number; [GameEvent.GameStateChange]: GameState; [GameEvent.ObjectRelease]: Node; - [GameEvent.BoosterActive]: BoosterType; + [GameEvent.BoosterActive]: [BoosterType, string]; [GameEvent.BoosterDisable]: BoosterType; [GameEvent.ControlTouchStart]: ControllerSide; [GameEvent.ControlTouchEnd]: ControllerSide; diff --git a/assets/_Game/Scripts/Manager/GameManager.ts b/assets/_Game/Scripts/Manager/GameManager.ts index 8796204..ced8cc4 100644 --- a/assets/_Game/Scripts/Manager/GameManager.ts +++ b/assets/_Game/Scripts/Manager/GameManager.ts @@ -351,14 +351,14 @@ export class GameManager extends Singleton() { SoundManager.instance.setPlayRateBGM(1); } - public async ActiveBooster(type: BoosterType, time: number) { + public async ActiveBooster(type: BoosterType, time: number, displayName: string) { //check booster already active for (let i = 0; i < this._boostersActive.length; i++) { const booster = this._boostersActive[i]; if (booster.type == type) return; } this._boostersActive.push(new Booster(type, time)); - EventManger.instance.emit(GameEvent.BoosterActive, type); + EventManger.instance.emit(GameEvent.BoosterActive, [type, displayName]); SoundManager.instance.playSfx(this._boosterActiveSound); SoundManager.instance.setPlayRateBGM(1.25); } diff --git a/assets/_Game/Scripts/UI/UIController.ts b/assets/_Game/Scripts/UI/UIController.ts index 0f3b627..2f5b84f 100644 --- a/assets/_Game/Scripts/UI/UIController.ts +++ b/assets/_Game/Scripts/UI/UIController.ts @@ -7,6 +7,7 @@ import { GameManager } from '../Manager/GameManager'; import BEConnector from '../API/BEConnector'; import Utilities from '../Utilities'; import { StickerManager } from '../Manager/StickerManager'; +import BoosterType from '../Enum/BoosterType'; const { ccclass, property } = _decorator; @ccclass('UIController') @@ -86,9 +87,9 @@ export class UIController extends Component { } } - public onBoosterActive() { + public onBoosterActive(type: BoosterType, displayName: string) { this._buffFx.play(); - StickerManager.instance.showLabel('CHEESE!!!', { + StickerManager.instance.showLabel(displayName + '!!!', { color: new Color('#ffb517'), outLineColor: new Color('#ec830a'), });