/// <summary>
        /// 获取攻击力(物,魂,魔)+ 触发的技能加成
        /// </summary>
        /// <returns></returns>
        public int GetAttackNum(AbilityProperty property)
        {
            //释放魂技加成
            decimal AttackRatio = ConfigEnvSet.GetDecimal("Combat.AttackRatio");
            int     attackNum   = 0;

            switch (property)
            {
            case AbilityProperty.Physical:
                attackNum = IsMonster ? PhyAttackNum : (int)Math.Floor(this.PowerNum * this.Lv * AttackRatio);
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.WuliNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.WuLiGongJi, attackNum));
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.AdditionWuliNum * attackNum).ToInt();
                break;

            case AbilityProperty.Ability:
                attackNum = IsMonster ? AbiAttackNum : (int)Math.Floor(this.SoulNum * this.Lv * AttackRatio);
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.HunjiNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.HunJiGongJi, attackNum));
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.AdditionHunjiNum * attackNum).ToInt();
                break;

            case AbilityProperty.Magic:
                attackNum = IsMonster ? MagAttackNum : (int)Math.Floor(this.IntellectNum * this.Lv * AttackRatio);
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.MofaNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.MoFaGongJi, attackNum));
                attackNum = MathUtils.Addition(attackNum, ExtraAttack.AdditionMofaNum * attackNum).ToInt();
                break;

            default:
                break;
            }
            return(attackNum);
        }
        /// <summary>
        /// 获取防御力(物,魂,魔)+ 触发的技能加成
        /// </summary>
        /// <returns></returns>
        public int GetDefenseNum(AbilityProperty property)
        {
            int defenseNum = 0;

            switch (property)
            {
            case AbilityProperty.Physical:
                defenseNum = IsMonster ? PhyDefenseNum : (int)Math.Floor(this.PowerNum * this.Lv * DefenseRatio);
                defenseNum = defenseNum.Addition(ExtraDefense.WuliNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.WuLiFangYu, defenseNum)).Validate();
                break;

            case AbilityProperty.Ability:
                defenseNum = IsMonster ? AbiDefenseNum : (int)Math.Floor(this.SoulNum * this.Lv * DefenseRatio);
                defenseNum = defenseNum.Addition(ExtraDefense.HunjiNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.HunJiFangYu, defenseNum)).Validate();
                break;

            case AbilityProperty.Magic:
                defenseNum = IsMonster ? MagDefenseNum : (int)Math.Floor(this.IntellectNum * this.Lv * DefenseRatio);
                defenseNum = defenseNum.Addition(ExtraDefense.MofaNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.MoFaFangYu, defenseNum)).Validate();
                break;

            default:
                break;
            }
            return(defenseNum);
        }
        /// <summary>
        /// 获取攻击力(物,魂,魔)+ 触发的技能加成
        /// </summary>
        /// <returns></returns>
        public int GetAttackNum(AbilityProperty property)
        {
            //释放魂技加成
            int attackNum = 0;

            switch (property)
            {
            case AbilityProperty.Physical:
                attackNum = IsMonster ? PhyAttackNum : (int)Math.Floor(this.PowerNum * this.Lv * AttackRatio);
                attackNum = attackNum.Addition(ExtraAttack.WuliNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.WuLiGongJi, attackNum));
                break;

            case AbilityProperty.Ability:
                attackNum = IsMonster ? AbiAttackNum : (int)Math.Floor(this.SoulNum * this.Lv * AttackRatio);
                attackNum = attackNum.Addition(ExtraAttack.HunjiNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.HunJiGongJi, attackNum));
                break;

            case AbilityProperty.Magic:
                attackNum = IsMonster ? MagAttackNum : (int)Math.Floor(this.IntellectNum * this.Lv * AttackRatio);
                attackNum = attackNum.Addition(ExtraAttack.MofaNum, int.MaxValue);
                attackNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.MoFaGongJi, attackNum));
                break;

            default:
                break;
            }
            return(attackNum);
        }
        /// <summary>
        /// 获取防御力(物,魂,魔)+ 触发的技能加成
        /// </summary>
        /// <returns></returns>
        public int GetDefenseNum(AbilityProperty property, CombatGeneral tagetGeneral)
        {
            var DefenseRatio = ConfigEnvSet.GetDecimal("Combat.DefenseRatio");
            int defenseNum   = 0;

            switch (property)
            {
            case AbilityProperty.Physical:
                bool    tType       = false;
                decimal tpLvPercent = GetLvPercent(tagetGeneral, out tType);
                defenseNum = IsMonster ? PhyDefenseNum : (int)Math.Floor(this.PowerNum * this.Lv * DefenseRatio);
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.WuliNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.WuLiFangYu, defenseNum));
                if (!tType)
                {
                    defenseNum = MathUtils.Subtraction(defenseNum, (tpLvPercent * defenseNum).ToInt());
                }
                else
                {
                    defenseNum = MathUtils.Addition(defenseNum, (tpLvPercent * defenseNum).ToInt());
                }
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionWuliNum * defenseNum).ToInt();
                break;

            case AbilityProperty.Ability:
                defenseNum = IsMonster ? AbiDefenseNum : (int)Math.Floor(this.SoulNum * this.Lv * DefenseRatio);
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.HunjiNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.HunJiFangYu, defenseNum));
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionHunjiNum * defenseNum).ToInt();
                break;

            case AbilityProperty.Magic:
                defenseNum = IsMonster ? MagDefenseNum : (int)Math.Floor(this.IntellectNum * this.Lv * DefenseRatio);
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.MofaNum, int.MaxValue);
                defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.MoFaFangYu, defenseNum));
                defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionMofaNum * defenseNum).ToInt();
                break;

            default:
                break;
            }

            if (!defenseNum.IsValid())
            {
                defenseNum = 0;
            }
            return(defenseNum);
        }
        public virtual bool Damage(AbilityProperty[] properties)
        {
            float damageTaken = 0f;

            foreach (AbilityProperty property in properties)
            {
                AbilityProperty[][] buffResistance = buffs
                                                     .Where(buff => buff.buff is DefensiveBuff dfb && dfb.Properties.HasResistanceTo(property))
                                                     .Select(buff => ((DefensiveBuff)buff.buff).Properties).ToArray();

                float damage = buffResistance.SelectMany(abilityProperties => abilityProperties)
                               .Aggregate(property.Amount, (current, p) => current - current * p.Amount);

                AbilityProperty resistance = stats.Resistances.FirstOrDefault(p =>
                                                                              property.IsElemental ? p.Element == property.Element : p.AttackType == property.AttackType);

                damage -= property.Amount * (resistance?.Amount ?? 0);

                damageTaken += damage;
            }

            currentHealth -= Mathf.Max(Random.Range(0, 100) <= 30 ? damageTaken * 2 : damageTaken, 0);

            damageCoolDownActive = true;
            damageCoolDown       = Time.time + 0.6f;
            sp.color             = Color.red;

            if (!(currentHealth <= 0))
            {
                return(true);
            }

            if (godMode)
            {
                return(true);
            }

            IsDead = true;
            Die();

            return(true);
        }
