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); }
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); }
private static IEnumerable <Unit> UnitsInBase(UnitType wantedType) => Game.Self.Units.Where(u => u.UnitType.Type == wantedType).Where(IsInBase);
public UnitExistsPrerequisite(UnitType unitType) { _unitType = unitType; }
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))); }
protected bool HasCompletedBuilding(UnitType buildingType) => OwnBuildings.Any(x => x.Is(buildingType) && x.IsCompleted);
public OrderIdleUnitsToAttack(UnitType unitType, int minCount, MapRegion basePosition) : base(basePosition) { _unitType = unitType; _minCount = minCount; }
public BuildingExistsPrerequisite(UnitType buildingType) { _buildingPrerequisite = buildingType; }