/// <summary> /// Generate bases and their positions. /// </summary> private void GenerateBases() { bases.Clear(); int tileSize = AIFramework.Bot.Game.Tile.TILE_SIZE_IN_PIXELS; int mapWidth = (int)CurrentMap.Width; int mapHeight = (int)CurrentMap.Height; const int EVENT_ID_MINIMUM = 8; const int EVENT_ID_MAXIMUM = 13; int basesFound = 0; for (int y = 0; y < mapHeight; ++y) { for (int x = 0; x < mapWidth; ++x) { AIFramework.Bot.Game.Tile tile = CurrentMap.GetTile(x, y); if (tile.EventID >= EVENT_ID_MINIMUM && tile.EventID <= EVENT_ID_MAXIMUM) { // Found base tile. ++basesFound; Point position = new Point(x * tileSize + (tileSize / 2), -(y * tileSize + (tileSize / 2))); GameSession.Alliance team = tile.EventID > 10 ? GameSession.Alliance.RED : GameSession.Alliance.BLUE; Base nextBase = new Base(tile.EventID, position, team); bases[nextBase.BaseID] = nextBase; } if (basesFound == BASE_COUNT) goto done; } } done: if (basesFound != BASE_COUNT) { Console.Error.WriteLine("[WARNING] Bases found = {0}", basesFound); } DetectAttackableBases(); }
/// <summary> /// See if the given player can attack the given base. /// </summary> /// <param name="b"></param> /// <param name="player"></param> /// <returns></returns> public bool IsBaseAttackable(Base b, AIFramework.Bot.Game.Player player) { if (b.Team != player.Team) { bool inContention = false; int id = b.BaseID; if (player.Team == GameSession.Alliance.RED && id == blueAttackableBaseID) inContention = true; else if (player.Team == GameSession.Alliance.BLUE && id == redAttackableBaseID) inContention = true; return inContention; } return false; }