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

📄 destroyballsworker.cs

📁 C#开发的运行于windows mobile PDA上的游戏
💻 CS
字号:
////////////////////////////////////////////////
// 
// Project: Lines.NET
// Version: 1.1
// Author:  Vladimir L.
// 
// homepage: http://www.boomsoft.org
// e-mail:   support@boomsoft.org
// 
// Copyright (c) 2003-2004, Boomsoft.org
// 

using System;
using System.Threading;

namespace Lines.Core
{
	/// <summary>
	/// Animates balls destruction.
	/// </summary>
	/// <remarks>
	/// Collapses the balls one after another with a pause between collapses 
	/// that is defined by application settings <see cref="AppSettings.PauseDestroyBall"/>.
	/// Supposed to be started in a separate thread.
	/// </remarks>
	/// <example>
	/// <code>
	/// DestroyBallsWorker worker = new DestroyBallsWorker(game, balls);
	/// Thread destroyThread = new Thread(new ThreadStart(worker.Execute));
	/// destroyThread.Start();
	/// </code>
	/// </example>
	public class DestroyBallsWorker
	{
		/// <summary>
		/// Holds the reference to a game object.
		/// </summary>
		private Game game;
		/// <summary>
		/// The array of balls to destroy.
		/// </summary>
		private Ball[] balls;
		/// <summary>
		/// The cached value of destroy pause.
		/// </summary>
		/// <remarks>
		/// This value is taken from <see cref="AppSettings.PauseDestroyBall"/> property.
		/// </remarks>
		private int pause = AppSettings.Instance.PauseDestroyBall;

		/// <summary>
		/// Creates an instance of destroy balls worker.
		/// </summary>
		/// <param name="game">The reference to a game object.</param>
		/// <param name="balls">The array of balls to destroy.</param>
		public DestroyBallsWorker(Game game, Ball[] balls)
		{
			this.game = game;
			this.balls = balls;
		}
		
		/// <summary>
		/// Executes the destruction.
		/// </summary>
		/// <remarks>
		/// This method is supposed to be used as an entry point for a thread.
		/// </remarks>
		public void Execute()
		{
			for (int i = 0; i < balls.Length; i++)
			{
				Ball ball = balls[i];
				Thread.Sleep(pause);
			}
		}
	}
}

⌨️ 快捷键说明

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