private void Menu_HighScore1P() { if (Score != 0) { GameOverLabel.Text = "GAME OVER"; GameOverLabel.ForeColor = Color.Red; GameOverLabel.Location = new Point(52, 33); ScoreLabel.Text = "Your Score"; ScoreNum.Text = Score.ToString(); } else { ScoreLabel.Text = ""; ScoreNum.Text = ""; GameOverLabel.Text = ""; } if (HighScore == -1) { //In case the HighScore is not loaded yet (value is -1) do so HighScoreClass hscr = new HighScoreClass(); HighScore = hscr.LoadHighScore(); } HighScoreLabel.Text = "Highest Score"; HighScoreLabel.ForeColor = Color.Yellow; HighScoreNum.ForeColor = Color.Yellow; HighScoreNum.Text = HighScore.ToString(); }
/// <summary> /// Procedure serving simply for initialization of variables at the map load up /// and displaying loading screen. /// </summary> /// <param name="loading">Control of loading label.</param> /// <param name="levelLabel">Control of level label.</param> /// <param name="color">From file loaded color.</param> private void LoadingAndInit(Label loading, Label levelLabel, Color color) { if (Level == 0) { defSize = this.Size; this.AutoSize = false; this.Size = new Size((FieldSizeInColumns + 1) * TileSizeInPxs, (FieldSizeInRows + 8) * TileSizeInPxs); g = this.CreateGraphics(); extraLifeGiven = false; //has the player received extra life at 10000pts? Score = 0; //p1 score Score2 = 0; //p2 score SoundTick = 0; //used for sound players to take turns for (int i = 0; i < SoundPlayersCount; i++) { SoundPlayers[i] = new WMPLib.WindowsMediaPlayer(); } CollectedDots = 0; Lives = 3; Level++; } this.Controls.Clear(); loading.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); loading.AutoSize = true; loading.Visible = true; PlaceLabel(loading, "Loading...", Color.Yellow, new Point(90, 159), new Font("Ravie", 30F, FontStyle.Bold)); levelLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); levelLabel.AutoSize = true; levelLabel.Visible = true; PlaceLabel(levelLabel, "- Level " + Level.ToString() + " -", Color.Red, new Point(120, 350), new Font("Ravie", 20F, FontStyle.Bold)); Refresh(); keyPressed1 = false; //has player 1 pressed a valid button? keyPressed2 = false; //has player 2 pressed a valid button? GhostsEaten = 0; //number of ghost eaten by pacman during pacman"s excitement keyCountdown1 = 0; keyCountdown2 = 0; killed = false; Ticks = 0; // Counts tick to enable power pellets flashing and ghost flashing at the end of pac's excitement. FreeGhost = 1; // Number of active ghosts moving through the map. GhostRelease = Player2 ? 130 / 3 : (260 - Level) / 3; // Timer for ghost releasing - decreasing with level. EatEmTimer = 0; //timer for pacman's excitement PacLives = new PictureBox[MaxLives]; for (int i = 0; i < MaxLives; i++) { PacLives[i] = new PictureBox(); } // Yet empty fields of the array would redraw over top right corner of the map. // This way it draw empty tile on pacman's initial position tile which is empty by definiton. for (int i = 0; i < RDPSize; i++) { redrawPellets[i] = new Point(pacmanInitialY, pacmanInitialX); } if (HighScore == -1) { HighScoreClass hscr = new HighScoreClass(); HighScore = hscr.LoadHighScore(); } }