feat: add edit display name of cheese mode
parent
81635f7de8
commit
29bf04091b
|
@ -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 ObjectPool from '../Pool/ObjectPool';
|
||||||
import { EventManger } from '../Manager/EventManger';
|
import { EventManger } from '../Manager/EventManger';
|
||||||
import GameEvent from '../Events/GameEvent';
|
import GameEvent from '../Events/GameEvent';
|
||||||
|
@ -15,6 +15,8 @@ export class BoosterBase extends Component implements IPoolable {
|
||||||
protected _collectSound: AudioClip;
|
protected _collectSound: AudioClip;
|
||||||
@property({ type: Animation, visible: true })
|
@property({ type: Animation, visible: true })
|
||||||
private _animation: Animation;
|
private _animation: Animation;
|
||||||
|
@property()
|
||||||
|
public readonly displayName: string = 'CHEESE';
|
||||||
|
|
||||||
@property(CCFloat)
|
@property(CCFloat)
|
||||||
protected time: number = 10;
|
protected time: number = 10;
|
||||||
|
|
|
@ -7,6 +7,6 @@ const { ccclass, property } = _decorator;
|
||||||
@ccclass('CumulativeBooster')
|
@ccclass('CumulativeBooster')
|
||||||
export class CumulativeBooster extends BoosterBase {
|
export class CumulativeBooster extends BoosterBase {
|
||||||
protected boosterActive(): void {
|
protected boosterActive(): void {
|
||||||
GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time);
|
GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time, this.displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export interface GameEventCallbackMap {
|
||||||
[GameEvent.TimeUpdate]: (time: number) => void;
|
[GameEvent.TimeUpdate]: (time: number) => void;
|
||||||
[GameEvent.GameStateChange]: (state: GameState) => void;
|
[GameEvent.GameStateChange]: (state: GameState) => void;
|
||||||
[GameEvent.ObjectRelease]: (obj: Node) => void;
|
[GameEvent.ObjectRelease]: (obj: Node) => void;
|
||||||
[GameEvent.BoosterActive]: (boosterType: BoosterType) => void;
|
[GameEvent.BoosterActive]: (boosterType: BoosterType, displayName: string) => void;
|
||||||
[GameEvent.BoosterDisable]: (boosterType: BoosterType) => void;
|
[GameEvent.BoosterDisable]: (boosterType: BoosterType) => void;
|
||||||
[GameEvent.ControlTouchStart]: (touchSide: ControllerSide) => void;
|
[GameEvent.ControlTouchStart]: (touchSide: ControllerSide) => void;
|
||||||
[GameEvent.ControlTouchEnd]: (touchSide: ControllerSide) => void;
|
[GameEvent.ControlTouchEnd]: (touchSide: ControllerSide) => void;
|
||||||
|
@ -39,7 +39,7 @@ export interface GameEventArgMap {
|
||||||
[GameEvent.TimeUpdate]: number;
|
[GameEvent.TimeUpdate]: number;
|
||||||
[GameEvent.GameStateChange]: GameState;
|
[GameEvent.GameStateChange]: GameState;
|
||||||
[GameEvent.ObjectRelease]: Node;
|
[GameEvent.ObjectRelease]: Node;
|
||||||
[GameEvent.BoosterActive]: BoosterType;
|
[GameEvent.BoosterActive]: [BoosterType, string];
|
||||||
[GameEvent.BoosterDisable]: BoosterType;
|
[GameEvent.BoosterDisable]: BoosterType;
|
||||||
[GameEvent.ControlTouchStart]: ControllerSide;
|
[GameEvent.ControlTouchStart]: ControllerSide;
|
||||||
[GameEvent.ControlTouchEnd]: ControllerSide;
|
[GameEvent.ControlTouchEnd]: ControllerSide;
|
||||||
|
|
|
@ -351,14 +351,14 @@ export class GameManager extends Singleton<GameManager>() {
|
||||||
SoundManager.instance.setPlayRateBGM(1);
|
SoundManager.instance.setPlayRateBGM(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ActiveBooster(type: BoosterType, time: number) {
|
public async ActiveBooster(type: BoosterType, time: number, displayName: string) {
|
||||||
//check booster already active
|
//check booster already active
|
||||||
for (let i = 0; i < this._boostersActive.length; i++) {
|
for (let i = 0; i < this._boostersActive.length; i++) {
|
||||||
const booster = this._boostersActive[i];
|
const booster = this._boostersActive[i];
|
||||||
if (booster.type == type) return;
|
if (booster.type == type) return;
|
||||||
}
|
}
|
||||||
this._boostersActive.push(new Booster(type, time));
|
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.playSfx(this._boosterActiveSound);
|
||||||
SoundManager.instance.setPlayRateBGM(1.25);
|
SoundManager.instance.setPlayRateBGM(1.25);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { GameManager } from '../Manager/GameManager';
|
||||||
import BEConnector from '../API/BEConnector';
|
import BEConnector from '../API/BEConnector';
|
||||||
import Utilities from '../Utilities';
|
import Utilities from '../Utilities';
|
||||||
import { StickerManager } from '../Manager/StickerManager';
|
import { StickerManager } from '../Manager/StickerManager';
|
||||||
|
import BoosterType from '../Enum/BoosterType';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('UIController')
|
@ccclass('UIController')
|
||||||
|
@ -86,9 +87,9 @@ export class UIController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onBoosterActive() {
|
public onBoosterActive(type: BoosterType, displayName: string) {
|
||||||
this._buffFx.play();
|
this._buffFx.play();
|
||||||
StickerManager.instance.showLabel('CHEESE!!!', {
|
StickerManager.instance.showLabel(displayName + '!!!', {
|
||||||
color: new Color('#ffb517'),
|
color: new Color('#ffb517'),
|
||||||
outLineColor: new Color('#ec830a'),
|
outLineColor: new Color('#ec830a'),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue