Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
        }