Exemple #6
0
        /// <summary>
        /// 计算伤害公式
        /// 攻击伤害 = 攻击力 - 物理防御力
        /// </summary>
        /// <param name="tagetGeneral">加血等辅助技能时可能为空值</param>
        /// <returns></returns>
        protected int GetPhysicalDamageNum(CombatGeneral tagetGeneral)
        {
            AbilityProperty property = General.AbilityProperty;

            ProcessLog.AbilityProperty = property;
            int     damageNum;
            int     attackNum;
            int     defenseNum = 0;
            decimal harmNum    = 0; //法宝属相克制伤害 --技能攻击

            attackNum = General.GetAttackNum(property);
            if (tagetGeneral != null)
            {
                harmNum    = TrumpAbilityAttack.TrumpZodiacHarm(General, tagetGeneral.UserID);
                defenseNum = tagetGeneral.GetDefenseNum(property, tagetGeneral);
                //普通攻击破防
                decimal normalAttackPoFang = TrumpAbilityAttack.GetEffect(General, AbilityType.NormalAttackPoFang);
                if (normalAttackPoFang > 0)
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.NormalAttackPoFang, 0));
                }
                defenseNum = (int)Math.Floor(MathUtils.Subtraction(defenseNum, defenseNum * normalAttackPoFang));
            }
            General.MinDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));

            damageNum = MathUtils.Subtraction(attackNum, defenseNum, General.MinDamageNum);

            //加固定伤害
            damageNum = MathUtils.Addition(damageNum, General.FixedDamageNum, int.MaxValue);

            //法宝属相克制伤害 --技能攻击
            if (harmNum > 0 && !isPyharm)
            {
                damageNum = (int)(damageNum * MathUtils.Addition(1, (harmNum + General.EffectValue)));
                isPyharm  = true;
            }

            return(damageNum);
        }
