mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-23 10:14:27 -05:00
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class dAerialGlidingState : dAerialBaseState
|
|
{
|
|
float tempTraction; // temp traction to store the actual player traction
|
|
|
|
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
|
|
|
//Modify base traction
|
|
tempTraction = aSM.pStats.Traction;
|
|
aSM.pStats.Traction = 1.0f;
|
|
}
|
|
|
|
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
|
|
|
//return traction to normal
|
|
aSM.pStats.Traction = tempTraction;
|
|
}
|
|
|
|
public override void UpdateState(dAerialStateManager aSM){
|
|
|
|
//if not holding jump fall
|
|
if(!Input.GetButton("Jump") || (aSM.mSM.currentState == aSM.mSM.RagdollState)){
|
|
aSM.SwitchState(aSM.FallingState);
|
|
}
|
|
|
|
//if is grounded then grounded
|
|
else if(aSM.isGrounded){
|
|
aSM.SwitchState(aSM.GroundedState);
|
|
}
|
|
|
|
//if isWallrunning and in state that allows it wallrun
|
|
else if(aSM.isWallRunning){
|
|
aSM.SwitchState(aSM.WallRunState);
|
|
}
|
|
|
|
//if can grapple and in state that allows it grapple
|
|
else if(aSM.CheckGrapple()){
|
|
aSM.SwitchState(aSM.GrappleAirState);
|
|
}
|
|
}
|
|
|
|
public override void FixedUpdateState(dAerialStateManager aSM){
|
|
|
|
//modified gravity calculation to fall slower
|
|
aSM.GravityCalculation(9);
|
|
|
|
//if grapple released apply release force
|
|
if(aSM.pStats.HasGrapple){
|
|
aSM.GrappleReleaseForce();
|
|
}
|
|
}
|
|
}
|