Пример #1
0
        /// <summary>
        /// Displays the stats board for the given player model.
        /// </summary>
        protected void ShowStats(PlayStats data)
        {
            data.EndTime = DateTime.Now;
            StatsBoard board = new StatsBoard(data);

            board.Owner = this;
            board.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Shows the login screen, which allows the user to either login or quit.
        /// </summary>
        protected void Login()
        {
            //TODO: Button for high performance
            _HighPerformance = true;
            //Clear out any potential game model data from last time.
            _P3DDictionary      = new Dictionary <int, Cube3D>();
            _F3DDictionary      = new Dictionary <int, Food3D>();
            _World              = new World(DefaultWorldSize, DefaultWorldSize);
            cameraMain.Position = new Point3D(DefaultWorldSize / 2, DefaultWorldSize / 2, 100);
            txtbxMessages.Text  = "";

            //Remove any 3D objects from prior game.
            groupFood3D.Children.Clear();
            groupPlayers3D.Children.Clear();

            //Create and run the loginwindow.
            LoginWindow loginWindow = new LoginWindow();

            loginWindow.ShowDialog();

            while (loginWindow.Result == MessageBoxResult.OK)
            {
                try
                {
                    string hostname = loginWindow.ServerAddress + ":" + loginWindow.Port;
                    Network.ConnectToServer(FirstConnectCallback, hostname);
                    _PlayerName = loginWindow.PlayerName;
                    //lblPlayerName.Content = loginWindow.PlayerName;
                    break;
                }
                catch (SocketException ex)
                {
                    MessageBox.Show(ex.Message);
                    //TODO: The program crashes after showing this dialog.
                    loginWindow.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unrecognized exception:\n" + ex.ToString());
                    loginWindow.ShowDialog();
                }
            }

            //If the result asks to quit, close the MainWindow.
            if (loginWindow.Result == MessageBoxResult.Cancel)
            {
                this.Close();
            }

            lblPlayerName.Content = _PlayerName;

            SetupPlayFloor(_World);

            _Stats = new PlayStats(_PlayerName);

            viewport.Focus();
        }
Пример #3
0
        /// <summary>
        /// A static mapper function for mapping from the data model to this ViewModel object.
        /// </summary>
        public static VideoPreviewViewModel FromDataModel(SuggestedVideos.Dtos.VideoPreview preview, UserProfile author, PlayStats stats, UrlHelper urlHelper)
        {
            if (preview == null)
            {
                return(null);
            }

            return(new VideoPreviewViewModel
            {
                VideoId = preview.VideoId,
                Name = preview.Name,
                AddedDate = preview.AddedDate,
                PreviewImageLocation = preview.PreviewImageLocation,
                AuthorFirstName = author.FirstName,
                AuthorLastName = author.LastName,
                AuthorProfileUrl = urlHelper.Action("Info", "Account", new { userId = author.UserId }),
                Views = stats.Views
            });
        }
Пример #4
0
 /// <summary>
 /// Creates a new StatsBoard, ready to show.
 /// </summary>
 /// <param name="data">The game completion data to display.</param>
 public StatsBoard(PlayStats data)
 {
     this.Data = data;
     InitializeComponent();
     this.DataContext = data;
 }