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: 8da7e24d55219204b86f9c99f23201c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NitroCooldownState : NitroBaseState
{
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){
}
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){
//nSM.driver.startUICooldown("Nitro");
yield return new WaitForSeconds(nSM.nitroItem.cooldownM);
cooldown = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 31aa143bf2a2d9c4ebccb1884b06e080
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 NitroIncapacitatedState : NitroBaseState
{
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
}
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
}
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){
}
}

View File

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

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NitroNitroingState : NitroBaseState
{
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){
}
}

View File

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

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NitroNoneState : NitroBaseState
{
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
}
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
}
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){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b274f44e4b258004587d2afe1c748474
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 NitroBaseState
{
public abstract void EnterState(NitroStateManager nSM, NitroBaseState previousState);
public abstract void ExitState(NitroStateManager nSM, NitroBaseState nextState);
public abstract void UpdateState(NitroStateManager nSM);
public abstract void FixedUpdateState(NitroStateManager nSM);
}

View File

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

View File

@@ -0,0 +1,96 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class NitroStateManager : NetworkBehaviour
{
////Player States
public NitroBaseState currentState;
public NitroBaseState previousState;
//Nitro States
public NitroNoneState NoneState = new NitroNoneState();
public NitroIncapacitatedState IncapacitatedState = new NitroIncapacitatedState();
public NitroCooldownState CooldownState = new NitroCooldownState();
public NitroNitroingState NitroingState = new NitroNitroingState();
////
////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 nitroItem;
////
////Variables Section
public float nitroVelBoost = 40;
public float nitroAccBoost = .4f;
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(NitroBaseState 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: 5f89839a9c7d0204ea00e910d9c5c5ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: