Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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();
            });
        }
Esempio n. 3
0
    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);
    }
Esempio n. 4
0
        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();
        }