Exemplo n.º 1
0
        public void SetDamage(BattleUnitSkillResult skillResult)
        {
            //设置数字
            if (skillResult.avoid)
            {
                tmpDamage.text = EGameConstL.MissText;
            }
            else
            {
                tmpDamage.text = skillResult.syncAttribute.hpChanged.ToString();
            }

            //目前设置为 播放普通伤害动画
            switch (skillResult.battleSkill.damageType)
            {
            case BattleSkillDamageType.Physical:
            case BattleSkillDamageType.Skill:
                animator.SetTrigger(EGameConstL.HashACKey_NormalDamage);
                break;

            case BattleSkillDamageType.Move:
                animator.SetTrigger(EGameConstL.HashACKey_NormalMagicDamage);
                break;

            case BattleSkillDamageType.Heal:
                animator.SetTrigger(EGameConstL.HashACKey_NormalHeal);
                break;

            default:
                break;
            }

            //根据动画长度开启自动回收
            Play();
        }
Exemplo n.º 2
0
        private void PlayDamageLabel(BattleUnitSkillResult skillResult)
        {
            //播放掉血特效
            EffectDamageLabel damageEffect = EffectManager.Instance.CreateEffectByName <EffectDamageLabel>(EGameConstL.Effect_DamageLabel, EffectPlayType.WorldPosition);

            if (damageEffect != null)
            {
                damageEffect.SortingLayer = EGameConstL.SortingLayer_Battle_Effect;
                damageEffect.gameObject.SetActive(true);
                damageEffect.transform.position = unitRenderer.transform.position;
                damageEffect.SetDamage(skillResult);
            }
        }
Exemplo n.º 3
0
        //技能命中时
        private IEnumerator OnSkillDamage(BattleUnitSkillResult skillResult)
        {
            if (skillResult == null)
            {
                yield return(null);
            }

            PlayDamageLabel(skillResult);

            //更新血条
            skillResult.battleUnit.battleUnitRenderer.RefreshAttribute(skillResult.syncAttribute);

            //判断是否跪了
            if (skillResult.syncAttribute.currentHP <= 0)
            {
                yield return(EGameConstL.WaitForHalfSecond);

                //离场
                yield return(skillResult.battleUnit.battleUnitRenderer.PlayDefeatedAction());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 计算单个效果
        /// </summary>
        /// <param name="releaser">释放者</param>
        /// <param name="target">目标</param>
        /// <param name="battleSkill">技能</param>
        /// <param name="mainEffect">是否主要伤害</param>
        /// <returns>技能结果</returns>
        public BattleUnitSkillResult CalcSingle(BattleUnit releaser, BattleUnit target, SO_BattleSkill battleSkill, bool mainEffect)
        {
            BattleUnitSkillResult result = new BattleUnitSkillResult();

            result.battleUnit    = target;
            result.battleSkill   = battleSkill;
            result.syncAttribute = new BattleUnitSyncAttribute();
            //简单计算生命值
            switch (battleSkill.damageType)
            {
            case BattleSkillDamageType.Physical:
            case BattleSkillDamageType.Move:
            case BattleSkillDamageType.Skill:
                float critRatio = releaser.battleUnitAttribute.GetTargetCritRatio(target);              //判断是否暴击
                float critNum   = Random.Range(0.0f, 1.0f);
                if (critNum < critRatio)
                {
                    result.crit = true;
                }
                else
                {
                    result.crit = false;
                }

                float hpChanged = releaser.battleUnitAttribute.power * battleSkill.powerModulus;        //力量补正
                hpChanged += releaser.battleUnitAttribute.speed * battleSkill.speedModulus;             //速度补正
                hpChanged += releaser.battleUnitAttribute.technic * battleSkill.technicModulus;         //技巧补正
                hpChanged += releaser.battleUnitAttribute.power * EGameConstL.PowerCommonModulus;       //力量值附加补正
                hpChanged *= releaser.battleUnitAttribute.AtkUpRatio;                                   //通用攻击力提升
                hpChanged *= releaser.battleUnitAttribute.GetDamageTypeModulus(target);                 //属性克制补正
                hpChanged  = Mathf.Max(0, hpChanged - target.battleUnitAttribute.Def);                  //直接减去目标防御值
                if (result.crit)
                {
                    hpChanged *= 2;                                  //判断是否暴击
                }
                result.syncAttribute.hpChanged = (int)-hpChanged;    //(Mathf.Max(0, releaser.battleUnitAttribute.Atk - target.battleUnitAttribute.Def + battleSkill.mainValue));
                //能量不变
                result.syncAttribute.energyChanged = 0;
                result.syncAttribute.currentEnergy = target.battleUnitAttribute.energy;

                float avoidRatio = releaser.battleUnitAttribute.GetTargetAvoidRatio(target);            //判断是否闪避
                float avoidNum   = Random.Range(0.0f, 1.0f);
                if (!result.crit && avoidNum < avoidRatio)
                {
                    result.syncAttribute.hpChanged = 0;
                    result.avoid = true;
                }
                else
                {
                    result.avoid = false;
                }
                UtilityHelper.LogFormat("Is critical: {0}, Is avoid: {1}", result.crit, result.avoid);
                break;

            case BattleSkillDamageType.Heal:
                result.syncAttribute.hpChanged = Mathf.Min(battleSkill.mainValue, target.battleUnitAttribute.maxHp - target.battleUnitAttribute.hp);
                //能量不变
                result.syncAttribute.energyChanged = 0;
                result.syncAttribute.currentEnergy = target.battleUnitAttribute.energy;
                break;

            default:
                break;
            }
            //hp变化
            target.battleUnitAttribute.hp += result.syncAttribute.hpChanged;
            target.battleUnitAttribute.hp  = Mathf.Clamp(target.battleUnitAttribute.hp, 0, target.battleUnitAttribute.maxHp);
            //记录变化
            result.syncAttribute.currentHP = target.battleUnitAttribute.hp;
            return(result);
        }