// ----------------- 更换角色状态 ------------------------- void StateEnter_ChangeRole(xc.Machine.State s) { if (ChangeRoleManager.Instance.IsChangeRole) { ChangeRoleManager.Instance.ChangeRole(); } }
static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <xc.Machine>(L, 4)) { string lua_script = LuaAPI.lua_tostring(L, 2); uint id = LuaAPI.xlua_touint(L, 3); xc.Machine machine = (xc.Machine)translator.GetObject(L, 4, typeof(xc.Machine)); xc.CommonLuaInstanceState __cl_gen_ret = new xc.CommonLuaInstanceState(lua_script, id, machine); translator.Push(L, __cl_gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 5 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <xc.Machine>(L, 4) && translator.Assignable <xc.Machine.State>(L, 5)) { string lua_script = LuaAPI.lua_tostring(L, 2); uint id = LuaAPI.xlua_touint(L, 3); xc.Machine machine = (xc.Machine)translator.GetObject(L, 4, typeof(xc.Machine)); xc.Machine.State owner = (xc.Machine.State)translator.GetObject(L, 5, typeof(xc.Machine.State)); xc.CommonLuaInstanceState __cl_gen_ret = new xc.CommonLuaInstanceState(lua_script, id, machine, owner); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.CommonLuaInstanceState constructor!")); }
void StateUpdate_ChangeRole(xc.Machine.State s) { if (!ChangeRoleManager.Instance.IsChangeRole) { mMachine.React((uint)GameEvent.GE_CHANGE_ROLE_FINISH); } }
static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <xc.Machine>(L, 2)) { xc.Machine machine = (xc.Machine)translator.GetObject(L, 2, typeof(xc.Machine)); xc.GameInitState __cl_gen_ret = new xc.GameInitState(machine); translator.Push(L, __cl_gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 3 && translator.Assignable <xc.Machine>(L, 2) && translator.Assignable <xc.Machine.State>(L, 3)) { xc.Machine machine = (xc.Machine)translator.GetObject(L, 2, typeof(xc.Machine)); xc.Machine.State owner = (xc.Machine.State)translator.GetObject(L, 3, typeof(xc.Machine.State)); xc.GameInitState __cl_gen_ret = new xc.GameInitState(machine, owner); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to xc.GameInitState constructor!")); }
public virtual void StateEnter_InPlay(xc.Machine.State s) { foreach (var behaviour in Behaviours) { behaviour.Value.StateEnter_InPlay(); } }
protected virtual void StateExit_InPause(xc.Machine.State s) { foreach (var behaviour in Behaviours) { behaviour.Value.StateExit_InPause(); } }
public void UpdateState_BeAtkBackward(xc.Machine.State s) { if (mkBackWardFunc != null) { mkBackWardFunc(); } }
protected virtual void StateEnter_Loadlevel(xc.Machine.State s) { GameDebug.Log("CommonInstanceState StateEnter_Loadlevel"); mUIStartLoaded = false; mLevelLoaded = false; }
public void UpdateState_Walk(xc.Machine.State s) { if (mOwner == null) { return; } if (mInBattleStatus != mOwner.InBattleStatus) { mInBattleStatus = mOwner.InBattleStatus; AnimationOptions op = mOwner.GetWalkAniOptions(); if (op != null) { float scale = op.OriSpeed != 0 ? MoveSpeed / op.OriSpeed : 1.0f; mOwner.SetMoveAnimationSpeed(scale); CrossFadeAnimation(op); } } // 变身状态下,播放动画的不是当前的模型 // 因此需要在此处检查下Animator下的状态是否正常 var walkOpt = mOwner.GetWalkAniOptions(); if (walkOpt != null) { if (!mOwner.IsInAnimationState(walkOpt.Name)) { CrossFadeAnimation(walkOpt); } } UpdateMoveToDest(); }
void StateEnter_LoginPlatform(xc.Machine.State s) { ControlServerLogHelper.GetInstance().PostStartClientLog(); GlobalConfig globalConfig = GlobalConfig.GetInstance(); if (globalConfig.IsEnterSDK) { login_wnd = "UIQuickLoginWindow"; UIManager.Instance.ShowWindow(login_wnd); } else { if (Game.Instance.IsSkillEditorScene == false) { if (string.IsNullOrEmpty(globalConfig.LoginInfo.AccName) == true) { login_wnd = "UIAccountWindow"; UIManager.Instance.ShowWindow(login_wnd); } else { login_wnd = "UILoginWindow"; UIManager.Instance.ShowWindow(login_wnd); } } } }
public void UpdateState_Reconnect(xc.Machine.State s) { if (!m_AutoConnect) { m_Machine.React((uint)EFSMEvent.DE_CannotReconnect); return; } m_RetryTime += Time.deltaTime; if (m_RetryTime > m_OfflineTimeout) { m_ForceRebot = false; m_Machine.React((uint)EFSMEvent.DE_ReconnectFail); return; } float cur_time = Time.time; if (cur_time < m_RetryNextTime) { return; } m_RetryNextTime = cur_time + 5.0f;// 5s尝试一次重连 if (Application.internetReachability == NetworkReachability.NotReachable) { } else { m_RetryCount++; RetryConnect(); GameDebug.Log(string.Format("重连{0}次", m_RetryCount)); } }
public CommonInstanceState(uint id, xc.Machine machine, xc.Machine.State owner, bool withInit = true) : base(id, machine, owner) { if (withInit) { Init(); } }
public void UpdateState_Idle(xc.Machine.State s) { if (mInBattleStatus != mOwner.InBattleStatus) { mInBattleStatus = mOwner.InBattleStatus; CrossFadeAnimation(mOwner.GetIdleAniOptions()); } }
public xc.Machine.State CreateState(uint id) { var state = new xc.Machine.State(id, mMachine, this); mStates[id] = state; return(state); }
// 第二层状态: normal State 的子状态 public void EnterState_Idle(xc.Machine.State s) // idle State { mIsIdle = true; mOwner.FireActorEvent(Actor.ActorEvent.ENTERIDLE, null); mWalkMode = EWalkMode.EWM_Uninit; CrossFadeAnimation(mOwner.GetIdleAniOptions()); mInBattleStatus = mOwner.InBattleStatus; }
protected virtual void Init() { InitBehaviours(); // 创建子状态 var stateLoadLevel = CreateState((uint)GameState.GS_LOADING_LEVEL); var stateLoadRes = CreateState((uint)GameState.GS_LOADING_RES); var stateInPlay = CreateState((uint)GameState.GS_IN_PLAY); var stateInPause = CreateState((uint)GameState.GS_IN_PAUSE); var stateComplete = CreateState((uint)GameState.GS_INSTANCE_COMPLETED); stateLoadLevel.SetEnterFunction(StateEnter_Loadlevel); stateLoadLevel.SetUpdateFunction(StateUpdate_Loadlevel); stateLoadLevel.SetExitFunction(StateExit_Loadlevel); stateLoadRes.SetEnterFunction(StateEnter_LoadRes); stateLoadRes.SetUpdateFunction(StateUpdate_LoadRes); stateLoadRes.SetExitFunction(StateExit_LoadRes); stateInPlay.SetEnterFunction(StateEnter_InPlay); stateInPlay.SetUpdateFunction(StateUpdate_InPlay); stateInPlay.SetExitFunction(StateExit_InPlay); stateInPause.SetEnterFunction(StateEnter_InPause); stateInPause.SetUpdateFunction(StateUpdate_InPause); stateInPause.SetExitFunction(StateExit_InPause); stateComplete.SetEnterFunction(StateEnter_Complete); stateComplete.SetUpdateFunction(StateUpdate_Complete); stateComplete.SetExitFunction(StateExit_Complete); // 状态图 -- begin stateLoadLevel.AddTransition((uint)GameEvent.GE_LEVEL_LOADED, stateLoadRes); stateLoadRes.AddTransition((uint)GameEvent.GE_INSTANCE_START, stateInPlay); stateLoadRes.AddTransition((uint)GameEvent.GE_DISCONNECT, stateLoadLevel); stateInPlay.AddTransition((uint)GameEvent.GE_INSTANCE_PAUSE, stateInPause); stateInPlay.AddTransition((uint)GameEvent.GE_INSTANCE_COMPLETED, stateComplete); stateInPlay.AddTransition((uint)GameEvent.GE_DISCONNECT, stateLoadLevel); stateInPause.AddTransition((uint)GameEvent.GE_DISCONNECT, stateLoadLevel); stateInPause.AddTransition((uint)GameEvent.GE_INSTANCE_RESUME, stateInPlay); stateComplete.AddTransition((uint)GameEvent.GE_INSTANCE_PAUSE, stateInPause); stateComplete.AddTransition((uint)GameEvent.GE_DISCONNECT, stateLoadLevel); stateComplete.AddTransition((uint)GameEvent.GE_INSTANCE_RESUME, stateInPlay); // 状态图 -- end foreach (var behaviour in Behaviours) { behaviour.Value.InitState(); } // 设置默认子状态 mInitChildState = stateLoadLevel; this.SetChild(mInitChildState); }
/// <summary> /// 更新死亡状态 /// </summary> public void UpdateState_Death(xc.Machine.State s) { if (mMoveImpl == null) { return; } if (!mDeathInfo.IsFlying) { if (!IsGrounded()) { Vector3 move = MoveSpeed * mDir * Time.deltaTime; move.y = mVerticalSpeed * Time.deltaTime; mMoveImpl.Move(move, true, false); mVerticalSpeed -= Time.deltaTime * m_Gravity; } // 因此在死亡前可能有恢复了变身状态,播放死亡动画的不是当前的模型 // 因此需要在此处检查下Animator下的状态是否正常 if (!mOwner.IsInAnimationState(DeathAnimation)) { PlayAnimation(DeathAnimation); } } else { // 浮空上升阶段 if (mVerticalSpeed > 0.0f || !mMoveImpl.IsGrounded) { Vector3 move = mDir * MoveSpeed * Time.deltaTime; // xz平面的移动 move.y = mVerticalSpeed * Time.deltaTime; // y高度的移动 mVerticalSpeed -= Time.deltaTime * m_Gravity; MoveSpeed -= Time.deltaTime * mDeathInfo.MoveXFric; MoveSpeed = Mathf.Max(MoveSpeed, 0); mMoveImpl.Move(move, false, false); } // 浮空下落阶段 if (mSwitch == false && mVerticalSpeed <= 0.0f) { AnimationOptions op = GetAnimationOptions(Actor.EAnimation.falling); PlayAnimation(op); mSwitch = true; } // 落地阶段 if (mDeathFlyDown == false && mMoveImpl.IsGrounded) { AnimationOptions falldownOp = GetAnimationOptions(Actor.EAnimation.falldown); PlayAnimation(falldownOp); mDeathFlyDown = true; } } }
public void ExitState_Attacking(xc.Machine.State s) { mIsAttacking = false; if (mOwner.GetCurSkill() != null) { mOwner.GetCurSkill().Interrupt(); } }
protected virtual void StateExit_LoadRes(xc.Machine.State s) { //GameInput.Instance.EnableInput(true); foreach (var behaviour in Behaviours) { behaviour.Value.StateExit_LoadRes(); } }
public void ExitState_JumpScene(xc.Machine.State s) { Debug.Log("ExitState_JumpScene"); if (mOwner.AnimationCtrl != null) { mOwner.AnimationCtrl.CullMode = mCullingMode; } mOwner.FireActorEvent(Actor.ActorEvent.EXIT_JUMPSCENE_STATE, null); }
public void UpdateState_JumpScene(xc.Machine.State s) { float curTime = Time.time; if (!mOwner.IsPlaying(mJumpSceneAnimation) || curTime - mJumpTime > mJumpMaxTime) { mMachine.React((uint)ActorMachine.EFSMEvent.DE_JumpSceneFinish); } }
public void ExitState_Interaction(xc.Machine.State s) { //GameDebug.LogError("ExitState_Interaction"); mIsInInteraction = false; if (mOwner != null && mOwner.IsLocalPlayer) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCAL_PLAYER_EXIT_INTERACTION, new CEventBaseArgs(null)); } }
protected virtual void StateEnter_Complete(xc.Machine.State s) { GameInput.Instance.EnableInput(false); foreach (var behaviour in Behaviours) { behaviour.Value.StateEnter_Complete(); } }
public void EnterState_Attacking(xc.Machine.State s)// Attack State { mIsAttacking = true; if (mOwner.mRideCtrl != null && mOwner.mRideCtrl.IsRiding()) { mOwner.mRideCtrl.UnRide(true); } }
void StateUpdate_LoadingLevel(xc.Machine.State s) { if (Game.GetInstance().GetLoadAsyncOp() == null || !Game.GetInstance().GetLoadAsyncOp().isDone) { return; } mMachine.React((uint)GameEvent.GE_LEVEL_LOADED); }
void ExitState_Idle(xc.Machine.State s) { mIsIdle = false; mOwner.FireActorEvent(Actor.ActorEvent.EXITIDLE, null); if (mOwner is LocalPlayer) { xc.ClientEventManager <ClientEvent> .Instance.FireEvent(ClientEvent.PLAYER_EXIT_IDLE, null); } }
public void ExitState_Death(xc.Machine.State s) { mIsDead = false; MoveSpeed = 0.0f; mVerticalSpeed = 0.0f; if (mOwner != null && mOwner.IsLocalPlayer) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCAL_PLAYER_NWAR_REVIVE, null); } }
void Init() { // 创建子状态 // 检查版本信息 xc.Machine.State stateCheckingVersion = new xc.Machine.State((uint)GameState.GS_CHECKING_VERSION, mMachine, this); // 加载登陆场景 xc.Machine.State stateLoadingScene = new xc.Machine.State((uint)GameState.GS_LOADING_LEVEL, mMachine, this); // 登陆sdk xc.Machine.State stateLoginPlatform = new xc.Machine.State((uint)GameState.GS_LOGIN_PLATFORM, mMachine, this); // 完成状态 xc.Machine.State stateInitDone = new xc.Machine.State((uint)GameState.GS_INIT_DONE, mMachine, this); // 更换角色状态 xc.Machine.State stateChangeRole = new xc.Machine.State((uint)GameState.GS_CHANGE_ROLE, mMachine, this); stateCheckingVersion.SetEnterFunction(StateEnter_CheckingVersion); stateCheckingVersion.SetUpdateFunction(StateUpdate_CheckingVersion); stateLoadingScene.SetEnterFunction(StateEnter_LoadingLevel); stateLoadingScene.SetUpdateFunction(StateUpdate_LoadingLevel); stateLoginPlatform.SetEnterFunction(StateEnter_LoginPlatform); stateLoginPlatform.SetUpdateFunction(StateUpdate_LoginPlatform); stateInitDone.SetEnterFunction(StateEnter_InitDone); stateChangeRole.SetEnterFunction(StateEnter_ChangeRole); stateChangeRole.SetUpdateFunction(StateUpdate_ChangeRole); // 状态图 -- begin stateCheckingVersion.AddTransition((uint)GameEvent.GE_VERSION_CHECKED, stateLoadingScene); stateLoadingScene.AddTransition((uint)GameEvent.GE_LEVEL_LOADED, stateLoginPlatform); stateLoginPlatform.AddTransition((uint)GameEvent.GE_LOGINED_PLATFORM, stateInitDone); stateChangeRole.AddTransition((uint)GameEvent.GE_CHANGE_ROLE_FINISH, stateInitDone); stateInitDone.AddTransition((uint)GameEvent.GE_CHANGE_ROLE, stateChangeRole); stateLoadingScene.AddTransition((uint)GameEvent.GE_RESET, stateCheckingVersion); stateLoginPlatform.AddTransition((uint)GameEvent.GE_RESET, stateCheckingVersion); stateInitDone.AddTransition((uint)GameEvent.GE_RESET, stateCheckingVersion); stateChangeRole.AddTransition((uint)GameEvent.GE_RESET, stateCheckingVersion); // 状态图 -- end // 设置默认子状态 this.SetChild(stateCheckingVersion); #if UNITY_IPHONE //断线手动点击取消按钮返回选服界面时,不清登录信息 if (Game.Instance.ManualCancelReconnect == false) { GlobalConfig.GetInstance().ResetLoginInfo(); } #endif }
void StateUpdate_Loadlevel(xc.Machine.State s) { if (Game.GetInstance().GetLoadAsyncOp() == null) { return; } if (Game.GetInstance().GetLoadAsyncOp().isDone&& mUILoaded) { mMachine.React((uint)xc.GameEvent.GE_LEVEL_LOADED); } }
static int _g_get_Name(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { xc.Machine.State __cl_gen_to_be_invoked = (xc.Machine.State)translator.FastGetCSObj(L, 1); LuaAPI.lua_pushstring(L, __cl_gen_to_be_invoked.Name); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }