Exemplo n.º 1
0
 public void TakeDameged(int dameged)
 {
     dameged -= Armor;
     if (dameged < 1)
     {
         dameged = 1;
     }
     currentHealth -= dameged;
     FloatingTextController.CreateFloatingText("-" + dameged, transform);
     healthBar.fillAmount = currentHealth / health;
     if (currentHealth <= 0)
     {
         playerLevel.addExp(enemyExp);
         CapsuleCollider2D col = gameObject.GetComponent <CapsuleCollider2D>();
         col.enabled = false;
         if (goldDropping > 0)
         {
             int index = Random.Range(0, dropingItem.Length + 1);
             if (index == dropingItem.Length)
             {
                 InteractionObject intaer = Gold.GetComponent <InteractionObject>();
                 int gold = (int)Random.Range((int)goldDropping * 0.9f, (int)goldDropping * 1.1f);
                 intaer.priceSell = gold;
                 Instantiate(Gold, transform.position, Quaternion.identity);
             }
             else
             {
                 Instantiate(dropingItem[index], transform.position, Quaternion.identity);
             }
         }
         else
         {
             if (dropingItem.Length > 0)
             {
                 int index = Random.Range(0, dropingItem.Length);
                 Instantiate(dropingItem[index], transform.position, Quaternion.identity);
             }
         }
         //target.gameObject.GetComponent<PlayerLevel>().SendMessage("addExp", enemyExp);
         string[] spawnerName = gameObject.name.Split('_');
         GameObject.Find(spawnerName[0]).GetComponent <Spawner>().Death = true;
         Destroy(gameObject, 0.5f);
     }
 }