Exemplo n.º 1
0
        private static void MorphLarvaInto(UnitType unitType)
        {
            var hatcheryWithMostLarvas = Game.Self.Units.Where(u => u.Is(UnitType.Zerg_Larva))
                                         .GroupBy(l => l.Hatchery)
                                         .Where(g => g.Key != null)
                                         .Where(g => g.Key.Exists).MaxBy(g => g.Key.Larva.Count).Key;

            var larva = hatcheryWithMostLarvas.Larva.FirstOrDefault();

            larva?.Morph(unitType);
        }
Exemplo n.º 2
0
        public int CompletionPercentage(UnitType ut)
        {
            var unitsOfType = Game.Self.Units.Where(u => u.Is(ut)).ToList();

            if (!unitsOfType.Any())
            {
                return(0);
            }
            var target = unitsOfType.First();

            if (target.IsCompleted)
            {
                return(100);
            }
            var buildTime     = UnitTypes.All[ut].Price.TimeFrames;
            var builtCurently = buildTime - target.RemainingBuildTime;
            var percentage    = (int)Math.Round((double)builtCurently / buildTime * 100);

            return(percentage);
        }
Exemplo n.º 3
0
 private static IEnumerable <Unit> UnitsInBase(UnitType wantedType) =>
 Game.Self.Units.Where(u => u.UnitType.Type == wantedType).Where(IsInBase);
 public UnitExistsPrerequisite(UnitType unitType)
 {
     _unitType = unitType;
 }
Exemplo n.º 5
0
        public bool HaveBuilding(UnitType ut)
        {
            var buildingOfType = Game.Self.Units.Where(u => u.UnitType.IsBuilding).Where(b => b.IsCompleted).ToList();

            return(buildingOfType.Any(b => b.Is(ut)));
        }
Exemplo n.º 6
0
 protected bool HasCompletedBuilding(UnitType buildingType) => OwnBuildings.Any(x => x.Is(buildingType) && x.IsCompleted);
Exemplo n.º 7
0
 public OrderIdleUnitsToAttack(UnitType unitType, int minCount, MapRegion basePosition) : base(basePosition)
 {
     _unitType = unitType;
     _minCount = minCount;
 }
 public BuildingExistsPrerequisite(UnitType buildingType)
 {
     _buildingPrerequisite = buildingType;
 }