Beispiel #1
0
        //Buff所在场景,承受者,Buff实例,触发点,特定参数(伤害值,治疗值),另一个个Obj参数(释放者,击杀者等等不一定)
        public void DoBuff(Scene scene,
                           ObjCharacter obj,
                           BuffData buff,
                           int delayView,
                           eEffectEventType eventType,
                           int Param             = 0,
                           ObjCharacter otherObj = null,
                           int checkParam        = 0)
        {
            if (null == buff)
            {
                return;
            }

            if (!buff.GetActive())
            {
                return; //没有激活的Buff不生效
            }
            if (!buff.IsCoolDown())
            {
                return;
            }
            //该BUFF产生的伤害统计
            var thisbuffdamage = new Dictionary <int, int>();
            //该BuFF产生的治疗统计
            var thisbuffhealth = new Dictionary <int, int>();
            //该BuFF产生的回蓝统计
            var thisbuffmana = new Dictionary <int, int>();
            var tb_buff      = buff.mBuff;

            for (var j = 0; j != tb_buff.effectid.Length; ++j)
            {
                if (!CheckEffectOk(buff, obj, eventType, j, checkParam))
                {
                    continue;
                }

                //执行BUFF效果需要
                switch ((eEffectType)tb_buff.effectid[j])
                {
                case eEffectType.DoDamage:
                {
                    BuffEffect.DO_DAMAGE(thisbuffdamage, scene, obj, buff, j, CheckEventResetHitType(eventType));
                }
                break;

                case eEffectType.DoHealth:
                {
                    BuffEffect.DO_HEALTH(thisbuffhealth, scene, obj, buff, j, CheckEventResetHitType(eventType));
                }
                break;

                case eEffectType.RefAttr:
                    BuffEffect.REF_ATTR(scene, obj, buff, j);
                    break;

                case eEffectType.PositionChange:
                    BuffEffect.POSITION_CHANGE(scene, obj, buff, j);
                    break;

                case eEffectType.ProAddBuff:
                    BuffEffect.PRO_ADD_BUFF(scene, obj, buff, j);
                    break;

                case eEffectType.DamageHealth:
                {
                    if (Param > 0)
                    {
                        BuffEffect.DAMAGE_HEALTH(scene, obj, Param, buff, j);
                    }
                }
                break;

                case eEffectType.DispelBuff:
                {
                    BuffEffect.DispelBuff(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.SpecialState:
                {
                    BuffEffect.SPEIALSTATE(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.CreateMonsterType1:
                {
                    BuffEffect.CREATER_MONSTER1TYPE(scene, obj, buff, j);
                }
                break;

                case eEffectType.ModifySkill:
                {
                    BuffEffect.NO_MODIFYSKILL(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.ModifyBuff:
                {
                    BuffEffect.NO_MODIFYBUFF(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.ModifyModel:
                {
                    BuffEffect.NO_MODIFYMODEL(eventType, obj, buff);
                }
                break;

                case eEffectType.CreateMonster:
                {
                    BuffEffect.CREATER_MONSTER(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.ExpModify:
                {
                    BuffEffect.EXP_MODIFY(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.ExpModify2:
                {
                    BuffEffect.EXP_MODIFY2(eventType, scene, obj, buff, j);
                }
                break;

                case eEffectType.DoMana:
                {
                    BuffEffect.DO_MANA(thisbuffmana, scene, obj, buff, j, CheckEventResetHitType(eventType));
                }
                break;

                case eEffectType.KillSelf:
                {
                    BuffEffect.Kill_SELF(scene, obj, buff, j);
                }
                break;

                case eEffectType.DoSkill:
                {
                    BuffEffect.DoSkill(scene, obj, otherObj, buff, j);
                }
                break;

                case eEffectType.HpInRangeTriggerBuff:
                {
                    BuffEffect.HP_TRIGGER_ADDBUFF(scene, obj, buff, j);
                }
                break;

                case eEffectType.AddExp:
                {
                    BuffEffect.EXP_ADD(eventType, scene, obj, buff, j);
                    break;
                }
                }

                buff.AddCoolDownTime();
            }

            CalcAttrDamage(thisbuffdamage, buff);

            if (thisbuffdamage.Count > 0 || thisbuffhealth.Count > 0 || thisbuffmana.Count > 0)
            {
                var caster = buff.GetCaster();
                if (caster != null)
                {
                    var replyMsg = new BuffResultMsg();
                    //发送伤害
                    foreach (var thisdamage in thisbuffdamage)
                    {
                        var damagevalue  = thisdamage.Value;
                        var absorbDamage = 0;
                        obj.DoDamage(eHitType.Hit, buff, caster, delayView, ref damagevalue, thisdamage.Key, ref absorbDamage);

                        //if (absorbDamage > 0)
                        //{ // 吸收
                        //    replyMsg.buff.Add(new BuffResult
                        //    {
                        //        SkillObjId = caster.ObjId,
                        //        TargetObjId = obj.ObjId,
                        //        BuffTypeId = buff.GetBuffId(),
                        //        Type = BuffType.HT_NODAMAGE,
                        //        Damage = damagevalue,
                        //        ViewTime = Extension.AddTimeDiffToNet(delayView)
                        //    });
                        //}

                        if (damagevalue > 0)
                        {
                            if (thisdamage.Key == (int)eDamageType.FireAttr)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Fire_DAMAGE, delayView);
                                replyMsg.buff.Add(result);
                                continue;
                            }
                            else if (thisdamage.Key == (int)eDamageType.IceAttr)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Ice_DAMAGE, delayView);
                                replyMsg.buff.Add(result);
                                continue;
                            }
                            else if (thisdamage.Key == (int)eDamageType.PoisonAttr)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Poison_DAMAGE, delayView);
                                replyMsg.buff.Add(result);
                                continue;
                            }

                            CauseCrit.DoEffect(scene, caster, buff, damagevalue);
                            WasCrit.DoEffect(scene, obj, buff, damagevalue);
                            //Logger.Info("伤害类型:{0},伤害值:{1}", thisdamage.Key, damagevalue);
                            if (buff.m_HitType == eHitType.Hit)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_NORMAL, delayView);
                                replyMsg.buff.Add(result);
                            }
                            else if (buff.m_HitType == eHitType.Lucky)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_CRITICAL, delayView);
                                replyMsg.buff.Add(result);
                            }
                            else if (buff.m_HitType == eHitType.Excellent)
                            {
                                var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_EXCELLENT, delayView);
                                replyMsg.buff.Add(result);
                            }
                            //击中回复生效
                            var HitRecoveryValue = caster.GetAttribute(eAttributeType.HitRecovery);
                            if (HitRecoveryValue > 0)
                            {
                                var healthvalue = HitRecoveryValue;
                                caster.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, 8);
                                //Logger.Info("治疗类型:{0},治疗值:{1}",8, healthvalue);
                                var nowHp = caster.GetAttribute(eAttributeType.HpNow);
                                if (scene != null && scene.isNeedDamageModify)
                                {
                                    if (Scene.IsNeedChangeHp(caster) != null)
                                    {
                                        nowHp = (int)(nowHp / scene.BeDamageModify);
                                    }
                                }
                                replyMsg.buff.Add(new BuffResult
                                {
                                    SkillObjId  = caster.ObjId,
                                    TargetObjId = caster.ObjId,
                                    BuffTypeId  = buff.GetBuffId(),
                                    Type        = BuffType.HT_HEALTH,
                                    Damage      = healthvalue,
                                    ViewTime    = Extension.AddTimeDiffToNet(delayView),
                                    Param       = { 0, nowHp }
                                });
                            }
                            //本Buff的吸血效果(给释放方的)
                            for (var j = 0; j != tb_buff.effectid.Length; ++j)
                            {
                                if (tb_buff.effectid[j] == 18 && tb_buff.effectparam[j, 1] == 0) //有吸血效果,并且是释放者
                                {
                                    BuffEffect.DAMAGE_HEALTH(scene, obj, damagevalue, buff, j, thisbuffhealth);
                                }
                            }
                            //伤害反弹
                            if (thisdamage.Key != (int)eDamageType.Rebound && thisdamage.Key != (int)eDamageType.Blood)
                            {
                                var DamageReboundValue = obj.GetAttribute(eAttributeType.DamageReboundPro);
                                if (DamageReboundValue > 0)
                                {
                                    var damageReboundValue = damagevalue * DamageReboundValue / 10000;
                                    if (damageReboundValue > 0)
                                    {
                                        //caster.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, 8);
                                        caster.DoRealDamage(eHitType.Hit, buff, obj, delayView, ref damageReboundValue,
                                                            (int)eDamageType.Rebound);
                                        //Logger.Info("伤害类型:{0},伤害值:{1}", eDamageType.Rebound, damageReboundValue);
                                        var nowHp = caster.GetAttribute(eAttributeType.HpNow);
                                        if (scene != null && scene.isNeedDamageModify)
                                        {
                                            if (Scene.IsNeedChangeHp(caster) != null)
                                            {
                                                nowHp = (int)(nowHp / scene.BeDamageModify);
                                            }
                                        }
                                        replyMsg.buff.Add(new BuffResult
                                        {
                                            SkillObjId  = obj.ObjId,
                                            TargetObjId = caster.ObjId,
                                            BuffTypeId  = buff.GetBuffId(),
                                            Type        = BuffType.HT_REBOUND,
                                            Damage      = damageReboundValue,
                                            ViewTime    = Extension.AddTimeDiffToNet(delayView),
                                            Param       = { 0, nowHp }
                                        });
                                    }
                                }
                            }
                        }
                        else if (absorbDamage <= 0)
                        {
//免疫
                            replyMsg.buff.Add(new BuffResult
                            {
                                SkillObjId  = caster.ObjId,
                                TargetObjId = obj.ObjId,
                                BuffTypeId  = buff.GetBuffId(),
                                Type        = BuffType.HT_NODAMAGE,
                                Damage      = damagevalue,
                                ViewTime    = Extension.AddTimeDiffToNet(delayView)
                            });
                        }
                    }
                    //发送治疗
                    foreach (var thishealth in thisbuffhealth)
                    {
                        if (obj.GetAttribute(eAttributeType.HpNow) == obj.GetAttribute(eAttributeType.HpMax))
                        {
                            continue;
                        }
                        var healthvalue = thishealth.Value;
                        obj.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, thishealth.Key);
                        //Logger.Info("治疗类型:{0},治疗值:{1}", thishealth.Key, healthvalue);
                        var nowHp = obj.GetAttribute(eAttributeType.HpNow);
                        if (scene != null && scene.isNeedDamageModify)
                        {
                            if (Scene.IsNeedChangeHp(obj) != null)
                            {
                                nowHp = (int)(nowHp / scene.BeDamageModify);
                            }
                        }
                        replyMsg.buff.Add(new BuffResult
                        {
                            SkillObjId  = caster.ObjId,
                            TargetObjId = obj.ObjId,
                            BuffTypeId  = buff.GetBuffId(),
                            Type        = BuffType.HT_HEALTH,
                            Damage      = healthvalue,
                            ViewTime    = Extension.AddTimeDiffToNet(delayView),
                            Param       = { 0, nowHp }
                        });
                    }

                    //发送回蓝
                    foreach (var thishealth in thisbuffmana)
                    {
                        var healthvalue = thishealth.Value;
                        obj.DoMana(eHitType.Hit, buff, caster, ref healthvalue, thishealth.Key);
                        //Logger.Info("回蓝类型:{0},回蓝值:{1}", thishealth.Key, healthvalue);
                        replyMsg.buff.Add(new BuffResult
                        {
                            SkillObjId  = caster.ObjId,
                            TargetObjId = obj.ObjId,
                            BuffTypeId  = buff.GetBuffId(),
                            Type        = BuffType.HT_MANA,
                            Damage      = healthvalue,
                            ViewTime    = Extension.AddTimeDiffToNet(delayView)
                        });
                    }
                    obj.BroadcastBuffList(replyMsg);
                }
            }
        }