private void Awake() { characterName = "SuckerYou"; //collect all the things idleState = GetComponentInChildren <SY_IdleState>(); attackState = GetComponentInChildren <SY_AttackState>(); chaseState = GetComponentInChildren <SY_ChaseState>(); runState = GetComponentInChildren <SY_RunState>(); healthBase = GetComponent <Health>(); //put them into the syStates array syStates = new StateBase[4] { idleState, attackState, chaseState, runState }; statesTxt = new string[4] { "idle", "attacking", "chasing", "running" }; //set health and health actions healthBase.maxAmount = 100; healthBase.OnDeathEvent += Death; healthBase.OnHurtEvent += Hurt; currentState = idleState; currentState.Enter(); }
public void ChangeState() { //go to currentState exit, then newState Enter, then set the new state currentState.Exit(next); //note - makes sure currentState exits pre newState starting newState.Enter(); currentState = newState; }
public void ChangeState(int next) { //finish old state currentState.Exit(next); //set current state as the new state, then start the new state currentState = syStates[next]; debugText = statesTxt[next]; currentState.Enter(); }
//public float health; public void Awake() { characterName = "myGuy"; //set everything up tauntState = GetComponent <TauntState>(); idleState = GetComponent <IdleState>(); runState = GetComponent <RunState>(); healthBase = GetComponent <Health>(); //health = healthBase.Amount; healthBase.maxAmount = 100; healthBase.OnDeathEvent += Die; currentState = idleState; currentState.Enter(); }