private void HandleMeditation() { if (upgrades.HasUpgrade(Upgrade.UpgradeType.Meditation)) { if (Input.GetKey(KeyCode.T)) { if (!isMeditating && _animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") && charge.GetCharge() > 0) { StartCoroutine(Meditation()); } } else if (isMeditating) { SetMeditation(false); } } }
public void UpdateCharge(float charge) { this.charge = charge; if (_contr == null) { _contr = FindObjectOfType <ResourceController>(); } _contr.SetCharge(pCharge.GetCharge()); //chargeText.text = "Charge: " + this.charge*100; }
private void HandleAttackInput() { if (Time.time >= nextAttackTime) { if (Input.GetKeyDown(KeyCode.W)) { if (_animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") && upgrades.HasUpgrade(Upgrade.UpgradeType.FireFist)) { nextAttackTime = Time.time + 1f / attackRate; chargeBeforePunch = charge.GetCharge(); punchCoroutine = WaitForPunchTime(); StartFirePunch(); } else { int a = UnityEngine.Random.Range(0, 2); if (a == 0) { Attack("punch"); } else { Attack("kick"); } nextAttackTime = Time.time + 1f / attackRate; } } } if (Input.GetKeyUp(KeyCode.W) && chargingFist) { DisruptFirePunch(); } if (Input.anyKeyDown && !Input.GetKeyDown(KeyCode.W) && chargingFist) { //just stops the charging if any other key is pressed without dealing damage DisruptFirePunch(false); } }