mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-22 09:44:15 -05:00
87 lines
2.5 KiB
C#
87 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using MLAPI;
|
|
|
|
public class dDashStateManager : NetworkBehaviour
|
|
{
|
|
////Player States
|
|
public dDashBaseState currentState;
|
|
public dDashBaseState previousState;
|
|
|
|
//Dash States
|
|
public dDashNoneState NoneState = new dDashNoneState();
|
|
public dDashIncapacitatedState IncapacitatedState = new dDashIncapacitatedState();
|
|
public dDashCooldownState CooldownState = new dDashCooldownState();
|
|
public dDashDashingState DashingState = new dDashDashingState();
|
|
////
|
|
|
|
////Components Section
|
|
public CharacterController moveController; // Character Controller
|
|
public Animator animator; // Animation Controller
|
|
////
|
|
|
|
////Scripts Section
|
|
public PlayerStats pStats; // Player Stats
|
|
public dMoveStateManager mSM; // movement state manager
|
|
public dCoolDown driver; // cooldown driver
|
|
//// AnimatorManagerScript
|
|
private dAnimationManager animationManager;
|
|
////
|
|
|
|
////Items Section
|
|
public SpecialItem dashItem; // dash item
|
|
////
|
|
|
|
void Awake(){
|
|
|
|
////Initialize Player Components
|
|
moveController = GetComponent<CharacterController>(); // set Character Controller
|
|
animator = GetComponent<Animator>(); // set animator
|
|
animationManager = GetComponent<dAnimationManager>();
|
|
////
|
|
|
|
////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(dDashBaseState state){
|
|
|
|
currentState.ExitState(this, state);
|
|
|
|
//Sets the previous State
|
|
previousState = currentState;
|
|
|
|
//updates current state and calls logic for entering
|
|
currentState = state;
|
|
//update current animation priorty in animation manager
|
|
animationManager.updateCurrentPriority();
|
|
currentState.EnterState(this, previousState);
|
|
}
|
|
}
|