public bool changeProcedure(PROCEDURE_TYPE procedure, string intent) { if (mSceneProcedureList.ContainsKey(procedure)) { // 将上一个流程记录到返回列表中 if (mCurProcedure != null) { mLastProcedureList.Add(mCurProcedure.getType()); } if (mCurProcedure == null || mCurProcedure.getType() != procedure) { SceneProcedure targetProcedure = mSceneProcedureList[procedure]; // 如果当前已经在一个流程中了,则要先退出当前流程,但是不要销毁流程 if (mCurProcedure != null) { // 需要找到共同的父节点,退到该父节点时则不再退出 SceneProcedure exitTo = mCurProcedure.getSameParent(targetProcedure); SceneProcedure nextPro = targetProcedure; mCurProcedure.exit(exitTo, nextPro); } SceneProcedure lastProcedure = mCurProcedure; mCurProcedure = targetProcedure; if (mCurProcedure != null) { mCurProcedure.init(lastProcedure, intent); } } return(true); } else { UnityUtility.logError("error : can not find scene procedure : " + procedure); } return(false); }
// 是否在指定的流程,不考虑子流程 public bool atSelfProcedure(Type type) { if (mCurProcedure == null) { return(false); } return(mCurProcedure.getType() == type); }
public bool addChildProcedure(SceneProcedure child) { if (child == null) { return(false); } if (mChildProcedureList.ContainsKey(child.getType())) { return(false); } child.setParent(this); mChildProcedureList.Add(child.getType(), child); return(true); }
public SceneProcedure addProcedure(Type type, Type parent = null) { SceneProcedure procedure = createInstance <SceneProcedure>(type); procedure.setGameScene(this); procedure.setType(type); if (parent != null) { SceneProcedure parentProcedure = getProcedure(parent); if (parentProcedure == null) { logError("invalid parent procedure, procedure:" + procedure.getType()); } parentProcedure.addChildProcedure(procedure); } mSceneProcedureList.Add(procedure.getType(), procedure); return(procedure); }
public T addProcedure <T>(PROCEDURE_TYPE type, SceneProcedure parent = null) where T : SceneProcedure, new() { SceneProcedure procedure = createProcedure <T>(this, type); if (parent != null) { parent.addChildProcedure(procedure); } mSceneProcedureList.Add(procedure.getType(), procedure); return(procedure as T); }
public void Update() { if (!FrameBase.mGameFramework.isEnableScriptDebug()) { return; } SceneProcedure sceneProcedure = mGameScene.getCurProcedure(); if (sceneProcedure != null) { mCurProcedure = sceneProcedure.getType().ToString(); } }
public SceneProcedure getParent(PROCEDURE_TYPE type) { // 没有父节点,返回null if (mParentProcedure == null) { return(null); } // 有父节点,则判断类型是否匹配,匹配则返回父节点 if (mParentProcedure.getType() == type) { return(mParentProcedure); } // 不匹配,则继续向上查找 else { return(mParentProcedure.getParent(type)); } }
public override void execute() { var gameScene = mReceiver as GameScene; // 当流程正在准备跳转流程时,不允许再跳转 SceneProcedure curProcedure = gameScene.getCurProcedure(); if (curProcedure != null && curProcedure.isPreparingExit()) { logError("procedure is preparing to change, can not change again!"); return; } // 不能重复进入同一流程 if (curProcedure != null && curProcedure.getType() == mProcedure) { return; } gameScene.changeProcedure(mProcedure, mIntent); }