Exemplo n.º 1
0
 protected void HPChange(int delta)
 {
     if (delta == 0)
     {
         return;
     }
     dmgTxtInst = Instantiate(dmgTxt);
     dmgTxtInst.transform.position = transform.position;
     doH = dmgTxtInst.GetComponent <DmgOrHeal>();
     if (delta < 0)
     {
         doH.SetText((-delta).ToString(), Color.white);
     }
     else
     {
         doH.SetText(delta.ToString(), Color.cyan);
     }
     hp += delta;
     if (hp > maxHp)
     {
         hp = maxHp;
     }
     else if (hp <= 0)
     {
         hp = 0;
         GetComponent <Collider2D>().enabled = false;
         p.gameObject.GetComponent <Player>().GainExp(exp);
         at.enabled = false;
         StartCoroutine(OnZero());
     }
 }
Exemplo n.º 2
0
    public void HpChange(int delta)     //체력 회복 or 피해, ui부는 나중에 옮기는 게 나을 수도 있음
    {
        if (delta == 0)
        {
            return;
        }
        hp        += delta;
        dmgTxtInst = Instantiate(dmgTxt);
        dmgTxtInst.transform.position = transform.position;
        doH = dmgTxtInst.GetComponent <DmgOrHeal>();
        if (delta < 0)
        {
            doH.SetText((-delta).ToString(), Color.red);
        }
        else
        {
            doH.SetText(delta.ToString(), Color.green);
        }

        if (hp > MAXHP)
        {
            hp = MAXHP;
        }
        else if (hp <= 0)
        {
            hp = 0;
            anim.SetTrigger("HIT");
            anim.SetInteger("OVR", 2);
            Invoke(nameof(Hp0), 1);
        }
    }
Exemplo n.º 3
0
 public void GainExp(int delta)
 {
     expe += delta;
     if (delta > 0)
     {
         dmgTxtInst = Instantiate(dmgTxt);
         dmgTxtInst.transform.position = transform.position;
         doH = dmgTxtInst.GetComponent <DmgOrHeal>();
         doH.SetText("+" + delta.ToString(), Color.yellow, 2);
     }
 }