public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { Player player = gameObject.GetComponent <Player>(); if (Input.GetKeyDown(KeyCode.Space)) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_JUMP); } if (Mathf.Abs(player.h) == 0 && Mathf.Abs(player.v) == 0) { fsmSystem.IsCanChange = true; if (player.IsInBattle) { fsmSystem.ChangeState(StateType.FSM_ATTACKIDLE); } else { fsmSystem.ChangeState(StateType.FSM_IDLE); } } if (Input.GetMouseButton(0)) { if (player.IsInBattle) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_ATTACK); } } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { Player player = gameObject.GetComponent <Player>(); if (Mathf.Abs(player.h) < 0.1f && Mathf.Abs(player.v) < 0.1f) { fsmSystem.IsCanChange = true; if (player.IsInBattle) { fsmSystem.ChangeState(StateType.FSM_ATTACKIDLE); } else { fsmSystem.ChangeState(StateType.FSM_IDLE); } } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { //现在的动画状态 AnimatorStateInfo currentBaseState = gameObject.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0); if (currentBaseState.normalizedTime > 1 && currentBaseState.IsName("Jump")) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_IDLE); } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { Player player = gameObject.GetComponent <Player>(); AnimatorStateInfo currentBaseState = gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1); if (player.IsInBattle && Mathf.Abs(player.h) > 0.1f || Mathf.Abs(player.v) > 0.1f) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_ATTACKWALK); } if (!player.IsInBattle && Mathf.Abs(player.h) > 0.1f || Mathf.Abs(player.v) > 0.1f) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_RUN); } if (Mathf.Abs(player.h) < 0.1f && Mathf.Abs(player.v) < 0.1f) { //如果离敌人距离过远 if (true) { if (!stateChanging) { player.StartCoroutine(DelayToInvokeDo(() => { fsmSystem.IsCanChange = true; player.IsInBattle = false; stateChanging = false; Debug.Log("进入攻击准备状态"); fsmSystem.ChangeState(StateType.FSM_IDLE); }, 5.0f)); stateChanging = true; } } } if (Input.GetMouseButton(0)) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_ATTACK); } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { Player player = gameObject.GetComponent <Player>(); // AnimatorStateInfo currentBaseState = gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(1); if (currentBaseState.normalizedTime > 1 && (currentBaseState.IsName("Jab") || currentBaseState.IsName("Jab 0"))) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_ATTACKIDLE); } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { GameObject player = GameObject.FindGameObjectWithTag("Player"); float distance = (player.transform.position - gameObject.transform.position).magnitude; if (distance > 5) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.EnemyPatrol); } }
public override void TriggerEvent(FsmSystem fsmSystem, GameObject gameObject) { Player player = gameObject.GetComponent <Player>(); if (Mathf.Abs(player.h) > 0.1f || Mathf.Abs(player.v) > 0.1f) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_RUN); } if (Input.GetKeyDown(KeyCode.Space)) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_JUMP); } if (Input.GetKeyDown(KeyCode.Z)) { fsmSystem.IsCanChange = true; fsmSystem.ChangeState(StateType.FSM_ATTACKIDLE); } }
private void Start() { EnemyFollowState followState = new EnemyFollowState(); followState.onFixedUpdateMethod += onUpdateFollowState; EnemyPatrolState patrolState = new EnemyPatrolState(); patrolState.onFixedUpdateMethod += onUpdatePatrolState; fsmSystem = new FsmSystem(); fsmSystem.AddState(followState); fsmSystem.AddState(patrolState); fsmSystem.ChangeState(StateType.EnemyPatrol); enemy = this.gameObject.GetComponent <EnemyCharacter>(); player = GameObject.FindGameObjectWithTag("Player"); }
// Use this for initialization void Start() { player = FindObjectOfType <Player>(); IdleState idleState = new IdleState(); idleState.onEnterMethod += OnEnterIdleState; idleState.onUpdateMethod += OnUpDateIdleState; idleState.onFixedUpdateMethod += OnFixedUpDateIdleState; RunState runState = new RunState(); runState.onFixedUpdateMethod += OnFixedUpDateRunState; runState.onUpdateMethod += OnUpDateRunState; runState.onEnterMethod += OnEnterRunState; JumpState jumpState = new JumpState(); jumpState.onEnterMethod += OnEnterJumpState; AttackIdleState AttackIdleState = new AttackIdleState(); AttackIdleState.onEnterMethod += OnEnterAttackIdleState; AttackIdleState.onUpdateMethod += OnUpdateAttackIdleState; AttackWalkState attackWalkState = new AttackWalkState(); attackWalkState.onFixedUpdateMethod += OnFixedUpDateAttackWalkState; attackWalkState.onUpdateMethod += OnUpDateAttackWalkState; attackWalkState.onEnterMethod += OnEnterAttackWalkState; AttackDoState attackDoState = new AttackDoState(); //attackDoState.onFixedUpdateMethod += OnFixedUpDateAttackWalkState; attackDoState.onUpdateMethod += OnUpDateAttackDoState; attackDoState.onEnterMethod += OnEnterAttackDoState; fsmSystem = new FsmSystem(); fsmSystem.AddState(idleState); fsmSystem.AddState(runState); fsmSystem.AddState(jumpState); fsmSystem.AddState(AttackIdleState); fsmSystem.AddState(attackWalkState); fsmSystem.AddState(attackDoState); fsmSystem.ChangeState(StateType.FSM_IDLE); }
/* * private void OnAddLabelToAutoLocaList(UILabel label, string locaCode) * { * * log.DebugMS("OnAddLabelToAutoLocaList - locaCode: " + locaCode); * // translate directly, no language switching supported anyway * label.text = Loca.Get(locaCode); * } */ public void ChangeState(string stateName, object onEnterParams = null) { FsmSystem.ChangeState(stateName, onEnterParams); }
protected void ChangeStateToPrevious(object onEnterParam = null) { FsmSystem.ChangeState(FsmSystem.PreviousStateName); }
//Helper methods. protected void ChangeState(string newStateName, object onEnterParam = null) { FsmSystem.ChangeState(newStateName, onEnterParam); }
/// <summary> /// 改变状态机状态 /// </summary> public void ChangeState(int stateType) { InternalSystem.ChangeState(stateType); }
public void OnButtonSkip() { FsmSystem.ChangeState("GameStateReadyForLogin"); }