mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-30 06:14:22 -05:00
Finished the Movement and Aerial groups
Working on the Dash, Nitro, and offense groups now
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveGrappleAirState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
mSM.driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
if(mSM.aSM.currentState != mSM.aSM.GrappleAirState){
|
||||
//Determine which state to go into based on player speed
|
||||
if(mSM.calculatedCurVel < mSM.walkLimit){
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
else if(mSM.calculatedCurVel < mSM.runLimit){
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
else{
|
||||
mSM.SwitchState(mSM.RunState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1fdba284bf4db40903d97f11507813
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,7 +8,7 @@ public class MoveRagdollState : MoveBaseState
|
||||
Vector3 prevRot;
|
||||
bool beginRagTimer = false;
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Ragdoll State");
|
||||
|
||||
ragTime = mSM.pStats.RecovTime;
|
||||
@@ -21,6 +21,15 @@ public class MoveRagdollState : MoveBaseState
|
||||
mSM.rB.AddForce(mSM.dirHit, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
mSM.pStats.GravVel = 50;
|
||||
mSM.capCol.enabled = false;
|
||||
mSM.moveController.enabled = true;
|
||||
mSM.rB.isKinematic = true;
|
||||
mSM.rB.detectCollisions = false;
|
||||
mSM.transform.localEulerAngles = prevRot;
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
if(!beginRagTimer){
|
||||
beginRagTimer = Physics.Raycast(mSM.transform.position, -Vector3.up, mSM.distToGround + 1f);
|
||||
@@ -36,17 +45,7 @@ public class MoveRagdollState : MoveBaseState
|
||||
ragTime = 0;
|
||||
beginRagTimer = false;
|
||||
|
||||
mSM.pStats.GravVel = 50;
|
||||
mSM.capCol.enabled = false;
|
||||
mSM.moveController.enabled = true;
|
||||
mSM.rB.isKinematic = true;
|
||||
mSM.rB.detectCollisions = false;
|
||||
mSM.transform.localEulerAngles = prevRot;
|
||||
mSM.SwitchState(mSM.RecoveringState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,14 @@ public class MoveRecoveringState : MoveBaseState
|
||||
{
|
||||
////// ADD SOMETHING THAT CHECKS ANIMATION FINISH BEFORE GO TO IDLE
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
mSM.CancelMomentum();
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
@@ -17,8 +21,4 @@ public class MoveRecoveringState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ using UnityEngine;
|
||||
|
||||
public abstract class MoveBaseState
|
||||
{
|
||||
public abstract void EnterState(MoveStateManager mSM);
|
||||
public abstract void EnterState(MoveStateManager mSM, MoveBaseState previousState);
|
||||
public abstract void ExitState(MoveStateManager mSM, MoveBaseState nextState);
|
||||
public abstract void UpdateState(MoveStateManager mSM);
|
||||
public abstract void FixedUpdateState(MoveStateManager mSM);
|
||||
public abstract void OnCollisionEnter(MoveStateManager mSM);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public class MoveStateManager : MonoBehaviour
|
||||
//Incapitated States
|
||||
public MoveRagdollState RagdollState = new MoveRagdollState();
|
||||
public MoveRecoveringState RecoveringState = new MoveRecoveringState();
|
||||
|
||||
//Grapple States
|
||||
public MoveGrappleAirState GrappleAirState = new MoveGrappleAirState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
@@ -69,12 +72,8 @@ public class MoveStateManager : MonoBehaviour
|
||||
public int sensitivity = 200; // Camera sensitivity
|
||||
|
||||
//Ragdoll Variables
|
||||
public Vector3 dirHit;
|
||||
public Vector3 dirHit; // Direction hit
|
||||
public float distToGround; // distance to ground
|
||||
|
||||
//Impact Variables
|
||||
private float mass = 5.0F; // mass variable for Impact
|
||||
private Vector3 impact = Vector3.zero; // Impact Vector
|
||||
////
|
||||
|
||||
|
||||
@@ -101,7 +100,7 @@ public class MoveStateManager : MonoBehaviour
|
||||
//players starting state
|
||||
currentState = IdleState;
|
||||
previousState = IdleState;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
//Slide Upwards Variable
|
||||
slideUp = GetComponentInParent<Transform>().up; // get parents up direction
|
||||
@@ -116,6 +115,8 @@ public class MoveStateManager : MonoBehaviour
|
||||
//calculates vel using driftVel will need to be relocated
|
||||
calculatedCurVel = driftVel.magnitude * 50f;
|
||||
|
||||
GoToGrapple();
|
||||
|
||||
//calls any logic in the update state from current state
|
||||
currentState.UpdateState(this);
|
||||
}
|
||||
@@ -131,12 +132,14 @@ public class MoveStateManager : MonoBehaviour
|
||||
|
||||
public void SwitchState(MoveBaseState state){
|
||||
|
||||
currentState.ExitState(this, state);
|
||||
|
||||
//Sets the previous State
|
||||
previousState = currentState;
|
||||
|
||||
//updates current state and calls logic for entering
|
||||
currentState = state;
|
||||
currentState.EnterState(this);
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,4 +255,9 @@ public class MoveStateManager : MonoBehaviour
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
void GoToGrapple(){
|
||||
if(aSM.currentState == aSM.GrappleAirState && (currentState != SlideState && currentState != RagdollState && currentState != RecoveringState)){
|
||||
SwitchState(GrappleAirState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ public class MoveCrouchState : MoveBaseState
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Crouch State");
|
||||
|
||||
if(mSM.previousState != mSM.SlideState){
|
||||
if(previousState != mSM.SlideState){
|
||||
//Initialize Important Stats On state enter
|
||||
mSM.pStats.CurVel = 0;
|
||||
originalTraction = mSM.pStats.Traction;
|
||||
@@ -22,6 +22,16 @@ public class MoveCrouchState : MoveBaseState
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
if(nextState != mSM.CrouchWalkState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
@@ -35,7 +45,6 @@ public class MoveCrouchState : MoveBaseState
|
||||
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
|
||||
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
|
||||
|
||||
ExitCrouchState(mSM);
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
else{
|
||||
@@ -52,15 +61,4 @@ public class MoveCrouchState : MoveBaseState
|
||||
*/
|
||||
mSM.SlideMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public void ExitCrouchState(MoveStateManager mSM){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@ using UnityEngine;
|
||||
|
||||
public class MoveCrouchWalkState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Crouch Walk State");
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
@@ -33,7 +37,4 @@ public class MoveCrouchWalkState : MoveBaseState
|
||||
*/
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class MoveSlideState : MoveBaseState
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Slide State");
|
||||
|
||||
//Initialize Important Stats On state enter
|
||||
@@ -19,6 +19,15 @@ public class MoveSlideState : MoveBaseState
|
||||
mSM.pStats.Traction = 0.01f;
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
if(nextState != mSM.CrouchState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//if player comes to a stop while sliding they crouch
|
||||
@@ -38,15 +47,12 @@ public class MoveSlideState : MoveBaseState
|
||||
|
||||
//Determine which state to go into based on player speed
|
||||
if(mSM.calculatedCurVel < mSM.walkLimit){
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
else if(mSM.calculatedCurVel < mSM.runLimit){
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
else{
|
||||
SlideToMoveState(mSM);
|
||||
mSM.SwitchState(mSM.RunState);
|
||||
}
|
||||
}
|
||||
@@ -76,15 +82,4 @@ public class MoveSlideState : MoveBaseState
|
||||
*/
|
||||
mSM.SlideMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public void SlideToMoveState(MoveStateManager mSM){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,14 @@ using UnityEngine;
|
||||
|
||||
public class MoveIdleState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Idle State");
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//Move to Walk State after speed increases
|
||||
@@ -16,7 +20,7 @@ public class MoveIdleState : MoveBaseState
|
||||
}
|
||||
|
||||
//If Q or joystick button1 crouch state
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.CrouchState);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +28,4 @@ public class MoveIdleState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveJogState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Jog State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to run state if speed increases
|
||||
@@ -21,7 +25,7 @@ public class MoveJogState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -29,8 +33,4 @@ public class MoveJogState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveRunState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Run State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to Jog if speed decreases
|
||||
@@ -17,7 +21,7 @@ public class MoveRunState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +29,4 @@ public class MoveRunState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class MoveWalkState : MoveBaseState
|
||||
{
|
||||
public override void EnterState(MoveStateManager mSM){
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Walk State");
|
||||
//Debug.Log(mSM.calculatedCurVel);
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//move to Jog if speed increases
|
||||
@@ -21,7 +25,7 @@ public class MoveWalkState : MoveBaseState
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && mSM.aSM.currentState != mSM.aSM.FallingState){
|
||||
if((Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) && (mSM.aSM.currentState != mSM.aSM.FallingState && mSM.aSM.currentState != mSM.aSM.WallRunState && mSM.aSM.currentState != mSM.aSM.WallIdleState && mSM.aSM.currentState != mSM.aSM.GrappleGroundedState)){
|
||||
mSM.SwitchState(mSM.SlideState);
|
||||
}
|
||||
}
|
||||
@@ -29,8 +33,4 @@ public class MoveWalkState : MoveBaseState
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
|
||||
public override void OnCollisionEnter(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user