public IHttpActionResult CreateGameWithEmptyMap(CreateGameMessage msg) { var gameHost = new GameHost(this.WarsimUser, msg.Title, msg.Description, msg.Password); this._mapRepo.CreateMap(gameHost.Map, true); this.GameManager.StartGame(gameHost); return(this.Ok(gameHost.Id)); }
private void HandlerGameCreatedMessage(CreateGameMessage createGameMessage) { Application.Current.Dispatcher.Invoke(delegate { clientLogic.Client.OnReceiveMessageEvent -= ReceivedMessageFromClient; var mainViewModel = new MainViewModel2(_login, createGameMessage.GameId, clientLogic); mainViewModel.Window.Show(); Window.Close(); }); }
public void CreateGame() { // user input InputField newGameNameInput = GameObject.Find("CreateGameInputField").GetComponent <InputField>(); string newGameName = newGameNameInput.text; Debug.Log("CreateGameInputField is: " + newGameName); CreateGameMessage msg = new CreateGameMessage(); msg.game_name = newGameName; gameConnection.sendJSON(msg); }
private static void Create_game_with_new_map_and_join() { WaitFor("Create game"); var postData = new CreateGameMessage { Title = "Wut a game", Password = "******" }; var result = HttpRequestHelper.PostAsync("http://127.0.0.1:4321/api/game/create/empty", postData, Token).Result; var gameId = JsonConvert.DeserializeObject <Guid>(result.Content.ReadAsStringAsync().Result); WaitFor("Join game"); var gameWebSocket = new WebSocketClient($"ws://127.0.0.1:6789/Game?auth_token={Token}&game_id={gameId}&game_password=123"); gameWebSocket.Connect(); WaitFor("Listen to game updates"); UdpGameClient.RegisterOnGameStateChangeListener((message, time) => { Console.WriteLine($"Scene update: {message.SceneObjects.Count} objects"); }); UdpGameClient.StartListening(); WaitFor("Send game update"); var gameUpdate = new UpdatedGameStateMessage { GameId = gameId, UserToken = Token, UpdatedSceneObjects = MapTests.GetNodes() }; UdpGameClient.Send(gameUpdate); WaitFor("Exit game"); UdpGameClient.StopListening(); gameWebSocket.Close(); }