// Collision check for boosters. private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("Entered"); if (collision.gameObject.tag != null) { Debug.Log("This hit: " + collision.gameObject.tag); if (collision.gameObject.tag == "WeaponPowerUp") { // If object is weapon booster. Debug.Log("Collected Weapon power up"); WeaponPowerUp hit = collision.gameObject.GetComponent <WeaponPowerUp>(); hit.Collected = true; _boosterTime += hit.BoosterTime; _boosterActive = true; } else if (collision.gameObject.tag == "HealthPowerUp") { // If object is health booster. Debug.Log("Collected Health power up"); HealthPowerUp hit = collision.gameObject.GetComponent <HealthPowerUp>(); Health.IncreaseHealth(hit.Healing); hit.Collected = true; } } }
//takes one life away and returns player to starting position protected void Respawn() { StartCoroutine(Flash(_flashSpeed)); transform.position = _starPosition; Health.IncreaseHealth(Health.MaxHealth); _lives -= 1; }
public override void TakeHealth(int amount) { Health.IncreaseHealth(amount); // Update the interface text. LevelController.Current.UpdateHealth(Health.CurrentHealth); }
protected void OnEnable() { // Enabling treated as a respawn and will give full health // and invulnerability for a limited amount of time. Health.IncreaseHealth(100); StartCoroutine(SpawnProtection()); StartCoroutine(InVulnerableFX()); }
public void OnTriggerEnter2D(Collider2D other) { Health playerHealth = other.GetComponent <Health>(); //Get the player Health component playerHealth.IncreaseHealth(healthAmount); //Heal the player up. Debug.Log("Health Increased!"); Destroy(gameObject); // Destroy the health item after usage. }
/// <summary> /// Restores health to the space ship. /// </summary> /// <param name="amount">the amount of health</param> public void RestoreHealth(int amount) { // Decreases the current health Health.IncreaseHealth(amount); // Prints debug info //Debug.Log(name + ": +" + amount + " health! HP: " // + Health.CurrentHealth); }
void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.CompareTag("power")) { Destroy(col.gameObject); Debug.Log("Health Before: " + Health.CurrentHealth); Health.IncreaseHealth(power.healingAmount); Debug.Log("Health After: " + Health.CurrentHealth); } }
public void OnTriggerEnter2D(Collider2D collision) { // The healing process of the player and the destruction // of the power-up after the player picks it up. Health playerHealth = collision.GetComponent <Health>(); playerHealth.IncreaseHealth(_healAmount); Debug.Log("Gained some health!"); Destroy(gameObject); }
// Receives powerup public void TakePowerup(PowerupBase.PowerUpProperties pUProperties) { // Receive health powerup value if (pUProperties.HealthToProvide > 0) { Health.IncreaseHealth(pUProperties.HealthToProvide); } // Receive bonus weapon time if (pUProperties.BonusWeaponTime > 0) { AddBonusTime(pUProperties.BonusWeaponTime); } }
protected IEnumerator Respawn(float respawnTimer) { yield return(new WaitForSeconds(respawnTimer)); if (_lives > 0) { rend.enabled = false; coll.enabled = false; transform.position = new Vector3(0, -4, 0); Health.IncreaseHealth(Health.InitialHealth); _lives--; StartCoroutine(Invulnerability()); } else { Debug.Log("Out of lives"); SceneManager.LoadScene(0); } }
private void PlayerDeath() { Debug.Log("PlayerDeath() called."); _isImmortal = true; _livesLeft--; UpdateLivesLeftText(); if (_livesLeft == 0) { Destroy(gameObject); } else { // Reset player's health back to the starting value. health.IncreaseHealth(100); // Reset the player's ship's location to the starting location. gameObject.transform.position = new Vector2(0f, -4f); } }
protected override void PowerUpPlayer(GameObject player) { Health playerHealth = player.GetComponent <Health>(); playerHealth.IncreaseHealth(20); }
public void TakeHeal(int amount) { Health.IncreaseHealth(amount); SetupCurrentHealth(); }
public void ReceiveHeal(int healAmount) { Health.IncreaseHealth(healAmount); }
public virtual void TakeHealth(int amount) { Health.IncreaseHealth(amount); }