Exemple #7
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "AbilityID": return(AbilityID);

                case "AbilityName": return(AbilityName);

                case "AttackType": return(AttackType);

                case "AbilityProperty": return(AbilityProperty);

                case "AttackUnit": return(AttackUnit);

                case "AttackTaget": return(AttackTaget);

                case "RatioNum": return(RatioNum);

                case "IsIncrease": return(IsIncrease);

                case "HitPercent": return(HitPercent);

                case "IsCorrect": return(IsCorrect);

                case "IsIncreaseCorrect": return(IsIncreaseCorrect);

                case "AbilityType": return(AbilityType);

                case "BaseEffectNum": return(BaseEffectNum);

                case "IncreaseNum": return(IncreaseNum);

                case "EffectCount": return(EffectCount);

                case "RatioIncreaseNum": return(RatioIncreaseNum);

                case "EffectDesc": return(EffectDesc);

                case "AbilityDesc": return(AbilityDesc);

                case "IsMove": return(IsMove);

                case "EffectID1": return(EffectID1);

                case "EffectID2": return(EffectID2);

                case "Version": return(Version);

                case "AbilityStyle": return(AbilityStyle);

                case "HeadID": return(HeadID);

                case "DemandLv": return(DemandLv);

                case "ChangeAbility": return(ChangeAbility);

                case "AfterAbility": return(AfterAbility);

                case "MaxHeadID": return(MaxHeadID);

                case "Probability": return(Probability);

                case "FntHeadID": return(FntHeadID);

                case "IsActive": return(IsActive);

                case "AbilityQuality": return(AbilityQuality);

                default: throw new ArgumentException(string.Format("AbilityInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "AbilityID":
                    _AbilityID = value.ToInt();
                    break;

                case "AbilityName":
                    _AbilityName = value.ToNotNullString();
                    break;

                case "AttackType":
                    _AttackType = value.ToEnum <AttackType>();
                    break;

                case "AbilityProperty":
                    _AbilityProperty = value.ToEnum <AbilityProperty>();
                    break;

                case "AttackUnit":
                    _AttackUnit = value.ToEnum <AttackUnit>();
                    break;

                case "AttackTaget":
                    _AttackTaget = value.ToEnum <AttackTaget>();
                    break;

                case "RatioNum":
                    _RatioNum = value.ToDecimal();
                    break;

                case "IsIncrease":
                    _IsIncrease = value.ToBool();
                    break;

                case "HitPercent":
                    _HitPercent = value.ToDecimal();
                    break;

                case "IsCorrect":
                    _IsCorrect = value.ToBool();
                    break;

                case "IsIncreaseCorrect":
                    _IsIncreaseCorrect = value.ToBool();
                    break;

                case "AbilityType":
                    _AbilityType = value.ToNotNullString();
                    break;

                case "BaseEffectNum":
                    _BaseEffectNum = value.ToNotNullString();
                    break;

                case "IncreaseNum":
                    _IncreaseNum = value.ToNotNullString();
                    break;

                case "EffectCount":
                    _EffectCount = value.ToShort();
                    break;

                case "RatioIncreaseNum":
                    _RatioIncreaseNum = value.ToDecimal();
                    break;

                case "EffectDesc":
                    _EffectDesc = value.ToNotNullString();
                    break;

                case "AbilityDesc":
                    _AbilityDesc = value.ToNotNullString();
                    break;

                case "IsMove":
                    _IsMove = value.ToBool();
                    break;

                case "EffectID1":
                    _EffectID1 = value.ToNotNullString();
                    break;

                case "EffectID2":
                    _EffectID2 = value.ToNotNullString();
                    break;

                case "Version":
                    _Version = value.ToInt();
                    break;

                case "AbilityStyle":
                    _AbilityStyle = value.ToShort();
                    break;

                case "HeadID":
                    _HeadID = value.ToNotNullString();
                    break;

                case "DemandLv":
                    _DemandLv = value.ToShort();
                    break;

                case "ChangeAbility":
                    _ChangeAbility = value.ToEnum <AbilityType>();
                    break;

                case "AfterAbility": _AfterAbility = value.ToEnum <AbilityType>();
                    break;

                case "MaxHeadID":
                    _MaxHeadID = value.ToNotNullString();
                    break;

                case "Probability":
                    _Probability = value.ToDecimal();
                    break;

                case "FntHeadID":
                    _FntHeadID = value.ToNotNullString();
                    break;

                case "IsActive":
                    _IsActive = value.ToShort();
                    break;

                case "AbilityQuality":
                    _AbilityQuality = value.ToInt();
                    break;

                default: throw new ArgumentException(string.Format("AbilityInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
Exemple #8
0
        /// <summary>
        /// 目标防御处理
        /// </summary>
        /// <param name="damageNum">伤害值</param>
        /// <param name="targetProcess"></param>
        /// <param name="isAbility">是否是技能伤害</param>
        protected void DoTargetDefense(int damageNum, TargetProcess targetProcess, bool isAbility)
        {
            //城市公会争斗战疲劳值
            var fatigue = General.Fatigue * GameConfigSet.Fatigue;

            if (fatigue > 0 && General.UserStatus == UserStatus.FightCombat)
            {
                damageNum = (int)Math.Floor(damageNum * (MathUtils.Subtraction(1, fatigue)));
            }

            //生命低于x%,战力加成
            double inspire = (double)TrumpAbilityAttack.GetEffect(General, AbilityType.Furious);

            if (inspire > 0)
            {
                ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.Furious, 0));
                damageNum = (int)Math.Floor(damageNum * (1 + inspire));
            }

            //鼓舞加成伤害
            if (General.InspirePercent > 0)
            {
                damageNum = (int)Math.Floor(damageNum * (1 + General.InspirePercent));
            }

            //是否有爆击
            decimal baojiPercent;
            bool    isBaoji = General.TriggerBaojiPercent(TagetGeneral, out baojiPercent);

            ProcessLog.AddPercent(2, baojiPercent);
            if (isBaoji)
            {
                targetProcess.IsBaoji = true;
                damageNum             = (int)Math.Floor(damageNum * (1 + BaojiAttack + General.BishaNum));
                //暴击加成
                decimal baojiJiaCheng = TrumpAbilityAttack.GetEffect(General, AbilityType.BaoJiJiaCheng);
                if (baojiJiaCheng > 1)
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.BaoJiJiaCheng, 0));
                    damageNum = (int)Math.Floor(damageNum * baojiJiaCheng);
                }

                //被暴击减免
                decimal baoJiReduce = TrumpAbilityAttack.GetEffect(TagetGeneral, AbilityType.IsBaoJiReduce);
                if (baoJiReduce < 1 && baoJiReduce > 0)
                {
                    targetProcess.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.IsBaoJiReduce, 0));
                    damageNum = (int)Math.Floor(damageNum * baoJiReduce);
                }

                if (damageNum >= 0)
                {
                    damageNum = MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                }
                else
                {
                    damageNum = -MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                }
                //爆击职业加成气势
                CareerAdditionInfo addition = new ShareCacheStruct <CareerAdditionInfo>().FindKey(General.CareerID, AbilityType.BaoJi);
                if (addition != null && !isAbility)
                {
                    General.Momentum = MathUtils.Addition(General.Momentum, addition.MomentumNum.ToShort(), short.MaxValue);
                }
            }

            //排除静默和混乱不能触发格档
            bool isTriggerGedang = TagetGeneral.IsSilentStatus || TagetGeneral.IsHunluanStatus;


            //先触发绝对防御  法宝破盾技能为开启时触发绝对防御
            if (TagetGeneral.IsJueduifangyuStatus)
            {
                if (TrumpAbilityAttack.AttackPoDun(General, AbilityType.AttackPoDun))
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.AttackPoDun, 0));
                }
                else
                {
                    damageNum = JueduiDefenseDamage;
                }
            }
            else if (!isTriggerGedang)
            {
                //是否产生格挡[?]
                decimal gedangPercent;
                var     fangjiNum = 0;
                var     isGedang  = TagetGeneral.TriggerGeDangPercent(General, out gedangPercent);
                ProcessLog.AddPercent(3, gedangPercent);
                if (isGedang)
                {
                    targetProcess.IsMove   = TagetGeneral.IsAttrMove;
                    targetProcess.IsGeDang = true;
                    damageNum = (int)Math.Floor(damageNum * GedangAttackPercent);
                    if (damageNum >= 0)
                    {
                        damageNum = MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                    }
                    else
                    {
                        damageNum = -MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                    }
                    if (TagetGeneral.CareerType != CareerType.Mofashi &&
                        TagetGeneral.CareerType != CareerType.Shenqiangshou)
                    {
                        AbilityProperty property = General.AbilityProperty;
                        //普通攻击力的50%
                        int attackNum    = TagetGeneral.GetAttackNum(property);
                        int defenseNum   = General.GetDefenseNum(property, TagetGeneral);
                        int minDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));

                        fangjiNum = MathUtils.Subtraction(attackNum, defenseNum, 0);
                        fangjiNum = (int)Math.Floor(fangjiNum * GedangAttackPercent);
                        fangjiNum = MathUtils.Subtraction(fangjiNum, 0, minDamageNum);

                        //没死才可扣反击伤害
                        if (TagetGeneral.LifeNum > damageNum)
                        {
                            General.TriggerDamageNum(fangjiNum);
                            ProcessLog.DamageNum       += fangjiNum;
                            ProcessLog.LiveNum          = General.LifeNum;
                            ProcessLog.AttStatus        = General.BattleStatus;
                            targetProcess.IsBack        = true;
                            targetProcess.BackDamageNum = fangjiNum;
                        }
                    }

                    //格挡职业加成气势
                    if (!isAbility)
                    {
                        TagetGeneral.TriggerGeDang();
                    }
                }
            }
            //扣物理攻击伤害
            TagetGeneral.TriggerDamageNum(damageNum);
            targetProcess.DamageNum = damageNum;
            //解除静默状态
            TagetGeneral.RemoveSilentStatus();

            if (TagetGeneral.IsOver)
            {
                //复活
                decimal resurrect = TrumpAbilityAttack.GetEffect(TagetGeneral, AbilityType.Resurrect);
                if (resurrect > 0)
                {
                    targetProcess.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.Resurrect, -(int)Math.Floor(TagetGeneral.LifeMaxNum * resurrect)));
                    TagetGeneral.LifeNum = (int)Math.Floor(TagetGeneral.LifeMaxNum * resurrect);
                }
                else
                {
                    TrumpAbilityAttack.GeneralOverTrumpLift(TagetGeneral.UserID, TagetGeneral.GeneralID);  //佣兵战斗死亡扣除N点寿命
                    targetProcess.TrumpStatusList = new List <SkillInfo>();
                }
            }

            //记录日志
            targetProcess.TargetStatus = TagetGeneral.BattleStatus;
            targetProcess.Momentum     = TagetGeneral.Momentum;
            targetProcess.LiveNum      = TagetGeneral.LifeNum;
            TargetProcess = targetProcess;
        }
