private void OrderToStackOnMineral()
        {
            var averagePosition = MineralWorkers.ToList().AveragePosition();
            var closestMineral  = BaseMinerals.ClosestTo(averagePosition);

            MineralWorkers.ForEach(w => w.Gather(closestMineral, false));
        }
        private void AttackClosestEnemy()
        {
            var averagePosition = MineralWorkers.ToList().AveragePosition();
            var closestEnemy    = EnemiesNearWorkers.ClosestTo(averagePosition);

            MineralWorkers.ForEach(w => w.Attack(closestEnemy, false));
        }
Ejemplo n.º 3
0
        public override void Execute()
        {
            if (!HasCompletedBuilding(UnitType.Zerg_Extractor))
            {
                return;
            }

            var workersGatheringMinerals = MineralWorkers.ToList();
            var workersGatheringGas      = GasWorkers.ToList();

            var hasNotEnoughOnGas    = workersGatheringGas.Count < 3;
            var isMineralLineHealthy = workersGatheringMinerals.Count > 6;

            if (hasNotEnoughOnGas && isMineralLineHealthy)
            {
                GatherClosestGas(workersGatheringMinerals.First());
                return;
            }

            var hasTooManyOnGas      = workersGatheringGas.Count > 3;
            var isMineralLineStarved = workersGatheringMinerals.Count < 6;

            if (hasTooManyOnGas || isMineralLineStarved && workersGatheringGas.Any())
            {
                GatherClosestMineral(workersGatheringGas.First());
            }
        }
 private bool AreWorkersAttacking() => MineralWorkers.Any(w => w.IsAttacking);
        private bool AreWorkersStacked()
        {
            var averagePosition = MineralWorkers.ToList().AveragePosition();

            return(MineralWorkers.All(w => w.TilePosition.CalcApproximateDistance(averagePosition) <= 1));
        }
 private bool AreEnemiesInMineralLine() =>
 EnemiesNearWorkers.Any() && MineralWorkers.Any();
Ejemplo n.º 7
0
        protected Unit GetFreeWorker()
        {
            var freeWorkers = MineralWorkers.Where(x => !x.IsCarryingMinerals).Where(x => !x.IsGatheringGas);

            return(freeWorkers.FirstOrDefault() ?? OwnWorkers.FirstOrDefault(x => !x.IsGatheringGas) ?? OwnWorkers.First());
        }