예제 #1
0
        public void RemoveSkill(int nSkillID)
        {
            if (!HasSkill(nSkillID))
            {
                return;
            }

            GSkillSpellLogic pSpellLogic = GetSkill(nSkillID);

            if (pSpellLogic == null)
            {
                return;
            }

            //停止施法
            if (pSpellLogic == m_pSpellLogic)
            {
                FinishSkill();
            }

            RemoveSubSkill(pSpellLogic);

            //刷新属性集
            TryCalculateAttribute(pSpellLogic);
            //移除被动技能
            RemovePassiveSkill(pSpellLogic);

            ReferencePool.Release(pSpellLogic);
            m_SkillLogicDict.Remove(nSkillID);
        }
예제 #2
0
        //创建技能
        private GSkillSpellLogic CreateSkill(GSkillInitParam initParam)
        {
            if (!Owner)
            {
                return(null);
            }

            if (initParam == null ||
                initParam.m_pOwner == null ||
                initParam.m_pSkillData == null)
            {
                return(null);
            }

            int nLogicID = initParam.m_pSkillData.MSV_SpellLogic;
            GSkillSpellLogic pSpellLogic = GSkillLogicManager.Instance.CreateSpellLogic(nLogicID);

            if (pSpellLogic == null)
            {
                return(null);
            }

            if (!pSpellLogic.Init(initParam))
            {
                ReferencePool.Release(pSpellLogic);
                return(null);
            }
            return(pSpellLogic);
        }
예제 #3
0
 private void AddPassiveSkill(GSkillSpellLogic pSpellLogic)
 {
     if (pSpellLogic == null)
     {
         return;
     }
     m_PassiveTempList.Add(pSpellLogic);
 }
예제 #4
0
        //移除技能触发
        private void RemoveTriggerSkill(GSkillSpellLogic pTriggerLogic)
        {
            if (pTriggerLogic == null || pTriggerLogic.m_pSkillData == null)
            {
                return;
            }

            int nType = pTriggerLogic.m_pSkillData.MSV_TriggerType;

            if (nType >= 0 && nType < (int)eTriggerNotifyType.NotifyType_Count)
            {
                m_TriggerSkillList[nType].Remove(pTriggerLogic);
            }
        }
예제 #5
0
        //获取技能,如果不是实例技能,返回模版技能
        public DRSkillData GetSkillData(int nSkillID)
        {
            GSkillSpellLogic pSpellLogic = GetSkill(nSkillID);

            if (pSpellLogic != null)
            {
                return(pSpellLogic.m_pSkillData);
            }

            DRSkillData pSkillData = GameEntry.DataTable.GetDataTable <DRSkillData>().GetDataRow(nSkillID);

            if (pSkillData != null && pSkillData.IsTemplateSkill())
            {
                return(pSkillData);
            }

            return(null);
        }
예제 #6
0
        //移除子技能
        private void RemoveSubSkill(GSkillSpellLogic pSpellLogic)
        {
            if (pSpellLogic == null)
            {
                return;
            }

            List <int> pSkillList = GSkillDataManager.Instance.GetSubSkillList(pSpellLogic.GetSkillID());

            if (pSkillList == null)
            {
                return;
            }

            foreach (var item in pSkillList)
            {
                RemoveSkill(item);
            }
        }
예제 #7
0
        //增加技能
        public bool AddSkill(int nSkillID /*, int nSlots = 0*/)
        {
            if (!Owner)
            {
                return(false);
            }
            DRSkillData pSkillData = GameEntry.DataTable.GetDataTable <DRSkillData>().GetDataRow(nSkillID);

            if (pSkillData == null)
            {
                return(false);
            }

            if (HasSkill(nSkillID))
            {
                return(false);
            }

            GTargetInfo sTarInfo = new GTargetInfo();

            sTarInfo.m_nTargetID = Owner.Id;
            sTarInfo.m_vSrcPos   = Owner.GetPos();
            sTarInfo.m_vAimDir   = Owner.GetDir();
            sTarInfo.m_vTarPos   = Owner.GetPos();

            GSkillInitParam  param       = new GSkillInitParam(Owner, sTarInfo, pSkillData);
            GSkillSpellLogic pSpellLogic = CreateSkill(param);

            if (pSpellLogic == null)
            {
                return(false);
            }

            m_SkillLogicDict.Add(nSkillID, pSpellLogic);
            if (pSkillData.IsPassiveSkill() && !pSkillData.IsBuffSkill())
            {
                AddPassiveSkill(pSpellLogic);
                TryCalculateAttribute(pSpellLogic);
            }

            AddSubSkill(pSpellLogic);
            return(true);
        }
