TheKingsRace/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dNitro.cs
Melbyj1125 c5ae603e8f swing feels a lot more complete
Takes into accoutn player height and speed
need to adjust slightly for better ingame feel when it is implemented
into the levels.
2022-02-01 20:32:55 -06:00

47 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dNitro : MonoBehaviour
{
private CoolDown driver;
private PlayerStats playerStats;
public SpecialItem nitroItem;
private bool isOnCoolDown = false;
private bool isNitroing = false;
//this will need to be set from scritable object or something;
// Start is called before the first frame update
void Start()
{
//driver = GameObject.Find("Canvas").GetComponent<CoolDown>();
playerStats = GetComponent<PlayerStats>();
}
// Update is called once per frame
void Update()
{
//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;
}
StartCoroutine(startCoolDown());
}
}
private IEnumerator startCoolDown(){
Debug.Log("start corotine");
isOnCoolDown = true;
driver.startUICooldown("Nitro");
yield return new WaitForSeconds(nitroItem.cooldownM);
isOnCoolDown = false;
Debug.Log("end corotine");
}
}