Ejemplo n.º 1
0
    public static void CreatDamageText(string str, Transform position, int DMGtype)
    {
        DamageText exp = Instantiate(damageText);

        if (exp != null)
        {
            exp.transform.SetParent(canv.transform, false);
            exp.GetComponent <RectTransform>().position = Camera.main.WorldToScreenPoint(position.position);
            exp.SetText(str);
            switch (DMGtype)
            {
            case 1:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "Cri1": "Cri2");
                break;

            case 2:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "DMG1":"DMG2");
                break;

            case 3:
                exp.GetComponentInChildren <Animator>().SetTrigger(Random.Range(0, 10) > 5 ? "Dot1":"Dot2");
                break;
            }
        }
    }
Ejemplo n.º 2
0
 public void ReceiveHealing(int _healing)
 {
     if (_healing + health > HP)
     {
         _healing = HP - health;
     }
     health += _healing;
     if (_healing > 0)
     {
         DamageText healing_text = Instantiate(Resources.Load <DamageText>("Prefabs/DamageText"));
         healing_text.GetComponent <TextMesh>().color = Color.green;
         healing_text.transform.position = transform.position + new Vector3(0, 5, 0);
         healing_text.SetText("+" + _healing.ToString());
         Debug.Log(name + " healed " + _healing);
     }
 }
 public void ShowDText(int Damage)
 {
     foreach (GameObject DamageText in DamageTexts)
     {
         if (!DamageText.activeSelf)
         {
             Debug.Log("show damage int !!!!!");
             DamageText.GetComponent <TextMeshProUGUI>().color = Color.white;
             DamageText.GetComponent <DisableTimer>().ResetTimer();
             DamageText.GetComponent <DisableTimer>().Resize(Damage);
             DamageText.GetComponent <TextMeshProUGUI>().text = Damage.ToString();
             DamageText.SetActive(true);
             return;
         }
     }
 }