public int TakeDam(int dam, ref eDamResistType DamResist)
    {
        //< 버프중에 쉴드가 있는지 검사한다.
        for (int i = 0; i < BuffDic.Count; i++)
        {
            if (BuffDic[i] == null)
            {
                continue;
            }

            if (BuffDic[i].buffInfo.buffType == (byte)BuffType.Shield)
            {
                DamResist = eDamResistType.Shield;
                if (BuffDic[i].affectedValue >= dam)
                {
                    BuffDic[i].affectedValue -= dam;
                    dam = 0;
                }
                else
                {
                    dam -= (int)BuffDic[i].affectedValue;
                    BuffDic[i].affectedValue = 0;
                }

                //< 쉴드가 다 사용되었다면 버프를 종료한다.
                if (BuffDic[i].affectedValue <= 0)
                {
                    BuffDic[i].DetachBuff();
                    i--;
                    continue;
                }

                if (dam <= 0)
                {
                    break;
                }
            }
        }

        //< 최소 1대미지띄우도록
        dam = Mathf.Clamp(dam, 1, dam);

        return(dam);
    }
예제 #2
0
    public void Show(GameObject _targetGO, GameObject attacker, int damage, bool isMyUnit, bool isCritical, bool isHeal = false, eDamResistType DamResist = eDamResistType.None)
    {
        owner = _targetGO;
        gameObject.SetActive(true);

        criticalSpr.enabled = isCritical;
        digitLbl.fontSize   = (isCritical) ? (int)((float)defaultFontSize * 1.5f) : defaultFontSize;
        digitLbl.text       = damage.ToString();

        DamInfoSprite.gameObject.SetActive(DamResist == eDamResistType.None && !isCritical /*&& _AttriButeType != eAttriButeType.NormalAttriBute*/);

        //< 대미지 감소상태라면 회색!
        if (DamResist != eDamResistType.None)
        {
            digitLbl.color = new Color(168 / 255f, 84 / 255f, 255 / 255f, 1f);
            digitLbl.text  = damage.ToString();
        }
        else
        {
            if (isCritical)
            {
                digitLbl.color = Color.yellow;
            }
            else if (isHeal)
            {
                digitLbl.color = Color.green;
            }
            else
            {
                if (!isMyUnit)
                {
                    digitLbl.color = Color.white;
                }
                else
                {
                    digitLbl.color = Color.red;
                }
            }

            /*
             * //< PVP는 예외처리
             * if (G_GameInfo.GameMode == GAME_MODE.PVP)
             * {
             *  if (isCritical)
             *  {
             *      digitLbl.color = Color.yellow;
             *  }
             *  else if (isHeal)
             *  {
             *      digitLbl.color = Color.green;
             *  }
             *  else
             *  {
             *      if (owner.GetComponent<Unit>().TeamID == 0)
             *          digitLbl.color = Color.red;
             *      else
             *          digitLbl.color = Color.white;
             *
             *      if (_AttriButeType == eAttriButeType.WinAttriBute)
             *      {
             *          DamInfoSprite.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));
             *          DamInfoSprite.color = WinAttriButeColor;
             *      }
             *      else if (_AttriButeType == eAttriButeType.LoseAttriBute)
             *      {
             *          DamInfoSprite.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, -180));
             *          DamInfoSprite.color = LoseAttriButeColor;
             *      }
             *  }
             * }
             * else
             * {
             *  Unit unit = owner.GetComponent<Unit>();
             *  if (null != unit)
             *  {
             *      switch (unit.UnitType)
             *      {
             *          case UnitType.Unit:
             *          case UnitType.Npc:
             *          case UnitType.Boss:
             *          case UnitType.Prop:
             *              {
             *                  if (isCritical)
             *                  {
             *                      digitLbl.color = Color.yellow;
             *                  }
             *                  else if (isHeal)
             *                  {
             *                      digitLbl.color = Color.green;
             *                  }
             *                  else
             *                  {
             *                      if (attacker.GetComponent<Unit>().UnitType == UnitType.Unit)
             *                          digitLbl.color = Color.white;
             *                      else
             *                          digitLbl.color = Color.red;
             *
             *                      if (_AttriButeType == eAttriButeType.WinAttriBute)
             *                      {
             *                          DamInfoSprite.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));
             *                          DamInfoSprite.color = WinAttriButeColor;
             *                      }
             *                      else if (_AttriButeType == eAttriButeType.LoseAttriBute)
             *                      {
             *                          DamInfoSprite.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, -180));
             *                          DamInfoSprite.color = LoseAttriButeColor;
             *                      }
             *                  }
             *
             *              }
             *              break;
             *
             *          default:
             *              digitLbl.color = Color.white;
             *              break;
             *      }
             *  }
             * }
             */
        }

        factor = 0;
        tweenAlpha.ResetToBeginning();
        tweenAlpha.PlayForward();
        tweenScale.ResetToBeginning();
        tweenScale.PlayForward();

        int RanX = Random.Range(0, 600);

        if (TownState.TownActive)
        {
            randomX += (float)(RanX * 0.01f);
        }
        else
        {
            randomX += (float)(RanX * 0.02f);
        }

        if (Random.Range(0, 2) != 0)
        {
            randomX *= -1;
        }

        // 시작, 끝점 설정
        transform.localPosition = GetUIPos();

        //< 처음 시작위치 저장
        StartOwnelPos = owner.transform.position;
        Update();
    }
    public void ShowDamage(GameObject target, GameObject attacker, int damage, bool isMyUnit, bool isCritical, bool isHeal = false, eDamResistType DamResist = eDamResistType.None)
    {
        GameObject damageObject = poolDic[ShowingType.Damage][damageIndex++];

        damageObject.GetComponent <DamageUI>().Show(target, attacker, damage, isMyUnit, isCritical, isHeal, DamResist);
        CheckPool();
    }