mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-22 18:34:32 -05:00
Fixed a lot of the issues we addressed on Monday
This commit is contained in:
@@ -10,7 +10,7 @@ public class dAerialFallingState : dAerialBaseState
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateState(dAerialStateManager aSM){
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@ public class dAerialGlidingState : dAerialBaseState
|
||||
|
||||
//Modify base traction
|
||||
aSM.pStats.CurTraction = 1.0f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
|
||||
//return traction to normal
|
||||
aSM.pStats.CurTraction = aSM.pStats.Traction;
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateState(dAerialStateManager aSM){
|
||||
|
||||
@@ -8,6 +8,8 @@ public class dAerialGroundedState : dAerialBaseState
|
||||
|
||||
//release is false if grounded
|
||||
aSM.release = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
|
||||
@@ -22,6 +22,10 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
float oldSwingMom; // old swing Momentum amplifier
|
||||
Vector3 momDirection; // momentum direction
|
||||
Vector3 tensionMomDirection; // tension momentum direction
|
||||
|
||||
float defaultGraceTimer = 1.0f; // default timer
|
||||
float graceTimer; // grace period at the end of the swing so the player has time to let go
|
||||
bool swingGrace = true; // is the grace timer over
|
||||
|
||||
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
||||
|
||||
@@ -47,6 +51,7 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
aSM.release = false; // player hasn't released
|
||||
aSM.lerpRelease = Vector3.zero; // reset lerp release
|
||||
spaceHeld = true;
|
||||
graceTimer = defaultGraceTimer; //sets grace timer
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
@@ -116,6 +121,7 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
//if Swing Momentum isn't zero then move player
|
||||
if(swingMom != 0){
|
||||
aSM.moveController.Move(CalculateMomentumDirection(aSM.pStats.GravVel, aSM.hookPoint.transform.position, aSM));
|
||||
|
||||
swingMom -= .5f;
|
||||
}
|
||||
if(swingMom<0) swingMom = 0;
|
||||
@@ -156,8 +162,17 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
|
||||
//if player is on the other side of hookpoint and swingMom is lower then update oldXZDir
|
||||
if(oldXZDir != curXZDir && swingMom <= (oldSwingMom*(.75f))){
|
||||
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;
|
||||
if(graceTimer >= 0){
|
||||
swingGrace = false;
|
||||
graceTimer -= .1f;
|
||||
}
|
||||
else{
|
||||
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;
|
||||
swingGrace = true;
|
||||
graceTimer = defaultGraceTimer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//current line between hookpoint and player
|
||||
@@ -179,7 +194,7 @@ public class dAerialGrappleAirState : dAerialBaseState
|
||||
}
|
||||
|
||||
//calculates swing momentum based on height ands speed
|
||||
float sMom = playerSpeed + (swingHeight * 2.5f);
|
||||
float sMom = playerSpeed + (swingHeight * 3f);
|
||||
if(sMom > aSM.maxSwingMom){
|
||||
sMom = aSM.maxSwingMom;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class dAerialStateManager : NetworkBehaviour
|
||||
void Jump(){
|
||||
if(!pStats.IsPaused){
|
||||
//If space/south gamepad button is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState))
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState && currentState != GlidingState))
|
||||
{
|
||||
if(currentState == WallRunState){
|
||||
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);
|
||||
|
||||
@@ -12,18 +12,20 @@ public class dMoveRagdollState : dMoveBaseState
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
ragTime = mSM.pStats.RecovTime; // how long to be ragdolled
|
||||
mSM.prevRot = mSM.transform.localEulerAngles; // save previous rotation
|
||||
prevRot = mSM.transform.localEulerAngles; // save previous rotation
|
||||
mSM.capCol.enabled = true; // enable capsule collider
|
||||
mSM.moveController.enabled = false; // disable move controller
|
||||
mSM.rB.isKinematic = false; // disable kinematic
|
||||
mSM.rB.detectCollisions = true; // detect collisions
|
||||
mSM.rB.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||
|
||||
//apply force
|
||||
mSM.rB.AddForce(mSM.dirHit, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
|
||||
mSM.transform.localEulerAngles = prevRot; // reset player rotation
|
||||
mSM.rB.collisionDetectionMode = CollisionDetectionMode.Discrete;
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -12,7 +12,6 @@ public class dMoveRecoveringState : dMoveBaseState
|
||||
mSM.moveController.enabled = true; // enable move controller
|
||||
mSM.rB.isKinematic = true; // enable kinematic
|
||||
mSM.rB.detectCollisions = false; // detect collisions false
|
||||
mSM.transform.localEulerAngles = mSM.prevRot; // reset player rotation
|
||||
mSM.CancelMomentum(); // reset player variables
|
||||
mSM.moveController.Move(new Vector3(0,2,0));
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ public class dMoveIdleState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
mSM.GetComponent<Animator>().SetBool("isIdle", true);
|
||||
Debug.Log("Entered Idle");
|
||||
//Debug.Log("Entered Idle");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
mSM.GetComponent<Animator>().SetBool("isIdle", false);
|
||||
Debug.Log("Exited Idle");
|
||||
//Debug.Log("Exited Idle");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -6,12 +6,12 @@ public class dMoveJogState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
mSM.GetComponent<Animator>().SetBool("isJogging", true);
|
||||
Debug.Log("Entered Jog");
|
||||
//Debug.Log("Entered Jog");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
mSM.GetComponent<Animator>().SetBool("isJogging", false);
|
||||
Debug.Log("Exited Jog");
|
||||
//Debug.Log("Exited Jog");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -6,12 +6,12 @@ public class dMoveRunState : dMoveBaseState
|
||||
{
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
mSM.GetComponent<Animator>().SetBool("isRunning", true);
|
||||
Debug.Log("Entered Run");
|
||||
//Debug.Log("Entered Run");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
mSM.GetComponent<Animator>().SetBool("isRunning", false);
|
||||
Debug.Log("Exit Run");
|
||||
//Debug.Log("Exit Run");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -9,12 +9,12 @@ public class dMoveWalkState : dMoveBaseState
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
//get component is semi expensive--may want to ahve all statemanagers have a reference to animator
|
||||
mSM.GetComponent<Animator>().SetBool("isWalking", true);
|
||||
Debug.Log("Entered Walk");
|
||||
//Debug.Log("Entered Walk");
|
||||
}
|
||||
|
||||
public override void ExitState(dMoveStateManager mSM, dMoveBaseState nextState){
|
||||
mSM.GetComponent<Animator>().SetBool("isWalking", false);
|
||||
Debug.Log("Exited Walk");
|
||||
//Debug.Log("Exited Walk");
|
||||
}
|
||||
|
||||
public override void UpdateState(dMoveStateManager mSM){
|
||||
|
||||
@@ -78,7 +78,6 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
//Ragdoll Variables
|
||||
public Vector3 dirHit; // Direction hit
|
||||
public float distToGround; // distance to ground
|
||||
public Vector3 prevRot; // previous rotation before ragdolled
|
||||
////
|
||||
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ public class AerialStateManager : NetworkBehaviour
|
||||
void Jump(){
|
||||
if(!pStats.IsPaused){
|
||||
//If space/south gamepad button is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState))
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpHeld && curJumpNum < pStats.JumpNum && (mSM.currentState != mSM.SlideState && mSM.currentState != mSM.CrouchState && mSM.currentState != mSM.RagdollState && mSM.currentState != mSM.RecoveringState && currentState != GlidingState))
|
||||
{
|
||||
if(currentState == WallRunState){
|
||||
AddImpact((GetWallJumpDirection()), pStats.JumpPow * 8.5f);
|
||||
|
||||
@@ -23,6 +23,10 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
Vector3 momDirection; // momentum direction
|
||||
Vector3 tensionMomDirection; // tension momentum direction
|
||||
|
||||
float defaultGraceTimer = 1.0f; // default timer
|
||||
float graceTimer; // grace period at the end of the swing so the player has time to let go
|
||||
bool swingGrace = true; // is the grace timer over
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
//refresh jump number
|
||||
@@ -47,6 +51,7 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
aSM.release = false; // player hasn't released
|
||||
aSM.lerpRelease = Vector3.zero; // reset lerp release
|
||||
spaceHeld = true;
|
||||
graceTimer = defaultGraceTimer; //sets grace timer
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
@@ -156,8 +161,17 @@ public class AerialGrappleAirState : AerialBaseState
|
||||
|
||||
//if player is on the other side of hookpoint and swingMom is lower then update oldXZDir
|
||||
if(oldXZDir != curXZDir && swingMom <= (oldSwingMom*(.75f))){
|
||||
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;
|
||||
if(graceTimer >= 0){
|
||||
swingGrace = false;
|
||||
graceTimer -= .1f;
|
||||
}
|
||||
else{
|
||||
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;
|
||||
swingGrace = true;
|
||||
graceTimer = defaultGraceTimer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//current line between hookpoint and player
|
||||
|
||||
@@ -7,11 +7,12 @@ public class MoveRagdollState : MoveBaseState
|
||||
|
||||
float ragTime; // ragdoll timer
|
||||
bool beginRagTimer = false; // whether ragtimer has started
|
||||
Vector3 prevRot;
|
||||
|
||||
public override void EnterState(MoveStateManager mSM, MoveBaseState previousState){
|
||||
|
||||
ragTime = mSM.pStats.RecovTime; // how long to be ragdolled
|
||||
mSM.prevRot = mSM.transform.localEulerAngles; // save previous rotation
|
||||
prevRot = mSM.transform.localEulerAngles; // save previous rotation
|
||||
mSM.capCol.enabled = true; // enable capsule collider
|
||||
mSM.moveController.enabled = false; // disable move controller
|
||||
mSM.rB.isKinematic = false; // disable kinematic
|
||||
@@ -22,6 +23,7 @@ public class MoveRagdollState : MoveBaseState
|
||||
}
|
||||
|
||||
public override void ExitState(MoveStateManager mSM, MoveBaseState nextState){
|
||||
mSM.transform.localEulerAngles = prevRot; // reset player rotation
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ public class MoveRecoveringState : MoveBaseState
|
||||
mSM.moveController.enabled = true; // enable move controller
|
||||
mSM.rB.isKinematic = true; // enable kinematic
|
||||
mSM.rB.detectCollisions = false; // detect collisions false
|
||||
mSM.transform.localEulerAngles = mSM.prevRot; // reset player rotation
|
||||
mSM.CancelMomentum(); // reset player variables
|
||||
mSM.moveController.Move(new Vector3(0,2,0));
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ public class MoveStateManager : NetworkBehaviour
|
||||
//Ragdoll Variables
|
||||
public Vector3 dirHit; // Direction hit
|
||||
public float distToGround; // distance to ground
|
||||
public Vector3 prevRot; // previous rotation before ragdolled
|
||||
////
|
||||
|
||||
|
||||
@@ -313,7 +312,7 @@ public class MoveStateManager : NetworkBehaviour
|
||||
//Apply Wind movement to the player
|
||||
public void ApplyWind(bool wind){
|
||||
if(wind){
|
||||
moveController.Move(pStats.WindDirection.normalized * 2);
|
||||
moveController.Move(pStats.WindDirection.normalized * .2f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,15 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
public PlayerStats pStats; // Player Stats
|
||||
public MoveStateManager mSM; // move state manager
|
||||
public AerialStateManager aSM; // aerial state manager
|
||||
////
|
||||
|
||||
//// AnimatorManagerScript
|
||||
private AnimationManager animationManager;
|
||||
////
|
||||
|
||||
//// Variables Section
|
||||
private GameObject[] players;
|
||||
|
||||
void Awake(){
|
||||
|
||||
////Initialize Player Components
|
||||
@@ -58,7 +63,6 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
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
|
||||
@@ -73,6 +77,7 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
currentState = NoneState;
|
||||
previousState = NoneState;
|
||||
currentState.EnterState(this, previousState);
|
||||
|
||||
}
|
||||
|
||||
void Update(){
|
||||
@@ -121,10 +126,12 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
if(collision.transform.CompareTag("ArcherTarget") && myCollider == legHitbox.GetComponent<Collider>()){
|
||||
Vector3 direction = this.transform.forward;
|
||||
|
||||
Debug.Log("---Player Being Kicked: " + collision.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
|
||||
Debug.Log("---Player Kicking: " + this.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
|
||||
ulong netObjID = collision.gameObject.transform.root.GetComponent<NetworkObject>().NetworkObjectId;
|
||||
ApplyKickServerRPC(direction, netObjID);
|
||||
if(netObjID != this.transform.root.GetComponent<NetworkObject>().NetworkObjectId){
|
||||
Debug.Log("NetObjID of Kicked Player: " + netObjID);
|
||||
ApplyKickServerRPC(direction, netObjID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (collision.transform.CompareTag("destroyable") && myCollider == legHitbox.GetComponent<Collider>()){
|
||||
@@ -155,9 +162,27 @@ public class OffenseStateManager : NetworkBehaviour
|
||||
|
||||
foreach(GameObject kickedPlayer in players){
|
||||
//First check if the player is kicked
|
||||
if(kickedPlayer.transform.root.GetComponent<NetworkObject>() != null && kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId == netObjId && kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId != this.transform.root.GetComponent<NetworkObject>().NetworkObjectId){
|
||||
|
||||
Debug.Log(kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
|
||||
|
||||
if(kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId == netObjId){
|
||||
Debug.Log("Kicked Players NetObjId is equal to the NetObjId");
|
||||
}
|
||||
else{
|
||||
Debug.Log("Kicked Player NetObjId not equal to the NetObjId");
|
||||
}
|
||||
|
||||
if(kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId != this.transform.root.GetComponent<NetworkObject>().NetworkObjectId){
|
||||
Debug.Log("Kicked Player Not The Same as Me");
|
||||
}
|
||||
else{
|
||||
Debug.Log("My RPC ID: " + this.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
|
||||
Debug.Log("Their RPC ID: " + kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId);
|
||||
}
|
||||
|
||||
if(kickedPlayer.transform.root.GetComponent<NetworkObject>() != null && kickedPlayer.transform.root.GetComponent<NetworkObject>().NetworkObjectId == netObjId){
|
||||
Debug.Log("Kicking other user");
|
||||
kickedPlayer.GetComponent<MoveStateManager>().GetHit(direction, 10);
|
||||
kickedPlayer.GetComponent<MoveStateManager>().GetHit(direction, 20);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -77,4 +77,10 @@ public class PlayerInventory : NetworkBehaviour
|
||||
AddItem(allItems[itemName]);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearInventory(){
|
||||
foreach(KeyValuePair<string, Item> item in PlayerItemDict){
|
||||
RemoveItem(item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user