mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Merge branch 'sprintActual2Melby'
This commit is contained in:
@@ -172,7 +172,7 @@ public class dGrapplingHook : NetworkBehaviour
|
||||
|
||||
//WILL NEED ADJUSTMENT OR REMOVAL IN THE FUTURE
|
||||
//ungrapple on jump
|
||||
if(playerMovement.GetJumpPressed() && !playerMovement.isGrounded && isGrappled){
|
||||
if(playerMovement.jumpHeld && !playerMovement.isGrounded && isGrappled){
|
||||
release = true;
|
||||
isGrappled = false;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class dKickController : NetworkBehaviour
|
||||
isKicking = true;
|
||||
isDiveKicking = true;
|
||||
leg.SetActive(true);
|
||||
legRotation = -90;
|
||||
}
|
||||
//otherwise do ground kick for .3 seconds
|
||||
else if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && pMove.isSliding==false){
|
||||
@@ -70,7 +71,6 @@ public class dKickController : NetworkBehaviour
|
||||
isKicking = false;
|
||||
legRotation = 0;
|
||||
leg.transform.eulerAngles = new Vector3(legRotation, leg.transform.eulerAngles.y, leg.transform.eulerAngles.z);
|
||||
legHitbox.GetComponent<Collider>().isTrigger = false;
|
||||
leg.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -45,14 +45,12 @@ public class dWallRun : NetworkBehaviour
|
||||
return !isPlayergrounded() && verticalAxis > 0 && VerticalCheck();
|
||||
}
|
||||
|
||||
bool VerticalCheck()
|
||||
{
|
||||
bool VerticalCheck(){
|
||||
return !Physics.Raycast(transform.position, Vector3.down, minimumHeight);
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
void Start(){
|
||||
playerMovementController = GetComponent<dPlayerMovement>();
|
||||
|
||||
directions = new Vector3[]{
|
||||
@@ -65,15 +63,14 @@ public class dWallRun : NetworkBehaviour
|
||||
}
|
||||
|
||||
|
||||
public void WallRunRoutine()
|
||||
{
|
||||
public void WallRunRoutine(){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
isWallRunning = false;
|
||||
|
||||
hits = new RaycastHit[directions.Length];
|
||||
|
||||
if(playerMovementController.GetJumpPressed())
|
||||
if(playerMovementController.jumpHeld)
|
||||
{
|
||||
jumping = true;
|
||||
}
|
||||
@@ -173,7 +170,7 @@ public class dWallRun : NetworkBehaviour
|
||||
moveToSet.y = 0;
|
||||
//
|
||||
|
||||
playerMovementController.SetPlayerVelocity(moveToSet);
|
||||
playerMovementController.vel = moveToSet;
|
||||
if(!isWallRunning){
|
||||
firstAttach = true;
|
||||
isWallRunning = true;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 462a7a4f48de76849922a2831f1b914e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 610121168135e404a920a8b2ea9aa8d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d141d72bd4c482a44b53b7b7681bf510
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialFallingState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Falling State");
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
//if Grav Vel > 0 then jumping
|
||||
if(aSM.pStats.GravVel > 0){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
//if jump has been pressed and has glider and is in a state that allows it glide
|
||||
else if(Input.GetButton("Jump") && aSM.pStats.HasGlider && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GlidingState);
|
||||
}
|
||||
|
||||
//if is grounded then grounded
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
//if is wallrunning ands is in a state that allows it wallrun
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
//if grapple is possible and in state that allows it grapple air
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
//Default gravity calculation
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
|
||||
//if grapple released apply release force
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61783f049a8966743ae46c39eeec1881
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGlidingState : AerialBaseState
|
||||
{
|
||||
float tempTraction; // temp traction to store the actual player traction
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Gliding State");
|
||||
|
||||
//Modify base traction
|
||||
tempTraction = aSM.pStats.Traction;
|
||||
aSM.pStats.Traction = 1.0f;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
//return traction to normal
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
//if not holding jump fall
|
||||
if(!Input.GetButton("Jump")){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
|
||||
//if is grounded then grounded
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
//if isWallrunning and in state that allows it wallrun
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
//if can grapple and in state that allows it grapple
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
//modified gravity calculation to fall slower
|
||||
aSM.GravityCalculation(9);
|
||||
|
||||
//if grapple released apply release force
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c12fc028d5f2f184584d2eca49241719
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGroundedState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Grounded State");
|
||||
|
||||
//release is false if grounded
|
||||
aSM.release = false;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
//if grav vel < 0 then falling
|
||||
if(aSM.pStats.GravVel < 0){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
//if grav vel > 0 then jumping
|
||||
else if(aSM.pStats.GravVel > 0){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
|
||||
//can grapple and in state that allows grapple
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleGroundedState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
//base gravity calculations
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8adbd7189ac5324ea70d17e1a7d80eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialJumpingState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Jumping State");
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
//if grav vel < 0 falling
|
||||
if(aSM.pStats.GravVel < 0){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
|
||||
//if is grounded then grounded
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
//if is wall running and in a state that allows it wallrun
|
||||
if(aSM.isWallRunning && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.WallRunState);
|
||||
}
|
||||
|
||||
//if can grapple and in a state that allows it grapple
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
//default gravity calculations
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
|
||||
//if grapple release then apply grapple release force
|
||||
if(aSM.pStats.HasGrapple){
|
||||
aSM.GrappleReleaseForce();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dc434010f70e6846821781075391a89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class AerialBaseState
|
||||
{
|
||||
public abstract void EnterState(AerialStateManager aSM, AerialBaseState previousState);
|
||||
public abstract void ExitState(AerialStateManager aSM, AerialBaseState nextState);
|
||||
public abstract void UpdateState(AerialStateManager aSM);
|
||||
public abstract void FixedUpdateState(AerialStateManager aSM);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3d9c78aa56075f4db2794b22eafce33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,506 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using MLAPI;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class AerialStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public AerialBaseState currentState;
|
||||
public AerialBaseState previousState;
|
||||
|
||||
//Aerial States
|
||||
public AerialFallingState FallingState = new AerialFallingState();
|
||||
public AerialGlidingState GlidingState = new AerialGlidingState();
|
||||
public AerialGroundedState GroundedState = new AerialGroundedState();
|
||||
public AerialJumpingState JumpingState = new AerialJumpingState();
|
||||
|
||||
//Wallrunning States
|
||||
public AerialWallRunState WallRunState = new AerialWallRunState();
|
||||
public AerialWallIdleState WallIdleState = new AerialWallIdleState();
|
||||
|
||||
//Grappling States
|
||||
public AerialGrappleGroundedState GrappleGroundedState = new AerialGrappleGroundedState();
|
||||
public AerialGrappleAirState GrappleAirState = new AerialGrappleAirState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
////
|
||||
|
||||
////Variables Section
|
||||
//Jump Variables
|
||||
public int curJumpNum; // current Jumps Used
|
||||
public bool jumpHeld; // Jump is Held
|
||||
bool jumpPressed; // Jamp was pressed
|
||||
public float coyJumpTimer = 0.1f; // Default Coyote Jump time
|
||||
public float curCoyJumpTimer = 0.1f; // current Coyote Jump time
|
||||
public float lowJumpMultiplier; // Short jump multiplier
|
||||
public float fallMultiplier; // High Jump Multiplier
|
||||
|
||||
//Gravity Variables//
|
||||
float maxG = -100; // max downwards velocity
|
||||
|
||||
//Ground Check
|
||||
public bool isGrounded; // is player grounded
|
||||
public float groundCheckDistance = 0.05f; // offset distance to check ground
|
||||
const float jumpGroundingPreventionTime = 0.2f; // delay so player doesn't get snapped to ground while jumping
|
||||
const float groundCheckDistanceInAir = 0.07f; // How close we have to get to ground to start checking for grounded again
|
||||
Ray groundRay; // ground ray
|
||||
RaycastHit groundHit; // ground raycast
|
||||
|
||||
//Wallrun
|
||||
float wallMaxDistance = 3f;
|
||||
float wallSpeedMultiplier = 1.5f;
|
||||
float minimumHeight = .1f;
|
||||
[Range(0.0f, 1.0f)]
|
||||
float normalizedAngleThreshold = 0.1f;
|
||||
float jumpDuration = .02f;
|
||||
float wallBouncing = 3;
|
||||
Vector3[] directions;
|
||||
RaycastHit[] hits;
|
||||
public bool isWallRunning = false;
|
||||
Vector3 lastWallPosition;
|
||||
Vector3 lastWallNormal;
|
||||
float elapsedTimeSinceJump = 0;
|
||||
float elapsedTimeSinceWallAttach = 0;
|
||||
float elapsedTimeSinceWallDetatch = 0;
|
||||
bool jumping;
|
||||
|
||||
//Impact Variables
|
||||
float mass = 5.0F; // mass variable for Impact
|
||||
Vector3 impact = Vector3.zero; // Impact Vector
|
||||
|
||||
//Grapple Variables
|
||||
public float maxGrabDistance = 30;// Max Distance can cast grapple
|
||||
public GameObject hookPoint; // Actual Hook points
|
||||
public GameObject[] hookPoints; // Hook point list
|
||||
public int hookPointIndex; // Hook point Index
|
||||
public float distance; // distance of hookpoints
|
||||
public float maxGrappleDistance = 20; // Max Rope Length
|
||||
public float maxSwingSpeed = 50;
|
||||
public float minSwingSpeed = 20;
|
||||
public float swingAcc = 3f;
|
||||
public float maxSwingMom = 60;
|
||||
public bool release = false;
|
||||
public Vector3 tempRelease;
|
||||
public Vector3 lerpRelease;
|
||||
public Vector3 forceDirection;
|
||||
public bool eHeld;
|
||||
////
|
||||
|
||||
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 = GroundedState;
|
||||
previousState = GroundedState;
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
////Initialize Variables
|
||||
//Wallrun Variables
|
||||
directions = new Vector3[]{
|
||||
Vector3.right,
|
||||
Vector3.right + Vector3.forward,
|
||||
Vector3.forward,
|
||||
Vector3.left + Vector3.forward,
|
||||
Vector3.left
|
||||
};
|
||||
|
||||
//Grapple Variables
|
||||
hookPoints = GameObject.FindGameObjectsWithTag("HookPoint");
|
||||
////
|
||||
}
|
||||
|
||||
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);
|
||||
if(moveController.enabled){
|
||||
Jump();
|
||||
GroundCheck();
|
||||
DownwardMovement();
|
||||
|
||||
if(pStats.HasWallrun){
|
||||
WallRunRoutine();
|
||||
}
|
||||
|
||||
//Dissipates Impact
|
||||
DissipateImpact();
|
||||
}
|
||||
else{
|
||||
//Gravity without moveController
|
||||
pStats.GravVel -= pStats.PlayerGrav * Time.deltaTime;
|
||||
rB.AddForce(new Vector3(0,pStats.GravVel,0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SwitchState(AerialBaseState 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);
|
||||
}
|
||||
|
||||
|
||||
////Jump & Gravity Calculations
|
||||
//Uses Given gravity to apply a downwards force while allowing coyote Jump and short hops
|
||||
public void GravityCalculation(float grav){
|
||||
if(moveController.enabled){
|
||||
|
||||
//apply slight upwards force for jump smoothing when g < 0
|
||||
if(pStats.GravVel < 0){
|
||||
pStats.GravVel += grav * (fallMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply smaller upwards force if jump is released early when jumping creating a short jump
|
||||
else if (pStats.GravVel > 0 && !Input.GetButton("Jump")){
|
||||
pStats.GravVel += grav * (lowJumpMultiplier - 1) * Time.deltaTime;
|
||||
}
|
||||
|
||||
//apply gravity if not grounded and coyote timer is less than 0
|
||||
if((isGrounded == false && curCoyJumpTimer <= 0) || currentState == GrappleAirState){
|
||||
pStats.GravVel -= grav * Time.deltaTime;
|
||||
}
|
||||
//else don't apply gravity
|
||||
else{
|
||||
pStats.GravVel = 0;
|
||||
}
|
||||
|
||||
//Caps out the players downwards speed
|
||||
if(pStats.GravVel < maxG){
|
||||
pStats.GravVel = maxG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Checks if player is grounded
|
||||
void GroundCheck(){
|
||||
// Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground
|
||||
float chosenGroundCheckDistance = isGrounded ? (moveController.skinWidth + groundCheckDistance) : groundCheckDistanceInAir;
|
||||
|
||||
// reset values before the ground check
|
||||
isGrounded = false;
|
||||
groundRay = new Ray(moveController.transform.position, Vector3.down);
|
||||
|
||||
if (Physics.Raycast(groundRay, out groundHit, moveController.height + groundCheckDistance) && !jumpPressed)
|
||||
{
|
||||
// Only consider this a valid ground hit if the ground normal goes in the same direction as the character up
|
||||
if (Vector3.Dot(groundHit.normal, transform.up) > 0f)
|
||||
{
|
||||
isGrounded = true;
|
||||
// handle snapping to the ground
|
||||
if (groundHit.distance > moveController.skinWidth && currentState != GrappleAirState)
|
||||
{
|
||||
moveController.Move(Vector3.down * groundHit.distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Actually applies the downwards movement
|
||||
void DownwardMovement(){
|
||||
Vector3 moveY = new Vector3(0,pStats.GravVel,0) * Time.deltaTime;
|
||||
|
||||
|
||||
|
||||
if(currentState == GrappleAirState){
|
||||
moveY = (new Vector3(0,pStats.GravVel,0) + forceDirection) * Time.deltaTime;
|
||||
}
|
||||
|
||||
moveController.Move(moveY);
|
||||
|
||||
}
|
||||
|
||||
//applies Jump values and Variables
|
||||
void Jump(){
|
||||
//If space/south gamepad button is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum)
|
||||
{
|
||||
if(currentState == WallRunState){
|
||||
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);
|
||||
pStats.GravVel = pStats.JumpPow;
|
||||
curJumpNum = 0;
|
||||
}
|
||||
else{
|
||||
pStats.GravVel = pStats.JumpPow;
|
||||
}
|
||||
|
||||
|
||||
curJumpNum++;
|
||||
jumpHeld = true;
|
||||
jumpPressed = true;
|
||||
}
|
||||
|
||||
//If grounded no jumps have been used and coyote Timer is refreshed
|
||||
if(isGrounded && pStats.GravVel == 0){
|
||||
curCoyJumpTimer = coyJumpTimer;
|
||||
curJumpNum = 0;
|
||||
}
|
||||
//else start the coyote timer
|
||||
else curCoyJumpTimer -= Time.deltaTime;
|
||||
|
||||
//if jump is being held coyote timer is zero
|
||||
if(jumpHeld) curCoyJumpTimer = 0;
|
||||
|
||||
//If space/south face gamepad button isn't being pressed then jump is false
|
||||
if (Input.GetAxis("Jump") == 0){
|
||||
jumpHeld = false;
|
||||
}
|
||||
|
||||
if(pStats.GravVel < 0){
|
||||
jumpPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Apply Impact for when force needs to be applied without ragdolling
|
||||
public void AddImpact(Vector3 dir, float force){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
//Normalize direction multiply by force and add it to the impact
|
||||
dir.Normalize();
|
||||
if (dir.y < 0) dir.y = -dir.y; // reflect down force on the ground
|
||||
impact += dir.normalized * force / mass;
|
||||
}
|
||||
|
||||
//Dissipates Impact Force
|
||||
void DissipateImpact(){
|
||||
//if suffiecient impact magnitude is applied then move player
|
||||
if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime);
|
||||
|
||||
// consumes the impact energy each cycle:
|
||||
impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime);
|
||||
}
|
||||
////
|
||||
|
||||
////Wallrun Functions
|
||||
//Checks if they can wallrun
|
||||
public bool CanWallRun(){
|
||||
float verticalAxis = Input.GetAxisRaw("Vertical");
|
||||
return !isGrounded && verticalAxis > 0 && !Physics.Raycast(transform.position, Vector3.down, minimumHeight);
|
||||
}
|
||||
|
||||
//checks if they can attach
|
||||
bool CanAttach(){
|
||||
if(jumping)
|
||||
{
|
||||
elapsedTimeSinceJump += Time.deltaTime;
|
||||
if(elapsedTimeSinceJump > jumpDuration)
|
||||
{
|
||||
elapsedTimeSinceJump = 0;
|
||||
jumping = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//On Wall calulations
|
||||
void OnWall(RaycastHit hit){
|
||||
float d = Vector3.Dot(hit.normal, Vector3.up);
|
||||
if(d >= -normalizedAngleThreshold && d <= normalizedAngleThreshold)
|
||||
{
|
||||
Vector3 alongWall = Vector3.Cross(hit.normal, Vector3.up);
|
||||
float vertical = Input.GetAxisRaw("Vertical");
|
||||
//Vector3 alongWall = transform.TransformDirection(Vector3.forward);
|
||||
|
||||
// Debug.DrawRay(transform.position, alongWall.normalized * 10, Color.green);
|
||||
// Debug.DrawRay(transform.position, lastWallNormal * 10, Color.magenta);
|
||||
|
||||
Vector3 moveToSet = alongWall * vertical * mSM.PlayerSpeed() * Time.deltaTime;
|
||||
Vector3 velNorm = mSM.vel;
|
||||
velNorm.Normalize();
|
||||
|
||||
moveToSet = new Vector3(moveToSet.x * -velNorm.x, moveToSet.y, moveToSet.z * -velNorm.z);
|
||||
|
||||
Vector3 moveToSetNorm = moveToSet;
|
||||
moveToSetNorm.Normalize();
|
||||
|
||||
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
|
||||
moveToSet.x = (moveToSet.x * -velNorm.x);
|
||||
}
|
||||
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
|
||||
moveToSet.x = (-moveToSet.x * -velNorm.x);
|
||||
}
|
||||
|
||||
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
|
||||
moveToSet.z = (moveToSet.z * -velNorm.z);
|
||||
}
|
||||
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
|
||||
moveToSet.z = (-moveToSet.z * -velNorm.z);
|
||||
}
|
||||
|
||||
moveToSet.y = 0;
|
||||
//
|
||||
|
||||
mSM.vel = moveToSet;
|
||||
if(!isWallRunning){
|
||||
isWallRunning = true;
|
||||
}
|
||||
|
||||
if(curJumpNum == mSM.pStats.JumpNum){
|
||||
curJumpNum = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Calculate wall direction
|
||||
float CalculateSide(){
|
||||
if(isWallRunning)
|
||||
{
|
||||
Vector3 heading = lastWallPosition - transform.position;
|
||||
Vector3 perp = Vector3.Cross(transform.forward, heading);
|
||||
float dir = Vector3.Dot(perp, transform.up);
|
||||
return dir;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//The Wallrun Routine itself
|
||||
void WallRunRoutine(){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
isWallRunning = false;
|
||||
|
||||
hits = new RaycastHit[directions.Length];
|
||||
|
||||
if(jumpHeld)
|
||||
{
|
||||
jumping = true;
|
||||
}
|
||||
|
||||
if(CanAttach())
|
||||
{
|
||||
for(int i=0; i<directions.Length; i++)
|
||||
{
|
||||
Vector3 dir = transform.TransformDirection(directions[i]);
|
||||
Physics.Raycast(transform.position, dir, out hits[i], wallMaxDistance);
|
||||
if(hits[i].collider != null)
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
if(CanWallRun())
|
||||
{
|
||||
hits = hits.ToList().Where(h => h.collider != null).OrderBy(h => h.distance).ToArray();
|
||||
if(hits.Length > 0)
|
||||
{
|
||||
if(hits[0].collider.tag == "WallRun")
|
||||
{
|
||||
OnWall(hits[0]);
|
||||
lastWallPosition = hits[0].point;
|
||||
lastWallNormal = hits[0].normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isWallRunning)
|
||||
{
|
||||
elapsedTimeSinceWallDetatch = 0;
|
||||
elapsedTimeSinceWallAttach += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsedTimeSinceWallAttach = 0;
|
||||
elapsedTimeSinceWallDetatch += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
//The Direction the player jumps on wall detachment
|
||||
public Vector3 GetWallJumpDirection(){
|
||||
return lastWallNormal * wallBouncing + (transform.up);
|
||||
}
|
||||
////
|
||||
|
||||
////Grapple Functions
|
||||
//Checks if the player can grapple
|
||||
public bool CheckGrapple(){
|
||||
if ((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && pStats.HasGrapple) //If grapple button is hit
|
||||
{
|
||||
hookPointIndex = FindHookPoint(); //Find the nearest hook point within max distance
|
||||
if (hookPointIndex != -1) //If there is a hookpoint
|
||||
{
|
||||
hookPoint = hookPoints[hookPointIndex]; //The point we are grappling from
|
||||
eHeld = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Finds the nearest hook to the player
|
||||
int FindHookPoint()
|
||||
{
|
||||
float least = maxGrabDistance;
|
||||
int index = -1;
|
||||
for(int i = 0; i<hookPoints.Length; i++)
|
||||
{
|
||||
distance = Vector3.Distance(gameObject.transform.position, hookPoints[i].transform.position);
|
||||
if (distance <= least)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public void GrappleReleaseForce(){
|
||||
if(release){
|
||||
lerpRelease = Vector3.Lerp(lerpRelease, tempRelease, 9f * Time.deltaTime);
|
||||
tempRelease *= .98f;
|
||||
moveController.Move(lerpRelease);
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 201caa2b2f1776a46af6bdfd52456028
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d9e7839f6deda248905235a2cc3e3cf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,235 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGrappleAirState : AerialBaseState
|
||||
{
|
||||
float ropeLength; // current rope length
|
||||
Vector3 swingDirection; // Swing direction
|
||||
float inclinationAngle; // inclination angle
|
||||
float theta = -1; // theta
|
||||
float swingMom;
|
||||
Vector3 tensionMomDirection;
|
||||
Vector3 hookPointRight;
|
||||
Vector3 momDirection;
|
||||
Vector3 curXZDir;
|
||||
Vector3 oldXZDir;
|
||||
float swingSpeed = 10;
|
||||
bool swingback = false; //swing the player back
|
||||
float oldSwingMom;
|
||||
Vector3 tensionDirection;
|
||||
float tensionForce;
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
Debug.Log("Grapple Air State");
|
||||
|
||||
//refresh jump number
|
||||
aSM.curJumpNum = 0;
|
||||
|
||||
//rope length limit
|
||||
ropeLength = Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position);
|
||||
if(ropeLength > aSM.maxGrappleDistance){
|
||||
ropeLength = aSM.maxGrappleDistance;
|
||||
}
|
||||
|
||||
//old and cur direction vector for player to hookpoint
|
||||
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
curXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
|
||||
//swing momentum calculation
|
||||
swingMom = CalculateSwingMom(aSM.mSM.driftVel.magnitude * 50f, aSM);
|
||||
oldSwingMom = swingMom;
|
||||
|
||||
//Initialize variables
|
||||
aSM.pStats.GravVel = -1; // grav vel is adjusted so things work
|
||||
aSM.release = false; // player hasn't released
|
||||
aSM.lerpRelease = Vector3.zero; // reset lerp release
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
if(nextState != aSM.GrappleGroundedState){
|
||||
aSM.release = true;
|
||||
aSM.pStats.GravVel = 0;
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
swingback = true;
|
||||
}
|
||||
else{
|
||||
aSM.pStats.GravVel = 0;
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
swingback = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
if((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2))){
|
||||
aSM.eHeld = false;
|
||||
}
|
||||
|
||||
if(Input.GetButton("Jump")){
|
||||
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
|
||||
if(aSM.isGrounded){
|
||||
aSM.SwitchState(aSM.GrappleGroundedState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
|
||||
|
||||
//Debug.Log(Vector3.Distance(gameObject.transform.position, hookPoint.transform.position));
|
||||
//Calculate tether force direction based on hookpoint
|
||||
if (Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) >= ropeLength )
|
||||
{
|
||||
aSM.forceDirection = CalculateForceDirection(1, aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM) + RopeLengthOffset(aSM.hookPoint.transform.position, Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position), aSM);
|
||||
}
|
||||
else{
|
||||
aSM.forceDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
aSM.moveController.Move(SwingMoveController(aSM));
|
||||
if(swingMom != 0){
|
||||
aSM.moveController.Move(CalculateMomentumDirection(aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM));
|
||||
swingMom -= .5f;
|
||||
}
|
||||
|
||||
if(swingMom<0) swingMom = 0;
|
||||
|
||||
aSM.tempRelease = CalculateSwingReleaseForce();
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
|
||||
//Needs to be Overhauled to properly implement energy loss taking into account players current Velocity, height and input
|
||||
//------Important Equations--------
|
||||
// TensionForce = Cos(theta) * g * m * Vector3(tensionDirection)
|
||||
// Potential Energy = m * g * h -- Will need to modify adding current speed
|
||||
// Kinetic Energy = 1/2 * m * V^2 -- assuming no energy loss at the bottom KE = PE at peak we will add energy loss ourselves
|
||||
// Total Energy = m * ((g*h) + (1/2 * V^2))
|
||||
// Velocity = (2 * ((TotalEnergy/m) - (g*h)))^(1/2) -- This hypothetically could be used for our swing momentum calculation
|
||||
// Movement Direction right angle of tension force = Sin(theta) * g * m * Vector3(Right angle to tensionDirection)
|
||||
|
||||
//Calculate the tether direction vector and how much force that vector needs
|
||||
Vector3 CalculateForceDirection(float mass, float g, Vector3 hPoint, AerialStateManager aSM){
|
||||
|
||||
//tension direction and angle calculation
|
||||
tensionDirection = (hPoint - aSM.transform.position).normalized;
|
||||
inclinationAngle = Vector3.Angle((aSM.transform.position - hPoint).normalized, -aSM.transform.up);
|
||||
theta = Mathf.Deg2Rad * inclinationAngle;
|
||||
if(theta<=.1) theta = 0;
|
||||
|
||||
//How much force the tension needs
|
||||
tensionForce = mass * -g * Mathf.Cos(theta);
|
||||
|
||||
//force direction calculation based on tension direction and force
|
||||
Vector3 fDirection = tensionDirection * tensionForce;
|
||||
return fDirection;
|
||||
}
|
||||
|
||||
Vector3 CalculateMomentumDirection(float g, Vector3 hPoint, AerialStateManager aSM){
|
||||
|
||||
tensionMomDirection = (hPoint - aSM.transform.position).normalized;
|
||||
hookPointRight = Vector3.Cross(oldXZDir, aSM.transform.up).normalized;
|
||||
momDirection = -1 * Vector3.Cross(hookPointRight, tensionMomDirection).normalized;
|
||||
|
||||
if(oldXZDir != curXZDir){
|
||||
//midpointMom = swingMom;
|
||||
swingback = false;
|
||||
//Debug.Log("flip");
|
||||
}
|
||||
|
||||
if(swingback == false && swingMom <= (oldSwingMom*(.75f))){
|
||||
swingback = true;
|
||||
oldSwingMom = swingMom;
|
||||
oldXZDir = (new Vector3(aSM.hookPoint.transform.position.x,0,aSM.hookPoint.transform.position.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
//Debug.Log("swingback");
|
||||
}
|
||||
|
||||
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(aSM.transform.position.x,0,aSM.transform.position.z)).normalized;
|
||||
Debug.DrawRay(aSM.transform.position, momDirection * Time.deltaTime* 100, Color.green);
|
||||
return (momDirection * Time.deltaTime * swingMom);
|
||||
}
|
||||
|
||||
//Calculates the players initial swing momentum using their height and their current velocity
|
||||
float CalculateSwingMom(float playerSpeed, AerialStateManager aSM){
|
||||
|
||||
//Calculate the players height compared to the lowest point in the swing
|
||||
float swingHeight = aSM.transform.position.y - (aSM.hookPoint.transform.position.y - ropeLength);
|
||||
if(swingHeight <= 1){
|
||||
swingHeight = 1;
|
||||
}
|
||||
|
||||
float sMom = playerSpeed + (swingHeight*2);
|
||||
if(sMom > aSM.maxSwingMom){
|
||||
sMom = aSM.maxSwingMom;
|
||||
}
|
||||
return sMom;
|
||||
}
|
||||
|
||||
//Special movement for the player while they swing
|
||||
Vector3 SwingMoveController(AerialStateManager aSM){
|
||||
|
||||
//WASD input
|
||||
float inputVert = Input.GetAxis("Vertical");
|
||||
float inputHor = Input.GetAxis("Horizontal");
|
||||
|
||||
//input is zero when nothing is pressed to prevent button easing values
|
||||
if((!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S))) inputVert = 0;
|
||||
if((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))) inputHor = 0;
|
||||
|
||||
//Swingspeed build up
|
||||
if((inputVert != 0 || inputHor != 0) && swingSpeed < aSM.maxSwingSpeed){
|
||||
swingSpeed += aSM.swingAcc;
|
||||
}
|
||||
else if((inputVert != 0 || inputHor != 0) && swingSpeed >= aSM.maxSwingSpeed){
|
||||
swingSpeed = aSM.maxSwingSpeed;
|
||||
}
|
||||
else if((inputVert == 0 && inputHor == 0)){
|
||||
swingSpeed = aSM.minSwingSpeed;
|
||||
}
|
||||
|
||||
//Swing direction based on player input
|
||||
swingDirection = Vector3.Cross(tensionDirection, ((aSM.transform.right * -inputVert) + (aSM.transform.forward * inputHor))).normalized;
|
||||
|
||||
|
||||
//NEED TO ADD SWINGSPEED EASING
|
||||
//this could be just adding a gradual increase in the swing speed instead of using a flat rate
|
||||
//Swing movement with swing speed added
|
||||
Vector3 swingMovement = (swingDirection * Time.deltaTime * swingSpeed);
|
||||
|
||||
|
||||
return (swingMovement);
|
||||
}
|
||||
|
||||
Vector3 RopeLengthOffset(Vector3 hPoint, float curDistance, AerialStateManager aSM){
|
||||
|
||||
//How powerful our offset movement has to be
|
||||
float offsetPower = ((curDistance - ropeLength) * 200f);
|
||||
|
||||
//The direction we need to apply force to offset when the rope gets lengthened beyond the necessary point
|
||||
Vector3 tenDirOffset = (hPoint - aSM.transform.position).normalized;
|
||||
|
||||
|
||||
return tenDirOffset * offsetPower * Time.deltaTime;
|
||||
}
|
||||
|
||||
Vector3 CalculateSwingReleaseForce(){
|
||||
|
||||
Vector3 releaseSwingForceDirection = momDirection * ((swingMom) + 10);
|
||||
|
||||
releaseSwingForceDirection = new Vector3(releaseSwingForceDirection.x,0,releaseSwingForceDirection.z);
|
||||
|
||||
if(swingMom < 5){
|
||||
return Vector3.zero;
|
||||
}
|
||||
return releaseSwingForceDirection * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f636cc4d77c0d439a1effaa5b08485
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialGrappleGroundedState : AerialBaseState
|
||||
{
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Grapple Grounded State");
|
||||
|
||||
aSM.release = false;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(!aSM.isGrounded && aSM.pStats.GravVel < 0){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
|
||||
if(Vector3.Distance(aSM.transform.position, aSM.hookPoint.transform.position) > aSM.maxGrappleDistance){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
|
||||
if((Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) && !aSM.eHeld){
|
||||
aSM.SwitchState(aSM.GroundedState);
|
||||
}
|
||||
else if((Input.GetKeyUp(KeyCode.E) || Input.GetKeyUp(KeyCode.JoystickButton2))){
|
||||
aSM.eHeld = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
Debug.DrawRay(aSM.transform.position, (aSM.hookPoint.transform.position - aSM.transform.position)); //Visual of line
|
||||
|
||||
aSM.GravityCalculation(aSM.pStats.PlayerGrav);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd53fea25f9a40e41812e6faae369b2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bdb37848afbcd446b59b3158927a111
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialWallIdleState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15b109cc50982684c9d17a41ec11dc32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AerialWallRunState : AerialBaseState
|
||||
{
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
Debug.Log("Wallrun State");
|
||||
aSM.pStats.GravVel = 0;
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
if(Input.GetButton("Jump")){
|
||||
aSM.SwitchState(aSM.JumpingState);
|
||||
}
|
||||
else if(!aSM.isWallRunning){
|
||||
aSM.SwitchState(aSM.FallingState);
|
||||
}
|
||||
|
||||
if(aSM.CheckGrapple() && (aSM.mSM.currentState != aSM.mSM.SlideState && aSM.mSM.currentState != aSM.mSM.RagdollState && aSM.mSM.currentState != aSM.mSM.RecoveringState)){
|
||||
aSM.SwitchState(aSM.GrappleAirState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(AerialStateManager aSM){
|
||||
aSM.GravityCalculation(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93ab0a7ac87da66408ced3667ae9b930
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9ee815c205c3f44d8052ed3699439e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a3e1f7f578e18f408e5ae9b97d27942
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashCooldownState : DashBaseState
|
||||
{
|
||||
bool cooldown = false;
|
||||
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
cooldown = false;
|
||||
dSM.StartCoroutine(startCoolDown(dSM));
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(cooldown && (dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.RecoveringState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState)){
|
||||
dSM.SwitchState(dSM.IncapacitatedState);
|
||||
}
|
||||
else if(cooldown){
|
||||
dSM.SwitchState(dSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(DashStateManager dSM){
|
||||
//dSM.driver.startUICooldown(dashItem.name);
|
||||
yield return new WaitForSeconds(dSM.dashItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad22bcf005335b43bc4ca573461d7ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashDashingState : DashBaseState
|
||||
{
|
||||
|
||||
Vector3 moveDirection;
|
||||
const float maxDashTime = 1.0f;
|
||||
float dashDistance = 10;
|
||||
float dashStoppingSpeed = 0.1f;
|
||||
float currentDashTime = maxDashTime;
|
||||
float dashSpeed = 12;
|
||||
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
currentDashTime = 0;
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
moveDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(currentDashTime < maxDashTime){
|
||||
moveDirection = dSM.transform.forward * dashDistance;
|
||||
currentDashTime += dashStoppingSpeed;
|
||||
}
|
||||
else{
|
||||
dSM.SwitchState(dSM.CooldownState);
|
||||
}
|
||||
|
||||
if(dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
dSM.moveController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b41f7d4ad84f9143bb3b8f570ee7505
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashIncapacitatedState : DashBaseState
|
||||
{
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(dSM.mSM.currentState != dSM.mSM.RagdollState && dSM.mSM.currentState != dSM.mSM.RecoveringState && dSM.mSM.currentState != dSM.mSM.SlideState && dSM.mSM.currentState != dSM.mSM.CrouchState && dSM.mSM.currentState != dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 603d43aaa9b286a43a78312d03135afe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashNoneState : DashBaseState
|
||||
{
|
||||
public override void EnterState(DashStateManager dSM, DashBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(DashStateManager dSM, DashBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(DashStateManager dSM){
|
||||
if(dSM.pStats.HasDash){
|
||||
if ((Input.GetKeyDown(KeyCode.R) || Input.GetAxis("Dash") != 0)){
|
||||
dSM.SwitchState(dSM.DashingState);
|
||||
}
|
||||
|
||||
if(dSM.mSM.currentState == dSM.mSM.RagdollState || dSM.mSM.currentState == dSM.mSM.SlideState || dSM.mSM.currentState == dSM.mSM.CrouchState || dSM.mSM.currentState == dSM.mSM.CrouchWalkState){
|
||||
dSM.SwitchState(dSM.IncapacitatedState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(DashStateManager dSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b1f874d79f4e64ea90f162d3cf01eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class DashBaseState
|
||||
{
|
||||
public abstract void EnterState(DashStateManager dSM, DashBaseState previousState);
|
||||
public abstract void ExitState(DashStateManager dSM, DashBaseState nextState);
|
||||
public abstract void UpdateState(DashStateManager dSM);
|
||||
public abstract void FixedUpdateState(DashStateManager dSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 672ce2f99c12e8e449bbd8a3238e601d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DashStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public DashBaseState currentState;
|
||||
public DashBaseState previousState;
|
||||
|
||||
//Dash States
|
||||
public DashNoneState NoneState = new DashNoneState();
|
||||
public DashIncapacitatedState IncapacitatedState = new DashIncapacitatedState();
|
||||
public DashCooldownState CooldownState = new DashCooldownState();
|
||||
public DashDashingState DashingState = new DashDashingState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
GameObject parentObj; // Parent object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
public CoolDown driver;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
public SpecialItem dashItem;
|
||||
////
|
||||
|
||||
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
|
||||
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
|
||||
////
|
||||
|
||||
////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(DashBaseState 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5904903ff376f25499c08e24ad00aaf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 971e1f1cbdebc9f49ac05494f803e05e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44ea0e21af7d7024099c4da443b76164
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5149f1c52a18e6a45b82453d3af9a9b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveRagdollState : MoveBaseState
|
||||
{
|
||||
float ragTime;
|
||||
Vector3 prevRot;
|
||||
bool beginRagTimer = false;
|
||||
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Ragdoll State");
|
||||
|
||||
ragTime = mSM.pStats.RecovTime;
|
||||
prevRot = mSM.transform.localEulerAngles;
|
||||
mSM.capCol.enabled = true;
|
||||
mSM.moveController.enabled = false;
|
||||
mSM.rB.isKinematic = false;
|
||||
mSM.rB.detectCollisions = true;
|
||||
|
||||
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);
|
||||
}
|
||||
else{
|
||||
ragTime -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
//Has to be in Fixed Update because it has player movement
|
||||
if(ragTime <= 0 && beginRagTimer){
|
||||
ragTime = 0;
|
||||
beginRagTimer = false;
|
||||
|
||||
mSM.SwitchState(mSM.RecoveringState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7164475ffa0df6409ecd43b0517e4b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveRecoveringState : MoveBaseState
|
||||
{
|
||||
////// ADD SOMETHING THAT CHECKS ANIMATION FINISH BEFORE GO TO IDLE
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dee57766c5fb3c34c8979d3e14d4e94e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class MoveBaseState
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7faaa4b89293d9e4992142ab5c4fcc35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveStateManager : MonoBehaviour
|
||||
{
|
||||
////Player States
|
||||
public MoveBaseState currentState;
|
||||
public MoveBaseState previousState;
|
||||
|
||||
//WASD States
|
||||
public MoveIdleState IdleState = new MoveIdleState();
|
||||
public MoveWalkState WalkState = new MoveWalkState();
|
||||
public MoveJogState JogState = new MoveJogState();
|
||||
public MoveRunState RunState = new MoveRunState();
|
||||
|
||||
//Slide States
|
||||
public MoveSlideState SlideState = new MoveSlideState();
|
||||
public MoveCrouchState CrouchState = new MoveCrouchState();
|
||||
public MoveCrouchWalkState CrouchWalkState = new MoveCrouchWalkState();
|
||||
|
||||
//Incapitated States
|
||||
public MoveRagdollState RagdollState = new MoveRagdollState();
|
||||
public MoveRecoveringState RecoveringState = new MoveRecoveringState();
|
||||
|
||||
//Grapple States
|
||||
public MoveGrappleAirState GrappleAirState = new MoveGrappleAirState();
|
||||
////
|
||||
|
||||
////Objects Sections
|
||||
private GameObject parentObj; // Parent object
|
||||
public Camera cam; // Camera object
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
public Rigidbody rB; // Players Rigidbody
|
||||
public CapsuleCollider capCol; // Players Capsule Collider
|
||||
private Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public AerialStateManager aSM;
|
||||
////
|
||||
|
||||
////State Transition Variables
|
||||
public float idleLimit = .3f;
|
||||
public float walkLimit = 10.0f;
|
||||
public float jogLimit = 20f;
|
||||
public float runLimit = 30f;
|
||||
////
|
||||
|
||||
////Player Variables Section
|
||||
//Speed Variables
|
||||
public Vector3 vel; // moveZ + moveX
|
||||
private Vector3 moveZ; // Local Horizontal Vector
|
||||
private Vector3 moveX; // Local Vertical Vector
|
||||
public Vector3 driftVel; // Lerped Movement Vector
|
||||
public float calculatedCurVel; // calculated current vel using driftVel
|
||||
|
||||
//Slide Variables
|
||||
public Vector3 slideUp; // Slide upwards direction
|
||||
|
||||
//Camera Variables
|
||||
private Vector3 camRotation; // cameras camera rotation vector
|
||||
[Range(-45, -15)]
|
||||
public int minAngle = -30; // minimum downwards cam angle
|
||||
[Range(30, 80)]
|
||||
public int maxAngle = 45; // Max upwards cam angle
|
||||
[Range(50, 500)]
|
||||
public int sensitivity = 200; // Camera sensitivity
|
||||
|
||||
//Ragdoll Variables
|
||||
public Vector3 dirHit; // Direction hit
|
||||
public float distToGround; // distance to ground
|
||||
////
|
||||
|
||||
|
||||
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
|
||||
aSM = GetComponent<AerialStateManager>();
|
||||
////
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//players starting state
|
||||
currentState = IdleState;
|
||||
previousState = IdleState;
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
//Slide Upwards Variable
|
||||
slideUp = GetComponentInParent<Transform>().up; // get parents up direction
|
||||
distToGround = GetComponent<Collider>().bounds.extents.y; // set players distance to ground
|
||||
|
||||
Cursor.lockState = CursorLockMode.Locked; // Lock cursor on start if you are the local player
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//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);
|
||||
}
|
||||
|
||||
void FixedUpdate(){
|
||||
|
||||
//calls any logic in the fixed update state from current state
|
||||
currentState.FixedUpdateState(this);
|
||||
|
||||
if(cam.enabled) Rotation();
|
||||
else Debug.Log("Cam Disabled");
|
||||
}
|
||||
|
||||
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, previousState);
|
||||
}
|
||||
|
||||
|
||||
////Broad Functions
|
||||
//Player Speed Calculator
|
||||
public float PlayerSpeed(){
|
||||
//If nothing is pressed speed is 0
|
||||
if ((Input.GetAxis("Vertical") == 0.0f && Input.GetAxis("Horizontal") == 0.0f))
|
||||
{
|
||||
pStats.CurVel = 0.0f;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
//If current speed is below min when pressed set to minimum speed
|
||||
else if (pStats.CurVel < pStats.MinVel)
|
||||
{
|
||||
pStats.CurVel = pStats.MinVel;
|
||||
return pStats.MinVel;
|
||||
}
|
||||
// while the speed is below max speed slowly increase it
|
||||
else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel))
|
||||
{
|
||||
pStats.CurVel += pStats.Acc;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
//If the players speed is above or equal to max speed set speed to max
|
||||
else if (pStats.CurVel >= pStats.MaxVel)
|
||||
{
|
||||
pStats.CurVel = pStats.MaxVel;
|
||||
return pStats.CurVel;
|
||||
|
||||
}
|
||||
//case if somehow they escape this check
|
||||
else{
|
||||
Debug.Log("Something has gone wrong with the PlayerSpeed()");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//Wasd movement using player speed
|
||||
public void DirectionalMovement(){
|
||||
//Keyboard inputs
|
||||
//Checks if movement keys have been pressed and calculates correct vector
|
||||
moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed();
|
||||
moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed();
|
||||
|
||||
vel = moveX + moveZ;
|
||||
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
|
||||
|
||||
//Actually move he player
|
||||
moveController.Move(driftVel);
|
||||
}
|
||||
|
||||
//Slide movement
|
||||
public void SlideMovement(){
|
||||
|
||||
moveX = Vector3.zero;
|
||||
moveZ = Vector3.zero;
|
||||
|
||||
//Adds vectors based on movement keys and other conditions to check what the
|
||||
//player vector should be under the circumstances
|
||||
vel = moveX + moveZ;
|
||||
Vector3 moveXZ = new Vector3(vel.x, 0, vel.z);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
|
||||
|
||||
//Actually move he player
|
||||
moveController.Move(driftVel);
|
||||
}
|
||||
|
||||
//Camera and player rotation
|
||||
private void Rotation(){
|
||||
//If moveController is enabled allow Camera control
|
||||
if(moveController.enabled){
|
||||
//if input is received from Mouse X
|
||||
if (Input.GetAxis("Mouse X") != 0){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
}
|
||||
|
||||
//if input is received from right analog stick (horizontal)
|
||||
else if(Input.GetAxis("HorizontalCam") != 0){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
|
||||
}
|
||||
|
||||
//if input is if input is received from Mouse Y
|
||||
if (Input.GetAxis("Mouse Y") != 0)
|
||||
{
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
|
||||
//if input is received from right analog stick (vertical)
|
||||
else if (Input.GetAxis("VerticalTurn") != 0){
|
||||
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetHit(Vector3 dir, float force){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
dir.Normalize();
|
||||
dirHit = dir * force;
|
||||
SwitchState(RagdollState);
|
||||
}
|
||||
|
||||
public void CancelMomentum(){
|
||||
pStats.CurVel = 0;
|
||||
vel = Vector3.zero;
|
||||
moveX = Vector3.zero;
|
||||
moveZ = Vector3.zero;
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
|
||||
void GoToGrapple(){
|
||||
if(aSM.currentState == aSM.GrappleAirState && (currentState != SlideState && currentState != RagdollState && currentState != RecoveringState)){
|
||||
SwitchState(GrappleAirState);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7adf74561e73e1c4e99ec7e3d6a08738
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca62a3355c93dd04a9c72b0327c603e2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveCrouchState : MoveBaseState
|
||||
{
|
||||
|
||||
//Slide Variables
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Crouch State");
|
||||
|
||||
if(previousState != mSM.SlideState){
|
||||
//Initialize Important Stats On state enter
|
||||
mSM.pStats.CurVel = 0;
|
||||
mSM.gameObject.transform.eulerAngles = new Vector3(mSM.transform.localEulerAngles.x - 90, mSM.transform.localEulerAngles.y, mSM.transform.localEulerAngles.z);
|
||||
mSM.moveController.height *= .5f;
|
||||
}
|
||||
}
|
||||
|
||||
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.moveController.height *= 2.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.transform.Rotate(Vector3.forward * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
|
||||
///////ONCE WE HAVE IT SO SLIDE DOESNT ROTATE PLAYER MOVE THIS TO UPDATE
|
||||
//If player isn't pressing either Q or the joystick button they stop crouching if nothing is above them
|
||||
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
|
||||
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
|
||||
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
else{
|
||||
Debug.Log("Object above you");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//If falling stop sliding and go to wasd states
|
||||
if(mSM.aSM.currentState == mSM.aSM.FallingState){
|
||||
ExitCrouchState(mSM);
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88c903fd0284d184dade30af31081373
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveCrouchWalkState : MoveBaseState
|
||||
{
|
||||
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){
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
|
||||
/*
|
||||
if(mSM.aSM.currentState == mSM.aSM.FallingState){
|
||||
//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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 502d8c0b8175a794ab08d2798a29465c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveSlideState : MoveBaseState
|
||||
{
|
||||
//Slide Variables
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
Debug.Log("Slide State");
|
||||
|
||||
//Initialize Important Stats On state enter
|
||||
mSM.pStats.CurVel = 0;
|
||||
originalTraction = mSM.pStats.Traction;
|
||||
mSM.gameObject.transform.eulerAngles = new Vector3(mSM.transform.eulerAngles.x - 90, mSM.transform.eulerAngles.y, mSM.transform.eulerAngles.z);
|
||||
mSM.moveController.height *= .5f;
|
||||
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;
|
||||
}
|
||||
else{
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(MoveStateManager mSM){
|
||||
|
||||
//if player comes to a stop while sliding they crouch
|
||||
if(mSM.calculatedCurVel < mSM.idleLimit){
|
||||
mSM.SwitchState(mSM.CrouchState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.transform.Rotate(Vector3.forward * -mSM.sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
mSM.pStats.Traction += .004f;
|
||||
|
||||
///////ONCE WE HAVE IT SO SLIDE DOESNT ROTATE PLAYER MOVE THIS TO UPDATE
|
||||
if((!Input.GetKey(KeyCode.JoystickButton1) && !Input.GetKey(KeyCode.Q))){
|
||||
if ((Physics.Raycast(mSM.gameObject.transform.position, mSM.slideUp, out slideRay, 5f) == false)){
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Debug.Log("Object above you");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
//If falling stop sliding and go to wasd states
|
||||
if(mSM.aSM.currentState == mSM.aSM.FallingState){
|
||||
//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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
mSM.SlideMovement();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4338a9bf5309e75489870c3702150aa8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e29a437006aa0374090c478aae4af886
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveIdleState : MoveBaseState
|
||||
{
|
||||
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
|
||||
if(mSM.calculatedCurVel >= mSM.idleLimit){
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
|
||||
//If Q or joystick button1 crouch state
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 125078d4aa4c6df499f04e79c5142b5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveJogState : MoveBaseState
|
||||
{
|
||||
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
|
||||
if(mSM.calculatedCurVel >= mSM.runLimit){
|
||||
mSM.SwitchState(mSM.RunState);
|
||||
}
|
||||
//move to walk if speed decreases
|
||||
else if(mSM.calculatedCurVel < mSM.walkLimit){
|
||||
mSM.SwitchState(mSM.WalkState);
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51bfa6fd57184214195d51b209c92454
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveRunState : MoveBaseState
|
||||
{
|
||||
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
|
||||
if(mSM.calculatedCurVel < mSM.runLimit){
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 022dbadfec93fcf489a6e2bab39d0553
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveWalkState : MoveBaseState
|
||||
{
|
||||
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
|
||||
if(mSM.calculatedCurVel >= mSM.jogLimit){
|
||||
mSM.SwitchState(mSM.JogState);
|
||||
}
|
||||
//move to Idle if speed decreases
|
||||
else if(mSM.calculatedCurVel < mSM.idleLimit){
|
||||
mSM.SwitchState(mSM.IdleState);
|
||||
}
|
||||
|
||||
//move to slide if Q or JoystickButton1
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(MoveStateManager mSM){
|
||||
mSM.DirectionalMovement();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44721a52e3dd5634bbd29b627ef2886b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49be17e5729da3e45ac2be9a69003e55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da7e24d55219204b86f9c99f23201c6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroCooldownState : NitroBaseState
|
||||
{
|
||||
bool cooldown = false;
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
cooldown = false;
|
||||
nSM.StartCoroutine(startCoolDown(nSM));
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(cooldown && (nSM.mSM.currentState == nSM.mSM.RagdollState || nSM.mSM.currentState == nSM.mSM.RecoveringState)){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
else if(cooldown){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(NitroStateManager nSM){
|
||||
//nSM.driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(nSM.nitroItem.cooldownM);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31aa143bf2a2d9c4ebccb1884b06e080
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroIncapacitatedState : NitroBaseState
|
||||
{
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(nSM.mSM.currentState != nSM.mSM.RagdollState && nSM.mSM.currentState != nSM.mSM.RecoveringState){
|
||||
nSM.SwitchState(nSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a331aa9af6c346f43b8123be4e308693
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNitroingState : NitroBaseState
|
||||
{
|
||||
|
||||
private float tempTimer;
|
||||
private float actualMaxVel;
|
||||
private float actualAcc;
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
actualMaxVel = nSM.pStats.MaxVel;
|
||||
actualAcc = nSM.pStats.Acc;
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost;
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost;
|
||||
|
||||
tempTimer = 5;
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
nSM.pStats.Acc = actualAcc;
|
||||
nSM.pStats.MaxVel = actualMaxVel;
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(tempTimer > 0){
|
||||
tempTimer -= .02f;
|
||||
}
|
||||
else{
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb069621f651c743b64a3604ba25e8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NitroNoneState : NitroBaseState
|
||||
{
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(NitroStateManager nSM){
|
||||
if(nSM.pStats.HasNitro){
|
||||
|
||||
if ((Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.JoystickButton8)))
|
||||
{
|
||||
nSM.SwitchState(nSM.NitroingState);
|
||||
}
|
||||
|
||||
if(nSM.mSM.currentState == nSM.mSM.RagdollState){
|
||||
nSM.SwitchState(nSM.IncapacitatedState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(NitroStateManager nSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b274f44e4b258004587d2afe1c748474
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class NitroBaseState
|
||||
{
|
||||
public abstract void EnterState(NitroStateManager nSM, NitroBaseState previousState);
|
||||
public abstract void ExitState(NitroStateManager nSM, NitroBaseState nextState);
|
||||
public abstract void UpdateState(NitroStateManager nSM);
|
||||
public abstract void FixedUpdateState(NitroStateManager nSM);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7142e15316cd1694983f38a584c89346
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
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
|
||||
////
|
||||
|
||||
////Components Section
|
||||
public CharacterController moveController; // Character Controller
|
||||
Rigidbody rB; // Players Rigidbody
|
||||
CapsuleCollider capCol; // Players Capsule Collider
|
||||
Animator animator; // Animation Controller
|
||||
////
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
public CoolDown driver;
|
||||
////
|
||||
|
||||
////Items Section
|
||||
public SpecialItem nitroItem;
|
||||
////
|
||||
|
||||
////Variables Section
|
||||
public float nitroVelBoost = 40;
|
||||
public float nitroAccBoost = .4f;
|
||||
|
||||
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
|
||||
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
|
||||
////
|
||||
|
||||
////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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f89839a9c7d0204ea00e910d9c5c5ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f2cb4f0002be5f46bbd5661b5364c16
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2292a829a1cb2c43b4e3889d4cfe7a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseAirKickState : OffenseBaseState
|
||||
{
|
||||
|
||||
private float legRotation = 0;
|
||||
bool kicked = false;
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
oSM.leg.SetActive(true);
|
||||
legRotation = -90;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
kicked = false;
|
||||
|
||||
oSM.StartCoroutine(kicking(8f));
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
legRotation = 0;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
oSM.leg.SetActive(false);
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
|
||||
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e963653fb34d3184fba3fb7e4417ed75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseAirPunchState : OffenseBaseState
|
||||
{
|
||||
|
||||
private float legRotation = 0;
|
||||
bool kicked = false;
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
oSM.leg.SetActive(true);
|
||||
legRotation = -90;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
kicked = false;
|
||||
|
||||
oSM.StartCoroutine(kicking(8f));
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
legRotation = 0;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
oSM.leg.SetActive(false);
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
|
||||
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f00bc672381c3a44b010d905fabe9a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseKickState : OffenseBaseState
|
||||
{
|
||||
|
||||
float legRotation = 0;
|
||||
bool kicked = false;
|
||||
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
Debug.Log("Kicking State");
|
||||
|
||||
oSM.leg.SetActive(true);
|
||||
kicked = false;
|
||||
|
||||
oSM.StartCoroutine(kicking(1f));
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
legRotation = 0;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
oSM.leg.SetActive(false);
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
|
||||
if(kicked){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
if(legRotation > -90){
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
legRotation -= 20;
|
||||
}
|
||||
else{
|
||||
legRotation = -90;
|
||||
}
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0447909f4233a324db4c49496dcc6bb8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffensePunchState : OffenseBaseState
|
||||
{
|
||||
|
||||
float legRotation = 0;
|
||||
bool kicked = false;
|
||||
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
oSM.leg.SetActive(true);
|
||||
kicked = false;
|
||||
|
||||
oSM.StartCoroutine(kicking(1f));
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
legRotation = 0;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
oSM.leg.SetActive(false);
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
|
||||
if(kicked){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
if(legRotation > -90){
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
legRotation -= 20;
|
||||
}
|
||||
else{
|
||||
legRotation = -90;
|
||||
}
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 994ebfe06000a58488b76579ebf2c4dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 703ef5745e09b544da4dace0f35c1ce5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseCooldownState : OffenseBaseState
|
||||
{
|
||||
bool cooldown = false;
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
cooldown = false;
|
||||
|
||||
oSM.StartCoroutine(kickCooldown());
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.IncapacitatedState);
|
||||
}
|
||||
else if(cooldown){
|
||||
oSM.SwitchState(oSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
}
|
||||
|
||||
private IEnumerator kickCooldown(){
|
||||
yield return new WaitForSeconds(.5f);
|
||||
cooldown = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68d73793d961c640a7028eeeddded66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OffenseIncapacitatedState : OffenseBaseState
|
||||
{
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(OffenseStateManager oSM, OffenseBaseState nextState){
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState && oSM.aSM.currentState != oSM.aSM.GrappleGroundedState)){
|
||||
oSM.SwitchState(oSM.NoneState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a55bc30803d5e034ca1a922fc86eff22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user