예제 #1
0
        /// <summary>
        /// 造成伤害或治疗
        /// </summary>
        /// <param name="tarObj"></param>
        /// <param name="srcObj"></param>
        /// <param name="damage">大于0是伤害,小于0是治疗</param>
        public static void DamageTarget(SkillObj tarObj, SkillObj srcObj, Damage damage)
        {
            SkillObj realSrcObj = srcObj;
            if(tarObj == null || tarObj.IsDead())
            {
                return;
            }
            if(realSrcObj != null && damage.srcId > 0 && realSrcObj.GetID() != damage.srcId)
            {
                realSrcObj = tarObj.GetSkillObj(damage.srcId);
            }
            BattleModule.CalcDamage(tarObj, realSrcObj, damage);
            //先修正伤害
            BattleModule.DamageFix(tarObj, realSrcObj, damage);
            //质量和造成伤害都是这个
            //造成伤害
            if(damage.value >= 0)
            {
                tarObj.OnDamage(damage, realSrcObj);
            }
            else
            {
                tarObj.OnDamage(damage, realSrcObj);
            }
            //检查技能与BUFF的相应触发
            if (realSrcObj != null && !realSrcObj.IsDead())
            {
                var srcSkillList = realSrcObj.GetSkillList();
                var srcBuffList = realSrcObj.GetBuffList();
                //Source skill fix
                if (srcSkillList != null)
                {
                    foreach (var skillInfo in srcSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, realSrcObj);
                        int skillId = realSrcObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = realSrcObj.GetSkillConfig(skillId);
                            if (damage.value >= 0)
                            {
                                skillLogic.OnDamageTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig);
                            }
                            else
                            {
                                skillLogic.OnHealTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig);
                            }
                        }
                        else
                        {
                            realSrcObj.LogInfo("something error in BattleModule.DamageTarget src skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Source buff fix
                if (srcBuffList != null)
                {
                    foreach (var buffInfo in srcBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, realSrcObj);
                        int buffId = realSrcObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = realSrcObj.GetBuffConfig(buffId);
                            if (damage.value >= 0)
                            {
                                buffLogic.OnDamageTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig);
                            }
                            else
                            {
                                buffLogic.OnHealTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig);
                            }
                        }
                        else
                        {
                            realSrcObj.LogInfo("something error in BattleModule.DamageTarget src buff:[{0}]".F(buffId));
                        }
                    }
                }
            }

            var tarSkillList = tarObj.GetSkillList();
            var tarBuffList = tarObj.GetBuffList();
            //Target skill fix
            if(!tarObj.IsDead())
            {
                if (tarSkillList != null)
                {
                    foreach (var skillInfo in tarSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj);
                        int skillId = tarObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId);
                            if (damage.value >= 0)
                            {
                                skillLogic.OnBeHurt(tarObj, realSrcObj, damage, skillInfo, skillConfig);
                            }
                            else
                            {
                                skillLogic.OnBeHeal(tarObj, realSrcObj, damage, skillInfo, skillConfig);
                            }
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Target buff fix
                if (tarBuffList != null)
                {
                    foreach (var buffInfo in tarBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj);
                        int buffId = tarObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId);
                            if (damage.value >= 0)
                            {
                                buffLogic.OnBeHurt(tarObj, realSrcObj, damage, buffInfo, buffConfig);
                            }
                            else
                            {
                                buffLogic.OnBeHeal(tarObj, realSrcObj, damage, buffInfo, buffConfig);
                            }
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId));
                        }
                    }
                }
            }

            if (tarObj.IsDead())
            {
                if (tarSkillList != null)
                {
                    foreach (var skillInfo in tarSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj);
                        int skillId = tarObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId);
                            skillLogic.OnDie(tarObj, realSrcObj, skillInfo, skillConfig);
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Target buff fix
                if (tarBuffList != null)
                {
                    foreach (var buffInfo in tarBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj);
                        int buffId = tarObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId);
                            buffLogic.OnDie(tarObj, realSrcObj, buffInfo, buffConfig);
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId));
                        }
                    }
                }
                bool ret = tarObj.OnDie(realSrcObj);
            }
        }
