public List <Planet> GenerateMap(MapGenerationOption mapGeneration)
        {
            var planets = generators[mapGeneration]();

            planets.First().OwnerId = 1;
            planets.Last().OwnerId  = 2;

            return(planets);
        }
Exemplo n.º 2
0
 private static async Task StartAgent(int gameId, MapGenerationOption mapGeneration)
 {
     try
     {
         var agent = new Agent(gameId, mapGeneration);
         await agent.Start();
     }
     catch (Exception ex)
     {
         Console.WriteLine($"An error occured: {ex}");
     }
 }
        public Game(MapGenerationOption mapGeneration)
        {
            Id = _MAXID++;

            Turn      = 0;
            Running   = false;
            Waiting   = true;
            _gameLoop = new HighFrequencyTimer(60, this.Update);
            GenerateMap(mapGeneration);

            gameQuit = DateTime.UtcNow.AddMilliseconds(MAX_WAIT);
            UpdateTimeInfo(DateTime.UtcNow.AddMilliseconds(START_DELAY));
        }
        public AgentBase(string name, int gameId, MapGenerationOption mapGeneration)
        {
            Name          = name;
            GameId        = gameId;
            MapGeneration = mapGeneration;

            _client = new HttpClient()
            {
                BaseAddress = new Uri("http://localhost/PlanetWars/")
            };
            _client.DefaultRequestHeaders.Accept.Clear();
            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        }
        static void GenerateMap(IMapGenerator generator, MapGenerationOption options)
        {
            var map = generator.DefineMap(
                options.Diagonal,
                options.Width,
                options.Height,
                options.Seed,
                options.MinPathLength
                );


            FileTool.SaveFileFromMap(map, options.Filename, options.Directory);
        }
        public static int RunMapGeneration(MapGenerationOption options)
        {
            IMapGenerator generator;



            generator = options.PatternLength > 0 ?
                        MapGeneratorFactory.GetStandardMapGeneratorImplementation(options.PatternLength)
                            : MapGeneratorFactory.GetRandomMapGeneratorImplementation();

            if (options.Qtd > 0)
            {
                var filename = Path.GetFileName(options.Filename);
                var ext      = Path.GetExtension(options.Filename);


                if (string.IsNullOrEmpty(ext))
                {
                    ext = "txt";
                }

                for (int i = 0; i < options.Qtd; i++)
                {
                    options.Filename = i.ToString().PadLeft(options.Qtd.ToString().Length, '0') + filename + "." + ext;
                    GenerateMap(generator, options);
                    DrawTextProgressBar(i, options.Qtd);
                }
                DrawTextProgressBar(options.Qtd, options.Qtd);
            }
            else
            {
                GenerateMap(generator, options);
            }



            return(0);
        }
 public Agent(int gameId, MapGenerationOption mapGeneration) : base(TeamName, gameId, mapGeneration)
 {
 }
 private void GenerateMap(MapGenerationOption mapGeneration)
 {
     _planets = mapGenerator.GenerateMap(mapGeneration);
 }