mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-31 14:55:01 -05:00
Setup all the files so they can be state machined
This commit is contained in:
@@ -2,17 +2,21 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroCooldownState : MonoBehaviour
|
||||
public class NitroCooldownState : NitroBaseState
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,21 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroIncapacitatedState : MonoBehaviour
|
||||
public class NitroIncapacitatedState : NitroBaseState
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,21 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNitroingState : MonoBehaviour
|
||||
public class NitroNitroingState : NitroBaseState
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,21 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNoneState : MonoBehaviour
|
||||
public class NitroNoneState : NitroBaseState
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,16 @@ public class NitroStateManager : MonoBehaviour
|
||||
////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
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
@@ -25,4 +30,50 @@ public class NitroStateManager : MonoBehaviour
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
|
||||
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
|
||||
////
|
||||
|
||||
////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(){
|
||||
//calls any logic in the update state from current state
|
||||
currentState.UpdateState(this);
|
||||
}
|
||||
|
||||
void FixedUpdate(){
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user