Exemple #1
0
        public bool SpellSkill()
        {
            if (Owner == null || Owner.SkillCom == null)
            {
                return(false);
            }
            if (!CanSpellSkill())
            {
                return(false);
            }

            int    nTarget = pMonster.ThreatCom.GetTarget();
            Avatar pTarget = GameEntry.Entity.GetGameEntity(nTarget) as Avatar;

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

            GTargetInfo sTarInfo = new GTargetInfo
            {
                m_nTargetID = pTarget.Id,
                m_vSrcPos   = Owner.GetPos(),
                m_vTarPos   = pTarget.GetPos(),
                m_vAimDir   = (pTarget.GetPos() - Owner.GetPos()).normalized2d()
            };

            bool bResult = Owner.SkillCom.SpellSkill(m_nNextSkill, sTarInfo);

            GetNextSkill();
            return(bResult);
        }
Exemple #2
0
        public override bool UseSkill()
        {
            GTargetInfo sTarInfo = SetDefaultTargetInfo();

            if (m_pSkillData == null || sTarInfo == null)
            {
                return(false);
            }

            if (m_pSkillData.IsTargetSelfOnly())
            {
                sTarInfo.m_nTargetID = Owner.Id;
                sTarInfo.m_vSrcPos   = Owner.GetPos();
                sTarInfo.m_vAimDir   = Owner.GetDir();
                sTarInfo.m_vTarPos   = Owner.GetPos();
            }
            else if (m_pSkillData.IsTargetAvatar() || m_pSkillData.IsTargetPos())
            {
                Avatar pTarget = Owner.AimCom.GetTarget();
                if (pTarget == null)
                {
                    return(false);
                }

                sTarInfo.m_nTargetID = pTarget.Id;
                sTarInfo.m_vSrcPos   = Owner.GetPos();
                sTarInfo.m_vTarPos   = pTarget.GetPos();
                sTarInfo.m_vAimDir   = (pTarget.GetPos() - Owner.GetPos()).normalized2d();
            }
            else if (m_pSkillData.IsTargetDir())
            {
                return(false);
            }
            return(Owner.SkillCom.SpellSkill(m_pSkillData.Id, sTarInfo));
        }
            protected override void OnUpdate(StateOwner pAvatar, float elapseSeconds, float realElapseSeconds)
            {
                base.OnUpdate(pAvatar, elapseSeconds, realElapseSeconds);

                int nTarget = pAvatar.Owner.ThreatCom.GetTarget();

                if (nTarget != m_Target.Id)
                {
                    m_Target = GameEntry.Entity.GetGameEntity(nTarget) as Avatar;
                }

                if (m_Target == null || !pAvatar.Owner.IsFight)
                {
                    ChangeState <AIState_Idle>(pAvatar);
                    return;
                }

                if (m_Target.GetPos().Distance2D(pAvatar.Owner.GetPos()) <= m_SkillRange)
                {
                    ChangeState <AIState_Combat>(pAvatar);
                }

                m_fTimer -= elapseSeconds;
                if (m_fTimer <= 0)
                {
                    m_fTimer = m_fChaseTickTime;
                    pAvatar.Owner.MoveToPoint(m_Target.GetPos());
                }
            }
        public bool CheckTarget(DRSkillData pSkillData, Avatar pCaster, int nTargetID)
        {
            Avatar pTarget = GameEntry.Entity.GetGameEntity(nTargetID) as Avatar;

            if (!pTarget)
            {
                return(false);
            }

            int nTarCheck = pSkillData.MSV_TarCheck;

            if (nTarCheck > 0)
            {
                //todo 条件检查组
                //SDConditionParamAvatar sParam;
                //sParam.ParamAvatar = pCaster;
                //if(!GSKillConditionCheckManager::Instance().Check(nTarCheck, pTarget, &sParam))
                //	return false;
            }

            float fRange = pSkillData.MSV_Range;

            if (fRange > 0)
            {
                float fDistance = pCaster.GetPos().Distance2D(pTarget.GetPos());
                if (fDistance > fRange + 0.5f)
                {
                    return(false);
                }
            }

            return(true);
        }
        //检查目标
        public bool CheckTarget(DRSkillData pSkillData, Avatar pCaster, GTargetInfo sTarInfo)
        {
            if (pSkillData == null || !pCaster)
            {
                return(false);
            }

            //检查目标条件
            if (pSkillData.IsTargetAvatar())
            {
                if (!CheckTarget(pSkillData, pCaster, sTarInfo.m_nTargetID))
                {
                    return(false);
                }
            }
            else if (pSkillData.IsTargetPos())
            {
                float fRange = pSkillData.MSV_Range;
                if (fRange > 0)
                {
                    float fDistance = pCaster.GetPos().Distance2D(sTarInfo.m_vTarPos);
                    if (fDistance > fRange + 0.5f)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemple #6
0
        public bool CanSpellSkill(DRSkillData pSkillData, GTargetInfo sTarInfo)
        {
            Avatar pCaster = Owner;

            if (!pCaster || pSkillData == null)
            {
                return(false);
            }

            if (!pSkillData.IsActiveSkill())
            {
                return(false);
            }

            //检查当前施放技能
            if (m_pSpellLogic != null && m_pSpellLogic.IsLock())
            {
                return(false);
            }

            //检查消耗
            if (!CheckCost(pSkillData))
            {
                return(false);
            }
            //检查CD
            if (!CheckCD(pSkillData))
            {
                return(false);
            }

            //检查施法者位置
            if (pCaster.GetPos().Distance2D(sTarInfo.m_vSrcPos) > 64.0f)
            {
                return(false);
            }

            //自身检查
            int nSrvCheck = pSkillData.MSV_SrcCheck;

            if (nSrvCheck > 0)
            {
                //todo 添加条件检查组后修复
                //if(!GSKillConditionCheckManager::Instance().Check(nSrvCheck, pCaster))
                //	return false;
            }

            //目标检查
            if (!GSkillLogicManager.Instance.CheckTarget(pSkillData, pCaster, sTarInfo))
            {
                return(false);
            }

            return(true);
        }
Exemple #7
0
        public bool CanSpellSkill()
        {
            if (pMonster == null)
            {
                return(false);
            }

            int    nTarget = pMonster.ThreatCom.GetTarget();
            Avatar pTarget = GameEntry.Entity.GetGameEntity(nTarget) as Avatar;

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

            return(pTarget.GetPos().Distance2D(pMonster.GetPos()) <= GetNextSkillRange());
        }
Exemple #8
0
        private void TickEntities()
        {
            IEntityGroup group = GameEntry.Entity.GetEntityGroup(Constant.Entity.MonsterGroupName);

            if (group == null)
            {
                return;
            }
            IEntity[] list = group.GetAllEntities();
            if (list == null || list.Length == 0)
            {
                return;
            }

            m_TargetList.Clear();
            foreach (var item in list)
            {
                Avatar actor = GameEntry.Entity.GetGameEntity(item.Id) as Avatar;
                if (actor == null || actor.IsDead)
                {
                    continue;
                }

                if (AIUtility.GetRelation(Owner.Camp, actor.Camp) != RelationType.Hostile)
                {
                    continue;
                }

                Vector3 vOffestPos = actor.GetPos() - Owner.GetPos();
                vOffestPos.y = 0;
                float fMagnitude = vOffestPos.magnitude + 0.5f;

                // 排除最远距离外的目标
                if (fMagnitude > 25f)
                {
                    continue;
                }

                m_TargetList.Add(actor);
            }
        }
        public bool CheckNotify(GTriggerNotify pNotify)
        {
            if (!m_pOwner || m_pSkillData == null || pNotify == null)
            {
                return(false);
            }

            Avatar pCaster = GetCaster();

            if (!pCaster || !pCaster.SkillCom)
            {
                return(false);
            }

            if (m_pSkillData.IsTargetSelfOnly())
            {
                m_TargetInfo.m_nTargetID = pCaster.Id;
                m_TargetInfo.m_vSrcPos   = pCaster.GetPos();
                m_TargetInfo.m_vTarPos   = pCaster.GetPos();
                m_TargetInfo.m_vAimDir   = pCaster.GetDir();
            }
            else
            {
                m_TargetInfo.m_nTargetID = pNotify.m_nTargetID;
                m_TargetInfo.m_vTarPos   = pNotify.m_vTarPos;
                m_TargetInfo.m_vSrcPos   = pNotify.m_vSrcPos;
                if (pNotify.m_vDir == default(Vector3))
                {
                    m_TargetInfo.m_vAimDir = m_TargetInfo.m_vTarPos - m_TargetInfo.m_vSrcPos;
                }
                else
                {
                    m_TargetInfo.m_vAimDir = pNotify.m_vDir;
                }
                m_TargetInfo.m_vAimDir.Normalize2D();
            }

            //检查cd与消耗
            if (!m_pOwner.CDCom || m_pOwner.CDCom.CheckCD(m_pSkillData.MSV_CDGroup))
            {
                return(false);
            }
            if (!pCaster.SkillCom.CheckCost(m_pSkillData))
            {
                return(false);
            }

            if (!pNotify.CheckTrigger(pCaster, m_pSkillData))
            {
                return(false);
            }

            //if(m_pBuff && m_pBuff->IsInvalid())
            //	return false;

            if (!PassiveProcessCheck())
            {
                return(false);
            }

            return(true);
        }
        public override List <Avatar> GetTargetList(DRSkillData pSkillData,
                                                    Avatar pCaster, GTargetInfo sTarInfo, HashSet <int> vExcludeList)
        {
            List <Avatar> vTargetList = new List <Avatar>();

            if (pSkillData == null || !pCaster)
            {
                return(vTargetList);
            }
            Avatar pTarget = GameEntry.Entity.GetGameEntity(sTarInfo.m_nTargetID) as Avatar;

            if (!pTarget)
            {
                pTarget = pCaster;
            }

            int   cnt    = GetTargetCount(pSkillData /*, vExcludeList*/);
            int   filter = pSkillData.MSV_AreaFilter;
            float minDis = pSkillData.MSV_AreaParam1;
            float maxDis = pSkillData.MSV_AreaParam2;
            float w      = pSkillData.MSV_AreaParam3;

            List <UnityGameFramework.Runtime.Entity> pList = new List <UnityGameFramework.Runtime.Entity>();

            GameEntry.Entity.GetAllLoadedEntities(pList);
            if (pList == null || pList.Count == 0)
            {
                return(vTargetList);
            }
            Vector3 pos    = /*pSkillData.IsAreaUseTarPos() ? sTarInfo.m_vTarPos :*/ sTarInfo.m_vSrcPos;
            Vector3 dir    = sTarInfo.m_vAimDir;
            Vector3 center = pos + dir * ((minDis + maxDis) / 2);

            SRect sRect = new SRect(center, maxDis - minDis, w);

            foreach (var item in pList)
            {
                Avatar actor = item.Logic as Avatar;
                if (actor == null || actor == pCaster)
                {
                    continue;
                }
                SSphere sTarSphere = new SSphere(actor.GetPos(), actor.ModelRadius);
                if (GCollider.RectCollideCheck(sRect, sTarSphere, dir))
                {
                    TryAddTarget(pSkillData, pCaster, actor, vExcludeList);
                    if (vTargetList.Count >= cnt)
                    {
                        if (filter > 0)
                        {
                            UpdateAreaFilter(filter, cnt, vTargetList);
                        }
                        else
                        {
                            return(vTargetList);
                        }
                    }
                    break;
                }
            }
            return(vTargetList);
        }
Exemple #11
0
        public override int AimAssist(DRSkillData pSkillData, Avatar pOwner)
        {
            if (pOwner == null)
            {
                return(0);
            }
            Vector3 vPos = pOwner.GetPos();
            Vector3 vDir = GameEntry.CameraMgr.GetCamDir().normalized2d();

            float fMinActorWeight = 3600000;
            int   nAvatarID       = 0;

            IEntity[] list = GetEnemyGroup(pOwner.Camp);
            if (list == null || list.Length == 0)
            {
                return(0);
            }

            foreach (IEntity item in list)
            {
                Avatar actor = GameEntry.Entity.GetGameEntity(item.Id) as Avatar;
                if (actor == null || actor.IsDead)
                {
                    continue;
                }

                if (AIUtility.GetRelation(pOwner.Camp, actor.Camp) != RelationType.Hostile)
                {
                    continue;
                }

                Vector3 vOffestPos = actor.GetPos() - vPos;
                vOffestPos.y = 0;
                float fMagnitude = vOffestPos.magnitude + 0.5f;

                // 排除最远距离外的目标
                if (fMagnitude > GetMaxRange(pSkillData))
                {
                    continue;
                }

                //计算各个角度的权重  以距离为权重
                float fCurActorWeight;
                float angle = Vector3.Angle(vDir, vOffestPos);
                if (angle <= 45f)
                {
                    fCurActorWeight = 9000 + fMagnitude;
                }
                else if (angle > 45f && angle < 90f)
                {
                    fCurActorWeight = 18000 + fMagnitude;
                }
                else
                {
                    fCurActorWeight = 36000 + fMagnitude;
                }

                if (fCurActorWeight < fMinActorWeight)
                {
                    fMinActorWeight = fCurActorWeight;
                    nAvatarID       = actor.Id;
                }
            }
            return(nAvatarID != 0 ? nAvatarID : 0);
        }