public void handleTransition(MeleeCombatState nextState) { if (currentState != null) { currentState.OnTransition -= handleTransition; Debug.Log("current: " + currentState.GetType().Name); } currentState = nextState; currentState.OnTransition += handleTransition; stateName = currentState.GetType().Name; }
public IBehaviorState StateFactory(States state) { IBehaviorState ret = null; switch (state) { case States.Idling: break; case States.Roaming: ret = new RoamingState(host) as IBehaviorState; break; case States.Pursuing: ret = new PursuingState(host) as IBehaviorState; break; case States.Fighting: ret = new FightingState(host) as IBehaviorState; break; case States.Ranged: ret = new RangedCombatState(host) as IBehaviorState; break; case States.Melee: ret = new MeleeCombatState(host) as IBehaviorState; break; } if (ret != null) { ret.Init(this); } return(ret); }