private void Awake() { _player = GetComponent <Player>(); // grounded IdleState = new PlayerIdleState(this, _player); MoveState = new PlayerMoveState(this, _player); JumpState = new PlayerJumpState(this, _player); LandState = new PlayerLandState(this, _player); CrouchState = new PlayerCrouchState(this, _player); CrouchMoveState = new PlayerCrouchMoveState(this, _player); // air AirJumpState = new PlayerAirJumpState(this, _player); FallingState = new PlayerFallingState(this, _player); // wall WallSlideState = new PlayerWallSlideState(this, _player); WallGrabState = new PlayerWallGrab(this, _player); WallClimbState = new PlayerWallClimbState(this, _player); WallJumpState = new PlayerWallJumpState(this, _player); // ledge LedgeClimbState = new PlayerLedgeClimbState(this, _player); // abilities DashState = new PlayerDashState(this, _player); // attacks GroundAttackState = new PlayerGroundAttackState(this, _player); AirAttackState = new PlayerAirAttackState(this, _player); WallAttackState = new PlayerWallAttackState(this, _player); BounceAttackState = new PlayerBounceAttackState(this, _player); }
private void Awake() { instance = this; StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, "idle"); MoveState = new PlayerMoveState(this, StateMachine, "move"); JumpState = new PlayerJumpState(this, StateMachine, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, "inAir"); LandState = new PlayerLandState(this, StateMachine, "land"); WallSlideState = new PlayerWallSlideState(this, StateMachine, "wallSlide"); WallJumpState = new PlayerWallJumpState(this, StateMachine, "inAir"); LedgeClimbState = new PlayerLedgeClimbState(this, StateMachine, "ledgeClimbState"); DashState = new PlayerDashState(this, StateMachine, "dash"); SlideState = new PlayerSlideState(this, StateMachine, "slide"); HurtState = new PlayerHurtState(this, StateMachine, "hurt"); SwordComboState = new PlayerSwordComboState(this, StateMachine, "swordCombo"); KnockDownState = new PlayerKnockDownState(this, StateMachine, "knockdown"); GetUpState = new PlayerGetUpState(this, StateMachine, "getUp"); KickComboState = new PlayerKickComboState(this, StateMachine, "kickCombo"); MagicStrongState = new PlayerMagicStrongState(this, StateMachine, "strongCast"); WeakMagicState = new PlayerWeakMagicState(this, StateMachine, "weakCast"); FullPowerMagicState = new PlayerFullPowerMagicState(this, StateMachine, "fullPowerMagicCast"); DeadState = new PlayerDeadState(this, StateMachine, "dead"); FlyingKickState = new PlayerFlyingKickState(this, StateMachine, "flyingKick"); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == globals.tag_Ground) { currentJumpHeight = 0f; jumpState = PlayerJumpState.Grounded; } }
private void CreateStates() { IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); RunState = new PlayerRunState(this, StateMachine, playerData, "run"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "jump"); FallState = new PlayerFallState(this, StateMachine, playerData, "fall"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, _playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, _playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, _playerData, "jump"); InAirState = new PlayerInAirState(this, StateMachine, _playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, _playerData, "land"); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); HurtState = new PlayerHurtState(this, StateMachine, playerData, "hurt"); DeadState = new PlayerDeadState(this, StateMachine, playerData, "dead"); }
private void StartStun(float stunTime) { // Set stun state, stop jumping stunState = PlayerStunnedState.Stunned; jumpState = PlayerJumpState.Falling; // Set stun timer stunTimer = stunTime; // TODO: Set Stun Animation MyRenderer.material.color = Color.red; }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "idle"); DashState = new PlayerDashState(this, StateMachine, playerData, "inAir"); AttackState = new PlayerAttackState(this, StateMachine, playerData, "attack"); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); RunState = new PlayerRunState(this, StateMachine, playerData, "run"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); DoubleJump = new PlayerDoubleJumpState(this, StateMachine, playerData, "doubleJump"); WallSlideState = new PlayerWallSlideState(this, StateMachine, playerData, "wallSlide"); WallJumpState = new PlayerWallJumpState(this, StateMachine, playerData, "inAir"); }
void Awake() { m_roundStart = true; m_renableCollisions = true; movementStates = gameObject.AddComponent <StateManager>(); driftState = gameObject.AddComponent <PlayerDriftState>(); jumpState = gameObject.AddComponent <PlayerJumpState>(); onPlanetState = gameObject.AddComponent <PlayerOnPlanetState>(); boostChargeState = gameObject.AddComponent <PlayerBoostChargeState>(); boostActiveState = gameObject.AddComponent <PlayerBoostActiveState>(); bigHitState = gameObject.AddComponent <PLayerBigHitState>(); respawnState = gameObject.AddComponent <RespawnState>(); }
public PlayerFallState(PlayerZero playerZero) { if (lastState != null && lastState is PlayerJumpState) { PlayerJumpState jumpSate = (PlayerJumpState)lastState; horizontalSpeed = jumpSate.speed; } else { horizontalSpeed = playerZero.runSpeed; } this.playerZero = playerZero; stateName = "fall"; }
private void Awake() { stateMachine = new PlayerStateMachine(); idleState = new PlayerIdleState(this, stateMachine, playerData, "Idle"); moveState = new PlayerMoveState(this, stateMachine, playerData, "Move"); jumpState = new PlayerJumpState(this, stateMachine, playerData, "InAir"); inAirState = new PlayerInAirState(this, stateMachine, playerData, "InAir"); landState = new PlayerLandState(this, stateMachine, playerData, "Land"); dashState = new PlayerDashState(this, stateMachine, playerData, "InAir"); crouchIdleState = new PlayerCrouchIdleState(this, stateMachine, playerData, "IdleCrouch"); crouchMoveState = new PlayerCrouchState(this, stateMachine, playerData, "MoveCrouch"); primAtkState = new PlayerPrimAtkState(this, stateMachine, playerData, "PrimAttack"); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); WallSlideState = new PlayerWallSlideState(this, StateMachine, playerData, "wallSlide"); WallGrabState = new PlayerWallGrabState(this, StateMachine, playerData, "wallGrab"); WallClimbState = new PlayerWallClimbState(this, StateMachine, playerData, "wallClimb"); WallJumpState = new PlayerWallJumpState(this, StateMachine, playerData, "inAir"); LedgeClimbState = new PlayerLedgeClimbState(this, StateMachine, playerData, "ledgeClimbState"); }
private void Awake() { FiniteStateMachine = new PlayerFiniteStateMachine(); SkillManager = new PlayerSkillsManager(); StatsManager = new PlayerStatsManager(_playerStatsData); IdleState = new PlayerIdleState(this, FiniteStateMachine, "idle", _idleStateData); MoveState = new PlayerMoveState(this, FiniteStateMachine, "move", _moveStateData); LandState = new PlayerLandState(this, FiniteStateMachine, "land"); JumpState = new PlayerJumpState(this, FiniteStateMachine, "inAir", _jumpStateData); InAirState = new PlayerInAirState(this, FiniteStateMachine, "inAir", _inAirStateData); WallSlideState = new PlayerWallSlideState(this, FiniteStateMachine, "wallSlide", _wallSlideStateData); WallGrabState = new PlayerWallGrabState(this, FiniteStateMachine, "wallGrab"); WallClimbState = new PlayerWallClimbState(this, FiniteStateMachine, "wallClimb", _wallClimbStateData); WallJumpState = new PlayerWallJumpState(this, FiniteStateMachine, "inAir", _wallJumpStateData); LedgeClimbState = new PlayerLedgeClimbState(this, FiniteStateMachine, "ledgeClimbState", _ledgeClimbStateData); DashState = new PlayerDashState(this, FiniteStateMachine, "inAir", _dashStateData); RollState = new PlayerRollState(this, FiniteStateMachine, "rollState", _rollStateData); CrouchIdleState = new PlayerCrouchIdleState(this, FiniteStateMachine, "crouchIdle", _crouchIdleStateData); CrouchMoveState = new PlayerCrouchMoveState(this, FiniteStateMachine, "crouchMove", _crouchMoveStateData); OnRopeStateAim = new PlayerOnRopeState_Aim(this, FiniteStateMachine, "idle", _onRopeStateData); OnRopeStateAttach = new PlayerOnRopeState_Attach(this, FiniteStateMachine, "inAir", _onRopeStateData); OnRopeStateMove = new PlayerOnRopeState_Move(this, FiniteStateMachine, "inAir", _onRopeStateData); OnRopeStateFinish = new PlayerOnRopeState_Finish(this, FiniteStateMachine, "inAir", _onRopeStateData); SwordAttackState01 = new PlayerSwordAttackState_01(this, FiniteStateMachine, "swordAttack01", _swordAttackPosition01, _swordAttackStateData01); SwordAttackState02 = new PlayerSwordAttackState_02(this, FiniteStateMachine, "swordAttack02", _swordAttackPosition02, _swordAttackStateData02); SwordAttackState03 = new PlayerSwordAttackState_03(this, FiniteStateMachine, "swordAttack03", _swordAttackPosition03, _swordAttackStateData03); FireArrowShotStateStart = new PlayerBowFireArrowShotState_Start(this, FiniteStateMachine, "bowFireShotStart", _fireArrowShotAttackPosition, _fireArrowShotStateData); FireArrowShotStateAim = new PlayerBowFireArrowShotState_Aim(this, FiniteStateMachine, "bowFireShotAim", _fireArrowShotAttackPosition, _fireArrowShotStateData); FireArrowShotStateFinish = new PlayerBowFireArrowShotState_Finish(this, FiniteStateMachine, "bowFireShotFinish", _fireArrowShotAttackPosition, _fireArrowShotStateData); StunState = new PlayerStunState(this, FiniteStateMachine, "stun", StunStateData); DeadState = new PlayerDeadState(this, FiniteStateMachine, "dead", _deadStateData); }
// Checks RigidBody2D to determine jump state/animation private void CheckJumpState() { if (playerRigidBody.velocity.y == 0) { playerJumpState = PlayerJumpState.LAND; } if (playerRigidBody.velocity.y > 0.1f) { playerJumpState = PlayerJumpState.UP; } if (playerRigidBody.velocity.y < -0.1f) { playerJumpState = PlayerJumpState.DOWN; } playerAnimator.SetInteger("JumpState", (int)playerJumpState); }
public void InitializePlayerStateMachine() { idleState = new PlayerIdleState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); walkState = new PlayerWalkState(stateMachine, this, AlfAnimationHash.RUN_0, playerData); jumpState = new PlayerJumpState(stateMachine, this, AlfAnimationHash.JUMP_0, playerData); inAirState = new PlayerInAirState(stateMachine, this, AlfAnimationHash.INAIR_0, playerData); meleeAttackState = new PlayerMeleeAttackState(stateMachine, this, AlfAnimationHash.ATTACK_0, playerData); parryState = new PlayerParryState(stateMachine, this, AlfAnimationHash.PARRY_1, playerData); rollState = new PlayerRollState(stateMachine, this, AlfAnimationHash.ROLL_0, playerData); stunState = new PlayerStunState(stateMachine, this, AlfAnimationHash.STUN_0, playerData); deadState = new PlayerDeadState(stateMachine, this, AlfAnimationHash.DEAD_0, playerData); takeDamageState = new PlayerTakeDamageState(stateMachine, this, AlfAnimationHash.TAKEDAMAGE_0, playerData); wallState = new PlayerWallState(stateMachine, this, AlfAnimationHash.WALL_0, playerData); dashState = new PlayerDashState(stateMachine, this, AlfAnimationHash.DASH_0, playerData); converseState = new PlayerConverseState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); cinemaState = new PlayerCinemaState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); ladderState = new PlayerLadderState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); InitializePlayerCooldownTimer(); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); WallClimbState = new PlayerWallClimbState(this, StateMachine, playerData, "wallClimb"); WallGrabState = new PlayerWallGrabState(this, StateMachine, playerData, "wallGrab"); WallSlideState = new PlayerWallSlideState(this, StateMachine, playerData, "wallSlide"); WallJumpState = new PlayerWallJumpState(this, StateMachine, playerData, "inAir"); LedgeClimbState = new PlayerLedgeClimbState(this, StateMachine, playerData, "ledgeClimbState"); DashState = new PlayerDashState(this, StateMachine, playerData, "inAir"); CrouchIdleState = new PlayerCrouchIdleState(this, StateMachine, playerData, "crouchIdle"); CrouchMoveState = new PlayerCrouchMoveState(this, StateMachine, playerData, "crouchMove"); PrimaryAttackState = new PlayerAttackState(this, StateMachine, playerData, "attack"); SecondaryAttackState = new PlayerAttackState(this, StateMachine, playerData, "attack"); }
void StartJump() { Vector3 NewVelocity = PlayerRB.velocity; if (AvailableJumps > 0) { AvailableJumps -= 1; JumpState = PlayerJumpState.Jumping; if (CurrentPlayer.Grounded) { NewVelocity.y = GroundJumpVelocity; } else { NewVelocity.y = AirJumpVelocity; } } PlayerRB.velocity = NewVelocity; }
private Vector3 JumpHandler() { if (jumpState == PlayerJumpState.Grounded) { // Start Jump if Grounded and Jump Key Down if (Input.GetKeyDown(JumpKey)) { jumpState = PlayerJumpState.Jumping; } } else if (jumpState == PlayerJumpState.Jumping) { // Start falling if jump key released if (Input.GetKey(JumpKey)) { float deltaJump = globals.JumpDelta * Time.deltaTime; float testHeight = currentJumpHeight + deltaJump; // Start falling if max height if (testHeight >= globals.MaxJumpHeight) { deltaJump = globals.MaxJumpHeight - currentJumpHeight; currentJumpHeight = 0f; jumpState = PlayerJumpState.Falling; } else { currentJumpHeight += deltaJump; } return(new Vector3(0f, deltaJump, 0f)); } else { currentJumpHeight = 0f; jumpState = PlayerJumpState.Falling; } } return(Vector3.zero); }
private void Awake() { FiniteStateMachine = new PlayerFiniteStateMachine(); IdleState = new PlayerIdleState(this, FiniteStateMachine, _playerData, "idle"); MoveState = new PlayerMoveState(this, FiniteStateMachine, _playerData, "move"); LandState = new PlayerLandState(this, FiniteStateMachine, _playerData, "land"); JumpState = new PlayerJumpState(this, FiniteStateMachine, _playerData, "inAir"); InAirState = new PlayerInAirState(this, FiniteStateMachine, _playerData, "inAir"); WallSlideState = new PlayerWallSlideState(this, FiniteStateMachine, _playerData, "wallSlide"); WallGrabState = new PlayerWallGrabState(this, FiniteStateMachine, _playerData, "wallGrab"); WallClimbState = new PlayerWallClimbState(this, FiniteStateMachine, _playerData, "wallClimb"); WallJumpState = new PlayerWallJumpState(this, FiniteStateMachine, _playerData, "inAir"); LedgeClimbState = new PlayerLedgeClimbState(this, FiniteStateMachine, _playerData, "ledgeClimbState"); DashState = new PlayerDashState(this, FiniteStateMachine, _playerData, "inAir"); CrouchIdleState = new PlayerCrouchIdleState(this, FiniteStateMachine, _playerData, "crouchIdle"); CrouchMoveState = new PlayerCrouchMoveState(this, FiniteStateMachine, _playerData, "crouchMove"); OnRopeStateAim = new PlayerOnRopeState_Aim(this, FiniteStateMachine, _playerData, "idle"); OnRopeStateAttach = new PlayerOnRopeState_Attach(this, FiniteStateMachine, _playerData, "inAir"); OnRopeStateMove = new PlayerOnRopeState_Move(this, FiniteStateMachine, _playerData, "inAir"); OnRopeStateFinish = new PlayerOnRopeState_Finish(this, FiniteStateMachine, _playerData, "inAir"); // TODO: Attack states using unnecessary Player Data SwordAttackState01 = new PlayerSwordAttackState_01(this, FiniteStateMachine, _playerData, "swordAttack01", _swordAttackPosition01, _playerSwordAttackData01); SwordAttackState02 = new PlayerSwordAttackState_02(this, FiniteStateMachine, _playerData, "swordAttack02", _swordAttackPosition02, _playerSwordAttackData02); SwordAttackState03 = new PlayerSwordAttackState_03(this, FiniteStateMachine, _playerData, "swordAttack03", _swordAttackPosition03, _playerSwordAttackData03); FireArrowShotStateStart = new PlayerBowFireArrowShotState_Start(this, FiniteStateMachine, _playerData, "bowFireShotStart", _fireArrowShotAttackPosition, _playerFireArrowShotData); FireArrowShotStateAim = new PlayerBowFireArrowShotState_Aim(this, FiniteStateMachine, _playerData, "bowFireShotAim", _fireArrowShotAttackPosition, _playerFireArrowShotData); FireArrowShotStateFinish = new PlayerBowFireArrowShotState_Finish(this, FiniteStateMachine, _playerData, "bowFireShotFinish", _fireArrowShotAttackPosition, _playerFireArrowShotData); }
private void Awake() { _stateMachine = new PlayerStateMachine(); CombatController = new CombatController(); IdleState = new PlayerIdleState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_IDLE_2_HASH); MoveState = new PlayerMoveState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_RUN_2_HASH); JumpState = new PlayerJumpState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_JUMP_HASH); InAirState = new PlayerInAirState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_AIR_HASH); LandState = new PlayerLandState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LAND_HASH); WallSlideState = new PlayerWallSlideState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_WALL_SLIDING_HASH); LedgeClimbState = new PlayerLedgeClimbState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LEDGE_GRAB_HASH); LedgeJumpState = new PlayerLedgeJumpState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LEDGE_JUMP_HASH); CrouchIdleState = new PlayerCrouchIdleState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_CROUCH_IDLE_HASH); CrouchMoveState = new PlayerCrouchMoveState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_CROUCH_WALK_HASH); SwordAttackState = new PlayerSwordAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_ATTACK_1_HASH, 3); HandAttackState = new PlayerHandAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_PUNCH_1_HASH, 5); AirAttackState = new PlayerAirAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_AIR_ATTACK_1_HASH, 2); SlideState = new PlayerSlideState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_SLIDE_HASH); ItemState = new PlayerItemState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_USE_ITEM_HASH); }
private void Awake() { playerStateMachine = new PlayerStateMachine(); playerIdleState = new PlayerIdleState(this, playerData, "idle"); playerMoveState = new PlayerMoveState(this, playerData, "move"); playerLandState = new PlayerLandState(this, playerData, "land"); playerJumpState = new PlayerJumpState(this, playerData, "inAir"); playerDashState = new PlayerDashState(this, playerData, "dash"); playerAttack1State = new PlayerAttack1State(this, playerData, "attack1"); playerAttack2State = new PlayerAttack2State(this, playerData, "attack2"); playerPrimaryAttackState = new PlayerAttackState(this, playerData, "attack"); playerSecondaryAttackState = new PlayerAttackState(this, playerData, "attack"); playerInAirState = new PLayerInAirState(this, playerData, "inAir"); playerAttackedState = new PlayerAttackedState(this, playerData, "attacked"); playerDeathState = new PlayerDeathState(this, playerData, "die"); }
public void InitializePlayerStateMachine() { idleState = new PlayerIdleState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); walkState = new PlayerWalkState(stateMachine, this, AlfAnimationHash.RUN_0, playerData); jumpState = new PlayerJumpState(stateMachine, this, AlfAnimationHash.JUMP_0, playerData); inAirState = new PlayerInAirState(stateMachine, this, AlfAnimationHash.INAIR_0, playerData); meleeAttackState = new PlayerMeleeAttackState(stateMachine, this, AlfAnimationHash.ATTACK_IRONSWORD, playerData); bowAttackState = new PlayerBowAttackState(stateMachine, this, AlfAnimationHash.IDLE_WOODBOW, playerData); magicAttackState = new PlayerMagicAttackState(stateMachine, this, AlfAnimationHash.IDLE_APPRENTICE_STICK, playerData); parryState = new PlayerParryState(stateMachine, this, AlfAnimationHash.PARRY_1, playerData); rollState = new PlayerRollState(stateMachine, this, AlfAnimationHash.ROLL_0, playerData); stunState = new PlayerStunState(stateMachine, this, AlfAnimationHash.STUN_0, playerData); deadState = new PlayerDeadState(stateMachine, this, AlfAnimationHash.DEAD_0, playerData); takeDamageState = new PlayerTakeDamageState(stateMachine, this, AlfAnimationHash.TAKEDAMAGE_0, playerData); wallState = new PlayerWallState(stateMachine, this, AlfAnimationHash.WALL_0, playerData); dashState = new PlayerDashState(stateMachine, this, AlfAnimationHash.DASH_0, playerData); converseState = new PlayerConverseState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); cinemaState = new PlayerCinemaState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); ladderState = new PlayerLadderState(stateMachine, this, AlfAnimationHash.IDLE_0, playerData); wakeupState = new PlayerWakeupState(stateMachine, this, AlfAnimationHash.WAKEUP_SITUP_0, playerData); littleSunState = new PlayerLittleSunState(stateMachine, this, AlfAnimationHash.LITTLESUN_SIT_0, playerData); InitializePlayerCooldownTimer(); }
private void Awake() { //Awake handles one time instatiation of the state machine and state components //Super States do not need to be instatiated StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); TurnState = new PlayerTurnState(this, StateMachine, playerData, "turn"); JumpSquatState = new PlayerJumpSquatState(this, StateMachine, playerData, "jumpSquat"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "jump"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); DiveState = new PlayerDiveState(this, StateMachine, playerData, "dive"); DoubleJumpState = new PlayerDoubleJumpState(this, StateMachine, playerData, "doubleJump"); EndFallState = new PlayerEndFallState(this, StateMachine, playerData, "endFall"); StartFallState = new PlayerStartFallState(this, StateMachine, playerData, "startFall"); AbilityOneState = new PlayerAbilityOneState(this, StateMachine, playerData, "abilityOne"); CrouchState = new PlayerCrouchState(this, StateMachine, playerData, "crouch"); AbilityCrouchOneState = new PlayerAbilityCrouchOneState(this, StateMachine, playerData, "abilityCrouchOne"); AbilityJumpOneState = new PlayerAbilityJumpOneState(this, StateMachine, playerData, "abilityJumpOne"); DodgeState = new PlayerDodgeState(this, StateMachine, playerData, "dodge"); AbilityTwoState = new PlayerAbilityTwoState(this, StateMachine, playerData, "abilityTwo"); }
private void Awake() { StateMachine = new PlayerStateMachine(); IdleState = new PlayerIdleState(this, StateMachine, playerData, "idle"); MoveState = new PlayerMoveState(this, StateMachine, playerData, "move"); JumpState = new PlayerJumpState(this, StateMachine, playerData, "inAir"); InAirState = new PlayerInAirState(this, StateMachine, playerData, "inAir"); LandState = new PlayerLandState(this, StateMachine, playerData, "land"); WallSlideState = new PlayerWallSlideState(this, StateMachine, playerData, "wallSlide"); WallGrabState = new PlayerWallGrabState(this, StateMachine, playerData, "wallGrab"); WallClimbState = new PlayerWallClimbState(this, StateMachine, playerData, "wallClimb"); WallJumpState = new PlayerWallJumpState(this, StateMachine, playerData, "inAir"); LedgeClimbState = new PlayerLedgeClimbState(this, StateMachine, playerData, "ledgeClimbState"); DashState = new PlayerDashState(this, StateMachine, playerData, "inAir"); CrouchIdleState = new PlayerCrouchIdleState(this, StateMachine, playerData, "crouchIdle"); CrouchMoveState = new PlayerCrouchMoveState(this, StateMachine, playerData, "crouchMove"); InjuredState = new PlayerInjuredState(this, StateMachine, playerData, "injured"); DeadState = new PlayerDeadState(this, StateMachine, playerData, "dead"); KickState = new PlayerKickState(this, StateMachine, playerData, "kick"); SlideKickState = new PlayerSlideKickState(this, StateMachine, playerData, "slideKick"); RollState = new PlayerRollState(this, StateMachine, playerData, "roll"); }
void Update() { Vector3 CurrentVelocity = PlayerRB.velocity; Vector3 NewVelocity = CurrentVelocity; bool JumpPressed = WKInput.instance.Jump.Down(); bool JumpHeld = WKInput.instance.Jump.Held(); Vector3 GroundVelocity = Vector3.zero; bool Grounded = CurrentPlayer.CheckIfGrounded();//out GroundVelocity); if (Grounded) { AvailableJumps = MaxAvailableJumps; } if (((JumpPressed) && (AvailableJumps > 0)) || Input.GetKey("p")) { AvailableJumps -= 1; JumpState = PlayerJumpState.Jumping; WKAudio.PlayAudio("Jump"); if (Grounded) { NewVelocity.y = GroundJumpVelocity; } else { NewVelocity.y = AirJumpVelocity; } } switch (JumpState) { case PlayerJumpState.Standing: if (Grounded) { NewVelocity.y += -1f * Time.deltaTime; } else { JumpState = PlayerJumpState.SlowFalling; goto case PlayerJumpState.SlowFalling; } break; case PlayerJumpState.Jumping: if (!JumpHeld) { JumpState = PlayerJumpState.FreeFalling; goto case PlayerJumpState.FreeFalling; } if (CurrentVelocity.y < 0) { JumpState = PlayerJumpState.SlowFalling; goto case PlayerJumpState.SlowFalling; } goto case PlayerJumpState.SlowFalling; //break; case PlayerJumpState.SlowFalling: if (!JumpHeld) { JumpState = PlayerJumpState.FreeFalling; goto case PlayerJumpState.FreeFalling; } if (CurrentVelocity.y < FreefallVelocity) { JumpState = PlayerJumpState.FreeFalling; goto case PlayerJumpState.FreeFalling; } if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0) { JumpState = PlayerJumpState.Standing; goto case PlayerJumpState.Standing; } NewVelocity.y += -RisingGravity * Time.deltaTime; break; case PlayerJumpState.FreeFalling: if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0) { JumpState = PlayerJumpState.Standing; goto case PlayerJumpState.Standing; } NewVelocity.y += -FallingGravity * Time.deltaTime; break; } PlayerRB.velocity = NewVelocity; }
// Use this for initialization void Start() { MyRenderer = transform.GetComponentInChildren<Renderer>(); MyCollider = transform.GetComponentInChildren<Collider>(); // TODO: Change if the players don't start falling jumpState = PlayerJumpState.Falling; stunState = PlayerStunnedState.Normal; LaneState = PlayerLaneState.One; // TODO: Set animation MyRenderer.material.color = Color.green; animation.Play ("Run"); }
void Update() { Vector3 CurrentVelocity = PlayerRB.velocity; Vector3 NewVelocity = CurrentVelocity; Vector3 GroundVelocity; bool Grounded = CurrentPlayer.CheckIfGrounded(out GroundVelocity); if (Grounded) { AvailableJumps = MaxAvailableJumps; } switch (JumpState) { case PlayerJumpState.Standing: if (Grounded) { NewVelocity.y += -1f * Time.deltaTime; } else { JumpState = PlayerJumpState.SlowFalling; goto case PlayerJumpState.SlowFalling; } break; case PlayerJumpState.Jumping: if (CurrentVelocity.y < 0) { JumpState = PlayerJumpState.SlowFalling; goto case PlayerJumpState.SlowFalling; } goto case PlayerJumpState.SlowFalling; //break; case PlayerJumpState.SlowFalling: if (CurrentVelocity.y < FreefallVelocity) { JumpState = PlayerJumpState.FreeFalling; goto case PlayerJumpState.FreeFalling; } if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0) { JumpState = PlayerJumpState.Standing; goto case PlayerJumpState.Standing; } NewVelocity.y += -RisingGravity * Time.deltaTime; break; case PlayerJumpState.FreeFalling: if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0) { JumpState = PlayerJumpState.Standing; goto case PlayerJumpState.Standing; } NewVelocity.y += -FallingGravity * Time.deltaTime; break; } PlayerRB.velocity = NewVelocity; }
void EndJump() { JumpState = PlayerJumpState.FreeFalling; }
private Vector3 JumpHandler() { if (jumpState == PlayerJumpState.Grounded) { // Start Jump if Grounded and Jump Key Down if (Input.GetKeyDown(JumpKey)) { jumpState = PlayerJumpState.Jumping; } } else if (jumpState == PlayerJumpState.Jumping) { // Start falling if jump key released if (Input.GetKey (JumpKey)) { float deltaJump = globals.JumpDelta * Time.deltaTime; float testHeight = currentJumpHeight + deltaJump; // Start falling if max height if (testHeight >= globals.MaxJumpHeight) { deltaJump = globals.MaxJumpHeight - currentJumpHeight; currentJumpHeight = 0f; jumpState = PlayerJumpState.Falling; } else { currentJumpHeight += deltaJump; } return new Vector3(0f, deltaJump, 0f); } else { currentJumpHeight = 0f; jumpState = PlayerJumpState.Falling; } } return Vector3.zero; }