void OnGUI() { if (GUI.Button(new Rect(Screen.width / 1.5f, Screen.height / 4 + Screen.width / 10 * 0, 100, 25), "Add Heart")) { heartBar.AddHearts(1); } if (GUI.Button(new Rect(Screen.width / 1.5f, Screen.height / 4 + Screen.width / 10 * 1, 100, 25), "TakeDamage")) { heartBar.ModifyHealth(-5); } if (GUI.Button(new Rect(Screen.width / 1.5f, Screen.height / 4 + Screen.width / 10 * 2, 100, 25), "Heal")) { heartBar.ModifyHealth(5); } }
void CollisionDamage(Enemy enemy) { // Don't take damage if you're already invincible if (invincibleBool) { return; } // The Mage has been hit by an enemy StopWalking(); ClearInput(); health -= enemy.touchDamage; // Take 1 point of damage (for now) heartBar.ModifyHealth(-10); if (health <= 0) { Die(); return; } damageTime = Time.time; knockbackBool = true; knockbackDir = (pos - enemy.pos).normalized; invincibleBool = true; }