예제 #2
0
        /// <summary>
        /// 造成伤害或治疗
        /// </summary>
        /// <param name="tarObj"></param>
        /// <param name="srcObj"></param>
        /// <param name="damage">大于0是伤害,小于0是治疗</param>
        public static void DamageTarget(SkillObj tarObj, SkillObj srcObj, Damage damage)
        {
            SkillObj realSrcObj = srcObj;

            if (tarObj == null || tarObj.IsDead())
            {
                return;
            }
            if (realSrcObj != null && damage.srcId > 0 && realSrcObj.GetID() != damage.srcId)
            {
                realSrcObj = tarObj.GetSkillObj(damage.srcId);
            }
            BattleModule.CalcDamage(tarObj, realSrcObj, damage);
            //先修正伤害
            BattleModule.DamageFix(tarObj, realSrcObj, damage);
            //质量和造成伤害都是这个
            //造成伤害
            if (damage.value >= 0)
            {
                tarObj.OnDamage(damage, realSrcObj);
            }
            else
            {
                tarObj.OnDamage(damage, realSrcObj);
            }
            //检查技能与BUFF的相应触发
            if (realSrcObj != null && !realSrcObj.IsDead())
            {
                var srcSkillList = realSrcObj.GetSkillList();
                var srcBuffList  = realSrcObj.GetBuffList();
                //Source skill fix
                if (srcSkillList != null)
                {
                    foreach (var skillInfo in srcSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, realSrcObj);
                        int        skillId    = realSrcObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = realSrcObj.GetSkillConfig(skillId);
                            if (damage.value >= 0)
                            {
                                skillLogic.OnDamageTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig);
                            }
                            else
                            {
                                skillLogic.OnHealTarget(realSrcObj, tarObj, damage, skillInfo, skillConfig);
                            }
                        }
                        else
                        {
                            realSrcObj.LogInfo("something error in BattleModule.DamageTarget src skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Source buff fix
                if (srcBuffList != null)
                {
                    foreach (var buffInfo in srcBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, realSrcObj);
                        int       buffId    = realSrcObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = realSrcObj.GetBuffConfig(buffId);
                            if (damage.value >= 0)
                            {
                                buffLogic.OnDamageTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig);
                            }
                            else
                            {
                                buffLogic.OnHealTarget(realSrcObj, tarObj, damage, buffInfo, buffConfig);
                            }
                        }
                        else
                        {
                            realSrcObj.LogInfo("something error in BattleModule.DamageTarget src buff:[{0}]".F(buffId));
                        }
                    }
                }
            }

            var tarSkillList = tarObj.GetSkillList();
            var tarBuffList  = tarObj.GetBuffList();

            //Target skill fix
            if (!tarObj.IsDead())
            {
                if (tarSkillList != null)
                {
                    foreach (var skillInfo in tarSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj);
                        int        skillId    = tarObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId);
                            if (damage.value >= 0)
                            {
                                skillLogic.OnBeHurt(tarObj, realSrcObj, damage, skillInfo, skillConfig);
                            }
                            else
                            {
                                skillLogic.OnBeHeal(tarObj, realSrcObj, damage, skillInfo, skillConfig);
                            }
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Target buff fix
                if (tarBuffList != null)
                {
                    foreach (var buffInfo in tarBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj);
                        int       buffId    = tarObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId);
                            if (damage.value >= 0)
                            {
                                buffLogic.OnBeHurt(tarObj, realSrcObj, damage, buffInfo, buffConfig);
                            }
                            else
                            {
                                buffLogic.OnBeHeal(tarObj, realSrcObj, damage, buffInfo, buffConfig);
                            }
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId));
                        }
                    }
                }
            }

            if (tarObj.IsDead())
            {
                if (tarSkillList != null)
                {
                    foreach (var skillInfo in tarSkillList)
                    {
                        SkillLogic skillLogic = GetSkillLogic(skillInfo, tarObj);
                        int        skillId    = tarObj.GetSkillID(skillInfo);
                        if (skillLogic != null)
                        {
                            SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId);
                            skillLogic.OnDie(tarObj, realSrcObj, skillInfo, skillConfig);
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar skill:[{0}]".F(skillId));
                        }
                    }
                }
                //Target buff fix
                if (tarBuffList != null)
                {
                    foreach (var buffInfo in tarBuffList)
                    {
                        BuffLogic buffLogic = GetBuffLogic(buffInfo, tarObj);
                        int       buffId    = tarObj.GetBuffID(buffInfo);
                        if (buffLogic != null)
                        {
                            BuffConfig_New buffConfig = tarObj.GetBuffConfig(buffId);
                            buffLogic.OnDie(tarObj, realSrcObj, buffInfo, buffConfig);
                        }
                        else
                        {
                            tarObj.LogInfo("something error in BattleModule.DamageTarget tar buff:[{0}]".F(buffId));
                        }
                    }
                }
                bool ret = tarObj.OnDie(realSrcObj);
            }
        }