Updated nitro restoring functionality and buffing

This commit is contained in:
Melbyj1125
2022-02-01 21:07:45 -06:00
parent c5ae603e8f
commit bf874ddc84
10 changed files with 224 additions and 58 deletions

View File

@@ -54,7 +54,7 @@ public class dDash : NetworkBehaviour{
private IEnumerator startCoolDown(){
Debug.Log("start corotine");
isOnCoolDown = true;
driver.startUICooldown(dashItem.name);
//driver.startUICooldown(dashItem.name);
yield return new WaitForSeconds(dashItem.cooldownM);
isOnCoolDown = false;
Debug.Log("end corotine");

View File

@@ -172,7 +172,6 @@ public class dGrapplingHook : NetworkBehaviour
swingback = true;
release = false;
}
Debug.Log(playerMovement.isGrounded);
}
//Finds the nearest hook to the player
@@ -226,14 +225,14 @@ public class dGrapplingHook : NetworkBehaviour
if(oldXZDir != curXZDir){
//midpointMom = swingMom;
swingback = false;
Debug.Log("flip");
//Debug.Log("flip");
}
if(swingback == false && swingMom <= (oldSwingMom*(.75f))){
swingback = true;
oldSwingMom = swingMom;
oldXZDir = (new Vector3(hookPoint.transform.position.x,0,hookPoint.transform.position.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized;
Debug.Log("swingback");
//Debug.Log("swingback");
}
curXZDir = (new Vector3(hPoint.x,0,hPoint.z) - new Vector3(transform.position.x,0,transform.position.z)).normalized;
@@ -254,7 +253,6 @@ public class dGrapplingHook : NetworkBehaviour
if(sMom > maxSwingMom){
sMom = maxSwingMom;
}
Debug.Log(playerSpeed);
return sMom;
}

View File

@@ -8,7 +8,9 @@ public class dNitro : MonoBehaviour
private PlayerStats playerStats;
public SpecialItem nitroItem;
private bool isOnCoolDown = false;
private bool isNitroing = false;
public bool isNitroing = false;
private float tempTimer = 5;
//this will need to be set from scritable object or something;
// Start is called before the first frame update
@@ -24,23 +26,40 @@ public class dNitro : MonoBehaviour
//once cooldowns are implemented, put this on one (a long one)
if (Input.GetKeyDown(KeyCode.LeftShift) && isOnCoolDown == false && playerStats.HasNitro)
{
if(playerStats.CurVel < playerStats.HardCapMaxVel){
playerStats.CurVel += playerStats.Acc * 10;
}
else if(playerStats.CurVel > playerStats.HardCapMaxVel){
playerStats.CurVel = playerStats.HardCapMaxVel;
}
isNitroing = true;
StartCoroutine(startCoolDown());
}
}
void FixedUpdate(){
if(isNitroing){
if(tempTimer > 0){
tempTimer -= .04f;
Debug.Log("nitro is on");
if(playerStats.CurVel < playerStats.HardCapMaxVel){
playerStats.CurVel += playerStats.Acc * 10;
}
else if(playerStats.CurVel > playerStats.HardCapMaxVel){
playerStats.CurVel = playerStats.HardCapMaxVel;
}
}
else{
StartCoroutine(startCoolDown());
isNitroing = false;
}
}
}
private IEnumerator startCoolDown(){
Debug.Log("start corotine");
isOnCoolDown = true;
driver.startUICooldown("Nitro");
//driver.startUICooldown("Nitro");
yield return new WaitForSeconds(nitroItem.cooldownM);
isOnCoolDown = false;
tempTimer = 5;
Debug.Log("end corotine");
}
}

View File

@@ -94,6 +94,9 @@ public class dPlayerMovement : NetworkBehaviour
//Grapple
private dGrapplingHook grapple;
//Nitro
private dNitro nitro;
//Animation controller
@@ -114,6 +117,7 @@ public class dPlayerMovement : NetworkBehaviour
wallRun = GetComponent<dWallRun>(); //Wallrun
blink = GetComponent<dBlink>(); //Blink
grapple = GetComponent<dGrapplingHook>();
nitro = GetComponent<dNitro>();
//Get parents up direction
up = GetComponentInParent<Transform>().up;
@@ -255,12 +259,15 @@ public class dPlayerMovement : NetworkBehaviour
return pStats.CurVel;
}
//If the players speed is above or equal to max speed set speed to max
else if (pStats.CurVel >= pStats.MaxVel)
else if (pStats.CurVel >= pStats.MaxVel && nitro.isNitroing == false)
{
pStats.CurVel = pStats.MaxVel;
return pStats.CurVel;
}
else if(nitro.isNitroing){
return pStats.CurVel;
}
else{
Debug.Log("Something has gone wrong with the PlayerSpeed()");
return -1;