public StateMachine(Player player) { stationaryState = new StationaryState(player); runningState = new RunningState(player); jumpingState = new JumpingState(player); fallingState = new FallingState(player); wallSlidingState = new WallSlidingState(player); wallHuggingState = new WallHuggingState(player); _currentState = stationaryState; }
public void Awake() { Input = GetComponent <IPlayerInput>(); Anim = GetComponent <IPlayerAnimationManager>(); RollHitbox = GetComponent <PlayerRollAttackHitbox>(); DiveHitbox = GetComponent <PlayerDiveAttackHitbox>(); Motor = GetComponent <PlayerMotor>(); Walking = new WalkingState(this); StandardJumping = new StandardJumpingState(this); DoubleJumping = new DoubleJumpingState(this); RollJumping = new RollJumpingState(this); SideFlipJumping = new SideFlipJumpingState(this); FreeFall = new FreeFallState(this); WallSliding = new WallSlidingState(this); WallJumping = new WallJumpingState(this); Rolling = new RollingState(this); Diving = new DivingState(this); Bonking = new BonkingState(this); GrabbingLedge = new GrabbingLedgeState(this); _allStates = new[] { Walking, FreeFall, WallSliding, WallJumping, Rolling, Diving, Bonking, GrabbingLedge }; // Start in FreeFall ChangeState(FreeFall); Debug.Log("Jump speed: " + PlayerConstants.STANDARD_JUMP_VSPEED); }