Ejemplo n.º 1
0
        public Point2D FindPartialWallPylonPlacement(WallData wallData)
        {
            if (wallData.Pylons == null)
            {
                return(null);
            }
            var unitData       = SharkyUnitData.BuildingData[UnitTypes.PROTOSS_PYLON];
            var pylonRadius    = (unitData.Size / 2f) - .00000f;
            var existingPylons = ActiveUnitData.SelfUnits.Values.Where(u => u.Unit.UnitType == (uint)UnitTypes.PROTOSS_PYLON);

            foreach (var pylon in wallData.Pylons)
            {
                if (!existingPylons.Any(e => e.Position.X == pylon.X && e.Position.Y == pylon.Y) && Buildable(pylon, pylonRadius))
                {
                    return(pylon);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public Point2D FindPartialWallProductionPlacement(WallData wallData, float size, float maxDistance)
        {
            if (wallData.WallSegments == null)
            {
                return(null);
            }
            var existingBuildings = ActiveUnitData.SelfUnits.Values.Where(u => u.Attributes.Contains(Attribute.Structure));
            var radius            = (size / 2f);
            var powerSources      = ActiveUnitData.Commanders.Values.Where(c => c.UnitCalculation.Unit.UnitType == (uint)UnitTypes.PROTOSS_PYLON && c.UnitCalculation.Unit.BuildProgress == 1).Where(c => Vector2.DistanceSquared(c.UnitCalculation.Position, new Vector2(wallData.Pylons.FirstOrDefault().X, wallData.Pylons.FirstOrDefault().Y)) < 15 * 15);

            foreach (var segment in wallData.WallSegments.Where(w => w.Size == size))
            {
                var point = segment.Position;
                if (!existingBuildings.Any(e => e.Position.X == point.X && e.Position.Y == point.Y) && Buildable(point, radius) && Powered(powerSources, point, radius))
                {
                    return(point);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
 public Point2D FindFullWallProductionPlacement(WallData wallData, float size, float maxDistance)
 {
     return(FindPartialWallProductionPlacement(wallData, size, maxDistance));
 }
Ejemplo n.º 4
0
 public Point2D FindFullWallPylonPlacement(WallData wallData)
 {
     return(FindPartialWallPylonPlacement(wallData));
 }