/// <summary> /// Get a path ideal to the current state and current game mode. /// </summary> /// <returns></returns> public Path GetIdealPath(VTankBot bot, Player player) { if (refreshSpawnPointList) { RefreshSpawnPointList(); } Path path = null; if (State == BotState.SEEK_AND_DESTROY) { path = GetSeekAndDestroyPath(player); } else if (State == BotState.COMPLETE_OBJECTIVE) { GameModeHandler handler = bot.Game.GameModeHandler; if (handler is CaptureTheBaseMode) { const int RANGE_MINIMUM = 50; CaptureTheBaseMode mode = (CaptureTheBaseMode)handler; Base targetBase = mode.GetAttackableBase(player); if (targetBase != null) { Point p1 = player.GetPosition(); Point p2 = targetBase.GetPosition(); double distance = GetDistance(p1, p2); if (distance > RANGE_MINIMUM) { int tilePositionX = (int)Math.Round((p2.x)); int tilePositionY = (int)Math.Round(-(p2.y)); TileNode node = new TileNode(tilePositionX, tilePositionY); path = PathFinder.FindPath(CurrentMap, player, node.X, node.Y); } } } // TODO: CTF. else { path = GetSeekAndDestroyPath(player); } } if (spawnPointIndex >= spawnPointList.Count) { spawnPointIndex = 0; } return(path); }
/// <summary> /// Get a list of targets available from the current game mode, if there are any. /// </summary> /// <returns></returns> private List <ITarget> GetGameModeTargets() { List <ITarget> results = new List <ITarget>(); GameModeHandler handler = Game.GameModeHandler; if (handler != null && handler is CaptureTheBaseMode) { CaptureTheBaseMode mode = (CaptureTheBaseMode)handler; Base b = mode.GetAttackableBase(Player); if (b != null) { results.Add(b); } } return(results); }