mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-22 18:34:32 -05:00
modified hook and adding testing
This commit is contained in:
@@ -5,65 +5,86 @@ using UnityEngine;
|
||||
public class dAerialGrappleAirState : dAerialBaseState
|
||||
{
|
||||
|
||||
Vector3 initialForceDirection;
|
||||
float distanceBeneathHook = -10f; // Distance Beneath Hook
|
||||
float distanceAfterHook = 8f; // Distance After Hook
|
||||
|
||||
float distanceBeneathHook;
|
||||
float distanceAfterHook;
|
||||
Vector3 desiredPosition;
|
||||
Vector3 tempForceDir;
|
||||
Vector3 updatedYHookPoint;
|
||||
Vector3 initialForceDirection; // Initial Force Direction
|
||||
Vector3 desiredPosition; // Desired Player Position
|
||||
Vector3 tempForceDir; // Temporary Force Direction for calculating if the position has been reached
|
||||
Vector3 updatedYHookPoint; // updated y position of the hook
|
||||
|
||||
|
||||
bool pointReached;
|
||||
bool handReached = false;
|
||||
bool pointReached; // Whether the player has reached the desired position
|
||||
bool handReached = false; // Whether the grapple hand has reached
|
||||
|
||||
float initialForcePower;
|
||||
float initialForcePower; // How much force to apply initially
|
||||
|
||||
|
||||
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
||||
|
||||
|
||||
distanceBeneathHook = -10f;
|
||||
distanceAfterHook = 8f;
|
||||
//Reset these Variables
|
||||
pointReached = false;
|
||||
handReached = false;
|
||||
initialForcePower = 120;
|
||||
|
||||
aSM.currentForcePower = initialForcePower;
|
||||
|
||||
//refresh jump number
|
||||
aSM.curJumpNum = 0;
|
||||
aSM.release = false;
|
||||
|
||||
//Calculate the update y position for the hook
|
||||
updatedYHookPoint = new Vector3(aSM.hookPoint.transform.position.x, aSM.hookPoint.transform.position.y - distanceBeneathHook, aSM.hookPoint.transform.position.z);
|
||||
aSM.currentForcePower = initialForcePower;
|
||||
handReached = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
|
||||
//Reset Hand Rotation
|
||||
aSM.stickyHandParent.transform.localEulerAngles = Vector3.zero;
|
||||
|
||||
//Deactivate Visuals
|
||||
aSM.handController.enabled = false;
|
||||
aSM.stickyHandParent.SetActive(false);
|
||||
aSM.lr.enabled = false;
|
||||
|
||||
//if the next state is grounded or wallrun
|
||||
if(nextState == aSM.GroundedState || nextState == aSM.WallRunState){
|
||||
|
||||
//don't apply the release force
|
||||
aSM.release = false;
|
||||
}
|
||||
else{
|
||||
|
||||
//apply release force
|
||||
aSM.release = true;
|
||||
|
||||
//give the player a slight upwards direction on releasing
|
||||
aSM.pStats.GravVel = 10;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(dAerialStateManager aSM){
|
||||
|
||||
//if the player has reached the calculated point
|
||||
if(pointReached){
|
||||
//if grounded at when the point is reached then goto grounded state
|
||||
//if grounded
|
||||
if(aSM.isGrounded){
|
||||
|
||||
//switch to grounded state
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
//if isn't grounded
|
||||
else if(!aSM.isGrounded){
|
||||
|
||||
//switch to falling state
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
//if wallrunning then wallrun
|
||||
|
||||
//if wallrunning
|
||||
else if(aSM.isWallRunning){
|
||||
|
||||
//switch to wallrun state
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
}
|
||||
@@ -73,68 +94,102 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
|
||||
public override void FixedUpdateState(dAerialStateManager aSM){
|
||||
|
||||
////////ADD A LINE RENDERER WHEN WE GET THE HAND MODEL
|
||||
//Draw Line between player and hookpoint for debug purposes
|
||||
Debug.DrawRay(aSM.transform.position, initialForceDirection); //Visual of line
|
||||
|
||||
//Apply default gravity
|
||||
//If the grapple hand hasn't reached
|
||||
if(!handReached){
|
||||
|
||||
//Throw player hand
|
||||
ThrowStickyHand(aSM);
|
||||
|
||||
//Apply Regular gravity
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
//If the grapple hand has reached and the player hasn't reached the correct point
|
||||
else if(!pointReached && handReached){
|
||||
|
||||
//Start Retrieving the grapple hand
|
||||
RetrieveStickyHand(aSM);
|
||||
|
||||
//Move the player using the calculated direction and power
|
||||
aSM.moveController.Move(initialForceDirection * initialForcePower * Time.deltaTime);
|
||||
|
||||
//Disable gravity while moving
|
||||
aSM.GravityCalculation(0);
|
||||
|
||||
//Set Gravity to 0
|
||||
aSM.pStats.GravVel = 0;
|
||||
|
||||
//Calculate A temporary force direction for checking if point is reached
|
||||
tempForceDir = desiredPosition - aSM.transform.position;
|
||||
tempForceDir = tempForceDir.normalized;
|
||||
tempForceDir = new Vector3(tempForceDir.x,0,tempForceDir.z).normalized;
|
||||
|
||||
//if the player has approximately reached the right position
|
||||
if((aSM.postForceDirection - tempForceDir).magnitude >= .1f && !pointReached){
|
||||
|
||||
//Player has reached the calculated position
|
||||
pointReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
//currentForcePower;
|
||||
|
||||
//normal gravity if grapple is finished
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
//Offset parent rotation for the hand
|
||||
if(aSM.stickyHandParent.active){
|
||||
aSM.stickyHandParent.transform.localRotation = Quaternion.Euler(0.0f, 0.0f, aSM.stickyHandParent.transform.parent.rotation.z * -1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Throw Hand toward hookpoint & calculate desired position
|
||||
public void ThrowStickyHand(dAerialStateManager aSM){
|
||||
|
||||
//If the sticky hand isn't active
|
||||
if(!aSM.stickyHandParent.active){
|
||||
|
||||
//enable hand
|
||||
aSM.stickyHandParent.SetActive(true);
|
||||
|
||||
//enable line renderer
|
||||
aSM.lr.enabled = true;
|
||||
|
||||
//move hand position to hand
|
||||
aSM.stickyHandParent.transform.position = aSM.handPosition.position;
|
||||
|
||||
//enable the character controller on the hand
|
||||
aSM.handController.enabled = true;
|
||||
}
|
||||
|
||||
//set positioning for the line renderer
|
||||
aSM.lr.SetPosition(0,aSM.stickyHandParent.transform.position);
|
||||
aSM.lr.SetPosition(1,aSM.handPosition.transform.position);
|
||||
|
||||
//Hand Throw Direction
|
||||
Vector3 throwDir = (aSM.hookPoint.transform.position - aSM.stickyHandParent.transform.position).normalized;
|
||||
|
||||
//move the hand
|
||||
aSM.stickyHandParent.GetComponent<CharacterController>().Move(throwDir * 120 * Time.deltaTime);
|
||||
|
||||
//if the hand approximately reaches the correct point
|
||||
if(Vector3.Distance(aSM.hookPoint.transform.position, aSM.stickyHandParent.transform.position) <= 3f){
|
||||
|
||||
//Calculate the desired position using current position when hook reaches
|
||||
Vector3 updatedXHookPointDirection = (new Vector3(aSM.transform.position.x, 0, aSM.transform.position.z) - new Vector3(aSM.hookPoint.transform.position.x, 0, aSM.hookPoint.transform.position.z)).normalized;
|
||||
|
||||
desiredPosition = updatedYHookPoint + (updatedXHookPointDirection * -distanceAfterHook);
|
||||
//rope length limit
|
||||
initialForceDirection = desiredPosition - aSM.transform.position;
|
||||
initialForceDirection = initialForceDirection.normalized;
|
||||
|
||||
aSM.postForceDirection = new Vector3(initialForceDirection.x, 0, initialForceDirection.z).normalized;
|
||||
|
||||
//Hand has Reached
|
||||
handReached = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Retrieve Grapple Hand
|
||||
public void RetrieveStickyHand(dAerialStateManager aSM){
|
||||
aSM.lr.SetPosition(0,aSM.stickyHandParent.transform.position);
|
||||
aSM.lr.SetPosition(1,aSM.handPosition.transform.position);
|
||||
|
||||
@@ -69,6 +69,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
Vector3 raycastOffset;
|
||||
Vector3 lastPos;
|
||||
Ray groundRay; // ground ray
|
||||
//Raycasts to ensure player slips down steep ledges
|
||||
Ray angleRayLeft;
|
||||
Ray angleRayRight;
|
||||
Ray angleRayForward;
|
||||
@@ -77,6 +78,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
Ray angleRayRightL;
|
||||
Ray angleRayForwardB;
|
||||
Ray angleRayBackwardsF;
|
||||
///
|
||||
RaycastHit groundHit; // ground raycast
|
||||
|
||||
//Wallrun
|
||||
@@ -586,33 +588,54 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
//Modify This So it Actually gets the nearest hook with a preference for the one they are looking at
|
||||
//Finds the nearest hook to the player
|
||||
//Finds the nearest hook to the player with visual Preference
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
bool inSightLine;
|
||||
bool hookInSight = false;
|
||||
float sightLineleastDistance = maxGrabDistance; // distance to check for sightline hookpoints
|
||||
float nonSightLineLeastDistance = maxGrabDistance; // distance to check for non sightline hookpoints
|
||||
int index = -1; // Default hook index
|
||||
bool inSightLine; // Whether a hook is in currently in sight line
|
||||
bool hookInSight = false; //Whether a hook was in sight
|
||||
|
||||
//Iterate through hookpoints
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
//checks player distance to current hook
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
|
||||
//Checks if the current hook is within the players view point
|
||||
Vector3 screenPoint = cam.WorldToViewportPoint(hookPoints[i].transform.position);
|
||||
inSightLine = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
|
||||
|
||||
if (distance <= least)
|
||||
//if the distance is less than the current closest closest sight line hook
|
||||
if (distance <= sightLineleastDistance)
|
||||
{
|
||||
//if the hook is in view point
|
||||
if(inSightLine){
|
||||
|
||||
//Update current grapple target
|
||||
index = i;
|
||||
least = distance;
|
||||
|
||||
//update closest sight line hook distance
|
||||
sightLineleastDistance = distance;
|
||||
|
||||
//A hook exists in sight line
|
||||
hookInSight = true;
|
||||
}
|
||||
else if(!hookInSight && !inSightLine){
|
||||
|
||||
//if no hookpoints are or has been in sight and the the distance is less than the current closest closest non sight line hook
|
||||
else if((!hookInSight && !inSightLine) && distance <= nonSightLineLeastDistance){
|
||||
|
||||
//update current grapple target
|
||||
index = i;
|
||||
|
||||
//Update the closest non sight line hook distance
|
||||
nonSightLineLeastDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//return the index of the closest hook with priority of ones in sightline
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ public class dDashDashingState : dDashBaseState
|
||||
|
||||
Vector3 moveDirection; // direction vector
|
||||
const float maxDashTime = .8f; // max dash time
|
||||
float dashDistance = 15; // distance to dash
|
||||
float dashDistance = 18; // distance to dash
|
||||
float dashStoppingSpeed = 0.1f; // how quickly they stop
|
||||
float currentDashTime = maxDashTime; // current dash time
|
||||
float dashSpeed = 12; // dash speed
|
||||
|
||||
@@ -603,31 +603,54 @@ public class AerialStateManager : NetworkBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
//Finds the nearest hook to the player with visual Preference
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
bool inSightLine;
|
||||
bool hookInSight = false;
|
||||
float sightLineleastDistance = maxGrabDistance; // distance to check for sightline hookpoints
|
||||
float nonSightLineLeastDistance = maxGrabDistance; // distance to check for non sightline hookpoints
|
||||
int index = -1; // Default hook index
|
||||
bool inSightLine; // Whether a hook is in currently in sight line
|
||||
bool hookInSight = false; //Whether a hook was in sight
|
||||
|
||||
//Iterate through hookpoints
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
//checks player distance to current hook
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
|
||||
//Checks if the current hook is within the players view point
|
||||
Vector3 screenPoint = cam.WorldToViewportPoint(hookPoints[i].transform.position);
|
||||
inSightLine = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
|
||||
|
||||
if (distance <= least)
|
||||
//if the distance is less than the current closest closest sight line hook
|
||||
if (distance <= sightLineleastDistance)
|
||||
{
|
||||
//if the hook is in view point
|
||||
if(inSightLine){
|
||||
|
||||
//Update current grapple target
|
||||
index = i;
|
||||
least = distance;
|
||||
|
||||
//update closest sight line hook distance
|
||||
sightLineleastDistance = distance;
|
||||
|
||||
//A hook exists in sight line
|
||||
hookInSight = true;
|
||||
}
|
||||
else if(!hookInSight && !inSightLine){
|
||||
|
||||
//if no hookpoints are or has been in sight and the the distance is less than the current closest closest non sight line hook
|
||||
else if((!hookInSight && !inSightLine) && distance <= nonSightLineLeastDistance){
|
||||
|
||||
//update current grapple target
|
||||
index = i;
|
||||
|
||||
//Update the closest non sight line hook distance
|
||||
nonSightLineLeastDistance = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//return the index of the closest hook with priority of ones in sightline
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ public class DashDashingState : DashBaseState
|
||||
|
||||
Vector3 moveDirection; // direction vector
|
||||
const float maxDashTime = .8f; // max dash time
|
||||
float dashDistance = 15; // distance to dash
|
||||
float dashDistance = 18; // distance to dash
|
||||
float dashStoppingSpeed = 0.1f; // how quickly they stop
|
||||
float currentDashTime = maxDashTime; // current dash time
|
||||
float dashSpeed = 12; // dash speed
|
||||
|
||||
@@ -7,16 +7,18 @@ using UnityEngine;
|
||||
public class PlayerInventory : NetworkBehaviour
|
||||
{
|
||||
|
||||
//List of items
|
||||
//Dictionary of items
|
||||
[SerializeField] private Dictionary<string, Item> playerItemDict = new Dictionary<string, Item>();
|
||||
public Dictionary<string, Item> PlayerItemDict{
|
||||
get{ return playerItemDict; }
|
||||
}
|
||||
|
||||
//List for the network
|
||||
[SerializeField] private List<string> networkItemList = new List<string>();
|
||||
public List<string> NetworkItemList{
|
||||
get{ return networkItemList; }
|
||||
}
|
||||
|
||||
//Scripts
|
||||
public PlayerStats pStats;
|
||||
|
||||
@@ -33,22 +35,30 @@ public class PlayerInventory : NetworkBehaviour
|
||||
//Add item to player Inventory
|
||||
public void UpdateItemNetwork(string itemName, int add){
|
||||
|
||||
//if Removing items
|
||||
if(add == 0) networkItemList.Remove(itemName);
|
||||
|
||||
//if adding items
|
||||
else if(add == 1 )networkItemList.Add(itemName);
|
||||
|
||||
//if nothing is being updated
|
||||
else Debug.Log("Nothing updated");
|
||||
}
|
||||
|
||||
//Remove Item player inv
|
||||
public void RemoveItem(Item item){
|
||||
//if item removal was successful
|
||||
if(playerItemDict.Remove(item.name)){
|
||||
|
||||
//Modify player stats
|
||||
item.Unequip(pStats, this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
//Updates Inventory to Add item to player list
|
||||
public int UpdateInventory(Item item, bool ableToAdd){
|
||||
|
||||
//if player can add the item
|
||||
if(!playerItemDict.ContainsKey(item.name) && ableToAdd){
|
||||
Debug.Log("Item Added");
|
||||
AddItem(item);
|
||||
|
||||
424
Assets/Scripts/PlayerScripts/SMUnitTest.cs
Normal file
424
Assets/Scripts/PlayerScripts/SMUnitTest.cs
Normal file
@@ -0,0 +1,424 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SMUnitTest : MonoBehaviour
|
||||
{
|
||||
|
||||
//Players State Managers
|
||||
public dAerialStateManager aSM;
|
||||
public dMoveStateManager mSM;
|
||||
public dNitroStateManager nSM;
|
||||
public dOffenseStateManager oSM;
|
||||
public dDashStateManager dSM;
|
||||
|
||||
//MoveState current and next state
|
||||
dMoveBaseState curMoveState;
|
||||
dMoveBaseState nextMoveState;
|
||||
//Legal move state transisitions
|
||||
List<dMoveBaseState> moveIdleTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveWalkTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveJogTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveRunTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveSlideTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveCrouchTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveCrouchWalkTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveRagdollTransitions = new List<dMoveBaseState>();
|
||||
List<dMoveBaseState> moveRecoverTransitions = new List<dMoveBaseState>();
|
||||
|
||||
//Aerial current and next state
|
||||
dAerialBaseState curAerialState;
|
||||
dAerialBaseState nextAerialState;
|
||||
//Legal aerial state transisitions
|
||||
List<dAerialBaseState> aerialGroundedTransitions = new List<dAerialBaseState>();
|
||||
List<dAerialBaseState> aerialFallTransitions = new List<dAerialBaseState>();
|
||||
List<dAerialBaseState> aerialJumpTransitions = new List<dAerialBaseState>();
|
||||
List<dAerialBaseState> aerialWallrunTransitions = new List<dAerialBaseState>();
|
||||
List<dAerialBaseState> aerialGlideTransitions = new List<dAerialBaseState>();
|
||||
List<dAerialBaseState> aerialGrappleTransitions = new List<dAerialBaseState>();
|
||||
|
||||
//Nitro current and next state
|
||||
dNitroBaseState curNitroState;
|
||||
dNitroBaseState nextNitroState;
|
||||
//Legal nitro state transisitions
|
||||
List<dNitroBaseState> nitroNoneTransitions = new List<dNitroBaseState>();
|
||||
List<dNitroBaseState> nitroNitroingTransitions = new List<dNitroBaseState>();
|
||||
List<dNitroBaseState> nitroIncapacitatedTransitions = new List<dNitroBaseState>();
|
||||
List<dNitroBaseState> nitroCooldownTransitions = new List<dNitroBaseState>();
|
||||
|
||||
|
||||
//Offense current and next state
|
||||
dOffenseBaseState curOffenseState;
|
||||
dOffenseBaseState nextOffenseState;
|
||||
//Legal offense state transisitions
|
||||
List<dOffenseBaseState> offenseNoneTransitions = new List<dOffenseBaseState>();
|
||||
List<dOffenseBaseState> offenseKickTransitions = new List<dOffenseBaseState>();
|
||||
List<dOffenseBaseState> offenseAirKickTransitions = new List<dOffenseBaseState>();
|
||||
List<dOffenseBaseState> offenseIncapacitatedTransitions = new List<dOffenseBaseState>();
|
||||
List<dOffenseBaseState> offenseCooldownTransitions = new List<dOffenseBaseState>();
|
||||
|
||||
//Dash current and next state
|
||||
dDashBaseState curDashState;
|
||||
dDashBaseState nextDashState;
|
||||
//Legal dash state transisitions
|
||||
List<dDashBaseState> dashNoneTransitions = new List<dDashBaseState>();
|
||||
List<dDashBaseState> dashDashingTransitions = new List<dDashBaseState>();
|
||||
List<dDashBaseState> dashIncapacitatedTransitions = new List<dDashBaseState>();
|
||||
List<dDashBaseState> dashCooldownTransitions = new List<dDashBaseState>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
|
||||
PopulateTransitionLists();
|
||||
|
||||
//Intitial States for each state manager
|
||||
curMoveState = mSM.currentState;
|
||||
curAerialState = aSM.currentState;
|
||||
curNitroState = nSM.currentState;
|
||||
curOffenseState = oSM.currentState;
|
||||
curDashState = dSM.currentState;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(!UpdateMoveStates()){
|
||||
Debug.LogAssertion("An Illegal Move State transition has occured " + curMoveState + " tried to transition into " + nextMoveState);
|
||||
}
|
||||
|
||||
if(!UpdateAerialStates()){
|
||||
Debug.LogAssertion("An Illegal Aerial State transition has occured " + curAerialState + " tried to transition into " + nextAerialState);
|
||||
}
|
||||
|
||||
if(!UpdateNitroStates()){
|
||||
Debug.LogAssertion("An Illegal Nitro State transition has occured " + curNitroState + " tried to transition into " + nextNitroState);
|
||||
}
|
||||
|
||||
if(!UpdateDashStates()){
|
||||
Debug.LogAssertion("An Illegal Dash State transition has occured " + curDashState + " tried to transition into " + nextDashState);
|
||||
}
|
||||
|
||||
if(!UpdateOffenseStates()){
|
||||
Debug.LogAssertion("An Illegal Offense State transition has occured " + curOffenseState + " tried to transition into " + nextOffenseState);
|
||||
}
|
||||
}
|
||||
|
||||
//Populates All State Manager Transition Lists
|
||||
private void PopulateTransitionLists(){
|
||||
|
||||
////Populate MoveStateManager Lists
|
||||
moveIdleTransitions.Add(mSM.CrouchState);
|
||||
moveIdleTransitions.Add(mSM.WalkState);
|
||||
moveIdleTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveWalkTransitions.Add(mSM.SlideState);
|
||||
moveWalkTransitions.Add(mSM.JogState);
|
||||
moveWalkTransitions.Add(mSM.IdleState);
|
||||
moveWalkTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveJogTransitions.Add(mSM.WalkState);
|
||||
moveJogTransitions.Add(mSM.SlideState);
|
||||
moveJogTransitions.Add(mSM.RunState);
|
||||
moveJogTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveRunTransitions.Add(mSM.SlideState);
|
||||
moveRunTransitions.Add(mSM.JogState);
|
||||
moveRunTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveSlideTransitions.Add(mSM.CrouchState);
|
||||
moveSlideTransitions.Add(mSM.WalkState);
|
||||
moveSlideTransitions.Add(mSM.JogState);
|
||||
moveSlideTransitions.Add(mSM.RunState);
|
||||
moveSlideTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveCrouchTransitions.Add(mSM.CrouchWalkState);
|
||||
moveCrouchTransitions.Add(mSM.WalkState);
|
||||
moveCrouchTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveCrouchWalkTransitions.Add(mSM.CrouchState);
|
||||
moveCrouchWalkTransitions.Add(mSM.WalkState);
|
||||
moveCrouchWalkTransitions.Add(mSM.RagdollState);
|
||||
|
||||
moveRagdollTransitions.Add(mSM.RecoveringState);
|
||||
|
||||
moveRecoverTransitions.Add(mSM.IdleState);
|
||||
////
|
||||
|
||||
////Populate AerialStateManager Lists
|
||||
aerialGroundedTransitions.Add(aSM.FallingState);
|
||||
aerialGroundedTransitions.Add(aSM.JumpingState);
|
||||
aerialGroundedTransitions.Add(aSM.WallRunState);
|
||||
aerialGroundedTransitions.Add(aSM.GrappleAirState);
|
||||
|
||||
aerialFallTransitions.Add(aSM.GroundedState);
|
||||
aerialFallTransitions.Add(aSM.GlidingState);
|
||||
aerialFallTransitions.Add(aSM.JumpingState);
|
||||
aerialFallTransitions.Add(aSM.WallRunState);
|
||||
aerialFallTransitions.Add(aSM.GrappleAirState);
|
||||
|
||||
aerialJumpTransitions.Add(aSM.GroundedState);
|
||||
aerialJumpTransitions.Add(aSM.FallingState);
|
||||
aerialJumpTransitions.Add(aSM.WallRunState);
|
||||
aerialJumpTransitions.Add(aSM.GrappleAirState);
|
||||
|
||||
aerialWallrunTransitions.Add(aSM.GroundedState);
|
||||
aerialWallrunTransitions.Add(aSM.FallingState);
|
||||
aerialWallrunTransitions.Add(aSM.JumpingState);
|
||||
aerialWallrunTransitions.Add(aSM.GrappleAirState);
|
||||
|
||||
aerialGlideTransitions.Add(aSM.GroundedState);
|
||||
aerialGlideTransitions.Add(aSM.FallingState);
|
||||
aerialGlideTransitions.Add(aSM.WallRunState);
|
||||
aerialGlideTransitions.Add(aSM.GrappleAirState);
|
||||
|
||||
aerialGrappleTransitions.Add(aSM.GroundedState);
|
||||
aerialGrappleTransitions.Add(aSM.FallingState);
|
||||
aerialGrappleTransitions.Add(aSM.WallRunState);
|
||||
////
|
||||
|
||||
////Populate NitroStateManager Lists
|
||||
nitroNoneTransitions.Add(nSM.NitroingState);
|
||||
nitroNoneTransitions.Add(nSM.IncapacitatedState);
|
||||
|
||||
nitroNitroingTransitions.Add(nSM.CooldownState);
|
||||
nitroNitroingTransitions.Add(nSM.IncapacitatedState);
|
||||
|
||||
nitroIncapacitatedTransitions.Add(nSM.NoneState);
|
||||
|
||||
nitroCooldownTransitions.Add(nSM.NoneState);
|
||||
nitroCooldownTransitions.Add(nSM.IncapacitatedState);
|
||||
////
|
||||
|
||||
////Populate DashStateManager Lists
|
||||
dashNoneTransitions.Add(dSM.DashingState);
|
||||
dashNoneTransitions.Add(dSM.IncapacitatedState);
|
||||
|
||||
dashDashingTransitions.Add(dSM.CooldownState);
|
||||
dashDashingTransitions.Add(dSM.IncapacitatedState);
|
||||
|
||||
dashIncapacitatedTransitions.Add(dSM.NoneState);
|
||||
|
||||
dashCooldownTransitions.Add(dSM.NoneState);
|
||||
dashCooldownTransitions.Add(dSM.IncapacitatedState);
|
||||
////
|
||||
|
||||
////Populate OffenseStateManager Lists
|
||||
offenseNoneTransitions.Add(oSM.KickState);
|
||||
offenseNoneTransitions.Add(oSM.AirKickState);
|
||||
offenseNoneTransitions.Add(oSM.IncapacitatedState);
|
||||
|
||||
offenseKickTransitions.Add(oSM.CooldownState);
|
||||
offenseKickTransitions.Add(oSM.IncapacitatedState);
|
||||
|
||||
offenseAirKickTransitions.Add(oSM.CooldownState);
|
||||
offenseAirKickTransitions.Add(oSM.IncapacitatedState);
|
||||
|
||||
offenseIncapacitatedTransitions.Add(oSM.NoneState);
|
||||
|
||||
offenseCooldownTransitions.Add(oSM.NoneState);
|
||||
offenseCooldownTransitions.Add(oSM.IncapacitatedState);
|
||||
////
|
||||
}
|
||||
|
||||
//Move State Testing
|
||||
private bool UpdateMoveStates(){
|
||||
if(curMoveState != mSM.currentState){
|
||||
if(ValidateMoveState(mSM.currentState)){
|
||||
curMoveState = mSM.currentState;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
curMoveState = mSM.currentState;
|
||||
nextMoveState = mSM.currentState;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateMoveState(dMoveBaseState nextState){
|
||||
//Checks if The next state exists within the current transitions list
|
||||
if(curMoveState == mSM.IdleState && moveIdleTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.WalkState && moveWalkTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.JogState && moveJogTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.RunState && moveRunTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.SlideState && moveSlideTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.CrouchState && moveCrouchTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.CrouchWalkState && moveCrouchWalkTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.RagdollState && moveRagdollTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curMoveState == mSM.RecoveringState && moveRecoverTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Aerial State Testing
|
||||
private bool UpdateAerialStates(){
|
||||
if(curAerialState != aSM.currentState){
|
||||
if(ValidateAerialState(aSM.currentState)){
|
||||
curAerialState = aSM.currentState;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
curAerialState = aSM.currentState;
|
||||
nextAerialState = aSM.currentState;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateAerialState(dAerialBaseState nextState){
|
||||
//Checks if The next state exists within the current transitions list
|
||||
if(curAerialState == aSM.GroundedState && aerialGroundedTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curAerialState == aSM.FallingState && aerialFallTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curAerialState == aSM.JumpingState && aerialJumpTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curAerialState == aSM.WallRunState && aerialWallrunTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curAerialState == aSM.GlidingState && aerialGlideTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curAerialState == aSM.GrappleAirState && aerialGrappleTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Nitro State Testing
|
||||
private bool UpdateNitroStates(){
|
||||
if(curNitroState != nSM.currentState){
|
||||
if(ValidateNitroState(nSM.currentState)){
|
||||
curNitroState = nSM.currentState;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
curNitroState = nSM.currentState;
|
||||
nextNitroState = nSM.currentState;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateNitroState(dNitroBaseState nextState){
|
||||
//Checks if The next state exists within the current transitions list
|
||||
if(curNitroState == nSM.NoneState && nitroNoneTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curNitroState == nSM.NitroingState && nitroNitroingTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curNitroState == nSM.IncapacitatedState && nitroIncapacitatedTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curNitroState == nSM.CooldownState && nitroCooldownTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Dash State Testing
|
||||
private bool UpdateDashStates(){
|
||||
if(curDashState != dSM.currentState){
|
||||
if(ValidateDashState(dSM.currentState)){
|
||||
curDashState = dSM.currentState;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
curDashState = dSM.currentState;
|
||||
nextDashState = dSM.currentState;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateDashState(dDashBaseState nextState){
|
||||
//Checks if The next state exists within the current transitions list
|
||||
if(curDashState == dSM.NoneState && dashNoneTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curDashState == dSM.DashingState && dashDashingTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curDashState == dSM.IncapacitatedState && dashIncapacitatedTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curDashState == dSM.CooldownState && dashCooldownTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Offense State Testing
|
||||
private bool UpdateOffenseStates(){
|
||||
if(curOffenseState != oSM.currentState){
|
||||
if(ValidateOffenseState(oSM.currentState)){
|
||||
curOffenseState = oSM.currentState;
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
curOffenseState = oSM.currentState;
|
||||
nextOffenseState = oSM.currentState;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateOffenseState(dOffenseBaseState nextState){
|
||||
//Checks if The next state exists within the current transitions list
|
||||
if(curOffenseState == oSM.NoneState && offenseNoneTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curOffenseState == oSM.KickState && offenseKickTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curOffenseState == oSM.AirKickState && offenseAirKickTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curOffenseState == oSM.IncapacitatedState && offenseIncapacitatedTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else if(curOffenseState == oSM.CooldownState && offenseCooldownTransitions.Contains(nextState)){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/PlayerScripts/SMUnitTest.cs.meta
Normal file
11
Assets/Scripts/PlayerScripts/SMUnitTest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa0652b68ed99a840aa63c2124fcb6ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user