mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-22 10:24:42 -05:00
weather wheel and weather adjustments
This commit is contained in:
@@ -4,19 +4,17 @@ using UnityEngine;
|
||||
|
||||
public class dAerialGlidingState : dAerialBaseState
|
||||
{
|
||||
float tempTraction; // temp traction to store the actual player traction
|
||||
|
||||
public override void EnterState(dAerialStateManager aSM, dAerialBaseState previousState){
|
||||
|
||||
//Modify base traction
|
||||
tempTraction = aSM.pStats.Traction;
|
||||
aSM.pStats.Traction = 1.0f;
|
||||
aSM.pStats.CurTraction = 1.0f;
|
||||
}
|
||||
|
||||
public override void ExitState(dAerialStateManager aSM, dAerialBaseState nextState){
|
||||
|
||||
//return traction to normal
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
aSM.pStats.CurTraction = aSM.pStats.Traction;
|
||||
}
|
||||
|
||||
public override void UpdateState(dAerialStateManager aSM){
|
||||
|
||||
@@ -5,16 +5,14 @@ using UnityEngine;
|
||||
public class dMoveSlideState : dMoveBaseState
|
||||
{
|
||||
//Slide Variables
|
||||
float originalTraction; // Traction before slide started
|
||||
RaycastHit slideRay; // slide raycast
|
||||
|
||||
public override void EnterState(dMoveStateManager mSM, dMoveBaseState previousState){
|
||||
|
||||
//Rotate player and adjust height and adjust traction
|
||||
mSM.pStats.CurVel = 0;
|
||||
originalTraction = mSM.pStats.Traction;
|
||||
mSM.moveController.height *= .5f;
|
||||
mSM.pStats.Traction = 0.01f;
|
||||
mSM.pStats.CurTraction = 0.01f;
|
||||
mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0);
|
||||
//mSM.moveController.Move(new Vector3(0,-0.1f,0));
|
||||
}
|
||||
@@ -25,7 +23,7 @@ public class dMoveSlideState : dMoveBaseState
|
||||
if(nextState != mSM.CrouchState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.pStats.CurTraction = mSM.pStats.Traction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0);
|
||||
}
|
||||
|
||||
@@ -116,6 +116,8 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
Cursor.lockState = CursorLockMode.Locked; // Lock cursor on start if you are the local player
|
||||
pStats.Traction = pStats.CurTraction;
|
||||
pStats.CurAcc = pStats.Acc;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -180,7 +182,7 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
// while the speed is below max speed slowly increase it
|
||||
else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel))
|
||||
{
|
||||
pStats.CurVel += pStats.Acc;
|
||||
pStats.CurVel += pStats.CurAcc;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
//If the players speed is above or equal to max speed set speed to max
|
||||
@@ -222,7 +224,7 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
Debug.DrawRay(gameObject.transform.position + new Vector3(0,.4f,0) + (rayOffset/2), moveXZ.normalized * 1f, Color.red);
|
||||
Debug.DrawRay(gameObject.transform.position + new Vector3(0,2.2f,0) + rayOffset, moveXZ.normalized * .2f, Color.red);
|
||||
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
|
||||
if(currentState == GrappleAirState){
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
@@ -241,7 +243,7 @@ public class dMoveStateManager : NetworkBehaviour
|
||||
//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);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
|
||||
|
||||
//need to have move controller involved for correct movement
|
||||
if(currentState == CrouchState){
|
||||
|
||||
@@ -7,19 +7,17 @@ public class dNitroNitroingState : dNitroBaseState
|
||||
|
||||
private float tempTimer; // temporary timer
|
||||
private float actualMaxVel; // actual max velocity
|
||||
private float actualAcc; // actual acceleration
|
||||
|
||||
public override void EnterState(dNitroStateManager nSM, dNitroBaseState previousState){
|
||||
actualMaxVel = nSM.pStats.MaxVel; // saves previous max velocity
|
||||
actualAcc = nSM.pStats.Acc; // saves previous max acc
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost; // increases acceleration
|
||||
nSM.pStats.CurAcc += nSM.nitroAccBoost; // increases acceleration
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost; // increases max velocity
|
||||
|
||||
tempTimer = 5; // how long we will be sped up
|
||||
}
|
||||
|
||||
public override void ExitState(dNitroStateManager nSM, dNitroBaseState nextState){
|
||||
nSM.pStats.Acc = actualAcc; // reset acceleration
|
||||
nSM.pStats.CurAcc = nSM.pStats.Acc; // reset acceleration
|
||||
nSM.pStats.MaxVel = actualMaxVel; // reset maximum velocity
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,17 @@ using UnityEngine;
|
||||
|
||||
public class AerialGlidingState : AerialBaseState
|
||||
{
|
||||
float tempTraction; // temp traction to store the actual player traction
|
||||
|
||||
public override void EnterState(AerialStateManager aSM, AerialBaseState previousState){
|
||||
|
||||
//Modify base traction
|
||||
tempTraction = aSM.pStats.Traction;
|
||||
aSM.pStats.Traction = 1.0f;
|
||||
aSM.pStats.CurTraction = 1.0f;
|
||||
}
|
||||
|
||||
public override void ExitState(AerialStateManager aSM, AerialBaseState nextState){
|
||||
|
||||
//return traction to normal
|
||||
aSM.pStats.Traction = tempTraction;
|
||||
aSM.pStats.CurTraction = aSM.pStats.Traction;
|
||||
}
|
||||
|
||||
public override void UpdateState(AerialStateManager aSM){
|
||||
|
||||
@@ -114,6 +114,8 @@ public class MoveStateManager : NetworkBehaviour
|
||||
|
||||
if (!IsLocalPlayer) { return; }
|
||||
Cursor.lockState = CursorLockMode.Locked; // Lock cursor on start if you are the local player
|
||||
pStats.CurTraction = pStats.Traction;
|
||||
pStats.CurAcc = pStats.Acc;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -178,7 +180,7 @@ public class MoveStateManager : NetworkBehaviour
|
||||
// while the speed is below max speed slowly increase it
|
||||
else if ((pStats.CurVel >= pStats.MinVel) && (pStats.CurVel < pStats.MaxVel))
|
||||
{
|
||||
pStats.CurVel += pStats.Acc;
|
||||
pStats.CurVel += pStats.CurAcc;
|
||||
return pStats.CurVel;
|
||||
}
|
||||
//If the players speed is above or equal to max speed set speed to max
|
||||
@@ -219,7 +221,7 @@ public class MoveStateManager : NetworkBehaviour
|
||||
Debug.DrawRay(gameObject.transform.position + new Vector3(0,.4f,0) + rayOffset, moveXZ.normalized * 1f, Color.red);
|
||||
Debug.DrawRay(gameObject.transform.position + new Vector3(0,2.2f,0) + rayOffset, moveXZ.normalized * 1f, Color.red);
|
||||
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.Traction * Time.deltaTime);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
|
||||
if(currentState == GrappleAirState){
|
||||
driftVel = Vector3.zero;
|
||||
}
|
||||
@@ -238,7 +240,7 @@ public class MoveStateManager : NetworkBehaviour
|
||||
//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);
|
||||
driftVel = Vector3.Lerp(driftVel, moveXZ, pStats.CurTraction * Time.deltaTime);
|
||||
|
||||
//Need to have movecontroller involved for correct movement
|
||||
if(currentState == CrouchState){
|
||||
|
||||
@@ -5,16 +5,14 @@ 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){
|
||||
|
||||
//Rotate player and adjust height and adjust traction
|
||||
mSM.pStats.CurVel = 0;
|
||||
originalTraction = mSM.pStats.Traction;
|
||||
mSM.moveController.height *= .5f;
|
||||
mSM.pStats.Traction = 0.01f;
|
||||
mSM.pStats.CurTraction = 0.01f;
|
||||
mSM.moveController.center = new Vector3(0,mSM.moveController.center.y - mSM.moveController.height * .5f,0);
|
||||
//mSM.moveController.Move(new Vector3(0,-0.1f,0));
|
||||
}
|
||||
@@ -25,14 +23,14 @@ public class MoveSlideState : MoveBaseState
|
||||
if(nextState != mSM.CrouchState){
|
||||
mSM.gameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||
mSM.pStats.CurVel = mSM.calculatedCurVel;
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.pStats.CurTraction = mSM.pStats.Traction;
|
||||
mSM.moveController.height *= 2.0f;
|
||||
mSM.moveController.center = new Vector3(0,mSM.moveController.center.y + mSM.moveController.height * .25f,0);
|
||||
}
|
||||
|
||||
//if state is crouch revert traction
|
||||
else{
|
||||
mSM.pStats.Traction = originalTraction;
|
||||
mSM.pStats.CurTraction = mSM.pStats.Traction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,19 +7,18 @@ public class NitroNitroingState : NitroBaseState
|
||||
|
||||
private float tempTimer; // temporary timer
|
||||
private float actualMaxVel; // actual max velocity
|
||||
private float actualAcc; // actual acceleration
|
||||
|
||||
public override void EnterState(NitroStateManager nSM, NitroBaseState previousState){
|
||||
actualMaxVel = nSM.pStats.MaxVel; // saves previous max velocity
|
||||
actualAcc = nSM.pStats.Acc; // saves previous max acc
|
||||
nSM.pStats.Acc += nSM.nitroAccBoost; // increases acceleration
|
||||
|
||||
nSM.pStats.CurAcc += nSM.nitroAccBoost; // increases acceleration
|
||||
nSM.pStats.MaxVel += nSM.nitroVelBoost; // increases max velocity
|
||||
|
||||
tempTimer = 5; // how long we will be sped up
|
||||
}
|
||||
|
||||
public override void ExitState(NitroStateManager nSM, NitroBaseState nextState){
|
||||
nSM.pStats.Acc = actualAcc; // reset acceleration
|
||||
nSM.pStats.CurAcc = nSM.pStats.Acc; // reset acceleration
|
||||
nSM.pStats.MaxVel = actualMaxVel; // reset maximum velocity
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ using UnityEngine.Assertions;
|
||||
|
||||
public class PlayerStats : MonoBehaviour
|
||||
{
|
||||
|
||||
public enum Weather {Rain, Snow, Wind, Fog};
|
||||
|
||||
//Soft cap max speed a player can achieve they can achieve this speed by running
|
||||
[SerializeField] private float maxVel = 40.0f;
|
||||
public float MaxVel{
|
||||
@@ -40,6 +43,12 @@ public class PlayerStats : MonoBehaviour
|
||||
set{ acc = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private float curAcc;
|
||||
public float CurAcc{
|
||||
get{ return curAcc; }
|
||||
set{ curAcc = value;}
|
||||
}
|
||||
|
||||
//Player Jump power
|
||||
[SerializeField] private float jumpPow = 60.0f;
|
||||
public float JumpPow{
|
||||
@@ -61,6 +70,12 @@ public class PlayerStats : MonoBehaviour
|
||||
set{ traction = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private float curTraction;
|
||||
public float CurTraction{
|
||||
get{ return curTraction; }
|
||||
set{ curTraction = value; }
|
||||
}
|
||||
|
||||
//Player Kick Power
|
||||
[SerializeField] private float kickPow = 500.0f;
|
||||
public float KickPow{
|
||||
@@ -131,6 +146,87 @@ public class PlayerStats : MonoBehaviour
|
||||
set{ playerPoints = value; }
|
||||
}
|
||||
|
||||
[SerializeField] private bool windOn = false;
|
||||
public bool WindOn{
|
||||
get{ return windOn; }
|
||||
}
|
||||
|
||||
private float tempTraction;
|
||||
private float tempAcc;
|
||||
private float accModification;
|
||||
|
||||
public void SetWeather(Weather weather){
|
||||
switch(weather){
|
||||
case Weather.Rain:{
|
||||
Debug.Log("Rain");
|
||||
|
||||
tempTraction = traction;
|
||||
tempAcc = acc;
|
||||
|
||||
traction -= 2;
|
||||
if(curTraction - 2 > 0){
|
||||
curTraction -= 2;
|
||||
}
|
||||
|
||||
acc += 2;
|
||||
curAcc += 2;
|
||||
accModification = 2;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Weather.Snow:{
|
||||
Debug.Log("Snow");
|
||||
|
||||
tempTraction = traction;
|
||||
tempAcc = acc;
|
||||
|
||||
traction += 2;
|
||||
if(curTraction > .01 && curTraction != 1){
|
||||
curTraction += 2;
|
||||
}
|
||||
|
||||
acc *= .5;
|
||||
curAcc *= .5;
|
||||
accModification = -acc;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Weather.Wind:{
|
||||
Debug.Log("Wind");
|
||||
windOn = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case Weather.Fog:{
|
||||
Debug.Log("Fog");
|
||||
break;
|
||||
}
|
||||
|
||||
default:{
|
||||
Debug.Log("Incorrect thing passed in");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearWeather(){
|
||||
|
||||
acc = tempAcc;
|
||||
traction = tempTraction;
|
||||
|
||||
if(curTraction > .01 && curTraction != 1){
|
||||
curTraction = traction;
|
||||
}
|
||||
|
||||
curAcc -= accModification;
|
||||
|
||||
windOn = false;
|
||||
|
||||
}
|
||||
|
||||
void Update(){
|
||||
VariableValidation();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user