/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <summary> /// Creates a new level selecting view /// </summary> /// <param name="game">The Game instance that will show this view</param> /// <param name="pNewGame">true if the level is going to be /// selected for the new game, false otherwise</param> /// <param name="myLevelsPage">true if the view is wanted to /// be opened on the custom level page</param> public LevelSelector(Game1 game, bool pNewGame, bool myLevelsPage) : base(game) { maxY = (int)(game.getHeight() * 0.1f); newGame = pNewGame; float screenXMiddle = game.getWidth() / 2; int spacing = 90; int top = 70; Button button = new Button("level1", Vector2.Zero, game.Content); button.ButtonPressed += new Action<Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count-1) + top); button = new Button("level2", Vector2.Zero, game.Content); button.ButtonPressed += new Action<Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count-1) + top); button = new Button("level3", Vector2.Zero, game.Content); button.ButtonPressed += new Action<Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count-1) + top); button = new Button("myLevels", Vector2.Zero, game.Content); button.ButtonPressed += new Action<Button>(button_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count-1) + top); IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication(); String[] fileNames = savegameStorage.GetFileNames(); for (int i = 0; i < fileNames.Length; i++) { String[] pieces = fileNames[i].Split('.'); if (pieces.Length > 1 && pieces[1] == "lvl") { var tmpButton = new Button(pieces[0].Replace('_', ' '), Vector2.Zero, game.Content, false); tmpButton.ButtonPressed += new Action<Button>(tmpButton_ButtonPressed); tmpButton.ButtonLongPressed += new Action<Button>(tmpButton_ButtonLongPressed); myButtons.Add(tmpButton); tmpButton.Position = new Vector2(screenXMiddle - tmpButton.Width * 0.5f, 60 * (myButtons.Count)); } } minY = -myButtons.Count * 60 + (int)(0.5f * game.getHeight()); yesButton = new Button("Yes", new Vector2(game.relativeX(290), game.relativeY(280)), game.Content, false); yesButton.ButtonPressed += new Action<Button>(yesButton_ButtonPressed); noButton = new Button("No", new Vector2(game.relativeX(490), game.relativeY(280)), game.Content, false); noButton.ButtonPressed += new Action<Button>(noButton_ButtonPressed); backButton = new Button("back", new Vector2(game.relativeX(10), game.relativeY(430)), game.Content, true); backButton.ButtonPressed += new Action<Button>(backButton_ButtonPressed); backButton.Width = 70; backButton.Height = 43; if (myLevelsPage) buttons = myButtons; else buttons = preDefinedButtons; font = game.Content.Load<SpriteFont>("SpriteFont1"); }
/// <summary> /// Creates a new level selecting view /// </summary> /// <param name="game">The Game instance that will show this view</param> /// <param name="pNewGame">true if the level is going to be /// selected for the new game, false otherwise</param> /// <param name="myLevelsPage">true if the view is wanted to /// be opened on the custom level page</param> public LevelSelector(Game1 game, bool pNewGame, bool myLevelsPage) : base(game) { maxY = (int)(game.getHeight() * 0.1f); newGame = pNewGame; float screenXMiddle = game.getWidth() / 2; int spacing = 90; int top = 70; Button button = new Button("level1", Vector2.Zero, game.Content); button.ButtonPressed += new Action <Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count - 1) + top); button = new Button("level2", Vector2.Zero, game.Content); button.ButtonPressed += new Action <Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count - 1) + top); button = new Button("level3", Vector2.Zero, game.Content); button.ButtonPressed += new Action <Button>(tmpButton_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count - 1) + top); button = new Button("myLevels", Vector2.Zero, game.Content); button.ButtonPressed += new Action <Button>(button_ButtonPressed); preDefinedButtons.Add(button); button.Position = new Vector2(screenXMiddle - button.Width * 0.5f, spacing * (preDefinedButtons.Count - 1) + top); IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication(); String[] fileNames = savegameStorage.GetFileNames(); for (int i = 0; i < fileNames.Length; i++) { String[] pieces = fileNames[i].Split('.'); if (pieces.Length > 1 && pieces[1] == "lvl") { var tmpButton = new Button(pieces[0].Replace('_', ' '), Vector2.Zero, game.Content, false); tmpButton.ButtonPressed += new Action <Button>(tmpButton_ButtonPressed); tmpButton.ButtonLongPressed += new Action <Button>(tmpButton_ButtonLongPressed); myButtons.Add(tmpButton); tmpButton.Position = new Vector2(screenXMiddle - tmpButton.Width * 0.5f, 60 * (myButtons.Count)); } } minY = -myButtons.Count * 60 + (int)(0.5f * game.getHeight()); yesButton = new Button("Yes", new Vector2(game.relativeX(290), game.relativeY(280)), game.Content, false); yesButton.ButtonPressed += new Action <Button>(yesButton_ButtonPressed); noButton = new Button("No", new Vector2(game.relativeX(490), game.relativeY(280)), game.Content, false); noButton.ButtonPressed += new Action <Button>(noButton_ButtonPressed); backButton = new Button("back", new Vector2(game.relativeX(10), game.relativeY(430)), game.Content, true); backButton.ButtonPressed += new Action <Button>(backButton_ButtonPressed); backButton.Width = 70; backButton.Height = 43; if (myLevelsPage) { buttons = myButtons; } else { buttons = preDefinedButtons; } font = game.Content.Load <SpriteFont>("SpriteFont1"); }