adjusted anything that refered to playerMovement

This commit is contained in:
Melbyj1125
2022-02-16 16:44:30 -06:00
parent f0936f4cee
commit e74a1c61c0
112 changed files with 60 additions and 67 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2a3e1f7f578e18f408e5ae9b97d27942
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DashCooldownState : DashBaseState
{
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){
}
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){
//dSM.driver.startUICooldown(dashItem.name);
yield return new WaitForSeconds(dSM.dashItem.cooldownM);
cooldown = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bad22bcf005335b43bc4ca573461d7ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
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;
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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b41f7d4ad84f9143bb3b8f570ee7505
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DashIncapacitatedState : DashBaseState
{
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
}
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
}
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){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 603d43aaa9b286a43a78312d03135afe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DashNoneState : DashBaseState
{
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
}
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
}
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){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8b1f874d79f4e64ea90f162d3cf01eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class DashBaseState
{
public abstract void EnterState(DashStateManager dSM, DashBaseState previousState);
public abstract void ExitState(DashStateManager dSM, DashBaseState nextState);
public abstract void UpdateState(DashStateManager dSM);
public abstract void FixedUpdateState(DashStateManager dSM);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 672ce2f99c12e8e449bbd8a3238e601d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class DashStateManager : NetworkBehaviour
{
////Player States
public DashBaseState currentState;
public DashBaseState previousState;
//Dash States
public DashNoneState NoneState = new DashNoneState();
public DashIncapacitatedState IncapacitatedState = new DashIncapacitatedState();
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;
////
////Items Section
public SpecialItem dashItem;
////
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>();
////
////Initialize Scripts
pStats = GetComponent<PlayerStats>(); // set PlayerStats
mSM = GetComponent<MoveStateManager>(); // set move state manager
////
}
void Start(){
//players starting state
currentState = NoneState;
previousState = NoneState;
currentState.EnterState(this, previousState);
}
void Update(){
if (!IsLocalPlayer) { return; }
//calls any logic in the update state from current state
currentState.UpdateState(this);
}
void FixedUpdate(){
if (!IsLocalPlayer) { return; }
//calls any logic in the fixed update state from current state
currentState.FixedUpdateState(this);
}
public void SwitchState(DashBaseState state){
currentState.ExitState(this, state);
//Sets the previous State
previousState = currentState;
//updates current state and calls logic for entering
currentState = state;
currentState.EnterState(this, previousState);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5904903ff376f25499c08e24ad00aaf8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: