mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Nitro has been State Machined
This commit is contained in:
@@ -4,8 +4,12 @@ using UnityEngine;
|
||||
|
||||
public class NitroCooldownState : NitroBaseState
|
||||
{
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
bool cooldown = false;
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
cooldown = false;
|
||||
nSM.StartCoroutine(startCoolDown(nSM));
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
@@ -13,10 +17,21 @@ public class NitroCooldownState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
if(cooldown && (nSM.mSM.currentState == nSM.mSM.RagdollState || nSM.mSM.currentState == nSM.mSM.RecoveringState)){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
else if(cooldown){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(NitroStateManager nSM){
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(nSM.nitroItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ public class NitroIncapacitatedState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
if(nSM.mSM.currentState != nSM.mSM.RagdollState && nSM.mSM.currentState != nSM.mSM.RecoveringState){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
@@ -4,16 +4,36 @@ using UnityEngine;
|
||||
|
||||
public class NitroNitroingState : NitroBaseState
|
||||
{
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
private float tempTimer;
|
||||
private float actualMaxVel;
|
||||
private float actualAcc;
|
||||
|
||||
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;
|
||||
|
||||
tempTimer = 5;
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
nSM.pStats.Acc = actualAcc;
|
||||
nSM.pStats.MaxVel = actualMaxVel;
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(tempTimer > 0){
|
||||
tempTimer -= .02f;
|
||||
}
|
||||
else{
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
@@ -13,7 +13,18 @@ public class NitroNoneState : NitroBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(nSM.pStats.HasNitro){
|
||||
|
||||
if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.JoystickButton8)))
|
||||
{
|
||||
nSM.SwitchState(nSM.NitroingState);
|
||||
}
|
||||
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
@@ -31,6 +31,14 @@ public class NitroStateManager : MonoBehaviour
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
public SpecialItem nitroItem;
|
||||
////
|
||||
|
||||
////Variables Section
|
||||
public float nitroVelBoost = 40;
|
||||
public float nitroAccBoost = .4f;
|
||||
|
||||
void Awake(){
|
||||
|
||||
////Initialize Player Components
|
||||
|
||||
Reference in New Issue
Block a user