Exemple #9
0
        /// <summary>
        /// 计算技能伤害公式,不产生负数
        /// </summary>
        /// <param name="tagetGeneral"></param>
        /// <returns></returns>
        protected int GetAbilityDamageNum(CombatGeneral tagetGeneral)
        {
            string traceStr = string.Empty;
            int    damageNum;
            int    attackNum;
            int    defenseNum = 0;

            decimal         harmNum  = 0; //法宝属相克制伤害 --技能攻击
            AbilityProperty property = General.AbilityProperty;

            ProcessLog.AbilityProperty = property;
            attackNum = General.GetAttackNum(AbilityProperty.Ability) + General.GetAttackNum(property);
            if (tagetGeneral != null)
            {
                //法宝属相克制伤害 --技能攻击
                harmNum = TrumpAbilityAttack.TrumpZodiacHarm(General, tagetGeneral.UserID);

                defenseNum = tagetGeneral.GetDefenseNum(AbilityProperty.Ability, tagetGeneral) + tagetGeneral.GetDefenseNum(property, tagetGeneral);
            }
            General.MinDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));
            damageNum            = MathUtils.Subtraction(attackNum, defenseNum, General.MinDamageNum);

            decimal ratioNum = General.TempAbility.RatioNum > 0 ? General.TempAbility.RatioNum : 1;

            damageNum = (int)Math.Floor(damageNum * ratioNum); //计算伤害系数
            //气势加成=气势/{100-(气势-100)*2/3}*100%
            if (General != null)
            {
                var qishiNum = General.Momentum == 0 ? (short)100 : General.Momentum;
                traceStr += "qishiNum:" + qishiNum;
                decimal qishiPercent = (decimal)qishiNum / 100;
                traceStr += "qishiPercent:" + qishiNum;
                damageNum = (int)Math.Floor(damageNum * qishiPercent);
                traceStr += "damageNum:" + qishiNum;
                //加固定伤害
                damageNum = MathUtils.Addition(damageNum, General.FixedDamageNum, int.MaxValue);
                traceStr += "FixedDamageNum:" + qishiNum;
            }
            //技能伤害,负数是增加,
            //damageNum = General != null && General.Ability.IsIncrease ? -damageNum : damageNum;
            if (damageNum == 0)
            {
                new BaseLog().SaveLog(new Exception("释放技能:" + General.TempAbility.AbilityName + General.TempAbility.AbilityID + "伤害为0,Trace:" + traceStr));
            }
            if (damageNum < General.MinDamageNum)
            {
                damageNum = General.MinDamageNum;
            }
            //法宝属相克制伤害 --技能攻击
            if (!isharm && harmNum > 0)
            {
                damageNum = (int)(damageNum * MathUtils.Addition(1, harmNum));
                isharm    = true;
            }
            //魂技等级与自身魂技加成

            int     abilityID   = General.TempAbility != null ? General.TempAbility.AbilityID : 0;
            decimal effectValue = AbilityDispose.GetAbilityEffect(General.UserID, General.GeneralID, abilityID);

            if (effectValue > 0)
            {
                damageNum = MathUtils.ToCeilingInt(damageNum * MathUtils.Addition(1, (effectValue)));
            }
            return(damageNum);
        }
