Beispiel #1
0
 void Die()
 {
     Destroy(this.gameObject);
     if (this.tag.Contains("colony"))
     {
         MainThreadOfGame.DecNumColony();
     }
     else
     {
         MainThreadOfGame.DecNumEnemy();
     }
 }
    void Decrease_Life_Building()
    {
        if (slide.value > 0)
        {
            float hitPower = 0;
            for (int i = 0; i < list_Attackers.Count; i++)
            {
                if (list_Attackers[i].gameObject.GetComponent <Attack>() != null)
                {
                    hitPower = hitPower + list_Attackers[i].GetComponent <Attack>().GetHitPower();
                }
            }

            slide.value = slide.value - hitPower;
            fill.color  = gradient.Evaluate(slide.normalizedValue);

            Set_Fire_Destroy();
        }
        else if (flag == false && slide.value <= 0)
        {
            for (int i = 0; i < list_Attackers.Count; i++)
            {
                if (list_Attackers[i].gameObject.GetComponent <Attack>() != null)
                {
                    list_Attackers[i].GetComponent <Animator>().SetBool("toAttack", false);
                    list_Attackers.RemoveAt(i);
                }
            }



            for (int i = 0; i < 7; i++)
            {
                particles[i].SetActive(false);
            }

            this.gameObject.SetActive(false);

            Destruct_Building.transform.position = this.transform.position;
            Destruct_Building.SetActive(true);

            if (this.tag.Contains("colony"))
            {
                MainThreadOfGame.DecNumColony();
            }
            else
            {
                MainThreadOfGame.DecNumEnemy();
            }

            flag = true;
            CancelInvoke("Decrease_Life_Building");

            list_Attackers.Clear();

            InvokeRepeating("Decrease_Life_Building", 6f, 6f);
        }

        else
        {
            Destruct_Building.SetActive(false);
            flag = false;

            CancelInvoke("Decrease_Life_Building");
        }
    }