void Start() { fsmObject = new FSMObject(gameObject); foreach (StateType state in states) { fsmObject.AddState(state.id, state.onEnter, state.onExec, state.onExit); } fsmObject.State = startState; }
protected void Awake() { playerState.AddState(PlayerStates.Idle, OnIdleEnter, OnIdleExec, OnIdleExit); playerState.AddState(PlayerStates.Moving, OnMovingEnter, OnMovingExec, OnMovingExit); playerState.AddState(PlayerStates.Jumping, OnJumpingEnter, OnJumpingExec, OnJumpingExit); playerState.AddState(PlayerStates.Falling, OnFallingEnter, OnFallingExec, OnFallingExit); playerState.AddState(PlayerStates.Throwed, OnThrowedEnter, OnThrowedExec, OnThrowedExit); playerState.AddState(PlayerStates.Die, OnDieEnter, OnDieExec, OnDieExit); playerState.AddState(PlayerStates.Special, OnSpecialEnter, OnSpecialExec, OnSpecialExit); playerState.State = PlayerStates.Falling; input = GetComponent <GameInput.PlayerInputs>(); rigidBody = GetComponent <Rigidbody2D>(); playerAnim = GetComponent <Animator>(); initialRotation = transform.eulerAngles; blood = transform.Find("Blood").GetComponent <ParticleSystem>(); pizzaCounterUi = GameObject.Find("PizzaCounter") ? GameObject.Find("PizzaCounter").GetComponent <Text>() : null; }