Exemple #10
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "AbilityID": return AbilityID;
             case "AbilityName": return AbilityName;
             case "AttackType": return AttackType;
             case "AbilityProperty": return AbilityProperty;
             case "AttackUnit": return AttackUnit;
             case "AttackTaget": return AttackTaget;
             case "RatioNum": return RatioNum;
             case "IsIncrease": return IsIncrease;
             case "HitPercent": return HitPercent;
             case "IsCorrect": return IsCorrect;
             case "IsIncreaseCorrect": return IsIncreaseCorrect;
             case "AbilityType": return AbilityType;
             case "BaseEffectNum": return BaseEffectNum;
             case "IncreaseNum": return IncreaseNum;
             case "EffectCount": return EffectCount;
             case "RatioIncreaseNum": return RatioIncreaseNum;
             case "EffectDesc": return EffectDesc;
             case "AbilityDesc": return AbilityDesc;
             case "IsMove": return IsMove;
             case "EffectID1": return EffectID1;
             case "EffectID2": return EffectID2;
             case "Version": return Version;
             case "AbilityStyle": return AbilityStyle;
             case "HeadID": return HeadID;
             case "DemandLv": return DemandLv;
             case "ChangeAbility": return ChangeAbility;
             case "AfterAbility": return AfterAbility;
             case "MaxHeadID": return MaxHeadID;
             case "Probability": return Probability;
             case "FntHeadID": return FntHeadID;
             case "IsActive": return IsActive;
             case "AbilityQuality": return AbilityQuality;
             default: throw new ArgumentException(string.Format("AbilityInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "AbilityID":
                 _AbilityID = value.ToInt();
                 break;
             case "AbilityName":
                 _AbilityName = value.ToNotNullString();
                 break;
             case "AttackType":
                 _AttackType = value.ToEnum<AttackType>();
                 break;
             case "AbilityProperty":
                 _AbilityProperty = value.ToEnum<AbilityProperty>();
                 break;
             case "AttackUnit":
                 _AttackUnit = value.ToEnum<AttackUnit>();
                 break;
             case "AttackTaget":
                 _AttackTaget = value.ToEnum<AttackTaget>();
                 break;
             case "RatioNum":
                 _RatioNum = value.ToDecimal();
                 break;
             case "IsIncrease":
                 _IsIncrease = value.ToBool();
                 break;
             case "HitPercent":
                 _HitPercent = value.ToDecimal();
                 break;
             case "IsCorrect":
                 _IsCorrect = value.ToBool();
                 break;
             case "IsIncreaseCorrect":
                 _IsIncreaseCorrect = value.ToBool();
                 break;
             case "AbilityType":
                 _AbilityType = value.ToNotNullString();
                 break;
             case "BaseEffectNum":
                 _BaseEffectNum = value.ToNotNullString();
                 break;
             case "IncreaseNum":
                 _IncreaseNum = value.ToNotNullString();
                 break;
             case "EffectCount":
                 _EffectCount = value.ToShort();
                 break;
             case "RatioIncreaseNum":
                 _RatioIncreaseNum = value.ToDecimal();
                 break;
             case "EffectDesc":
                 _EffectDesc = value.ToNotNullString();
                 break;
             case "AbilityDesc":
                 _AbilityDesc = value.ToNotNullString();
                 break;
             case "IsMove":
                 _IsMove = value.ToBool();
                 break;
             case "EffectID1":
                 _EffectID1 = value.ToNotNullString();
                 break;
             case "EffectID2":
                 _EffectID2 = value.ToNotNullString();
                 break;
             case "Version":
                 _Version = value.ToInt();
                 break;
             case "AbilityStyle":
                 _AbilityStyle = value.ToShort();
                 break;
             case "HeadID":
                 _HeadID = value.ToNotNullString();
                 break;
             case "DemandLv":
                 _DemandLv = value.ToShort();
                 break;
             case "ChangeAbility":
                 _ChangeAbility = value.ToEnum<AbilityType>();
                 break;
             case "AfterAbility": _AfterAbility = value.ToEnum<AbilityType>();
                 break;
             case "MaxHeadID":
                 _MaxHeadID = value.ToNotNullString();
                 break;
             case "Probability":
                 _Probability = value.ToDecimal();
                 break;
             case "FntHeadID":
                 _FntHeadID = value.ToNotNullString();
                 break;
             case "IsActive":
                 _IsActive = value.ToShort();
                 break;
             case "AbilityQuality":
                 _AbilityQuality = value.ToInt();
                 break;
             default: throw new ArgumentException(string.Format("AbilityInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Exemple #11
0
        public override bool Damage(AbilityProperty[] properties)
        {
            float previousHealth = currentHealth;

            float damageTaken = 0f;

            foreach (AbilityProperty property in properties)
            {
                // buff resistances
                AbilityProperty[][] buffResistance = buffs
                                                     .Where(buff => buff.buff is DefensiveBuff dfb && dfb.Properties.HasResistanceTo(property))
                                                     .Select(buff => ((DefensiveBuff)buff.buff).Properties).ToArray();

                float damage = buffResistance.SelectMany(abilityProperty => abilityProperty).Aggregate(property.Amount,
                                                                                                       (current, property1) => current - current * property1.Amount);

                // Armor resistances
                if (_playerInventory != null)
                {
                    AbilityProperty[][] armorResistance = _playerInventory.ArmorInventory.GetItemStacks()
                                                          .Where(stack =>
                                                                 !stack.IsEmpty && stack.Item is ArmorItem ai && ai.properties.HasResistanceTo(property))
                                                          .Select(stack => ((ArmorItem)stack.Item).properties).ToArray();

                    damage = armorResistance.SelectMany(abilityProperty => abilityProperty).Aggregate(damage,
                                                                                                      (current, property1) => current - current * property1.Amount);
                }

                // natural resistances
                AbilityProperty resistance = stats.Resistances.FirstOrDefault(p =>
                                                                              property.IsElemental ? p.Element == property.Element : p.AttackType == property.AttackType);

                damage -= damage * (resistance?.Amount ?? 0);


                damageTaken += damage;
            }

            currentHealth -= Random.Range(0, 100) <= 30 ? damageTaken * 2 : damageTaken;

            damageCoolDownActive = true;
            damageCoolDown       = Time.time + 0.6f;
            sp.color             = Color.red;

            if (!(currentHealth <= 0))
            {
                return(true);
            }

            if (godMode)
            {
                return(true);
            }

            IsDead = true;
            Die();

            StatisticsManager.Instance.AddFloatValue("Player.Damage Taken", previousHealth - currentHealth);

            return(true);
        }