Ejemplo n.º 1
0
 public void SendImpactToCharacter(CharacterInfo sender, int impactId, int targetId)
 {
     //LogSystem.Debug("character {0} send impact {1} to character {2}", sender.GetId(), impactId, targetId);
     if (null != sender)
     {
         CharacterInfo target = sender.SceneContext.GetCharacterInfoById(targetId);
         if (null != target)
         {
             ImpactLogicData impactLogicData = (ImpactLogicData)SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_IMPACT, impactId);
             if (null != impactLogicData)
             {
                 IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactLogicData.ImpactLogicId);
                 if (null != logic)
                 {
                     ImpactInfo impactInfo = new ImpactInfo();
                     impactInfo.m_IsActivated      = true;
                     impactInfo.m_ImpactId         = impactLogicData.ImpactId;
                     impactInfo.ConfigData         = impactLogicData;
                     impactInfo.m_StartTime        = TimeUtility.GetServerMilliseconds();
                     impactInfo.m_ImpactDuration   = impactLogicData.ImpactTime;
                     impactInfo.m_ImpactSenderId   = sender.GetId();
                     impactInfo.m_HasEffectApplyed = false;
                     target.GetSkillStateInfo().AddImpact(impactInfo);
                 }
             }
         }
     }
 }
        private void AppendDamage(CharacterInfo sender, CharacterInfo receiver, ImpactInfo impactInfo, int parentDamage)
        {
            if (sender == null || receiver == null || impactInfo == null)
            {
                return;
            }
            int       skillLevel = 0;
            bool      isCritical = false;
            bool      isOrdinary = false;
            SkillInfo skillInfo  = sender.GetSkillStateInfo().GetSkillInfoById(impactInfo.m_SkillId);

            if (null != skillInfo)
            {
                skillLevel = skillInfo.SkillLevel;
                if (skillInfo.Category == SkillCategory.kAttack)
                {
                    isOrdinary = true;
                }
            }
            ElementDamageType element_type = (ElementDamageType)impactInfo.ConfigData.ElementType;

            if (ElementDamageType.DC_None == element_type)
            {
                element_type = sender.GetEquipmentStateInfo().WeaponDamageType;
            }
            int appendDamage = (int)(impactInfo.ConfigData.DamageRate * parentDamage + impactInfo.ConfigData.DamageValue);

            if (appendDamage <= 0)
            {
                return;
            }
            int curDamage = DamageCalculator.CalcImpactDamage(sender, receiver,
                                                              (SkillDamageType)impactInfo.ConfigData.DamageType,
                                                              element_type,
                                                              0,
                                                              appendDamage,
                                                              out isCritical);
            List <ImpactInfo> impactInfos = receiver.GetSkillStateInfo().GetAllImpact();

            for (int i = 0; i < impactInfos.Count; i++)
            {
                IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactInfos[i].ConfigData.ImpactLogicId);
                if (null != logic)
                {
                    curDamage = logic.RefixHpDamage(receiver, impactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, receiver.GetId());
                }
            }

            /*
             * foreach (ImpactInfo ii in receiver.GetSkillStateInfo().GetAllImpact()) {
             * IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(ii.ConfigData.ImpactLogicId);
             * if (null != logic) {
             *  curDamage = logic.RefixHpDamage(receiver, ii.m_ImpactId, curDamage, sender.GetId(), ref isCritical, receiver.GetId());
             * }
             * }*/
            OnCharacterDamage(sender, receiver, curDamage, isCritical, isOrdinary);
        }
Ejemplo n.º 3
0
        public IImpactLogic GetImpactLogic(int id)
        {
            IImpactLogic logic = null;

            if (m_ImpactLogics.ContainsKey(id))
            {
                logic = m_ImpactLogics[id];
            }
            return(logic);
        }
Ejemplo n.º 4
0
 private void OnAddImpact(CharacterInfo target, int impactId)
 {
     foreach (ImpactInfo info in target.GetSkillStateInfo().GetAllImpact())
     {
         if (info.m_ImpactId != impactId)
         {
             IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(info.ConfigData.ImpactLogicId);
             if (null != logic)
             {
                 logic.OnAddImpact(target, info.m_ImpactId, impactId);
             }
         }
     }
 }
