public CommonLuaInstanceState(string lua_script, uint id, xc.Machine machine, xc.Machine.State owner) : base(id, machine, owner, false) { this.LuaScript = lua_script; this.Prepare(); this.Init(); }
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!")); }
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 CommonInstanceState(uint id, xc.Machine machine, xc.Machine.State owner, bool withInit = true) : base(id, machine, owner) { if (withInit) { Init(); } }
static int _s_set_bIsDebug(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { xc.Machine __cl_gen_to_be_invoked = (xc.Machine)translator.FastGetCSObj(L, 1); __cl_gen_to_be_invoked.bIsDebug = LuaAPI.lua_toboolean(L, 2); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
static int _g_get_StateList(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { xc.Machine __cl_gen_to_be_invoked = (xc.Machine)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.StateList); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }
public void Destroy() { RecycleState(); if (mMachine != null) { mMachine.Destroy(); ObjCachePoolMgr.Instance.RecycleCSharpObject(mMachine, ObjCachePoolType.MACHINE, mMachinePoolKey); mMachine = null; } mDestList.Release(); }
/// <summary> /// 创建对应的角色状态 /// </summary> xc.Machine.State CreateState(uint id, xc.Machine machine, xc.Machine.State owner = null) { var state = ObjCachePoolMgr.Instance.TryLoadCSharpObject <xc.Machine.State>(ObjCachePoolType.STATE, mStatePoolKey); if (state == null) { state = new xc.Machine.State(id, mMachine, owner); } else { state.Reset(id, machine, null); } return(state); }
static int __CreateInstance(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { if (LuaAPI.lua_gettop(L) == 1) { xc.Machine __cl_gen_ret = new xc.Machine(); 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.Machine constructor!")); }
static int _m_Reset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); xc.Machine __cl_gen_to_be_invoked = (xc.Machine)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.Reset( ); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_SetCurState(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); xc.Machine __cl_gen_to_be_invoked = (xc.Machine)translator.FastGetCSObj(L, 1); try { { xc.Machine.State s = (xc.Machine.State)translator.GetObject(L, 2, typeof(xc.Machine.State)); __cl_gen_to_be_invoked.SetCurState(s); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_CanReact(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); xc.Machine __cl_gen_to_be_invoked = (xc.Machine)translator.FastGetCSObj(L, 1); try { { uint fsmEvent = LuaAPI.xlua_touint(L, 2); bool __cl_gen_ret = __cl_gen_to_be_invoked.CanReact(fsmEvent); LuaAPI.lua_pushboolean(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_ConstructCommonInstanceState_xlua_st_(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { { string lua_script = LuaAPI.lua_tostring(L, 1); uint id = LuaAPI.xlua_touint(L, 2); xc.Machine machine = (xc.Machine)translator.GetObject(L, 3, typeof(xc.Machine)); xc.Machine.State __cl_gen_ret = xc.ClassConstructHelper.ConstructCommonInstanceState(lua_script, id, machine); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_Reset(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); xc.Machine.State __cl_gen_to_be_invoked = (xc.Machine.State)translator.FastGetCSObj(L, 1); try { { uint id = LuaAPI.xlua_touint(L, 2); xc.Machine machine = (xc.Machine)translator.GetObject(L, 3, typeof(xc.Machine)); xc.Machine.State owner = (xc.Machine.State)translator.GetObject(L, 4, typeof(xc.Machine.State)); __cl_gen_to_be_invoked.Reset(id, machine, owner); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
public static xc.Machine.State ConstructCommonInstanceState(string lua_script, uint id, xc.Machine machine) { return(new CommonLuaInstanceState(lua_script, id, machine)); }
public void Init() { // 初始化状态机 mMachine = ObjCachePoolMgr.Instance.TryLoadCSharpObject <xc.Machine>(ObjCachePoolType.MACHINE, mMachinePoolKey); if (mMachine == null) { mMachine = new xc.Machine(); } else { mMachine.Reset(); } // 构建状态图 // 第一层状态: normal, beattacking, attacking, death, transfering xc.Machine.State normalState = CreateState((uint)EFSMState.DS_Normal, mMachine); xc.Machine.State beattackingState = CreateState((uint)EFSMState.DS_BeAttacking, mMachine); xc.Machine.State attackingState = CreateState((uint)EFSMState.DS_Attacking, mMachine); xc.Machine.State deathState = CreateState((uint)EFSMState.DS_Death, mMachine); xc.Machine.State jumpsceneState = CreateState((uint)EFSMState.DS_JumpScene, mMachine); // normal state的子状态 xc.Machine.State normalNullState = CreateState((uint)EFSMState.DS_NULL, mMachine, normalState); xc.Machine.State idleState = CreateState((uint)EFSMState.DS_Idle, mMachine, normalState); xc.Machine.State walkState = CreateState((uint)EFSMState.DS_Walking, mMachine, normalState); xc.Machine.State interactionState = CreateState((uint)EFSMState.DS_Interaction, mMachine, normalState); // attacking state的子状态 xc.Machine.State nullAttackState = CreateState((uint)EFSMState.DS_NULL, mMachine, attackingState); xc.Machine.State normalAttackState = CreateState((uint)EFSMState.DS_NormalAttack, mMachine, attackingState); // beattacking state的子状态 xc.Machine.State beAtkNullState = CreateState((uint)EFSMState.DS_NULL, mMachine, beattackingState); xc.Machine.State beAtkBackwardState = CreateState((uint)EFSMState.DS_BeAtkBackward, mMachine, beattackingState); // 设置初始子状态 normalState.SetChild(idleState); beattackingState.SetChild(beAtkNullState); attackingState.SetChild(nullAttackState); // 设置Enter/Exit/Update State的函数 normalState.SetEnterFunction(EnterState_Normal); normalState.SetExitFunction(ExitState_Normal); attackingState.SetEnterFunction(EnterState_Attacking); attackingState.SetUpdateFunction(UpdateState_Attacking); attackingState.SetExitFunction(ExitState_Attacking); beattackingState.SetEnterFunction(EnterState_BeAttacking); beattackingState.SetExitFunction(ExitState_BeAttacking); deathState.SetEnterFunction(EnterState_Death); deathState.SetUpdateFunction(UpdateState_Death); deathState.SetExitFunction(ExitState_Death); idleState.SetEnterFunction(EnterState_Idle); idleState.SetUpdateFunction(UpdateState_Idle); idleState.SetExitFunction(ExitState_Idle); walkState.SetEnterFunction(EnterState_Walk); walkState.SetUpdateFunction(UpdateState_Walk); walkState.SetExitFunction(ExitState_Walk); interactionState.SetEnterFunction(EnterState_Interaction); interactionState.SetUpdateFunction(UpdateState_Interaction); interactionState.SetExitFunction(ExitState_Interaction); jumpsceneState.SetEnterFunction(EnterState_JumpScene); jumpsceneState.SetUpdateFunction(UpdateState_JumpScene); jumpsceneState.SetExitFunction(ExitState_JumpScene); beAtkBackwardState.SetEnterFunction(EnterState_BeAtkBackward); beAtkBackwardState.SetUpdateFunction(UpdateState_BeAtkBackward); normalAttackState.SetEnterFunction(EnterState_NormalAttack); normalAttackState.SetUpdateFunction(UpdateState_NormalAttack); normalAttackState.SetExitFunction(ExitState_NormalAttack); //// 构建状态图 //// 第一层 // normal normalState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, beattackingState); normalState.AddTransition((uint)EFSMEvent.DE_NormalAttack, attackingState); normalState.AddTransition((uint)EFSMEvent.DE_Death, deathState); normalState.AddTransition((uint)EFSMEvent.DE_JumpScene, jumpsceneState); // jumpscene jumpsceneState.AddTransition((uint)EFSMEvent.DE_JumpSceneFinish, normalState); jumpsceneState.AddTransition((uint)EFSMEvent.DE_Death, deathState); jumpsceneState.AddTransition((uint)EFSMEvent.DE_Stop, normalState); // death deathState.AddTransition((uint)EFSMEvent.DE_Relive, normalState); deathState.AddTransition((uint)EFSMEvent.DE_JumpScene, jumpsceneState); // 防止死亡后的异常 // beattacking beattackingState.AddTransition((uint)EFSMEvent.DE_Stop, normalState); beattackingState.AddTransition((uint)EFSMEvent.DE_Death, deathState); beattackingState.AddTransition((uint)EFSMEvent.DE_JumpScene, jumpsceneState); // 受击的优先级最低,需要增加受击到各状态的转换 @rr add 2016.10.10 #if BEATTACK_LOW_PROPETY beattackingState.AddTransition((uint)EFSMEvent.DE_NormalAttack, attackingState); beattackingState.AddTransition((uint)EFSMEvent.DE_Walk, normalState); #endif // attacking attackingState.AddTransition((uint)EFSMEvent.DE_Stop, normalState); attackingState.AddTransition((uint)EFSMEvent.DE_NormalAttack, attackingState); attackingState.AddTransition((uint)EFSMEvent.DE_JumpScene, jumpsceneState); // 受击的优先级最低,攻击时不能被受击打断 @rr del 2016.10.10 #if !BEATTACK_LOW_PROPETY attackingState.AddTransition((uint)EFSMEvent.DE_BeAtkThrowAway, beattackingState); attackingState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, beattackingState); #endif //// 第二层 // normal state的子状态图 normalNullState.AddTransition((uint)EFSMEvent.DE_Stop, idleState); normalNullState.AddTransition((uint)EFSMEvent.DE_ReachDst, idleState); normalNullState.AddTransition((uint)EFSMEvent.DE_Walk, walkState); normalNullState.AddTransition((uint)EFSMEvent.DE_Interaction, interactionState); normalNullState.AddTransition((uint)EFSMEvent.DE_Relive, idleState); idleState.AddTransition((uint)EFSMEvent.DE_Walk, walkState); idleState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, normalNullState); idleState.AddTransition((uint)EFSMEvent.DE_NormalAttack, normalNullState); idleState.AddTransition((uint)EFSMEvent.DE_Interaction, interactionState); idleState.AddTransition((uint)EFSMEvent.DE_Death, normalNullState); idleState.AddTransition((uint)EFSMEvent.DE_Stop, idleState); idleState.AddTransition((uint)EFSMEvent.DE_JumpScene, normalNullState); walkState.AddTransition((uint)EFSMEvent.DE_ReachDst, idleState); walkState.AddTransition((uint)EFSMEvent.DE_ResetWalk, walkState); // 增加walk事件的响应,使其重新调用EnterState_Walk walkState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, normalNullState); walkState.AddTransition((uint)EFSMEvent.DE_NormalAttack, normalNullState); walkState.AddTransition((uint)EFSMEvent.DE_Interaction, interactionState); walkState.AddTransition((uint)EFSMEvent.DE_Death, normalNullState); walkState.AddTransition((uint)EFSMEvent.DE_Stop, idleState); walkState.AddTransition((uint)EFSMEvent.DE_JumpScene, normalNullState); interactionState.AddTransition((uint)EFSMEvent.DE_Walk, walkState); interactionState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, normalNullState); interactionState.AddTransition((uint)EFSMEvent.DE_NormalAttack, normalNullState); interactionState.AddTransition((uint)EFSMEvent.DE_Death, normalNullState); interactionState.AddTransition((uint)EFSMEvent.DE_Stop, idleState); interactionState.AddTransition((uint)EFSMEvent.DE_JumpScene, normalNullState); // beattacking state的子状态图 beAtkNullState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, beAtkBackwardState); beAtkBackwardState.AddTransition((uint)EFSMEvent.DE_BeAtkBackward, beAtkBackwardState); beAtkBackwardState.AddTransition((uint)EFSMEvent.DE_Stop, beAtkNullState); beAtkBackwardState.AddTransition((uint)EFSMEvent.DE_JumpScene, beAtkNullState); // attacking state的子状态图 nullAttackState.AddTransition((uint)EFSMEvent.DE_NormalAttack, normalAttackState); normalAttackState.AddTransition((uint)EFSMEvent.DE_Stop, nullAttackState); normalAttackState.AddTransition((uint)EFSMEvent.DE_NormalAttack, normalAttackState); normalAttackState.AddTransition((uint)EFSMEvent.DE_JumpScene, nullAttackState); mMachine.SetCurState(normalState); }
public PlayingTestState(xc.Machine machine) : base((uint)GameState.GS_PLAYING_TEST, machine) { Init(); }