IEnumerator repairTimeEnum(float repairTime, repairDelegate repairAction, string actionButton) { velocity = Vector3.zero; healtbar?.ShowSlider(); float t = 0; canMove = false; anim?.setBoolean("repair", true); float soundtime = 0; while (t < repairTime && Input.GetButton(actionButton)) { healtbar?.UpdateSlider(t / repairTime); if (t > soundtime) { AudioManager.instance.Play("repair"); soundtime += repairTime / 3; } t += Time.deltaTime; yield return(null); } healtbar?.HideSlider(); if (t >= repairTime) { repairAction.Invoke(); } anim?.setBoolean("repair", false); currentRepair = null; canMove = true; }
void Start() { controller = GetComponent <Controller2D>(); gravity = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2); maxJump = Mathf.Abs(gravity) * timeToJumpApex; minJump = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight); anim = GetComponentInChildren <PlayerAnimation>(); healtbar = GetComponentInChildren <Healthbar>(); healtbar?.HideSlider(); }