public void ChangeState(int i) { currentState = i; if (currentstate != null) { if (currentstate == states[i]) { return; } currentstate.ExitState(); } currentstate = states[i]; currentstate.EnterState(); }