Exemplo n.º 1
0
        private void Cleanup(Bot bot)
        {
            HashSet <ulong> unburrowedMines = new HashSet <ulong>();

            foreach (Unit enemy in bot.Enemies())
            {
                if (enemy.UnitType == UnitTypes.WIDOW_MINE)
                {
                    unburrowedMines.Add(enemy.Tag);
                }
            }

            for (int i = Mines.Count - 1; i >= 0; i--)
            {
                UnitLocation mine = Mines[i];
                if (unburrowedMines.Contains(mine.Tag))
                {
                    Remove(i);
                    continue;
                }
                bool removed = false;
                foreach (Agent agent in bot.UnitManager.Agents.Values)
                {
                    if (agent.Unit.DetectRange <= 1)
                    {
                        continue;
                    }

                    if (agent.DistanceSq(mine.Pos) <= agent.Unit.DetectRange * agent.Unit.DetectRange - 4)
                    {
                        Remove(i);
                        removed = true;
                        break;
                    }
                }
                if (removed)
                {
                    continue;
                }
                foreach (SC2APIProtocol.Effect effect in bot.Observation.Observation.RawData.Effects)
                {
                    if (effect.EffectId != 6)
                    {
                        continue;
                    }
                    if (SC2Util.DistanceSq(effect.Pos[0], mine.Pos) <= 8 * 8)
                    {
                        Remove(i);
                        removed = true;
                        break;
                    }
                }
                if (removed)
                {
                    continue;
                }
            }
        }
Exemplo n.º 2
0
        private void Cleanup(Bot bot)
        {
            HashSet <ulong> unsiegedTanks = new HashSet <ulong>();

            foreach (Unit enemy in bot.Enemies())
            {
                if (enemy.UnitType == UnitTypes.SIEGE_TANK)
                {
                    unsiegedTanks.Add(enemy.Tag);
                }
            }

            for (int i = Tanks.Count - 1; i >= 0; i--)
            {
                UnitLocation tank = Tanks[i];
                if (unsiegedTanks.Contains(tank.Tag))
                {
                    Remove(i);
                    continue;
                }
                bool removed = false;
                foreach (Agent agent in bot.UnitManager.Agents.Values)
                {
                    float sightRange = UnitTypes.LookUp[agent.Unit.UnitType].SightRange;
                    if (agent.DistanceSq(tank.Pos) <= sightRange * sightRange - 4)
                    {
                        Remove(i);
                        removed = true;
                        break;
                    }
                }
                if (removed)
                {
                    continue;
                }
            }
        }