mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Finished State Machining Dash
This commit is contained in:
@@ -4,8 +4,12 @@ using UnityEngine;
|
||||
|
||||
public class DashCooldownState : DashBaseState
|
||||
{
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
private CoolDown driver;
|
||||
bool cooldown = false;
|
||||
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
cooldown = false;
|
||||
dSM.StartCoroutine(startCoolDown(dSM));
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
@@ -13,10 +17,21 @@ public class DashCooldownState : DashBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
|
||||
if(cooldown && (dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.RecoveringState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState)){
|
||||
dSM.SwitchState(dSM.IncapacitatedState);
|
||||
}
|
||||
else if(cooldown){
|
||||
dSM.SwitchState(dSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(DashStateManager dSM){
|
||||
//driver.startUICooldown(dashItem.name);
|
||||
yield return new WaitForSeconds(dSM.dashItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,37 @@ using UnityEngine;
|
||||
|
||||
public class DashDashingState : DashBaseState
|
||||
{
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
|
||||
Vector3 moveDirection;
|
||||
const float maxDashTime = 1.0f;
|
||||
float dashDistance = 10;
|
||||
float dashStoppingSpeed = 0.1f;
|
||||
float currentDashTime = maxDashTime;
|
||||
float dashSpeed = 12;
|
||||
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
currentDashTime = 0;
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
|
||||
moveDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(currentDashTime < maxDashTime){
|
||||
moveDirection = dSM.transform.forward * dashDistance;
|
||||
currentDashTime += dashStoppingSpeed;
|
||||
}
|
||||
else{
|
||||
dSM.SwitchState(dSM.CooldownState);
|
||||
}
|
||||
|
||||
if(dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
dSM.moveController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ public class DashIncapacitatedState : DashBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
|
||||
if(dSM.mSM.currentState != dSM.mSM.RagdollState && dSM.mSM.currentState != dSM.mSM.RecoveringState && dSM.mSM.currentState != dSM.mSM.SlideState && dSM.mSM.currentState != dSM.mSM.CrouchState && dSM.mSM.currentState != dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
@@ -13,7 +13,16 @@ public class DashNoneState : DashBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(dSM.pStats.HasDash){
|
||||
if ((Input.GetKeyDown(KeyCode.R) || Input.GetAxis("Dash") != 0)){
|
||||
dSM.SwitchState(dSM.DashingState);
|
||||
}
|
||||
|
||||
if(dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.IncapacitatedState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
@@ -31,6 +31,10 @@ public class DashStateManager : MonoBehaviour
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
public SpecialItem dashItem;
|
||||
////
|
||||
|
||||
void Awake(){
|
||||
|
||||
////Initialize Player Components
|
||||
|
||||
Reference in New Issue
Block a user