123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import BasicTreeBehaviorNode from "../../Engine/Basic/BasicTreeBehaviorNode";
- import BasicTreeControlNode from "../../Engine/Basic/BasicTreeControlNode";
- import EventManager from "../../Engine/Event/EventManager";
- import { ConstObject } from "../Data/GameDataType";
- import GameEventName from "../Event/GameEventName";
- import { _EGameFlow } from "./Data/GameFlowConfig";
- import Game_Gameing_Flow from "./Game_Gameing_Flow";
- import Game_Hall_Flow from "./Game_Hall_Flow";
- import { Game_Hall_Precondition } from "./Game_Hall_Precondition";
- import Game_InitLoad_Flow from "./Game_InitLoad_Flow";
- import Game_Login_Flow from "./Game_Login_Flow";
- import Game_Over_Flow from "./Game_Over_Flow";
- import { GameFlowTree_Precondition } from "./GameFlowTree_Precondition";
- import Game_WaitStart_Flow from "./Game_WaitStart_Flow";
- import { _IBehaviorTreeConfig } from "../../Engine/Data/CommonDataType";
- /**
- * 游戏流程树 - 逻辑层
- */
- export default class GameFlowTree extends BasicTreeControlNode {
- constructor (node: cc.Node, flowTreeConfig: _IBehaviorTreeConfig) {
- let GameFlowComponent = {
- "Login": Game_Login_Flow,
- "InitLoad": Game_InitLoad_Flow,
- "Hall": Game_Hall_Flow,
- "WaitStart": Game_WaitStart_Flow,
- "Gameing": Game_Gameing_Flow,
- "Over": Game_Over_Flow,
- };
- let data: Array<_EGameFlow> = Object.values(_EGameFlow);
- let controls = new Map<_EGameFlow, BasicTreeBehaviorNode>();
- for (let index in data) {
- let key = data[index];
- let control: any = GameFlowComponent[key];
- if (control != null) {
- let precondition: GameFlowTree_Precondition = new GameFlowTree_Precondition(flowTreeConfig.priority[key]);
- ConstObject.CreatePrecondition(precondition, data)
- controls.set(key, new control(node, _EGameFlow[key], precondition));
- }
- }
-
- super(node, "", ConstObject.GameFlowTreeID, flowTreeConfig, controls);
- EventManager.onEvent(GameEventName.Game_GetGameFlow, this, this.onGetGameFlow);
- }
- protected _enterFail (): void {
-
- }
- protected _enterAgain (): void {
-
- }
-
- /**获得当前游戏流程 */
- private onGetGameFlow (callback: Function): void {
- callback && callback(this.currentChilds.pop());
- }
- }
|