Exemple #1
0
 public void TakeDamage(float damage)
 {
     if (invulnEndTime <= Time.time)
     {
         invulnEndTime  = Time.time + msInvulnerability / 1000f;
         currentHealth -= damage;
         if (gameObject.name == "Player")
         {
             Debug.Log("Starting Static...");
             screenStaticController.StartScreenStatic(currentHealth / maxHealth);
         }
         if (currentHealth <= 0)
         {
             gameObject.SetActive(false);
             if (gameObject.GetComponent <BaseEnemyAI>())
             {
                 DropTableController.Instance.RollDropTable(gameObject.GetComponent <BaseEnemyAI>().dropTableName, gameObject.transform);
             }
             //Destroy(gameObject);
             if (gameObject.name == "Player")
             {
                 gameObject.SetActive(true);
                 //GameObject.FindGameObjectWithTag("DebugScreen").gameObject.SetActive(false);
                 SceneManager.LoadScene("GameOverScreen");
                 gameObject.transform.position = Vector3.zero;
                 currentHealth = maxHealth;
             }
         }
     }
 }
Exemple #2
0
 public void TakeDamage(float damage)
 {
     hits++;
     if (hurtAudio != null)
     {
         if (hurtVolume == 0f)
         {
             hurtVolume = hurtAudio.volume;
         }
         hurtAudio.PlayWithVolume(hurtVolume);
     }
     if (invulnEndTime <= Time.time)
     {
         invulnEndTime  = Time.time + msInvulnerability / 1000f;
         currentHealth -= damage;
         if (gameObject.name == "Player")
         {
             Debug.Log("Starting Static...");
             screenStaticController.StartScreenStatic(currentHealth / maxHealth);
         }
         if (currentHealth <= 0)
         {
             if (deathAudio != null)
             {
                 deathAudio.Play(-1, this.transform);
             }
             m_OnDeath.Invoke();
             gameObject.SetActive(false);
             if (gameObject.GetComponent <BaseEnemyAI>())
             {
                 DropTableController.Instance.RollDropTable(gameObject.GetComponent <BaseEnemyAI>().dropTableName, gameObject.transform);
             }
             //Destroy(gameObject);
             if (gameObject.name == "Player")
             {
                 // Change this so that enemies dont keep moving when they are disabled. Maybe destroy the enemy when they die instead
                 gameObject.SetActive(true);
                 //GameObject.FindGameObjectWithTag("DebugScreen").gameObject.SetActive(false);
                 SceneManager.LoadScene("GameOverScreen");
                 gameObject.transform.position = Vector3.zero;
                 currentHealth = maxHealth;
             }
         }
     }
 }