mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Did some bugfixing and commented on everything
This commit is contained in:
@@ -4,10 +4,12 @@ using UnityEngine;
|
||||
|
||||
public class NitroCooldownState : NitroBaseState
|
||||
{
|
||||
bool cooldown = false;
|
||||
bool cooldown = false; // whether or not cooldown has ended
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
cooldown = false;
|
||||
cooldown = false; // cooldown hasn't ended
|
||||
|
||||
//start cooldown
|
||||
nSM.StartCoroutine(startCoolDown(nSM));
|
||||
}
|
||||
|
||||
@@ -16,9 +18,13 @@ public class NitroCooldownState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
//if off cooldown and incapacitated then incapacitated
|
||||
if(cooldown && (nSM.mSM.currentState == nSM.mSM.RagdollState || nSM.mSM.currentState == nSM.mSM.RecoveringState)){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
|
||||
//if off cooldown then None
|
||||
else if(cooldown){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
@@ -28,6 +34,7 @@ public class NitroCooldownState : NitroBaseState
|
||||
|
||||
}
|
||||
|
||||
//cooldown timer
|
||||
private IEnumerator startCoolDown(NitroStateManager nSM){
|
||||
//nSM.driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(nSM.nitroItem.cooldownM);
|
||||
|
||||
@@ -13,6 +13,8 @@ public class NitroIncapacitatedState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
//if no longer incapacitated then None
|
||||
if(nSM.mSM.currentState != nSM.mSM.RagdollState && nSM.mSM.currentState != nSM.mSM.RecoveringState){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
|
||||
@@ -5,32 +5,37 @@ using UnityEngine;
|
||||
public class NitroNitroingState : NitroBaseState
|
||||
{
|
||||
|
||||
private float tempTimer;
|
||||
private float actualMaxVel;
|
||||
private float actualAcc;
|
||||
private float tempTimer; // temporary timer
|
||||
private float actualMaxVel; // actual max velocity
|
||||
private float actualAcc; // actual acceleration
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
actualMaxVel = nSM.pStats.MaxVel;
|
||||
actualAcc = nSM.pStats.Acc;
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost;
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost;
|
||||
actualMaxVel = nSM.pStats.MaxVel; // saves previous max velocity
|
||||
actualAcc = nSM.pStats.Acc; // saves previous max acc
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost; // increases acceleration
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost; // increases max velocity
|
||||
|
||||
tempTimer = 5;
|
||||
tempTimer = 5; // how long we will be sped up
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
nSM.pStats.Acc = actualAcc;
|
||||
nSM.pStats.MaxVel = actualMaxVel;
|
||||
nSM.pStats.Acc = actualAcc; // reset acceleration
|
||||
nSM.pStats.MaxVel = actualMaxVel; // reset maximum velocity
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
//if still nitroing decrease timer
|
||||
if(tempTimer > 0){
|
||||
tempTimer -= .02f;
|
||||
}
|
||||
|
||||
//otherwise cooldown
|
||||
else{
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
|
||||
//if ragdolling then cooldown
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
|
||||
@@ -13,16 +13,21 @@ public class NitroNoneState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
//if player has nitro
|
||||
if(nSM.pStats.HasNitro){
|
||||
|
||||
//if ragdolling then incapacitiated
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
|
||||
if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.JoystickButton8)))
|
||||
//if pressing left shift then nitroing
|
||||
else if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.JoystickButton8)))
|
||||
{
|
||||
nSM.SwitchState(nSM.NitroingState);
|
||||
}
|
||||
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user