adjusted anything that refered to playerMovement

This commit is contained in:
Melbyj1125
2022-02-16 16:44:30 -06:00
parent f0936f4cee
commit e74a1c61c0
112 changed files with 60 additions and 67 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b2292a829a1cb2c43b4e3889d4cfe7a6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e963653fb34d3184fba3fb7e4417ed75
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f00bc672381c3a44b010d905fabe9a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
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){
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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0447909f4233a324db4c49496dcc6bb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 994ebfe06000a58488b76579ebf2c4dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 703ef5745e09b544da4dace0f35c1ce5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d68d73793d961c640a7028eeeddded66
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a55bc30803d5e034ca1a922fc86eff22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OffenseNoneState : 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.IncapacitatedState);
}
else if(oSM.aSM.currentState == oSM.aSM.GroundedState && (Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
if(oSM.pStats.KickPow > 300){
oSM.SwitchState(oSM.PunchState);
}
else{
oSM.SwitchState(oSM.KickState);
}
}
else if((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
if(oSM.pStats.KickPow > 300){
oSM.SwitchState(oSM.AirPunchState);
}
else{
oSM.SwitchState(oSM.AirKickState);
}
}
}
public override void FixedUpdateState(OffenseStateManager oSM){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49f93bffb8401e14dbd4b9ebf76442aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class OffenseBaseState
{
public abstract void EnterState(OffenseStateManager oSM, OffenseBaseState previousState);
public abstract void ExitState(OffenseStateManager oSM, OffenseBaseState nextState);
public abstract void UpdateState(OffenseStateManager oSM);
public abstract void FixedUpdateState(OffenseStateManager oSM);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 865c3dd440a18de45b59955da056df65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,118 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class OffenseStateManager : NetworkBehaviour
{
////Player States
public OffenseBaseState currentState;
public OffenseBaseState previousState;
//Offense States
public OffenseNoneState NoneState = new OffenseNoneState();
public OffenseIncapacitatedState IncapacitatedState = new OffenseIncapacitatedState();
public OffenseCooldownState CooldownState = new OffenseCooldownState();
//Kick&Punch States
public OffenseKickState KickState = new OffenseKickState();
public OffenseAirKickState AirKickState = new OffenseAirKickState();
public OffensePunchState PunchState = new OffensePunchState();
public OffenseAirPunchState AirPunchState = new OffenseAirPunchState();
////
////Objects Sections
GameObject parentObj; // Parent object
public GameObject leg; // leg object
public GameObject legHitbox; // leg hitbox
////
////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 AerialStateManager aSM;
////
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;
animator = GetComponent<Animator>(); // set animator
////
////Initialize Player Objects
leg = transform.Find("Leg").gameObject; // Set Leg Object
legHitbox = leg.transform.Find("LegHitbox").gameObject; // Set Leg Hitbox
leg.SetActive(false);
parentObj = transform.parent.gameObject; // set parent object
////
////Initialize Scripts
pStats = GetComponent<PlayerStats>(); // set PlayerStats
mSM = GetComponent<MoveStateManager>(); // set move state manager
aSM = GetComponent<AerialStateManager>();
////
}
void Start(){
//players starting state
currentState = NoneState;
previousState = NoneState;
currentState.EnterState(this, previousState);
}
void Update(){
if (!IsLocalPlayer) { return; }
//calls any logic in the update state from current state
currentState.UpdateState(this);
}
void FixedUpdate(){
if (!IsLocalPlayer) { return; }
//calls any logic in the fixed update state from current state
currentState.FixedUpdateState(this);
}
public void SwitchState(OffenseBaseState 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);
}
private void OnCollisionEnter(Collision collision)
{
//if (!IsLocalPlayer) { return; }
Collider myCollider = collision.contacts[0].thisCollider;
if (collision.transform.CompareTag("kickable") && myCollider == legHitbox.GetComponent<Collider>()){
if(collision.gameObject.GetComponent<Rigidbody>().isKinematic == true){
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
}
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
}
if (collision.transform.CompareTag("destroyable") && myCollider == legHitbox.GetComponent<Collider>()){
collision.transform.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dc5a1a9c85c29a744aa6ca7f1a8dbc60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: