diff --git a/Assets/AnimationManager.cs b/Assets/AnimationManager.cs index 766585b..cd1c9d2 100644 --- a/Assets/AnimationManager.cs +++ b/Assets/AnimationManager.cs @@ -1,8 +1,9 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using MLAPI; -public class AnimationManager : MonoBehaviour +public class AnimationManager : NetworkBehaviour { //current priority weight @@ -17,11 +18,11 @@ public class AnimationManager : MonoBehaviour private int currentPriority = 1; //declare references to all the state managers - private dOffenseStateManager offenseState; - private dNitroStateManager nitroState; - private dMoveStateManager moveState; - private dDashStateManager dashState; - private dAerialStateManager aerialState; + private OffenseStateManager offenseState; + private NitroStateManager nitroState; + private MoveStateManager moveState; + private DashStateManager dashState; + private AerialStateManager aerialState; //declare reference to animator private Animator animator; @@ -30,11 +31,11 @@ public class AnimationManager : MonoBehaviour private void Awake() { //initialize all state managers references - offenseState = GetComponent(); - nitroState = GetComponent(); - moveState = GetComponent(); - dashState = GetComponent(); - aerialState = GetComponent(); + offenseState = GetComponent(); + nitroState = GetComponent(); + moveState = GetComponent(); + dashState = GetComponent(); + aerialState = GetComponent(); animator = GetComponent(); @@ -46,32 +47,39 @@ public class AnimationManager : MonoBehaviour //then the current priorty will changed //Note: if we ever want to have this manager keep track of current animation state and not just a priorty number, //then this will need to be changed later (also if we want to add additional animations) - public void updateCurrentPriority(){ + public void updateCurrentPriority() + { int highestPriority; //check if MoveStateManager's current state is incapcitated state - if (moveState.currentState.GetType() == typeof(dMoveRagdollState) || moveState.currentState.GetType() == typeof(dMoveRecoveringState)){ + if (moveState.currentState.GetType() == typeof(MoveRagdollState) || moveState.currentState.GetType() == typeof(MoveRecoveringState)) + { highestPriority = 5; } //if dash manager current state is dashing - else if (dashState.currentState.GetType() == typeof(dDashDashingState)){ + else if (dashState.currentState.GetType() == typeof(DashDashingState)) + { highestPriority = 4; } //check to see if offense manager current state is any state that's doesn't have a weight of 0; - else if (offenseState.currentState.GetType() != typeof(dOffenseIncapacitatedState) && offenseState.currentState.GetType() != typeof(dOffenseNoneState) && offenseState.currentState.GetType() != typeof(dOffenseCooldownState)){ + else if (offenseState.currentState.GetType() != typeof(OffenseIncapacitatedState) && offenseState.currentState.GetType() != typeof(OffenseNoneState) && offenseState.currentState.GetType() != typeof(OffenseCooldownState)) + { highestPriority = 3; } //if current state in aerialManager is not grounded - else if (aerialState.currentState.GetType() != typeof(dAerialGroundedState)){ + else if (aerialState.currentState.GetType() != typeof(AerialGroundedState)) + { highestPriority = 2; } //ground movement is the only state with a animation right now - else{ + else + { highestPriority = 1; } //if highest priorty does not equal current, then a state changed has resulted in a new higher priorty animation - if(highestPriority != currentPriority){ + if (highestPriority != currentPriority) + { currentPriority = highestPriority; animator.SetInteger("currentPriority", currentPriority); @@ -79,21 +87,25 @@ public class AnimationManager : MonoBehaviour } //function will set the currentPriorty to the newPriority arguement. //Note: this function is mostly meant to exist if we need to force a new priorty for some reason, otherwise lgoci will be handled in check - public void SetCurrentPriorityState(int newPriority){ + public void SetCurrentPriorityState(int newPriority) + { //set var to new prio currentPriority = newPriority; //set animator priority var animator.SetInteger("currentPriority", currentPriority); } - + //return priority of a given state (stubbed out for not as not needed for current implementation but may be desired later) - public int GetCurrentPriortyValue(){ + public int GetCurrentPriortyValue() + { return 0; } - + //retrieve highest priority value (current priorty should almost always be - public int GetHighestPriorityValue(){ + public int GetHighestPriorityValue() + { return currentPriority; } } + diff --git a/Assets/AnimationManager.cs.meta b/Assets/AnimationManager.cs.meta index ec04819..5171a35 100644 --- a/Assets/AnimationManager.cs.meta +++ b/Assets/AnimationManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: db0579f1149ac2f4295639b1c9430bf6 +guid: 8ab36263847f7f2408ee4621b46003a3 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Racer/Animations/New Animator Controller.controller b/Assets/Racer/Animations/New Animator Controller.controller index 104122c..4125f8c 100644 --- a/Assets/Racer/Animations/New Animator Controller.controller +++ b/Assets/Racer/Animations/New Animator Controller.controller @@ -192,7 +192,7 @@ AnimatorState: m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 - m_Motion: {fileID: 0} + m_Motion: {fileID: -203655887218126122, guid: 94c70f0bbd236cc4ebf08227b01b3f95, type: 3} m_Tag: m_SpeedParameter: m_MirrorParameter: @@ -553,43 +553,43 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: isWalking m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: isJogging m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: isIdle m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: isDashing m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: currentPriority m_Type: 3 m_DefaultFloat: 0 m_DefaultInt: 1 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} - m_Name: IsKicking m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 0} + m_Controller: {fileID: 9100000} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer @@ -664,7 +664,7 @@ AnimatorState: m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 - m_Motion: {fileID: 0} + m_Motion: {fileID: -203655887218126122, guid: 94c70f0bbd236cc4ebf08227b01b3f95, type: 3} m_Tag: m_SpeedParameter: m_MirrorParameter: diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugDashState/dDashStateManager.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugDashState/dDashStateManager.cs index fa042ad..102075f 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugDashState/dDashStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugDashState/dDashStateManager.cs @@ -26,7 +26,7 @@ public class dDashStateManager : NetworkBehaviour public dMoveStateManager mSM; // movement state manager public CoolDown driver; // cooldown driver //// AnimatorManagerScript - private AnimationManager animationManager; + private dAnimationManager animationManager; //// ////Items Section @@ -38,7 +38,7 @@ public class dDashStateManager : NetworkBehaviour ////Initialize Player Components moveController = GetComponent(); // set Character Controller animator = GetComponent(); // set animator - animationManager = GetComponent(); + animationManager = GetComponent(); //driver = GameObject.Find("Canvas").GetComponent(); //// diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/dMoveStateManager.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/dMoveStateManager.cs index 2deb981..bf98372 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/dMoveStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugMoveState/dMoveStateManager.cs @@ -44,7 +44,7 @@ public class dMoveStateManager : NetworkBehaviour public PlayerStats pStats; // Player Stats public dAerialStateManager aSM; //// AnimatorManagerScript - private AnimationManager animationManager; + private dAnimationManager animationManager; //// ////State Transition Variables @@ -90,7 +90,7 @@ public class dMoveStateManager : NetworkBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator - animationManager = GetComponent(); + animationManager = GetComponent(); //// ////Initialize Scripts diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugNitroState/dNitroStateManager.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugNitroState/dNitroStateManager.cs index c8644db..b8ea7cc 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugNitroState/dNitroStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugNitroState/dNitroStateManager.cs @@ -32,7 +32,7 @@ public class dNitroStateManager : NetworkBehaviour public dMoveStateManager mSM; // move state manager public CoolDown driver; // cooldown driver //// AnimatorManagerScript - private AnimationManager animationManager; + private dAnimationManager animationManager; //// ////Items Section @@ -53,7 +53,7 @@ public class dNitroStateManager : NetworkBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator - animationManager = GetComponent(); + animationManager = GetComponent(); //driver = GameObject.Find("Canvas").GetComponent(); //// diff --git a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugOffenseState/dOffenseStateManager.cs b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugOffenseState/dOffenseStateManager.cs index 0c84ebe..7c632c2 100644 --- a/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugOffenseState/dOffenseStateManager.cs +++ b/Assets/Scripts/PlayerScripts/DebugStateMachine/DebugOffenseState/dOffenseStateManager.cs @@ -40,7 +40,7 @@ public class dOffenseStateManager : NetworkBehaviour public dMoveStateManager mSM; // move state manager public dAerialStateManager aSM; // aerial state manager //// AnimatorManagerScript - private AnimationManager animationManager; + private dAnimationManager animationManager; /// void Awake(){ @@ -51,7 +51,7 @@ public class dOffenseStateManager : NetworkBehaviour capCol = GetComponent(); // set Capsule Collider capCol.enabled = true; animator = GetComponent(); // set animator - animationManager = GetComponent(); + animationManager = GetComponent(); //// ////Initialize Player Objects diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/AerialState/AerialStateManager.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/AerialState/AerialStateManager.cs index 1dd2e90..8280f45 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/AerialState/AerialStateManager.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/AerialState/AerialStateManager.cs @@ -35,12 +35,14 @@ public class AerialStateManager : NetworkBehaviour ////Components Section public CharacterController moveController; // Character Controller Rigidbody rB; // Players Rigidbody - Animator animator; // Animation Controller + public Animator animator; // Animation Controller //// ////Scripts Section public PlayerStats pStats; // Player Stats public MoveStateManager mSM; + //// AnimatorManagerScript + private AnimationManager animationManager; //// ////Variables Section @@ -115,6 +117,7 @@ public class AerialStateManager : NetworkBehaviour ////Initialize Scripts pStats = GetComponent(); // set PlayerStats mSM = GetComponent(); // set move state manager + animationManager = GetComponent(); //// } @@ -195,6 +198,7 @@ public class AerialStateManager : NetworkBehaviour //updates current state and calls logic for entering currentState = state; + animationManager.updateCurrentPriority(); currentState.EnterState(this, previousState); } diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/Dash/DashDashingState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/Dash/DashDashingState.cs index 01281cd..377aec3 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/Dash/DashDashingState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/Dash/DashDashingState.cs @@ -14,10 +14,12 @@ public class DashDashingState : DashBaseState public override void EnterState(DashStateManager dSM, DashBaseState previousState){ currentDashTime = 0; // resets dash time + dSM.GetComponent().SetBool("isDashing", true); } public override void ExitState(DashStateManager dSM, DashBaseState nextState){ moveDirection = Vector3.zero; // resets moveDirection + dSM.GetComponent().SetBool("isDashing", false); } public override void UpdateState(DashStateManager dSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/DashStateManager.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/DashStateManager.cs index 3e5529d..8e25816 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/DashStateManager.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/DashState/DashStateManager.cs @@ -18,13 +18,15 @@ public class DashStateManager : NetworkBehaviour ////Components Section public CharacterController moveController; // Character Controller - Animator animator; // Animation Controller + public Animator animator; // Animation Controller //// ////Scripts Section public PlayerStats pStats; // Player Stats public MoveStateManager mSM; // movement state manager public CoolDown driver; // cooldown driver + //// AnimatorManagerScript + private AnimationManager animationManager; //// ////Items Section @@ -42,6 +44,7 @@ public class DashStateManager : NetworkBehaviour ////Initialize Scripts pStats = GetComponent(); // set PlayerStats mSM = GetComponent(); // set move state manager + animationManager = GetComponent(); //// } @@ -77,6 +80,7 @@ public class DashStateManager : NetworkBehaviour //updates current state and calls logic for entering currentState = state; + animationManager.updateCurrentPriority(); currentState.EnterState(this, previousState); } } diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/MoveStateManager.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/MoveStateManager.cs index 53c119e..4c7f1a9 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/MoveStateManager.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/MoveStateManager.cs @@ -37,12 +37,14 @@ public class MoveStateManager : NetworkBehaviour public CharacterController moveController; // Character Controller public Rigidbody rB; // Players Rigidbody public CapsuleCollider capCol; // Players Capsule Collider - private Animator animator; // Animation Controller + public Animator animator; // Animation Controller //// ////Scripts Section public PlayerStats pStats; // Player Stats public AerialStateManager aSM; + //// AnimatorManagerScript + private AnimationManager animationManager; //// ////State Transition Variables @@ -88,6 +90,7 @@ public class MoveStateManager : NetworkBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator + animationManager = GetComponent(); //// ////Initialize Scripts @@ -162,6 +165,7 @@ public class MoveStateManager : NetworkBehaviour //updates current state and calls logic for entering currentState = state; + animationManager.updateCurrentPriority(); currentState.EnterState(this, previousState); } diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveIdleState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveIdleState.cs index 982c424..a042656 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveIdleState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveIdleState.cs @@ -5,11 +5,13 @@ using UnityEngine; public class MoveIdleState : MoveBaseState { public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){ - + mSM.GetComponent().SetBool("isIdle", true); + Debug.Log("Entered Idle"); } public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){ - + mSM.GetComponent().SetBool("isIdle", false); + Debug.Log("Exited Idle"); } public override void UpdateState(MoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveJogState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveJogState.cs index d2fdf75..3c50e87 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveJogState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveJogState.cs @@ -5,11 +5,13 @@ using UnityEngine; public class MoveJogState : MoveBaseState { public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){ - + mSM.GetComponent().SetBool("isJogging", true); + Debug.Log("Entered Jog"); } public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){ - + mSM.GetComponent().SetBool("isJogging", false); + Debug.Log("Exited Jog"); } public override void UpdateState(MoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveRunState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveRunState.cs index b663e29..845d5be 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveRunState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveRunState.cs @@ -5,11 +5,13 @@ using UnityEngine; public class MoveRunState : MoveBaseState { public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){ - + mSM.GetComponent().SetBool("isRunning", true); + Debug.Log("Entered Run"); } public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){ - + mSM.GetComponent().SetBool("isRunning", false); + Debug.Log("Exit Run"); } public override void UpdateState(MoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveWalkState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveWalkState.cs index 636f002..ecd37c9 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveWalkState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/MovementState/WASD/MoveWalkState.cs @@ -5,11 +5,13 @@ using UnityEngine; public class MoveWalkState : MoveBaseState { public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){ - + mSM.GetComponent().SetBool("isWalking", true); + Debug.Log("Entered Walk"); } public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){ - + mSM.GetComponent().SetBool("isWalking", false); + Debug.Log("Exited Walk"); } public override void UpdateState(MoveStateManager mSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/NitroState/NitroStateManager.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/NitroState/NitroStateManager.cs index 02340e8..ac85ee0 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/NitroState/NitroStateManager.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/NitroState/NitroStateManager.cs @@ -17,7 +17,7 @@ public class NitroStateManager : NetworkBehaviour //// ////Objects Sections - GameObject parentObj; // Parent object + public GameObject parentObj; // Parent object //// ////Components Section @@ -31,6 +31,8 @@ public class NitroStateManager : NetworkBehaviour public PlayerStats pStats; // Player Stats public MoveStateManager mSM; // move state manager public CoolDown driver; // cooldown driver + //// AnimatorManagerScript + private AnimationManager animationManager; //// ////Items Section @@ -50,6 +52,7 @@ public class NitroStateManager : NetworkBehaviour capCol.enabled = true; parentObj = transform.parent.gameObject; // set parent object animator = GetComponent(); // set animator + animationManager = GetComponent(); //driver = GameObject.Find("Canvas").GetComponent(); //// @@ -91,6 +94,7 @@ public class NitroStateManager : NetworkBehaviour //updates current state and calls logic for entering currentState = state; + animationManager.updateCurrentPriority(); currentState.EnterState(this, previousState); } } diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/Kick&Punch/OffenseKickState.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/Kick&Punch/OffenseKickState.cs index bdfa466..f8118ba 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/Kick&Punch/OffenseKickState.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/Kick&Punch/OffenseKickState.cs @@ -13,7 +13,7 @@ public class OffenseKickState : OffenseBaseState oSM.leg.SetActive(true); // activate leg kicked = false; // haven't kicked - + oSM.animator.SetBool("IsKicking", true); //start kicking routine oSM.StartCoroutine(kicking(1f)); } @@ -22,6 +22,7 @@ public class OffenseKickState : OffenseBaseState legRotation = 0; // reset leg angle oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg oSM.leg.SetActive(false); // reset leg angle + oSM.animator.SetBool("IsKicking", false); } public override void UpdateState(OffenseStateManager oSM){ diff --git a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/OffenseStateManager.cs b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/OffenseStateManager.cs index f571479..231a214 100644 --- a/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/OffenseStateManager.cs +++ b/Assets/Scripts/PlayerScripts/NetworkedStateMachines/OffenseState/OffenseStateManager.cs @@ -32,13 +32,15 @@ public class OffenseStateManager : NetworkBehaviour public CharacterController moveController; // Character Controller Rigidbody rB; // Players Rigidbody CapsuleCollider capCol; // Players Capsule Collider - Animator animator; // Animation Controller + public Animator animator; // Animation Controller //// ////Scripts Section public PlayerStats pStats; // Player Stats public MoveStateManager mSM; // move state manager public AerialStateManager aSM; // aerial state manager + //// AnimatorManagerScript + private AnimationManager animationManager; //// void Awake(){ @@ -49,6 +51,7 @@ public class OffenseStateManager : NetworkBehaviour capCol = GetComponent(); // set Capsule Collider capCol.enabled = true; animator = GetComponent(); // set animator + animationManager = GetComponent(); //// ////Initialize Player Objects @@ -97,6 +100,7 @@ public class OffenseStateManager : NetworkBehaviour //updates current state and calls logic for entering currentState = state; + animationManager.updateCurrentPriority(); currentState.EnterState(this, previousState); } diff --git a/Assets/dAnimationManager.cs b/Assets/dAnimationManager.cs new file mode 100644 index 0000000..90dcc3b --- /dev/null +++ b/Assets/dAnimationManager.cs @@ -0,0 +1,99 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class dAnimationManager : MonoBehaviour +{ + //current priority weight + + //priority 0: priority value of offense and aerial state when not active (should never be current priority)-- is grounded/ incapactiatated, None, and cooldown + //priority 1: ground state (nothing else active) + //priority 2: aerial state (nothing above it) + //priority 3: offense state (nothing above it) + //priority 4: dash state (nothing above it) + //priority 5: incapacitated state + + //highest priority/currently active animations; + private int currentPriority = 1; + + //declare references to all the state managers + private dOffenseStateManager offenseState; + private dNitroStateManager nitroState; + private dMoveStateManager moveState; + private dDashStateManager dashState; + private dAerialStateManager aerialState; + + //declare reference to animator + private Animator animator; + + //retrieve all state managers + private void Awake() + { + //initialize all state managers references + offenseState = GetComponent(); + nitroState = GetComponent(); + moveState = GetComponent(); + dashState = GetComponent(); + aerialState = GetComponent(); + + animator = GetComponent(); + + } + + + + //this function will be called everytime a state is switched. If the new state change would change the current priority number, + //then the current priorty will changed + //Note: if we ever want to have this manager keep track of current animation state and not just a priorty number, + //then this will need to be changed later (also if we want to add additional animations) + public void updateCurrentPriority(){ + int highestPriority; + //check if MoveStateManager's current state is incapcitated state + if (moveState.currentState.GetType() == typeof(dMoveRagdollState) || moveState.currentState.GetType() == typeof(dMoveRecoveringState)){ + highestPriority = 5; + + } + //if dash manager current state is dashing + else if (dashState.currentState.GetType() == typeof(dDashDashingState)){ + highestPriority = 4; + } + + //check to see if offense manager current state is any state that's doesn't have a weight of 0; + else if (offenseState.currentState.GetType() != typeof(dOffenseIncapacitatedState) && offenseState.currentState.GetType() != typeof(dOffenseNoneState) && offenseState.currentState.GetType() != typeof(dOffenseCooldownState)){ + highestPriority = 3; + } + //if current state in aerialManager is not grounded + else if (aerialState.currentState.GetType() != typeof(dAerialGroundedState)){ + highestPriority = 2; + } + //ground movement is the only state with a animation right now + else{ + highestPriority = 1; + } + //if highest priorty does not equal current, then a state changed has resulted in a new higher priorty animation + if(highestPriority != currentPriority){ + currentPriority = highestPriority; + animator.SetInteger("currentPriority", currentPriority); + + } + } + //function will set the currentPriorty to the newPriority arguement. + //Note: this function is mostly meant to exist if we need to force a new priorty for some reason, otherwise lgoci will be handled in check + public void SetCurrentPriorityState(int newPriority){ + //set var to new prio + currentPriority = newPriority; + //set animator priority var + animator.SetInteger("currentPriority", currentPriority); + } + + //return priority of a given state (stubbed out for not as not needed for current implementation but may be desired later) + public int GetCurrentPriortyValue(){ + return 0; + } + + //retrieve highest priority value (current priorty should almost always be + public int GetHighestPriorityValue(){ + return currentPriority; + } + +} diff --git a/Assets/dAnimationManager.cs.meta b/Assets/dAnimationManager.cs.meta new file mode 100644 index 0000000..ec04819 --- /dev/null +++ b/Assets/dAnimationManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db0579f1149ac2f4295639b1c9430bf6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: