mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
created a debug prefab
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dDashCooldownState : dDashBaseState
|
||||
{
|
||||
bool cooldown = false; // is cooldown over
|
||||
|
||||
public override void EnterState(dDashStateManager dSM, dDashBaseState previousState){
|
||||
cooldown = false; // sets cooldown
|
||||
dSM.StartCoroutine(startCoolDown(dSM)); // activates cooldown
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dDashStateManager 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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dDashStateManager dSM){
|
||||
|
||||
}
|
||||
|
||||
//cooldown function
|
||||
private IEnumerator startCoolDown(dDashStateManager dSM){
|
||||
//dSM.driver.startUICooldown(dashItem.name);
|
||||
yield return new WaitForSeconds(dSM.dashItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa9f95b37196a914db649108d4732827
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dDashDashingState : dDashBaseState
|
||||
{
|
||||
|
||||
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(dDashStateManager dSM, dDashBaseState previousState){
|
||||
currentDashTime = 0; // resets dash time
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
moveDirection = Vector3.zero; // resets moveDirection
|
||||
}
|
||||
|
||||
public override void UpdateState(dDashStateManager 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(dDashStateManager dSM){
|
||||
|
||||
//Actually moves the player
|
||||
dSM.moveController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56ebe9dc3558ad84998741b5be0cda1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dDashIncapacitatedState : dDashBaseState
|
||||
{
|
||||
public override void EnterState(dDashStateManager dSM, dDashBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dDashStateManager 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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dDashStateManager dSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3980edf85fc6c74595f75901648239b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dDashNoneState : dDashBaseState
|
||||
{
|
||||
public override void EnterState(dDashStateManager dSM, dDashBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dDashStateManager dSM, dDashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dDashStateManager dSM){
|
||||
|
||||
//checks if player has dash
|
||||
if(dSM.pStats.HasDash){
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dDashStateManager dSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f665861e6fe6d10448d94669cb14ba01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user