Setup all the files so they can be state machined

This commit is contained in:
Melbyj1125
2022-02-15 21:37:49 -06:00
parent 833183d034
commit f580be178a
18 changed files with 352 additions and 139 deletions

View File

@@ -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){
}
}

View File

@@ -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){
}
}

View File

@@ -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){
}
}

View File

@@ -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){
}
}

View File

@@ -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);
}
}