Did some bugfixing and commented on everything

This commit is contained in:
Melbyj1125
2022-02-17 20:55:23 -06:00
parent e74a1c61c0
commit 820b11dd61
40 changed files with 528 additions and 250 deletions

View File

@@ -4,11 +4,11 @@ using UnityEngine;
public class DashCooldownState : DashBaseState
{
bool cooldown = false;
bool cooldown = false; // is cooldown over
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
cooldown = false;
dSM.StartCoroutine(startCoolDown(dSM));
cooldown = false; // sets cooldown
dSM.StartCoroutine(startCoolDown(dSM)); // activates cooldown
}
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
@@ -16,9 +16,13 @@ public class DashCooldownState : DashBaseState
}
public override void UpdateState(DashStateManager dSM){
//if after cooldown player is incapacitated still then Incapacitated
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);
}
//if cooldown is over then None
else if(cooldown){
dSM.SwitchState(dSM.NoneState);
}
@@ -28,6 +32,7 @@ public class DashCooldownState : DashBaseState
}
//cooldown function
private IEnumerator startCoolDown(DashStateManager dSM){
//dSM.driver.startUICooldown(dashItem.name);
yield return new WaitForSeconds(dSM.dashItem.cooldownM);

View File

@@ -5,36 +5,42 @@ using UnityEngine;
public class DashDashingState : DashBaseState
{
Vector3 moveDirection;
const float maxDashTime = 1.0f;
float dashDistance = 10;
float dashStoppingSpeed = 0.1f;
float currentDashTime = maxDashTime;
float dashSpeed = 12;
Vector3 moveDirection; // direction vector
const float maxDashTime = .8f; // max dash time
float dashDistance = 10; // distance to dash
float dashStoppingSpeed = 0.1f; // how quickly they stop
float currentDashTime = maxDashTime; // current dash time
float dashSpeed = 12; // dash speed
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
currentDashTime = 0;
currentDashTime = 0; // resets dash time
}
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
moveDirection = Vector3.zero;
moveDirection = Vector3.zero; // resets moveDirection
}
public override void UpdateState(DashStateManager dSM){
//if dash timer is active then move player
if(currentDashTime < maxDashTime){
moveDirection = dSM.transform.forward * dashDistance;
currentDashTime += dashStoppingSpeed;
}
//if dashtimer runs out then cooldown
else{
dSM.SwitchState(dSM.CooldownState);
}
//if player becomes incapacitated then cooldown
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){
//Actually moves the player
dSM.moveController.Move(moveDirection * Time.deltaTime * dashSpeed);
}
}

View File

@@ -13,6 +13,8 @@ public class DashIncapacitatedState : DashBaseState
}
public override void UpdateState(DashStateManager dSM){
//if no longer incapacitated then None
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);
}

View File

@@ -13,14 +13,20 @@ public class DashNoneState : DashBaseState
}
public override void UpdateState(DashStateManager dSM){
//checks if player has dash
if(dSM.pStats.HasDash){
if ((Input.GetKeyDown(KeyCode.R) || Input.GetAxis("Dash") != 0)){
//if incapacitated then incapacitated
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);
}
//if R key then Dashing
else 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);
}
}
}

View File

@@ -15,36 +15,26 @@ public class DashStateManager : NetworkBehaviour
public DashCooldownState CooldownState = new DashCooldownState();
public DashDashingState DashingState = new DashDashingState();
////
////Objects Sections
GameObject parentObj; // Parent object
////
////Components Section
public CharacterController moveController; // Character Controller
Rigidbody rB; // Players Rigidbody
CapsuleCollider capCol; // Players Capsule Collider
Animator animator; // Animation Controller
////
////Scripts Section
public PlayerStats pStats; // Player Stats
public MoveStateManager mSM;
public CoolDown driver;
public MoveStateManager mSM; // movement state manager
public CoolDown driver; // cooldown driver
////
////Items Section
public SpecialItem dashItem;
public SpecialItem dashItem; // dash item
////
void Awake(){
////Initialize Player Components
moveController = GetComponent<CharacterController>(); // set Character Controller
rB = GetComponent<Rigidbody>(); //set Rigid Body
capCol = GetComponent<CapsuleCollider>(); // set Capsule Collider
capCol.enabled = true;
parentObj = transform.parent.gameObject; // set parent object
animator = GetComponent<Animator>(); // set animator
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
////