diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialFallingState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialFallingState.cs index e111edd..c341a94 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialFallingState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialFallingState.cs @@ -13,31 +13,40 @@ public class AerialFallingState : AerialBaseState } public override void UpdateState(AerialStateManager aSM){ + + //if Grav Vel > 0 then jumping if(aSM.pStats.GravVel > 0){ aSM.SwitchState(aSM.JumpingState); } + //if jump has been pressed and has glider and is in a state that allows it glide else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.GlidingState); } + //if is grounded then grounded if(aSM.isGrounded){ aSM.SwitchState(aSM.GroundedState); } + //if is wallrunning ands is in a state that allows it wallrun if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.WallRunState); } - } - - public override void FixedUpdateState(AerialStateManager aSM){ - aSM.GravityCalculation(aSM.pStats.PlayerGrav); - - if(aSM.pStats.HasGrapple){ - aSM.GrappleReleaseForce(); - } + //if grapple is possible and in state that allows it grapple air if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.GrappleAirState); } } + + public override void FixedUpdateState(AerialStateManager aSM){ + + //Default gravity calculation + aSM.GravityCalculation(aSM.pStats.PlayerGrav); + + //if grapple released apply release force + if(aSM.pStats.HasGrapple){ + aSM.GrappleReleaseForce(); + } + } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGlidingState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGlidingState.cs index 31ee640..fa16e11 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGlidingState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGlidingState.cs @@ -4,40 +4,51 @@ using UnityEngine; public class AerialGlidingState : AerialBaseState { - float tempTraction; + float tempTraction; // temp traction to store the actual player traction public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){ Debug.Log("Gliding State"); + //Modify base traction tempTraction = aSM.pStats.Traction; aSM.pStats.Traction = 1.0f; } public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){ + + //return traction to normal aSM.pStats.Traction = tempTraction; } public override void UpdateState(AerialStateManager aSM){ + + //if not holding jump fall if(!Input.GetButton("Jump")){ aSM.SwitchState(aSM.FallingState); } + //if is grounded then grounded if(aSM.isGrounded){ aSM.SwitchState(aSM.GroundedState); } - + + //if isWallrunning and in state that allows it wallrun if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.WallRunState); } + //if can grapple and in state that allows it grapple if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.GrappleAirState); } } public override void FixedUpdateState(AerialStateManager aSM){ + + //modified gravity calculation to fall slower aSM.GravityCalculation(9); + //if grapple released apply release force if(aSM.pStats.HasGrapple){ aSM.GrappleReleaseForce(); } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGroundedState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGroundedState.cs index d985778..b5f10d1 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGroundedState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialGroundedState.cs @@ -7,6 +7,7 @@ public class AerialGroundedState : AerialBaseState public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){ Debug.Log("Grounded State"); + //release is false if grounded aSM.release = false; } @@ -15,19 +16,25 @@ public class AerialGroundedState : AerialBaseState } public override void UpdateState(AerialStateManager aSM){ + + //if grav vel < 0 then falling if(aSM.pStats.GravVel < 0){ aSM.SwitchState(aSM.FallingState); } + //if grav vel > 0 then jumping else if(aSM.pStats.GravVel > 0){ aSM.SwitchState(aSM.JumpingState); } + //can grapple and in state that allows grapple if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.GrappleGroundedState); } } public override void FixedUpdateState(AerialStateManager aSM){ + + //base gravity calculations aSM.GravityCalculation(aSM.pStats.PlayerGrav); } } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialJumpingState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialJumpingState.cs index 8c58281..64333b1 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialJumpingState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Aerial/AerialJumpingState.cs @@ -15,26 +15,33 @@ public class AerialJumpingState : AerialBaseState public override void UpdateState(AerialStateManager aSM){ + //if grav vel < 0 falling if(aSM.pStats.GravVel < 0){ aSM.SwitchState(aSM.FallingState); } + //if is grounded then grounded if(aSM.isGrounded){ aSM.SwitchState(aSM.GroundedState); } - + + //if is wall running and in a state that allows it wallrun if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.WallRunState); } + //if can grapple and in a state that allows it grapple if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){ aSM.SwitchState(aSM.GrappleAirState); } } public override void FixedUpdateState(AerialStateManager aSM){ + + //default gravity calculations aSM.GravityCalculation(aSM.pStats.PlayerGrav); + //if grapple release then apply grapple release force if(aSM.pStats.HasGrapple){ aSM.GrappleReleaseForce(); } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Grapple/AerialGrappleAirState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Grapple/AerialGrappleAirState.cs index 88ee5a7..2bf92ac 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Grapple/AerialGrappleAirState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/AerialState/Grapple/AerialGrappleAirState.cs @@ -24,24 +24,31 @@ public class AerialGrappleAirState : AerialBaseState Debug.Log("Grapple Air State"); + //refresh jump number aSM.curJumpNum = 0; + //rope length limit ropeLength = Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position); if(ropeLength > aSM.maxGrappleDistance){ ropeLength = aSM.maxGrappleDistance; } + //old and cur direction vector for player to hookpoint oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized; curXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized; + //swing momentum calculation swingMom = CalculateSwingMom(aSM.mSM.driftVel.magnitude * 50f, aSM); oldSwingMom = swingMom; - aSM.pStats.GravVel = -1; - aSM.release = false; - aSM.lerpRelease = Vector3.zero; + + //Initialize variables + aSM.pStats.GravVel = -1; // grav vel is adjusted so things work + aSM.release = false; // player hasn't released + aSM.lerpRelease = Vector3.zero; // reset lerp release } public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){ + if(nextState != aSM.GrappleGroundedState){ aSM.release = true; aSM.pStats.GravVel = 0; diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/Dash/DashCooldownState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/Dash/DashCooldownState.cs index aa78fb4..a80097e 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/Dash/DashCooldownState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/Dash/DashCooldownState.cs @@ -4,7 +4,6 @@ using UnityEngine; public class DashCooldownState : DashBaseState { - private CoolDown driver; bool cooldown = false; public override void EnterState(DashStateManager dSM, DashBaseState previousState){ @@ -30,7 +29,7 @@ public class DashCooldownState : DashBaseState } private IEnumerator startCoolDown(DashStateManager dSM){ - //driver.startUICooldown(dashItem.name); + //dSM.driver.startUICooldown(dashItem.name); yield return new WaitForSeconds(dSM.dashItem.cooldownM); cooldown = true; } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/DashStateManager.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/DashStateManager.cs index c7d0f11..eb49e0f 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/DashStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/DashState/DashStateManager.cs @@ -29,6 +29,7 @@ public class DashStateManager : MonoBehaviour ////Scripts Section public PlayerStats pStats; // Player Stats public MoveStateManager mSM; + public CoolDown driver; //// ////Items Section @@ -44,6 +45,7 @@ public class DashStateManager : MonoBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator + //driver = GameObject.Find("Canvas").GetComponent(); //// ////Initialize Scripts diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/Nitro/NitroCooldownState.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/Nitro/NitroCooldownState.cs index a0f618d..1265414 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/Nitro/NitroCooldownState.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/Nitro/NitroCooldownState.cs @@ -4,7 +4,6 @@ using UnityEngine; public class NitroCooldownState : NitroBaseState { - bool cooldown = false; public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){ @@ -30,7 +29,7 @@ public class NitroCooldownState : NitroBaseState } private IEnumerator startCoolDown(NitroStateManager nSM){ - //driver.startUICooldown("Nitro"); + //nSM.driver.startUICooldown("Nitro"); yield return new WaitForSeconds(nSM.nitroItem.cooldownM); cooldown = true; } diff --git a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/NitroStateManager.cs b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/NitroStateManager.cs index c80aba6..3c0fd4d 100644 --- a/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/NitroStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugPlayer/DebugStateStuff/NitroState/NitroStateManager.cs @@ -29,6 +29,7 @@ public class NitroStateManager : MonoBehaviour ////Scripts Section public PlayerStats pStats; // Player Stats public MoveStateManager mSM; + public CoolDown driver; //// ////Items Section @@ -48,6 +49,7 @@ public class NitroStateManager : MonoBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator + //driver = GameObject.Find("Canvas").GetComponent(); //// ////Initialize Scripts