Exemple #1
0
        public void StartGame(string name, int rows, int cols, string client)
        {
            users[client] = Context.ConnectionId;
            Maze    maze = m.StartGame(name, rows, cols, client);
            JObject obj  = JObject.Parse(maze.ToJSON());

            Clients.Client(users[client]).drawMaze(obj);
        }
        /// <summary>
        /// Starts the game created by the player
        /// </summary>
        /// <param name="sender">window</param>
        /// <param name="e">none</param>
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            waitingWindow ww = new waitingWindow();

            ww.Show();
            MultiMazeModel m = myVM.MyModel as MultiMazeModel;

            m.StartGame("start");
            MultiGame mg = new MultiGame();

            mg.SetVM(myVM);
            myVM.VM_GameList = null;
            ww.Close();
            mg.Show();
            this.Close();
        }
        /// <summary>
        /// Joins the game selected in the comboBox
        /// </summary>
        /// <param name="sender">This window</param>
        /// <param name="e">sd</param>
        private void JoinClicked(object sender, RoutedEventArgs e)
        {
            MultiMazeModel m       = myVM.MyModel as MultiMazeModel;
            int            success = m.Connect();

            if (success < 0)
            {
                ConnectionFailedWindow c = new ConnectionFailedWindow();
                c.Show();
            }
            if (success >= 0)
            {
                GameInfo.btnStart.Click += BtnStart_Click;
                this.Show();
                m.GetListOfGames();
                m.StartGame("join");
                MultiGame mg = new MultiGame();
                mg.SetVM(myVM);
                mg.Show();
                this.Close();
            }
        }