public EndComponent(Game game, HighScore result) : base(game) { this.result = result; inputField = new InputField(Game, new Vector2(100, 280), new Vector2(350, 50), defealtName); }
//===================================================================== INITIALIZE public HighScoreScene(Window container, Mode mode, int newLevel, int newScore) : base(container) { _mode = mode; LoadScores(); _newScore = new HighScore(_lastName, newLevel, newScore); AddScoreIfGreater(_newScore); _rectHighScore = new Rectangle((Container.Rectangle.Width - HIGH_SCORE_WIDTH) / 2, Game.MARGIN * 5, HIGH_SCORE_WIDTH, HIGH_SCORE_HEIGHT); }
//===================================================================== FUNCTIONS public override void Update() { if (IsEditing) { UpdateNameInput(); if (Input.IsTrigger(Keys.Enter) && _newScore.Name.Length > 0) { _newScore.Name = _lastName = _newScore.Name.Replace("_", ""); SaveScores(); _newScore = null; NewScoreIndex = -1; } } else { if (_mode == Mode.Marathon && Input.IsTrigger(Keys.Right)) _mode = Mode.TimeAttack; else if (_mode == Mode.TimeAttack && Input.IsTrigger(Keys.Left)) _mode = Mode.Marathon; if (Input.IsTrigger(Keys.Enter)) Container.Scene = new GameScene(Container, _mode); } }
private void AddScoreIfGreater(HighScore score) { if (_newScore.Score > Scores[Scores.Count - 1].Score) { Scores.RemoveAt(Scores.Count - 1); Scores.Add(_newScore); Scores.Sort(); } }
private void button4_Click(object sender, EventArgs e) { HighScore highScore = new HighScore(); highScore.ShowDialog(); }
public static void addBest(HighScore newScore) { scores.Add(newScore); HighScore.Save(scores); }