protected virtual void UpdateSelfCtrlState(fsm.State _curState) { if (thisPlayer != null && !thisPlayer.commandMng.HasCommand() && !PlayerInputListener.isDragingRockerItem) //如果自主命令都已经执行完毕,重新回到战斗 { startFightPos = thisPlayer.transform.position; switch (thisPlayer.AttakType) { case MainPlayer.AttackType.NONE: stateMachine.Stop(); break; case MainPlayer.AttackType.NORMALFIGHT: thisPlayer.GoNormal(); break; case MainPlayer.AttackType.AUTOFIGHT: case MainPlayer.AttackType.COMPLETE_TASK: stateMachine.Send((int)EventType.AUTOFIGHT); break; default: break; } } }
protected virtual void UpdateTargetState(fsm.State _curState) { if (Time.frameCount % 10 == 0) { if (thisTarget != null) { thisPlayer.CurTarget = thisTarget; switch (thisPlayer.AttakType) { case MainPlayer.AttackType.NONE: stateMachine.Stop(); break; case MainPlayer.AttackType.NORMALFIGHT: stateMachine.Send((int)EventType.FIGHT); break; case MainPlayer.AttackType.AUTOFIGHT: case MainPlayer.AttackType.COMPLETE_TASK: stateMachine.Send((int)EventType.AUTOFIGHT); break; default: break; } } else { ChangeTarget(); } } }
/// <summary> /// 加载结束,进入游戏运行状态 by吴江 /// </summary> /// <param name="_from"></param> /// <param name="_to"></param> /// <param name="_event"></param> protected void EnterRunState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (_from.name != "load" && _from.name != "newbieGuide") { GameCenter.cameraMng.BlackCoverAll(false); } SystemSettingMng.CullingShow = true; LoadSceneEffects(); //NPC BuildNPCs(); BuildMonsters(); BuildTraps(); BuildOPCs(); BuildItems(); RefreshAbilityBallisticCurve(-1); GameCenter.mainPlayerMng.lastSceneID = sceneID; // //if (GameCenter.sceneAnimMng.RestAnimCount > 0) //{ // stateMachine.Send((int)EventType.SCENE_ANIMATION); //} if (_from.name != "load" && _from.name != "newbieGuide") { // GameCenter.uIMng.GenGUI(GUIType.MAINDUNGEON, true); } // if(_from.name == "sceneAnimState") // { // OnSceneStateChange(true); // } alreadyHasMob = false; }
protected override void EnterMoveState(fsm.State _from, fsm.State _to, fsm.Event _event) { anim.Rewind(curMoveName); float fadeDuraton = 0.3f; anim.CrossFade(curMoveName, fadeDuraton); }
void EnterFollowState(fsm.State _from, fsm.State _to, fsm.Event _event) { GameSys.Log("NPC开始跟随"); if (moveFSM != null) { moveFSM.UnLockMoving(); } int count = curTarget.positionSlots.Count; bool foundSlot = false; for (int i = 0; i < count; i++) { if (curTarget.positionSlots[i].occupyObj == null) { foundSlot = true; followSlot = i; } } if (!foundSlot) { followSlot = curTarget.AddPositionSlot(); } curTarget.positionSlots[followSlot].occupyObj = this.gameObject; MoveTo(curTarget.positionSlots[followSlot].obj.transform.position); }
protected virtual void UpdateInitConfigState(fsm.State _curState) { if (TableMng.intance.LoadFinish) { stateMachine.Send((int)EventType.ENTER_DUNGEON); } }
protected virtual void UpdateAwakeState(fsm.State _curState) { if (thisPlayer != null && !thisPlayer.isDummy && GameCenter.curGameStage != null && GameCenter.sceneMng != null) { stateMachine.Send((int)EventType.FLOW); } }
/// <summary> /// 更新启动状态 by吴江 /// </summary> /// <param name="_curState"></param> protected void UpdateAwakeState(fsm.State _curState) { if (SceneManager.GetActiveScene().name == "CityStage") { stateMachine.Send((int)EventType.LOAD); } }
protected void EnterCreateCharState(fsm.State _from, fsm.State _to, fsm.Event _event) { curGameStage.UnRegistAll(); curGameStage = null; Destroy(stageObj.GetComponent <GameStage>()); //curGameStage = stageObj.AddComponent<CharacterCreateStage>(); }
protected void ExitRunState(fsm.State _from, fsm.State _to, fsm.Event _event) { GameCenter.uIMng.ReleaseGUI(GUIType.LITTLEMAP); GameCenter.uIMng.ReleaseGUI(GUIType.TASK); GameCenter.uIMng.ReleaseGUI(GUIType.MAINFIGHT); GameCenter.uIMng.ReleaseGUI(GUIType.GUILDACTIVITYCOPPY); }
void ExitSelectedState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (OnFinish != null) { OnFinish(); } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected override void InitStateMachine() { // ======================================================== // init states // ======================================================== fsm.State launch = new fsm.State("launch", stateMachine); launch.onEnter += EnterLaunchState; launch.onExit += ExitLaunchState; fsm.State loading = new fsm.State("loading", stateMachine); loading.onEnter += EnterLoadingState; loading.onExit += ExitLoadingState; fsm.State stage = new fsm.State("stage", stateMachine); stage.onEnter += EnterStageState; stage.onExit += ExitStageState; // ======================================================== // setup transitions // ======================================================== launch.Add <fsm.EventTransition> (stage, (int)EventType.ShowStage); loading.Add <fsm.EventTransition> (stage, (int)EventType.ShowStage); stage.Add <fsm.EventTransition> (loading, (int)EventType.LoadStage); }
void UpdateFightWinState(fsm.State _curState) { if (Time.time - winStartTime >= winDuration) { stateMachine.Send((int)EventType.Idle); } }
protected override void InitStateMachine() { base.InitStateMachine(); fsm.State cower = new fsm.State("cower", stateMachine); cower.onEnter += EnterCowerState; cower.onAction += UpdateCowerState; fsm.State backOn = new fsm.State("beckon", stateMachine); backOn.onEnter += EnterBeckonState; backOn.onAction += UpdateBeckonState; idle.Add <fsm.EventTransition>(cower, (int)EventType.Cower); idle.Add <fsm.EventTransition>(backOn, (int)EventType.Beckon); cower.Add <fsm.EventTransition>(idle, (int)EventType.Idle); cower.Add <fsm.EventTransition>(backOn, (int)EventType.Beckon); cower.Add <fsm.EventTransition>(move, (int)EventType.Move); backOn.Add <fsm.EventTransition>(idle, (int)EventType.Idle); backOn.Add <fsm.EventTransition>(cower, (int)EventType.Cower); backOn.Add <fsm.EventTransition>(move, (int)EventType.Move); move.Add <fsm.EventTransition>(backOn, (int)EventType.Beckon); move.Add <fsm.EventTransition>(idle, (int)EventType.Idle); move.Add <fsm.EventTransition>(cower, (int)EventType.Cower); randIdle.Add <fsm.EventTransition>(cower, (int)EventType.Cower); randIdle.Add <fsm.EventTransition>(backOn, (int)EventType.Beckon); }
protected void UpdateFightLoseState(fsm.State _curState) { if (Time.time - loseStartTime >= loseDuration) { stateMachine.Send((int)EventType.Idle); } }
protected void EnterAwakeState(fsm.State _from, fsm.State _to, fsm.Event _event) { GameCenter.instance.IsReConnecteding = false; GameCenter.uIMng.ReleaseGUI(GUIType.MERRYGOROUND); GameCenter.uIMng.ReleaseGUI(GUIType.LOADING); GameCenter.uIMng.ReleaseGUI(GUIType.MAINFIGHT); GameCenter.uIMng.ReleaseGUI(GUIType.LITTLEMAP); GameCenter.uIMng.ReleaseGUI(GUIType.TASK); GameCenter.uIMng.ReleaseGUI(GUIType.GUILDACTIVITYCOPPY); GameCenter.uIMng.ReleaseGUI(GUIType.TASK_FINDING); if (GameCenter.curMainPlayer != null) { Destroy(GameCenter.curMainPlayer.gameObject); } if (GameCenter.curMainEntourage != null) { Destroy(GameCenter.curMainEntourage.gameObject); } //GameCenter.uIMng.GenGUI(GUIType.LOGIN,true); GameCenter.cameraMng.BlackCoverAll(false); SceneManager.LoadScene("LoginStage"); YvVoiceSdk.YvVoiceLogOut(); CurLoginState = EventType.AWAKE; NetMsgMng.ConectClose(); }
protected virtual void UpdateFlowState(fsm.State _curState) { if (thisPlayer.isDead) { return; } if (CheckNeedTeleport()) { return; } if (thisPlayer != null && !thisPlayer.commandMng.HasCommand())//如果自主命令都已经执行完毕,重新回到战斗 { float sqr = (thisPlayer.transform.position - owner.transform.position).sqrMagnitude; if (sqr >= stopFollowRange * stopFollowRange) { Command_MoveTo movetoCMD = new Command_MoveTo(); movetoCMD.destPos = Utils.GetRandomPos(owner.transform); thisPlayer.commandMng.PushCommand(movetoCMD); } else { stateMachine.Send((int)EventType.PVP_FIGHT_TRACE); } } }
void UpdateCowerState(fsm.State _curState) { if (Time.time - timer > duration) { stateMachine.Send((int)NPCAnimFSM.EventType.Idle); } }
protected override void InitStateMachine() { base.InitStateMachine(); fsm.State awake = new fsm.State("awake", stateMachine); awake.onEnter += EnterAwakeState; awake.onAction += UpdateAwakeState; fsm.State load = new fsm.State("load", stateMachine); load.onEnter += EnterLoadtate; load.onAction += UpdateLoadState; load.onExit += ExitLoadState; reconnectState = new fsm.State("reconnectState", stateMachine); reconnectState.onEnter += EnterReconnectState; reconnectState.onAction += UpdateReconnectState; reconnectState.onExit += ExitReconnectState; fsm.State run = new fsm.State("run", stateMachine); run.onEnter += EnterRunState; run.onAction += UpdateRunState; run.onExit += ExitRunState; reconnectState.Add <fsm.EventTransition>(run, (int)EventType.RUN); run.Add <fsm.EventTransition>(reconnectState, (int)EventType.RECONNECT); awake.Add <fsm.EventTransition>(load, (int)EventType.LOAD); load.Add <fsm.EventTransition>(run, (int)EventType.RUN); load.Add <fsm.EventTransition>(awake, (int)EventType.AWAKE); load.Add <fsm.EventTransition>(reconnectState, (int)EventType.RECONNECT);//加载的时候可能掉线重连 stateMachine.initState = awake; }
protected override void InitStateMachine() { base.InitStateMachine(); fsm.State awake = new fsm.State("awake", stateMachine); awake.onEnter += EnterAwakeState; awake.onAction += UpdateAwakeState; fsm.State newbieGuide = new fsm.State("newbieGuide", stateMachine); newbieGuide.onEnter += EnterNewbieGuideState; newbieGuide.onAction += UpdateNewbieGuideState; newbieGuide.onExit += ExitNewbieGuideState; fsm.State load = new fsm.State("load", stateMachine); load.onEnter += EnterLoadtate; load.onAction += UpdateLoadState; load.onExit += ExitLoadState; reconnectState = new fsm.State("reconnectState", stateMachine); reconnectState.onEnter += EnterReconnectState; reconnectState.onAction += UpdateReconnectState; reconnectState.onExit += ExitReconnectState; fsm.State run = new fsm.State("run", stateMachine); run.onEnter += EnterRunState; run.onAction += UpdateRunState; run.onExit += ExitRunState; fsm.State blackProcess = new fsm.State("blackProcess", stateMachine); blackProcess.onEnter += EnterBlackProcesstate; blackProcess.onAction += UpdateBlackProcesState; blackProcess.onExit += ExitBlackProcesState; awake.Add <fsm.EventTransition>(load, (int)EventType.LOAD); awake.Add <fsm.EventTransition>(newbieGuide, (int)EventType.NEWBIE_GUIDE); newbieGuide.Add <fsm.EventTransition>(load, (int)EventType.LOAD); newbieGuide.Add <fsm.EventTransition>(run, (int)EventType.RUN); load.Add <fsm.EventTransition>(run, (int)EventType.RUN); load.Add <fsm.EventTransition>(awake, (int)EventType.AWAKE); //加载的时候可能掉线重连 load.Add <fsm.EventTransition>(newbieGuide, (int)EventType.NEWBIE_GUIDE); //run.Add<fsm.EventTransition>(sceneAnimState, (int)EventType.SCENE_ANIMATION); //sceneAnimState.Add<fsm.EventTransition>(run, (int)EventType.RUN); blackProcess.Add <fsm.EventTransition>(run, (int)EventType.RUN); //blackProcess.Add<fsm.EventTransition>(sceneAnimState, (int)EventType.SCENE_ANIMATION); blackProcess.Add <fsm.EventTransition>(load, (int)EventType.LOAD); //sceneAnimState.Add<fsm.EventTransition>(blackProcess, (int)EventType.BLACK_PROCESS); run.Add <fsm.EventTransition>(blackProcess, (int)EventType.BLACK_PROCESS); load.Add <fsm.EventTransition>(blackProcess, (int)EventType.BLACK_PROCESS); //load.Add<fsm.EventTransition>(reconnectState, (int)EventType.RECONNECT); reconnectState.Add <fsm.EventTransition>(run, (int)EventType.RUN); run.Add <fsm.EventTransition>(reconnectState, (int)EventType.RECONNECT); load.Add <fsm.EventTransition>(reconnectState, (int)EventType.RECONNECT); stateMachine.initState = awake; }
void EnterAppearState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (anim == null) { anim = gameObject.GetComponentInChildren <Animation>(); } anim.CrossFade("airwall_loop", 0.5f); }
protected virtual void UpdatePVEFightState(fsm.State _curState) { if (thisPlayer.isDead) { return; } TryFight(EventType.PVE_FIGHT, EventType.FLOW, pveReturnRange); }
void EnterNormalState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (anim == null) { anim = gameObject.GetComponentInChildren <Animation>(); } // anim.CrossFade(curIdleName, 0.5f); }
protected void EnterStopState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (choosePlayerSceneObj != null) { Destroy(choosePlayerSceneObj); choosePlayerSceneObj = null; } }
protected void EnterMagicState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (anim["magic01"] != null) { anim.CrossFade("magic01"); anim["magic01"].wrapMode = WrapMode.Loop; } }
protected virtual void UpdatePVPFightState(fsm.State _curState) { if (thisPlayer.isDead) { return; } TryFight(EventType.PVP_FIGHT, EventType.PVE_FIGHT, pvpAttackRange); }
protected virtual void UpdatePVPTraceFightState(fsm.State _curState) { if (thisPlayer.isDead) { return; } TryFight(EventType.PVP_FIGHT_TRACE, EventType.PVP_FIGHT_DEFENSE, pvpMasterAtkRange); }
protected virtual void UpdatePVPDefenseFightState(fsm.State _curState) { if (thisPlayer.isDead) { return; } TryFight(EventType.PVP_FIGHT_DEFENSE, EventType.PVE_TRACE, pvpDefenseRange); }
protected virtual void ExitHoldOnState(fsm.State _from, fsm.State _to, fsm.Event _event) { if (moveFSM != null) { moveFSM.UnLockMoving(); } lastFSMState = EventType.HOLD_ON; }
void UpdateCowerState(fsm.State _curState) { timer -= Time.deltaTime; if (timer < 0) { stateMachine.Send((int)EventType.Idle); } }