Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new HighScores view
        /// </summary>
        /// <param name="game">The Game instance that will show this view</param>
        /// <param name="levelName">The name of the level which high scores this view will
        ///                         show</param>
        public HighScores(Game1 game, String levelName)
            : base(game)
        {
            level = levelName.Replace('_', ' ');
            recordHandler = new RecordHandler(level);
            recordHandler.LoadRecords();
            for (int i = 0; i < recordHandler.Records.Count; i++)
            {
                TimeSpan time = TimeSpan.FromMilliseconds(recordHandler.Records[i].Time);

                scoresList += (i + 1) + "  " + recordHandler.Records[i].Name + "  " +
                              String.Format("{0:d2}:{1:d2}:{2:d3}",
                                            time.Minutes, time.Seconds, time.Milliseconds) + "\n";
            }
            font = game.Content.Load<SpriteFont>("SpriteFont1");
            topic = game.Content.Load<Texture2D>("Images/highScores");
            topicPos = new Vector2(game.getWidth() * 0.5f - topic.Width * 0.5f, 0);
            namePos = new Vector2(game.getWidth() * 0.5f - font.MeasureString(level).X * 0.5f,
                                  topic.Height);

            closeButton = new Button("ok", new Vector2(game.getWidth() * 0.7f,
                                           game.getHeight() * 0.75f),
                                           game.Content);

            closeButton.Position = new Vector2(game.getWidth() * 0.5f - closeButton.Width * 0.5f,
                                               game.getHeight() * 0.78f);

            closeButton.ButtonPressed += new Action<Button>(closeButton_ButtonPressed);

            backButton = new Button("back", new Vector2(game.relativeX(10), game.relativeY(430)),
                                            game.Content,
                                            true);
            backButton.Width = 70; backButton.Height = 43;
            backButton.ButtonPressed += new Action<Button>(backButton_ButtonPressed);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new HighScores view
        /// </summary>
        /// <param name="game">The Game instance that will show this view</param>
        /// <param name="levelName">The name of the level which high scores this view will
        ///                         show</param>
        public HighScores(Game1 game, String levelName) : base(game)
        {
            level         = levelName.Replace('_', ' ');
            recordHandler = new RecordHandler(level);
            recordHandler.LoadRecords();
            for (int i = 0; i < recordHandler.Records.Count; i++)
            {
                TimeSpan time = TimeSpan.FromMilliseconds(recordHandler.Records[i].Time);

                scoresList += (i + 1) + "  " + recordHandler.Records[i].Name + "  " +
                              String.Format("{0:d2}:{1:d2}:{2:d3}",
                                            time.Minutes, time.Seconds, time.Milliseconds) + "\n";
            }
            font     = game.Content.Load <SpriteFont>("SpriteFont1");
            topic    = game.Content.Load <Texture2D>("Images/highScores");
            topicPos = new Vector2(game.getWidth() * 0.5f - topic.Width * 0.5f, 0);
            namePos  = new Vector2(game.getWidth() * 0.5f - font.MeasureString(level).X * 0.5f,
                                   topic.Height);

            closeButton = new Button("ok", new Vector2(game.getWidth() * 0.7f,
                                                       game.getHeight() * 0.75f),
                                     game.Content);

            closeButton.Position = new Vector2(game.getWidth() * 0.5f - closeButton.Width * 0.5f,
                                               game.getHeight() * 0.78f);

            closeButton.ButtonPressed += new Action <Button>(closeButton_ButtonPressed);


            backButton = new Button("back", new Vector2(game.relativeX(10), game.relativeY(430)),
                                    game.Content,
                                    true);
            backButton.Width          = 70; backButton.Height = 43;
            backButton.ButtonPressed += new Action <Button>(backButton_ButtonPressed);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new view for telling that the player has completed the level
        /// </summary>
        /// <param name="game">The Game instance that will show this view</param>
        public WinView(Game1 game) : base(game)
        {
            recordHandler = new RecordHandler(game.currentLevelName);
            recordHandler.LoadRecords();
            closeButton = new Button("ok", new Vector2(0, 0), game.Content);
            closeButton.ButtonPressed += new Action <Button>(closeButton_ButtonPressed);

            closeButton.Position = new Vector2(game.getWidth() * 0.5f -
                                               closeButton.Width * 0.5f,
                                               game.getHeight() * 0.75f);
            textInput = new TextInput("Enter your name here",
                                      new Vector2(game.getWidth() * 0.3f, game.relativeY(200)),
                                      game.Content, (int)(game.getWidth() * 0.4f),
                                      (int)(game.getHeight() * 0.1f));
            font      = game.Content.Load <SpriteFont>("SpriteFont2");
            placement = recordHandler.GetPlacement((int)(game.finishTime.TotalMilliseconds));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new view for telling that the player has completed the level
        /// </summary>
        /// <param name="game">The Game instance that will show this view</param>
        public WinView(Game1 game)
            : base(game)
        {
            recordHandler = new RecordHandler(game.currentLevelName);
            recordHandler.LoadRecords();
            closeButton = new Button("ok", new Vector2(0, 0), game.Content);
            closeButton.ButtonPressed += new Action<Button>(closeButton_ButtonPressed);

            closeButton.Position = new Vector2(game.getWidth() * 0.5f -
                                                  closeButton.Width * 0.5f,
                                               game.getHeight() * 0.75f);
            textInput = new TextInput("Enter your name here",
                                      new Vector2(game.getWidth() * 0.3f, game.relativeY(200)),
                                      game.Content, (int)(game.getWidth() * 0.4f),
                                      (int)(game.getHeight() * 0.1f));
            font = game.Content.Load<SpriteFont>("SpriteFont2");
            placement = recordHandler.GetPlacement((int)(game.finishTime.TotalMilliseconds));
        }