예제 #1
0
파일: Program.cs 프로젝트: Lat0ur/Ensage-
        private static Unit GetClosestCreep(CreepWaves creepWave)
        {
            float[] distance = { float.MaxValue };
            Unit    closest  = null;

            try
            {
                var creeps = creepWave.Creeps;
                foreach (var creep in creeps.Where(creep => creep.IsValidTarget() && distance[0] > creepWave.Illusion.Distance2D(creep.Position))
                         )
                {
                    distance[0] = creepWave.Illusion.Distance2D(creep.Position);
                    closest     = creep;
                }
                return(closest ?? ObjectManager
                       .GetEntities <Unit>(
                           ).Where(
                           x => x.IsAlive && x.IsVisible && x.IsValidTarget() && x.Team != _me.Team &&
                           (x.ClassID == ClassID.CDOTA_BaseNPC_Barracks ||
                            x.ClassID == ClassID.CDOTA_BaseNPC_Tower ||
                            x.ClassID == ClassID.CDOTA_BaseNPC_Building
                           ) && x.Distance2D(creepWave.Position) < 2000)
                       .OrderBy(x => x.Distance2D(creepWave.Illusion))
                       .DefaultIfEmpty(null)
                       .FirstOrDefault());
            }
            catch (Exception)
            {
                //
            }
            return(closest);
        }
예제 #2
0
파일: Program.cs 프로젝트: Lat0ur/Ensage-
        private static Vector3 GetNextWave(CreepWaves creepWave)
        {
            float[] distance = { float.MaxValue };
            var     p        = 0;
            var     coords   = creepWave.Coords.ToArray();

            for (var i = 0; i < coords.Length; i++)
            {
                if (coords[i].Distance2D(creepWave.Illusion.Position) < distance[0])
                {
                    distance[0] = coords[i].Distance2D(creepWave.Illusion.Position);
                    p           = i + 1 < coords.Length ? i + 1 : i;
                }
            }
            return(coords[p]);
        }
예제 #3
0
파일: Program.cs 프로젝트: Lat0ur/Ensage-
        private static Vector3 GetClosestWave(CreepWaves creepWave)
        {
            var pos = new Vector3();

            try
            {
                float[] distance = { float.MaxValue };
                foreach (var position in creepWave.Coords)
                {
                    if (!(position.Distance2D(creepWave.Position) < distance[0]))
                    {
                        continue;
                    }
                    distance[0] = position.Distance2D(creepWave.Position);
                    pos         = position;
                }
                return(pos);
            }
            catch (Exception)
            {
                Console.WriteLine("Error GetClosestWave");
            }
            return(pos);
        }