// state logic public void SetState(POPPER_STATE _state) { if (currentState != _state) { POPPER_STATE _prevState = currentState; currentState = _state; prevState = _prevState; OnStateChange(_prevState); } }
protected void OnStateChange(POPPER_STATE _from) { switch (currentState) { case POPPER_STATE.DESTROY: { // changing state to destroy. currentPopper.SetActive(false); projectileParent.SetActive(true); gameObject.GetComponentInChildren <ProjectileController>().StartExplotion(); SetState(POPPER_STATE.INACTIVE); break; } } }