예제 #8
0
        //增加子技能
        private void AddSubSkill(GSkillSpellLogic pSpellLogic)
        {
            if (pSpellLogic == null)
            {
                return;
            }

            List <int> pSkillList = GSkillDataManager.Instance.GetSubSkillList(pSpellLogic.GetSkillID());

            if (pSkillList == null)
            {
                return;
            }

            //todo 技能修正
            //int nSlots = pSpellLogic.GetSkillSlots();
            foreach (var item in pSkillList)
            {
                AddSkill(item /*, nSlots*/);
            }
        }
예제 #9
0
 //移除被动技能
 private void RemovePassiveSkill(GSkillSpellLogic pSpellLogic)
 {
     m_PassiveList.Remove(pSpellLogic);
     m_PassiveTempList.Remove(pSpellLogic);
     RemoveTriggerSkill(pSpellLogic);
 }
 public void TryCalculateAttribute(GSkillSpellLogic pSpellLogic)
 {
 }
예제 #11
0
        //使用技能
        public bool SpellSkill(int nSkillID, GTargetInfo sTarInfo)
        {
            if (Owner == null)
            {
                return(false);
            }

            GSkillSpellLogic pSpellLogic = GetSkill(nSkillID);

            if (pSpellLogic == null)
            {
                DRSkillData skillData = GameEntry.DataTable.GetDataTable <DRSkillData>().GetDataRow(nSkillID);
                if (skillData != null && skillData.IsTemplateSkill())
                {
                    if (AddSkill(nSkillID))
                    {
                        pSpellLogic = GetSkill(nSkillID);
                    }
                }
            }
            if (pSpellLogic == null)
            {
                return(false);
            }

            DRSkillData pSkillData = pSpellLogic.m_pSkillData;

            if (pSkillData == null)
            {
                return(false);
            }

            if (!CanSpellSkill(pSkillData, sTarInfo))
            {
                return(false);
            }

            if (m_pSpellLogic != null)
            {
                FinishSkill();
            }

            if (!pSpellLogic.SetFSMState())
            {
                return(false);
            }

            //初始化施法逻辑
            m_pSpellLogic = pSpellLogic;

            m_pSpellLogic.Reset();
            if (sTarInfo.m_vAimDir == default(Vector3))
            {
                sTarInfo.m_vAimDir = Owner.GetDir();
            }

            m_pSpellLogic.m_TargetInfo = sTarInfo;

            m_pSpellLogic.ResetSkillAValue();

            if (!pSkillData.IsEffectStateCost())
            {
                DoCost(pSkillData);
                StartCD(pSkillData, true);
                //todo 允许部分技能在生效时产生消耗
                //m_pSpellLogic.SetCosted();
            }

            m_pSpellLogic.ReInit();
            sTarInfo = m_pSpellLogic.m_TargetInfo;

            Log.Debug("Avatar'{0}' Skill'{1}' Spell", Owner.Id, nSkillID);

            //产生技能事件
            if (pSkillData.IsTriggerSkillNotify())
            {
                PushTriggerNotify(nSkillID, sTarInfo.m_nTargetID,
                                  (int)eTriggerNotifyType.NotifyType_Skill,
                                  (int)eTriggerNotify.TriggerNotify_SkillStart, 0,
                                  sTarInfo.m_vSrcPos, sTarInfo.m_vTarPos, sTarInfo.m_vAimDir);
            }

            //执行瞬发效果
            m_pSpellLogic.Tick(0);
            return(true);
        }