mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 09:54:28 -05:00
Did some bugfixing and commented on everything
This commit is contained in:
@@ -5,38 +5,46 @@ using UnityEngine;
|
||||
public class OffenseAirKickState : OffenseBaseState
|
||||
{
|
||||
|
||||
private float legRotation = 0;
|
||||
bool kicked = false;
|
||||
private float legRotation = 0; // angle for leg rotation
|
||||
bool kicked = false; // whether they have kicked or not
|
||||
|
||||
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.leg.SetActive(true); // activate leg
|
||||
legRotation = -90;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
kicked = false; // haven't kicked
|
||||
|
||||
//start kicking routine
|
||||
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);
|
||||
legRotation = 0; // reset leg angle
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
oSM.leg.SetActive(false); // reset leg angle
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if incapacitated then cooldown
|
||||
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 or grounded then cooldown
|
||||
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
//jitter player upwards because of a weird issue with collider
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
//kicking timer
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
|
||||
@@ -5,38 +5,46 @@ using UnityEngine;
|
||||
public class OffenseAirPunchState : OffenseBaseState
|
||||
{
|
||||
|
||||
private float legRotation = 0;
|
||||
bool kicked = false;
|
||||
private float legRotation = 0; // angle for leg rotation
|
||||
bool kicked = false; // whether they have kicked or not
|
||||
|
||||
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.leg.SetActive(true); // activate leg
|
||||
legRotation = -90;
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
kicked = false; // haven't kicked
|
||||
|
||||
//start kicking routine
|
||||
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);
|
||||
legRotation = 0; // reset leg angle
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
oSM.leg.SetActive(false); // reset leg angle
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if incapacitated then cooldown
|
||||
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 or grounded then cooldown
|
||||
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
//jitter player upwards because of a weird issue with collider
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
//kicking timer
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
|
||||
@@ -5,35 +5,41 @@ using UnityEngine;
|
||||
public class OffenseKickState : OffenseBaseState
|
||||
{
|
||||
|
||||
float legRotation = 0;
|
||||
bool kicked = false;
|
||||
float legRotation = 0; // angle for leg rotation
|
||||
bool kicked = false; // whether they have kicked or not
|
||||
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
|
||||
oSM.leg.SetActive(true);
|
||||
kicked = false;
|
||||
oSM.leg.SetActive(true); // activate leg
|
||||
kicked = false; // haven't kicked
|
||||
|
||||
//start kicking routine
|
||||
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);
|
||||
legRotation = 0; // reset leg angle
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
oSM.leg.SetActive(false); // reset leg angle
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if incapacitated then cooldown
|
||||
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 then cooldown
|
||||
if(kicked){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if leg isn't fully extended rotate it
|
||||
if(legRotation > -90){
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
legRotation -= 20;
|
||||
@@ -41,9 +47,12 @@ public class OffenseKickState : OffenseBaseState
|
||||
else{
|
||||
legRotation = -90;
|
||||
}
|
||||
|
||||
//jitter player upwards because of a weird issue with collider
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
//kicking timer
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
|
||||
@@ -5,35 +5,41 @@ using UnityEngine;
|
||||
public class OffensePunchState : OffenseBaseState
|
||||
{
|
||||
|
||||
float legRotation = 0;
|
||||
bool kicked = false;
|
||||
float legRotation = 0; // angle for leg rotation
|
||||
bool kicked = false; // whether they have kicked or not
|
||||
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
|
||||
oSM.leg.SetActive(true);
|
||||
kicked = false;
|
||||
oSM.leg.SetActive(true); // activate leg
|
||||
kicked = false; // haven't kicked
|
||||
|
||||
//start kicking routine
|
||||
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);
|
||||
legRotation = 0; // reset leg angle
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
|
||||
oSM.leg.SetActive(false); // deactivate leg
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if incapacitated then cooldown
|
||||
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 then cooldown
|
||||
if(kicked){
|
||||
oSM.SwitchState(oSM.CooldownState);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FixedUpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if leg isn't fully extended rotate it
|
||||
if(legRotation > -90){
|
||||
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
|
||||
legRotation -= 20;
|
||||
@@ -41,9 +47,12 @@ public class OffensePunchState : OffenseBaseState
|
||||
else{
|
||||
legRotation = -90;
|
||||
}
|
||||
|
||||
//jitter player upwards because of a weird issue with collider
|
||||
oSM.moveController.Move(new Vector3(0,.002f,0));
|
||||
}
|
||||
|
||||
//kicking timer
|
||||
private IEnumerator kicking(float waitTime){
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
kicked = true;
|
||||
|
||||
@@ -4,11 +4,12 @@ using UnityEngine;
|
||||
|
||||
public class OffenseCooldownState : OffenseBaseState
|
||||
{
|
||||
bool cooldown = false;
|
||||
bool cooldown = false; // whether or not cooldown is over
|
||||
|
||||
public override void EnterState(OffenseStateManager oSM, OffenseBaseState previousState){
|
||||
cooldown = false;
|
||||
cooldown = false; // cooldown isn't over
|
||||
|
||||
//start cooldown
|
||||
oSM.StartCoroutine(kickCooldown());
|
||||
}
|
||||
|
||||
@@ -17,9 +18,13 @@ public class OffenseCooldownState : OffenseBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if cooldown over and incapacitated then incapacitated
|
||||
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);
|
||||
}
|
||||
|
||||
//if cooldown over then None
|
||||
else if(cooldown){
|
||||
oSM.SwitchState(oSM.NoneState);
|
||||
}
|
||||
@@ -29,6 +34,7 @@ public class OffenseCooldownState : OffenseBaseState
|
||||
|
||||
}
|
||||
|
||||
//kick cooldown
|
||||
private IEnumerator kickCooldown(){
|
||||
yield return new WaitForSeconds(.5f);
|
||||
cooldown = true;
|
||||
|
||||
@@ -13,6 +13,8 @@ public class OffenseIncapacitatedState : OffenseBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
//if no longer incapacitated then None
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -13,22 +13,36 @@ public class OffenseNoneState : OffenseBaseState
|
||||
}
|
||||
|
||||
public override void UpdateState(OffenseStateManager oSM){
|
||||
|
||||
|
||||
//if incapacitated then incapacitated
|
||||
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);
|
||||
}
|
||||
|
||||
//if grounded then grounded kick states
|
||||
else if(oSM.aSM.currentState == oSM.aSM.GroundedState && (Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
|
||||
|
||||
//if power is above 300 then punch
|
||||
if(oSM.pStats.KickPow > 300){
|
||||
oSM.SwitchState(oSM.PunchState);
|
||||
}
|
||||
|
||||
//otherwise kick
|
||||
else{
|
||||
oSM.SwitchState(oSM.KickState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if in the air
|
||||
else if((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
|
||||
|
||||
//if power is above 300 air punch
|
||||
if(oSM.pStats.KickPow > 300){
|
||||
oSM.SwitchState(oSM.AirPunchState);
|
||||
}
|
||||
|
||||
//otherwise air kick
|
||||
else{
|
||||
oSM.SwitchState(oSM.AirKickState);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
|
||||
////Scripts Section
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM;
|
||||
public AerialStateManager aSM;
|
||||
public MoveStateManager mSM; // move state manager
|
||||
public AerialStateManager aSM; // aerial state manager
|
||||
////
|
||||
|
||||
void Awake(){
|
||||
@@ -60,7 +60,7 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
////Initialize Scripts
|
||||
pStats = GetComponent<PlayerStats>(); // set PlayerStats
|
||||
mSM = GetComponent<MoveStateManager>(); // set move state manager
|
||||
aSM = GetComponent<AerialStateManager>();
|
||||
aSM = GetComponent<AerialStateManager>(); // set aerial state manager
|
||||
////
|
||||
}
|
||||
|
||||
@@ -99,9 +99,10 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
currentState.EnterState(this, previousState);
|
||||
}
|
||||
|
||||
//Collision checker for the leg
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
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){
|
||||
|
||||
Reference in New Issue
Block a user