Ejemplo n.º 1
0
 private void FinishFlying(GameObject arrow)
 {
     if (skill2 != null && normalAttackCount == (int)skill2.arg3)
     {
         normalAttackCount = 0;
         Instantiate(attackEffect, aim.transform.position + new Vector3(0, .5f, 0), Quaternion.identity);
         float dmg = CalcDamage() + skill2.arg1;
         AddGauge(100);
         aim.Damage(dmg, this);
         aim.AddGauge(-1 * skill2.arg4);
     }
     else
     {
         base.DoNormalAttack(aim);
     }
     Destroy(arrow);
 }
Ejemplo n.º 2
0
    public void Damage(float value, BaseUnit attacker = null, bool isDot = false)
    {
        if (current_hp == 0)
        {
            return;
        }
        //暴击
        bool isCrit = false;

        if (!isDot && Random.Range(0, 1f) <= attacker.critical)
        {
            value *= attacker.critical_coe;
            isCrit = true;
        }
        //减伤DOT
        foreach (var item in dots)
        {
            if (item.type == DotType.reduceDmg)
            {
                value = Mathf.Max(1, value - item.num);
            }
        }
        //shield
        foreach (var item in dots)
        {
            if (item.type == DotType.shield)
            {
                if (item.num > value)
                {
                    item.num -= value;
                    return;
                }
                else
                {
                    value        -= item.num;
                    item.duration = 0;
                }
            }
        }
        if (!isDot)
        {
            if ((action == HeroAction.idle || action == HeroAction.hurt))
            {
                DoAction(HeroAction.hurt);
            }
            SetBodyIllumin(new Color(0.5f, 0.5f, 0.5f));
            injuryColorTime = 0.2f;
        }
        if (isCrit)
        {
            GameObject critNum = Instantiate(BattleManager.Instance.GetHUD("CriticalNum")) as GameObject;
            critNum.transform.GetChild(0).GetComponent <InjuryNum>().Init(value, this);
        }
        else
        {
            GameObject normalNum = Instantiate(BattleManager.Instance.GetHUD("NormalNum")) as GameObject;
            normalNum.transform.GetChild(0).GetComponent <InjuryNum>().Init(value, this);
        }

        attacker.exportDamage += value;

        AddGauge(1000 * value / hp / 2);

        bloodSlider.Show();

        current_hp -= value;
        if (current_hp <= 0)
        {
            StopMoving();
            current_hp = 0;
            DeadEvent();
            foreach (var item in dots)
            {
                if (item.eff)
                {
                    Destroy(item.eff);
                }
            }
            DoAction(HeroAction.die);
            iTween.MoveAdd(this.gameObject, iTween.Hash("y", -3f, "speed", 1, "oncomplete", "Hide", "delay", 2));
            attacker.AddGauge(300);
            troop.InformDead();
            if (skillBtn)
            {
                AddGauge(-1000);
                skillBtn.transform.GetChild(4).GetComponent <Image>().color = new Color(.4f, .4f, .4f);
            }
        }
        else
        {
            DamageEvent();
        }
        if (skillBtn)
        {
            skillBtn.transform.GetChild(1).GetComponent <Image>().fillAmount = current_hp / hp;
        }
    }