コード例 #1
0
 public static bool UpdatePathsIfPossible(this GameLevel gameLevel)
 {
     for (int i = 0; i < gameLevel.SpawnPoints.Count; i++)
     {
         for (int j = 0; j < gameLevel.GoalPoints.Count; j++)
         {
             var list = gameLevel.GetPath(gameLevel.SpawnPoints[i], gameLevel.GoalPoints[j]);
             if (list.GetListOfCoordinates().Count == 0)
             {
                 return(false);
             }
             var storedPaths = gameLevel.GetStoredPaths();
             storedPaths[i * gameLevel.SpawnPoints.Count + j] = list;
         }
     }
     gameLevel.UpdateTracers();
     return(true);
 }
コード例 #2
0
        private static bool IsTherePossibleExitPath(this GameLevel gameLevel, Creep creep)
        {
            var isThereWay = false;

            for (int i = 0; i < gameLevel.GoalPoints.Count; i++)
            {
                var list =
                    gameLevel.GetPath(creep.Position.GetVector2D(), gameLevel.GoalPoints[i]).
                    GetListOfCoordinates();
                if (list.Count == 0)
                {
                    continue;
                }
                creep.Path        = list.Select(element => element + Vector2D.Half).ToList();
                creep.FinalTarget = creep.Path[creep.Path.Count - 1];
                isThereWay        = true;
                break;
            }
            return(isThereWay);
        }