mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 01:44:30 -05:00
created a debug prefab
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b01e94869f67a4b419906fd52ad3bd4c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dNitroCooldownState : dNitroBaseState
|
||||
{
|
||||
bool cooldown = false; // whether or not cooldown has ended
|
||||
|
||||
public override void EnterState(dNitroStateManager nSM, dNitroBaseState previousState){
|
||||
cooldown = false; // cooldown hasn't ended
|
||||
|
||||
//start cooldown
|
||||
nSM.StartCoroutine(startCoolDown(nSM));
|
||||
}
|
||||
|
||||
public override void ExitState(dNitroStateManager nSM, dNitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dNitroStateManager nSM){
|
||||
|
||||
//if off cooldown and incapacitated then incapacitated
|
||||
if(cooldown && (nSM.mSM.currentState == nSM.mSM.RagdollState || nSM.mSM.currentState == nSM.mSM.RecoveringState)){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
|
||||
//if off cooldown then None
|
||||
else if(cooldown){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dNitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
//cooldown timer
|
||||
private IEnumerator startCoolDown(dNitroStateManager nSM){
|
||||
//nSM.driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(nSM.nitroItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fb7f3ef3c9577f4287b92706af55e2f
|
||||
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 dNitroIncapacitatedState : dNitroBaseState
|
||||
{
|
||||
public override void EnterState(dNitroStateManager nSM, dNitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dNitroStateManager nSM, dNitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dNitroStateManager nSM){
|
||||
|
||||
//if no longer incapacitated then None
|
||||
if(nSM.mSM.currentState != nSM.mSM.RagdollState && nSM.mSM.currentState != nSM.mSM.RecoveringState){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dNitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1508acc725507574c8ed912792441f18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dNitroNitroingState : dNitroBaseState
|
||||
{
|
||||
|
||||
private float tempTimer; // temporary timer
|
||||
private float actualMaxVel; // actual max velocity
|
||||
private float actualAcc; // actual acceleration
|
||||
|
||||
public override void EnterState(dNitroStateManager nSM, dNitroBaseState previousState){
|
||||
actualMaxVel = nSM.pStats.MaxVel; // saves previous max velocity
|
||||
actualAcc = nSM.pStats.Acc; // saves previous max acc
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost; // increases acceleration
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost; // increases max velocity
|
||||
|
||||
tempTimer = 5; // how long we will be sped up
|
||||
}
|
||||
|
||||
public override void ExitState(dNitroStateManager nSM, dNitroBaseState nextState){
|
||||
nSM.pStats.Acc = actualAcc; // reset acceleration
|
||||
nSM.pStats.MaxVel = actualMaxVel; // reset maximum velocity
|
||||
}
|
||||
|
||||
public override void UpdateState(dNitroStateManager nSM){
|
||||
|
||||
//if still nitroing decrease timer
|
||||
if(tempTimer > 0){
|
||||
tempTimer -= .02f;
|
||||
}
|
||||
|
||||
//otherwise cooldown
|
||||
else{
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
|
||||
//if ragdolling then cooldown
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dNitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a43417b0cdae78446b79108e34bbf903
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class dNitroNoneState : dNitroBaseState
|
||||
{
|
||||
public override void EnterState(dNitroStateManager nSM, dNitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dNitroStateManager nSM, dNitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dNitroStateManager nSM){
|
||||
|
||||
//if player has nitro
|
||||
if(nSM.pStats.HasNitro){
|
||||
|
||||
//if ragdolling then incapacitiated
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
|
||||
//if pressing left shift then nitroing
|
||||
else if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.JoystickButton8)))
|
||||
{
|
||||
nSM.SwitchState(nSM.NitroingState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(dNitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62a4ada9bb0dd0a43b2218ddcb3a71f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class dNitroBaseState
|
||||
{
|
||||
public abstract void EnterState(dNitroStateManager nSM, dNitroBaseState previousState);
|
||||
public abstract void ExitState(dNitroStateManager nSM, dNitroBaseState nextState);
|
||||
public abstract void UpdateState(dNitroStateManager nSM);
|
||||
public abstract void FixedUpdateState(dNitroStateManager nSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0695391761689164ca7276b45f57ece3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MLAPI;
|
||||
|
||||
public class dNitroStateManager : NetworkBehaviour
|
||||
{
|
||||
////Player States
|
||||
public dNitroBaseState currentState;
|
||||
public dNitroBaseState previousState;
|
||||
|
||||
//Nitro States
|
||||
public dNitroNoneState NoneState = new dNitroNoneState();
|
||||
public dNitroIncapacitatedState IncapacitatedState = new dNitroIncapacitatedState();
|
||||
public dNitroCooldownState CooldownState = new dNitroCooldownState();
|
||||
public dNitroNitroingState NitroingState = new dNitroNitroingState();
|
||||
////
|
||||
|
||||
////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 dMoveStateManager mSM; // move state manager
|
||||
public CoolDown driver; // cooldown driver
|
||||
////
|
||||
|
||||
////Items Section
|
||||
public SpecialItem nitroItem; // nitro item
|
||||
////
|
||||
|
||||
////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<dMoveStateManager>(); // 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(dNitroBaseState 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 455a2b894b8cfef4bab705dde1a6784b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user