Ejemplo n.º 5
0
        private bool StopImpactImpl(CharacterInfo target, int impactId)
        {
            ImpactInfo impactInfo = target.GetSkillStateInfo().GetImpactInfoById(impactId);

            if (null != impactInfo)
            {
                IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactInfo.ConfigData.ImpactLogicId);
                if (null != logic && logic.CanInterrupt(target, impactId))
                {
                    logic.OnInterrupted(target, impactId);
                    impactInfo.m_IsActivated = false;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 6
0
        public void Tick(CharacterInfo obj)
        {
            List <ImpactInfo> impactInfos = obj.GetSkillStateInfo().GetAllImpact();
            int ct = impactInfos.Count;

            for (int i = ct - 1; i >= 0; --i)
            {
                ImpactInfo   info  = impactInfos[i];
                IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(info.ConfigData.ImpactLogicId);
                if (info.m_IsActivated)
                {
                    if (null != logic)
                    {
                        logic.Tick(obj, info.m_ImpactId);
                    }
                }
                else
                {
                    obj.GetSkillStateInfo().RemoveImpact(info.m_ImpactId);
                }
            }
        }
Ejemplo n.º 7
0
        public void Tick(CharacterInfo obj)
        {
            List <ImpactInfo> impactInfos = obj.GetSkillStateInfo().GetAllImpact();
            int ct = impactInfos.Count;

            for (int i = ct - 1; i >= 0; --i)
            {
                ImpactInfo   info  = impactInfos[i];
                IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(info.ConfigData.ImpactLogicId);
                if (info.m_IsActivated)
                {
                    if (null != logic)
                    {
                        logic.Tick(obj, info.m_ImpactId);
                    }
                }
                else
                {
                    logic.OnInterrupted(obj, info.m_ImpactId);
                    obj.GetSkillStateInfo().RemoveImpact(info.m_ImpactId);
                }
            }
            obj.GetSkillStateInfo().CleanupImpactInfoForCheck(TimeUtility.GetServerMilliseconds(), 5000);//用于校验的impact比正常时间晚5秒清除
        }
Ejemplo n.º 8
0
        protected void ApplyDamageImpl(CharacterInfo sender, CharacterInfo obj, ImpactInfo impactInfo, out int damage, bool is_ignore_passive_check = false)
        {
            damage = 0;
            int  skillLevel = 0;
            bool isCritical = false;
            bool isOrdinary = false;

            if (null != sender)
            {
                SkillInfo skillInfo = sender.GetSkillStateInfo().GetSkillInfoById(impactInfo.m_SkillId);
                if (null != skillInfo)
                {
                    skillLevel = skillInfo.SkillLevel;
                    if (skillInfo.Category == SkillCategory.kAttack)
                    {
                        isOrdinary = true;
                    }
                }
                float old_critical = 0;
                bool  is_adjusted  = AdjustCritical(sender, out old_critical);
                int   curDamage    = DamageCalculator.CalcImpactDamage(
                    sender,
                    obj,
                    (SkillDamageType)impactInfo.ConfigData.DamageType,
                    ElementDamageType.DC_None == (ElementDamageType)impactInfo.ConfigData.ElementType ? sender.GetEquipmentStateInfo().WeaponDamageType : (ElementDamageType)impactInfo.ConfigData.ElementType,
                    impactInfo.ConfigData.DamageRate + skillLevel * impactInfo.ConfigData.LevelRate,
                    impactInfo.ConfigData.DamageValue,
                    out isCritical);
                if (is_adjusted)
                {
                    //LogSystem.Error("----critical: reset critical to {0}", old_critical);
                    sender.GetActualProperty().SetCritical(Operate_Type.OT_Absolute, old_critical);
                }
                curDamage = TalentAdjustDamage(sender, obj, curDamage);
                List <ImpactInfo> targetImpactInfos = obj.GetSkillStateInfo().GetAllImpact();
                for (int i = 0; i < targetImpactInfos.Count; i++)
                {
                    if (is_ignore_passive_check && targetImpactInfos[i].m_ImpactType == (int)ImpactType.PASSIVE)
                    {
                        continue;
                    }
                    IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(obj.GetSkillStateInfo().GetAllImpact()[i].ConfigData.ImpactLogicId);
                    if (null != logic)
                    {
                        curDamage = logic.RefixHpDamage(obj, targetImpactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, obj.GetId());
                    }
                }

                /*
                 * foreach (ImpactInfo ii in obj.GetSkillStateInfo().GetAllImpact()) {
                 * if (is_ignore_passive_check && ii.m_ImpactType == (int)ImpactType.PASSIVE) {
                 *  continue;
                 * }
                 * IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(ii.ConfigData.ImpactLogicId);
                 * if (null != logic) {
                 *  curDamage = logic.RefixHpDamage(obj, ii.m_ImpactId, curDamage, sender.GetId(), ref isCritical, obj.GetId());
                 * }
                 * }*/
                if (!is_ignore_passive_check)
                {
                    List <ImpactInfo> senderImpactInfos = sender.GetSkillStateInfo().GetAllImpact();
                    for (int i = 0; i < senderImpactInfos.Count; i++)
                    {
                        if (senderImpactInfos[i].m_ImpactType == (int)ImpactType.PASSIVE)
                        {
                            IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(senderImpactInfos[i].ConfigData.ImpactLogicId);
                            if (null != logic)
                            {
                                curDamage = logic.RefixHpDamage(obj, senderImpactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, sender.GetId());
                            }
                        }
                    }

                    /*
                     * foreach (ImpactInfo passive_impact in sender.GetSkillStateInfo().GetAllImpact()) {
                     * if (passive_impact.m_ImpactType == (int)ImpactType.PASSIVE) {
                     *  IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(passive_impact.ConfigData.ImpactLogicId);
                     *  if (null != logic) {
                     *    curDamage = logic.RefixHpDamage(obj, passive_impact.m_ImpactId, curDamage, sender.GetId(), ref isCritical, sender.GetId());
                     *  }
                     * }
                     * }*/
                }
                damage = curDamage;
                OnCharacterDamage(sender, obj, curDamage, isCritical, isOrdinary);
            }
        }
Ejemplo n.º 9
0
        private bool SendImpactImpl(CharacterInfo sender, int impactId, int targetId, int skillId, int duration)
        {
            //LogSystem.Debug("character {0} send impact {1} to character {2}", sender.GetId(), impactId, targetId);
            if (null != sender)
            {
                CharacterInfo target = sender.SceneContext.GetCharacterInfoById(targetId);
                if (null != target)
                {
                    if (target.IsUser && target.IsDead())
                    {
                        return(false);
                    }
                    if (target.IsNpc && target.IsDead())
                    {
                        NpcInfo npc = target.CastNpcInfo();
                        if ((int)NpcTypeEnum.SceneObject == npc.NpcType)
                        {
                            return(false);
                        }
                    }
                    ImpactLogicData impactLogicData = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_IMPACT, impactId) as ImpactLogicData;
                    if (null != impactLogicData)
                    {
                        IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactLogicData.ImpactLogicId);
                        if (null != logic)
                        {
                            ImpactInfo oldImpactInfo = target.GetSkillStateInfo().GetImpactInfoById(impactId);
                            if (null != oldImpactInfo)
                            {
                                logic.OnInterrupted(target, impactId);
                                target.GetSkillStateInfo().RemoveImpact(impactId);
                            }
                            ImpactInfo impactInfo = new ImpactInfo();
                            impactInfo.m_IsActivated    = true;
                            impactInfo.m_SkillId        = skillId;
                            impactInfo.m_ImpactId       = impactLogicData.ImpactId;
                            impactInfo.m_ImpactType     = impactLogicData.ImpactType;
                            impactInfo.m_BuffDataId     = impactLogicData.BuffDataId;
                            impactInfo.ConfigData       = impactLogicData;
                            impactInfo.m_StartTime      = TimeUtility.GetServerMilliseconds();
                            impactInfo.m_ImpactDuration = impactLogicData.ImpactTime;
                            if (-1 == duration || duration > impactLogicData.ImpactTime)
                            {
                                impactInfo.m_ImpactDuration = impactLogicData.ImpactTime;
                            }
                            else
                            {
                                impactInfo.m_ImpactDuration = duration;
                            }
                            impactInfo.m_HasEffectApplyed = false;
                            if (0 == impactInfo.ConfigData.ImpactGfxLogicId)
                            {
                                impactInfo.m_IsGfxControl = false;
                            }
                            else
                            {
                                impactInfo.m_IsGfxControl = true;
                            }
                            impactInfo.m_ImpactSenderId  = sender.GetId();
                            impactInfo.m_MaxMoveDistance = impactLogicData.CalcMaxMoveDistance();
                            if (impactLogicData.ImpactGfxLogicId == 0)
                            {
                                impactInfo.m_LeftEnableMoveCount = 0;//禁止位移
                            }
                            else
                            {
                                impactInfo.m_LeftEnableMoveCount = 1;//允许位移
                            }

                            //LogSystem.Warn("impact {0} EnableMoveCount {1} MaxMoveDistanceSqr {2}", impactId, impactInfo.m_LeftEnableMoveCount, impactInfo.m_MaxMoveDistanceSqr);

                            target.GetSkillStateInfo().AddImpact(impactInfo);
                            logic.StartImpact(target, impactId);

                            if ((int)ImpactType.INSTANT == impactInfo.m_ImpactType)
                            {
                                impactInfo.m_IsActivated = false;
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }