Esempio n. 1
0
    // Handle damage
    public void TakeDamage(int damageAmount)
    {
        bossHealth -= damageAmount;
        // Update health bar each time damage is taken
        bossHealthBar.value = bossHealth;
        if (bossHealth <= 0)
        {
            HandleBossDeathEffects();
            Destroy(this.gameObject);
            // Hide the health bar when the boss is dead
            bossHealthBar.gameObject.SetActive(false);
            // When final boss is dead, load Game Won scene
            sceneFadeTransition.LoadScene("GameWon");
        }
        // In case of reaching half health points trigger chasing behaviour
        if (bossHealth <= halfHealth)
        {
            bossAnimator.SetTrigger("FromWalkToRun");
        }

        // Choose random enemy
        Enemy randomEnemy = enemies[Random.Range(0, enemies.Length)];

        // Instantiate enemy away from boss using offset
        Instantiate(randomEnemy, transform.position + new Vector3(spawnOffset, spawnOffset, 0), transform.rotation);
    }
Esempio n. 2
0
 // Handle damage and destroy player
 public void TakeDamage(int damageAmount)
 {
     playerHealth -= damageAmount;
     UpdateHealthUI(playerHealth);
     panelHurtEffect.SetTrigger("Hurt");
     if (playerHealth <= 0)
     {
         Destroy(gameObject);
         // When player is dead, load Game Lost scene
         sceneFadeTransition.LoadScene("GameLost");
     }
 }
Esempio n. 3
0
 // Load main menu and resume the game flow
 public void LoadStartMenu()
 {
     GameIsPaused   = false;
     Time.timeScale = 1.0f;
     sceneFade.LoadScene("MainMenu");
 }