66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
const { ccclass } = cc._decorator;
|
|
|
|
type WinPanelAction = (event?: cc.Event, customEventData?: string) => void;
|
|
|
|
interface WinPanelActions {
|
|
[name: string]: WinPanelAction;
|
|
}
|
|
|
|
/** Win prefab 内部按钮入口;具体游戏流程由 Map 在实例化后注入。 */
|
|
@ccclass
|
|
export default class WinPanel extends cc.Component {
|
|
private actions: WinPanelActions = null;
|
|
|
|
bind(actions: WinPanelActions) {
|
|
this.actions = actions || {};
|
|
}
|
|
|
|
setSpecialTipsVisible(visible: boolean) {
|
|
const specialTips = this.node.getChildByName("specialTips");
|
|
if (specialTips) {
|
|
specialTips.active = visible;
|
|
}
|
|
}
|
|
|
|
openPosition(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("openPosition", event, customEventData);
|
|
}
|
|
|
|
winMaxLevelShowClose() {
|
|
this.setSpecialTipsVisible(false);
|
|
}
|
|
|
|
winLevel(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("winLevel", event, customEventData);
|
|
}
|
|
|
|
winLevel2(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("winLevel2", event, customEventData);
|
|
}
|
|
|
|
returnHome(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("returnHome", event, customEventData);
|
|
}
|
|
|
|
returnHomeScene(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("returnHomeScene", event, customEventData);
|
|
}
|
|
|
|
showDoubleCoin(event?: cc.Event, customEventData?: string) {
|
|
this.invoke("showDoubleCoin", event, customEventData);
|
|
}
|
|
|
|
private invoke(name: string, event?: cc.Event, customEventData?: string) {
|
|
const action = this.actions && this.actions[name];
|
|
if (action) {
|
|
action(event, customEventData);
|
|
return;
|
|
}
|
|
cc.warn("WinPanel action is not bound:", name);
|
|
}
|
|
|
|
onDestroy() {
|
|
this.actions = null;
|
|
}
|
|
}
|