⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myblockmain.cs

📁 这个程序是基于c#平台的俄罗斯方框游戏。拿来共享。要求加分哦!
💻 CS
📖 第 1 页 / 共 5 页
字号:
			this.lblTextLevel.ImageIndex = ((int)(resources.GetObject("lblTextLevel.ImageIndex")));
			this.lblTextLevel.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblTextLevel.ImeMode")));
			this.lblTextLevel.Location = ((System.Drawing.Point)(resources.GetObject("lblTextLevel.Location")));
			this.lblTextLevel.Name = "lblTextLevel";
			this.lblTextLevel.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblTextLevel.RightToLeft")));
			this.lblTextLevel.Size = ((System.Drawing.Size)(resources.GetObject("lblTextLevel.Size")));
			this.lblTextLevel.TabIndex = ((int)(resources.GetObject("lblTextLevel.TabIndex")));
			this.lblTextLevel.Text = resources.GetString("lblTextLevel.Text");
			this.lblTextLevel.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextLevel.TextAlign")));
			this.lblTextLevel.Visible = ((bool)(resources.GetObject("lblTextLevel.Visible")));
			// 
			// lblTextNextBlock
			// 
			this.lblTextNextBlock.AccessibleDescription = resources.GetString("lblTextNextBlock.AccessibleDescription");
			this.lblTextNextBlock.AccessibleName = resources.GetString("lblTextNextBlock.AccessibleName");
			this.lblTextNextBlock.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblTextNextBlock.Anchor")));
			this.lblTextNextBlock.AutoSize = ((bool)(resources.GetObject("lblTextNextBlock.AutoSize")));
			this.lblTextNextBlock.BackColor = System.Drawing.Color.Transparent;
			this.lblTextNextBlock.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblTextNextBlock.Dock")));
			this.lblTextNextBlock.Enabled = ((bool)(resources.GetObject("lblTextNextBlock.Enabled")));
			this.lblTextNextBlock.Font = ((System.Drawing.Font)(resources.GetObject("lblTextNextBlock.Font")));
			this.lblTextNextBlock.Image = ((System.Drawing.Image)(resources.GetObject("lblTextNextBlock.Image")));
			this.lblTextNextBlock.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextNextBlock.ImageAlign")));
			this.lblTextNextBlock.ImageIndex = ((int)(resources.GetObject("lblTextNextBlock.ImageIndex")));
			this.lblTextNextBlock.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblTextNextBlock.ImeMode")));
			this.lblTextNextBlock.Location = ((System.Drawing.Point)(resources.GetObject("lblTextNextBlock.Location")));
			this.lblTextNextBlock.Name = "lblTextNextBlock";
			this.lblTextNextBlock.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblTextNextBlock.RightToLeft")));
			this.lblTextNextBlock.Size = ((System.Drawing.Size)(resources.GetObject("lblTextNextBlock.Size")));
			this.lblTextNextBlock.TabIndex = ((int)(resources.GetObject("lblTextNextBlock.TabIndex")));
			this.lblTextNextBlock.Text = resources.GetString("lblTextNextBlock.Text");
			this.lblTextNextBlock.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextNextBlock.TextAlign")));
			this.lblTextNextBlock.Visible = ((bool)(resources.GetObject("lblTextNextBlock.Visible")));
			// 
			// picNextBlock
			// 
			this.picNextBlock.AccessibleDescription = resources.GetString("picNextBlock.AccessibleDescription");
			this.picNextBlock.AccessibleName = resources.GetString("picNextBlock.AccessibleName");
			this.picNextBlock.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("picNextBlock.Anchor")));
			this.picNextBlock.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(235)), ((System.Byte)(235)), ((System.Byte)(235)));
			this.picNextBlock.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("picNextBlock.BackgroundImage")));
			this.picNextBlock.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.picNextBlock.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("picNextBlock.Dock")));
			this.picNextBlock.Enabled = ((bool)(resources.GetObject("picNextBlock.Enabled")));
			this.picNextBlock.Font = ((System.Drawing.Font)(resources.GetObject("picNextBlock.Font")));
			this.picNextBlock.Image = ((System.Drawing.Image)(resources.GetObject("picNextBlock.Image")));
			this.picNextBlock.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("picNextBlock.ImeMode")));
			this.picNextBlock.Location = ((System.Drawing.Point)(resources.GetObject("picNextBlock.Location")));
			this.picNextBlock.Name = "picNextBlock";
			this.picNextBlock.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("picNextBlock.RightToLeft")));
			this.picNextBlock.Size = ((System.Drawing.Size)(resources.GetObject("picNextBlock.Size")));
			this.picNextBlock.SizeMode = ((System.Windows.Forms.PictureBoxSizeMode)(resources.GetObject("picNextBlock.SizeMode")));
			this.picNextBlock.TabIndex = ((int)(resources.GetObject("picNextBlock.TabIndex")));
			this.picNextBlock.TabStop = false;
			this.picNextBlock.Text = resources.GetString("picNextBlock.Text");
			this.picNextBlock.Visible = ((bool)(resources.GetObject("picNextBlock.Visible")));
			this.picNextBlock.Paint += new System.Windows.Forms.PaintEventHandler(this.picNextBlock_Paint);
			// 
			// AnotherBlockMain
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackColor = System.Drawing.Color.White;
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.picNextBlock);
			this.Controls.Add(this.lblTextNextBlock);
			this.Controls.Add(this.lblLevel);
			this.Controls.Add(this.lblTextLevel);
			this.Controls.Add(this.lblLines);
			this.Controls.Add(this.lblTextLines);
			this.Controls.Add(this.lblScore);
			this.Controls.Add(this.lblTextScore);
			this.Controls.Add(this.picPlayingField);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximizeBox = false;
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.Menu = this.mainMenu;
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "AnotherBlockMain";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.AnotherBlockMain_KeyDown);
			this.LostFocus += new System.EventHandler(this.AnotherBlockMain_LostFocus);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new AnotherBlockMain());
		}

		/// <summary>
		/// The override of the Paint event in the playing field, where the current block and the
		/// pile of blocks will be drawn.
		/// </summary>
		/// <param name="sender">The parent control who triggered the event.</param>
		/// <param name="e">The paint event arguments.</param>
		private void picPlayingField_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
			// Checks if there is a current game.
			if (game != null)
			{
				// There is a current game.
				// Checks if the game is running.
				if (game.GameState == GameState.Running)
				{
					// Game is running.
					// Draw the current block in the graphics object of the picture box.
					game.DrawCurrentBlock(e.Graphics);
					// Draw the current pile in the graphics object of the picture box.
					game.DrawPile(e.Graphics);
				}
			}
		}

		/// <summary>
		/// The click of the "Exit" menu. Exits the application.
		/// </summary>
		/// <param name="sender">The parent control who triggered the event.</param>
		/// <param name="e">Default event arguments.</param>
		private void mnuExit_Click(object sender, System.EventArgs e)
		{
			// Exits the application.
			Application.Exit();
		}

		/// <summary>
		/// The click of the "Start Game" menu. Creates a new game, starts the timer and resets the interface.
		/// </summary>
		/// <param name="sender">The parent control who triggered the event.</param>
		/// <param name="e">Default event arguments.</param>
		private void mnuStartGame_Click(object sender, System.EventArgs e)
		{
			// Creates a new game.
			game = new Game();
			// Resets the score, lines and level labels in the interface, with the initial values.
			lblScore.Text = game.Score.ToString();
			lblLines.Text = game.Lines.ToString();
			lblLevel.Text = game.Level.ToString();
			// Enables the "Pause" menu.
			mnuPause.Enabled = true;

			// Sets the initial timer interval.
			tmrTimer.Interval = (int)((Math.Pow((double)basicInterval / (double)(1000), (double)(game.Level)) + 0.05) * 1000);
			// Starts the timer.
			tmrTimer.Start();
			// Checks if the Music option is set.
			if (mnuMusic.Checked)
			{
				// The Music option is set.
				// Starts playing the music.
				soundMusic.Play();
			}

			// Forces the paint event to occurr in both picture boxes (the playing field and the next block).
			picPlayingField.Invalidate();
			picNextBlock.Invalidate();
		}

		/// <summary>
		/// The tick of the game timer. Moves the current block down, and checks for game over state and
		/// for a change of level. Also updates the score, lines and level in the interface.
		/// </summary>
		/// <param name="sender">The parent control who triggered the event.</param>
		/// <param name="e">Default event arguments.</param>
		private void tmrTimer_Tick(object sender, System.EventArgs e)
		{
			// Checks if the game is not paused.
			if (game.GameState != GameState.Paused)
			{
				// Game is not paused.
				// Stops the timer so that if the processing time here takes more than the time interval,
				// the blocks don't go down, and makes stranges things happen.
				tmrTimer.Stop();
				// Moves the current block down, and checks if there was a hit.
				if (game.MoveCurrentBlockDown())
				{
					// There was a hit.
					// Checks if the sounds menu is checked.
					if (mnuSounds.Checked)
					{
						// Sounds menu is checked.
						// Plays the hit sound.
						soundHit.Play();
					}
					// Makes the dontMoveDown attribute true, so that the user can't force the next block to move down.
					dontMoveDown = true;
					// Checks if the double of the current interval is smaller than the basic interval.
					if(((int)((Math.Pow((double)basicInterval / (double)(1000), (double)(game.Level)) + 0.05) * 1000) * 2) < basicInterval)
					{
						// The double of the current interval is smaller than the basic interval.
						// Makes the timer interval the double of the current interval.
						tmrTimer.Interval = (int)((Math.Pow((double)basicInterval / (double)(1000), (double)(game.Level)) + 0.05) * 1000) * 2;
					}
					else
					{
						// The double of the current interval is not smaller than the basic interval.
						// Makes the timer interval the basic interval, like in level 1.
						tmrTimer.Interval = basicInterval;
					}
				}
				else
				{
					// There wasn't a hit.
					// Checks if there was a flag for the pieces not to move down.
					if (dontMoveDown)
					{
						// There was a flag for the pieces not to move down.
						// Makes the dontMoveDown attribute false, so that the user can force the next block to move down.
						dontMoveDown = false;
						// Sets the timer interval to the normal interval for the level.
						tmrTimer.Interval = (int)((Math.Pow((double)basicInterval / (double)(1000), (double)(game.Level)) + 0.05) * 1000);
					}
				}

				// Checks if the game is over.
				if (game.GameState == GameState.Over)
				{
					// Game is over.
					// Stops the music if its playing.
					soundMusic.Stop();
					// Checks if the game has set a new high score.
					if (CheckForHighScore())
					{
						// Game has set a new high score.
						// Creates a InputName form, and show its window.
						InputName inputName = new InputName();
						inputName.ShowDialog(this);

						// Creates a high score entry with the given name and the current score.
						HighScoreEntry highScoreEntry = new HighScoreEntry();
						highScoreEntry.Name = inputName.HighScoreName;
						highScoreEntry.Score = game.Score;
						// Records the created high score entry in the registry.
						RecordHighScore(highScoreEntry);
						// Destroys the InputName form.
						inputName.Dispose();
						inputName = null;

						// Creates a HighScore form.
						HighScore highScore = new HighScore();
						// Gets the 10 firsts high scores entries.
						for(int i = 1; i <= 10; i++)
						{
							// Gets the current high score entry.
							highScoreEntry = GetHighScoreEntry(i);
							// Includes the current high score entry in the HighScore form.
							highScore.IncludeHighScore(highScoreEntry);
						}

						// Shows the HighScore form window.
						highScore.ShowDialog(this);

						// Destroys the HighScore form.
						highScore.Dispose();
						highScore = null;
					}
					else
					{
						// Game hasn't set a new high score.
						// Shows a "Game over" message.
						MessageBox.Show(resources.GetString("GameOver"));
					}

					// Destroys the game object.
					game = null;
					// Disables the "Pause" menu.
					mnuPause.Enabled = false;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -