Ejemplo n.º 1
0
        public async Task CreateGame(String mapName, Race opponentRace, Difficulty opponentDifficulty)
        {
            RequestCreateGame createGame = new RequestCreateGame();

            createGame.Realtime = false;

            string mapPath = Path.Combine(starcraftDir, "maps", mapName);

            if (!File.Exists(mapPath))
            {
                throw new Exception("Could not find map at " + mapPath);
            }
            createGame.LocalMap         = new LocalMap();
            createGame.LocalMap.MapPath = mapPath;

            PlayerSetup player1 = new PlayerSetup();

            createGame.PlayerSetup.Add(player1);
            player1.Type = PlayerType.Participant;

            PlayerSetup player2 = new PlayerSetup();

            createGame.PlayerSetup.Add(player2);
            player2.Race       = opponentRace;
            player2.Type       = PlayerType.Computer;
            player2.Difficulty = opponentDifficulty;

            Request request = new Request();

            request.CreateGame = createGame;
            Response response = await proxy.SendRequest(request);
        }
        private async Task CreateGame(string mapName, Race opponentRace, Difficulty opponentDifficulty)
        {
            var createGame = new RequestCreateGame();

            createGame.Realtime = false;

            var mapPath = Path.Combine(starcraftMaps, mapName);

            if (!File.Exists(mapPath))
            {
                Logger.Info("Unable to locate map: " + mapPath);
                throw new Exception("Unable to locate map: " + mapPath);
            }

            createGame.LocalMap         = new LocalMap();
            createGame.LocalMap.MapPath = mapPath;

            var player1 = new PlayerSetup();

            createGame.PlayerSetup.Add(player1);
            player1.Type = PlayerType.Participant;

            var player2 = new PlayerSetup();

            createGame.PlayerSetup.Add(player2);
            player2.Race       = opponentRace;
            player2.Type       = PlayerType.Computer;
            player2.Difficulty = opponentDifficulty;

            var request = new Request();

            request.CreateGame = createGame;
            var response = await proxy.SendRequest(request);
        }
Ejemplo n.º 3
0
        public async Task CreateGame(string mapName, Race opponentRace, Difficulty opponentDifficulty)
        {
            RequestCreateGame createGame = new RequestCreateGame
            {
                Realtime = false,
                LocalMap = new LocalMap {
                    MapPath = mapName
                }
            };


            var player1 = new PlayerSetup();

            createGame.PlayerSetup.Add(player1);
            player1.Type = PlayerType.Participant;

            var player2 = new PlayerSetup();

            createGame.PlayerSetup.Add(player2);
            player2.Race       = opponentRace;
            player2.Type       = PlayerType.Computer;
            player2.Difficulty = opponentDifficulty;

            Request request = new Request {
                CreateGame = createGame
            };
            Response response = await proxy.SendRequest(request);
        }
Ejemplo n.º 4
0
        private async Task CreateGame(string mapName, Race opponentRace, Difficulty opponentDifficulty)
        {
            var createGame = new RequestCreateGame();

            createGame.Realtime = false;

            var mapPath = Path.Combine(starcraftMaps, mapName);

            if (!File.Exists(mapPath))
            {
                Logger.Info("Unable to locate map: " + mapPath);
                throw new Exception("Unable to locate map: " + mapPath);
            }

            createGame.LocalMap         = new LocalMap();
            createGame.LocalMap.MapPath = mapPath;

            var player1 = new PlayerSetup();

            createGame.PlayerSetup.Add(player1);
            player1.Type = PlayerType.Participant;

            var player2 = new PlayerSetup();

            createGame.PlayerSetup.Add(player2);
            player2.Race       = opponentRace;
            player2.Type       = PlayerType.Computer;
            player2.Difficulty = opponentDifficulty;

            var request = new Request();

            request.CreateGame = createGame;
            var response = CheckResponse(await proxy.SendRequest(request));

            if (response.CreateGame.Error != ResponseCreateGame.Types.Error.Unset)
            {
                Logger.Error("CreateGame error: {0}", response.CreateGame.Error.ToString());
                if (!String.IsNullOrEmpty(response.CreateGame.ErrorDetails))
                {
                    Logger.Error(response.CreateGame.ErrorDetails);
                }
            }
        }
Ejemplo n.º 5
0
        public async Task CreateGame()
        {
            var createGame = new RequestCreateGame
            {
                Realtime = true
            };

            var mapPath = Path.Combine(@"C:\Program Files (x86)\StarCraft II\Maps", "AcropolisLE.SC2Map");

            if (!File.Exists(mapPath))
            {
                Console.WriteLine("Unable to locate map: " + mapPath);
                throw new Exception("Unable to locate map: " + mapPath);
            }

            createGame.LocalMap = new LocalMap {
                MapPath = mapPath
            };

            var player1 = new PlayerSetup();

            createGame.PlayerSetup.Add(player1);
            player1.Type = PlayerType.Participant;

            var player2 = new PlayerSetup();

            createGame.PlayerSetup.Add(player2);
            player2.Race       = Race.Terran;
            player2.Type       = PlayerType.Computer;
            player2.Difficulty = Difficulty.VeryEasy;

            var request = new Request();

            request.CreateGame = createGame;
            await _connectionService.SendRequestAsync(request);

            Console.WriteLine("request sent");
        }