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

📄 ball.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.Drawing;

namespace Lines.Core
{
	/// <summary>
	/// Contains properties and basic methods of ball object.
	/// </summary>
	public class Ball
	{
		/// <summary>
		/// Refers to the container of this ball - the game board.
		/// </summary>
		private Board owner = null;
		/// <summary>
		/// The horizontal position of this ball on the board.
		/// </summary>
		private int x;
		/// <summary>
		/// The vertical position of this ball on the board.
		/// </summary>
		private int y;
		/// <summary>
		/// The color index of ball.
		/// </summary>
		private int color;
		/// <summary>
		/// Indicates whether ball is selected or not.
		/// </summary>
		private bool selected;

		/// <summary>
		/// Gets the horizontal position of this ball on board.
		/// </summary>
		public int X
		{
			get {return x;}
		}
		/// <summary>
		/// Gets the vertical position of this ball on board.
		/// </summary>
		public int Y
		{
			get {return y;}
		}
		/// <summary>
		/// Gets the horizontal and vertical position of this ball on board.
		/// </summary>
		public Point Position
		{
			get {return new Point(x, y);}
		}

		/// <summary>
		/// Gets the color index of ball.
		/// </summary>
		public int Color
		{
			get {return color;}
		}

		/// <summary>
		/// Refers to the ball's container, the board this ball is placed on.
		/// </summary>
		public Board Owner
		{
			get {return owner;}
		}

		/// <summary>
		/// Gets a value of flag "selected". Indicates whether ball is selected or not.
		/// </summary>
		public bool Selected
		{
			get {return selected;}
		}
		
		/// <summary>
		/// Creates an instance of ball with a predefined color.
		/// </summary>
		/// <param name="color">The color index of ball.</param>
		/// <remarks>
		/// The owner of the ball will be automatically set to <c>null</c> and 
		/// ball will be assigned to [0:0] coordinates.
		/// </remarks>
		public Ball(int color)
			: this(null, color)
		{
		}

		/// <summary>
		/// Creates an instance of ball with a predefined color and reference to the 
		/// ball's container.
		/// </summary>
		/// <param name="owner">The reference to a ball's container.</param>
		/// <param name="color">The color index of ball.</param>
		/// <remarks>
		/// The ball's location will be automatically set to [0:0] coordinates.
		/// </remarks>
		public Ball(Board owner, int color)
			: this(owner, color, 0, 0)
		{
		}

		/// <summary>
		/// Creates an instance of ball with a predefined color, reference to the 
		/// ball's container and coordinates of this ball inside the container.
		/// </summary>
		/// <param name="owner">The reference to a ball's container.</param>
		/// <param name="color">The color index of ball.</param>
		/// <param name="x">The horizontal coordinate of a ball on the board.</param>
		/// <param name="y">The vertical coordinate of a ball on the board.</param>
		public Ball(Board owner, int color, int x, int y)
		{
			this.owner = owner;
			this.color = color;
			this.x = x;
			this.y = y;
			this.selected = false;
		}
		
		/// <summary>
		/// Moves ball to a certain position.
		/// </summary>
		/// <param name="x">The value of new horizontal coordinate of ball on the board.</param>
		/// <param name="y">The value of new vertical coordinate of ball on the board.</param>
		public void MoveTo(int x, int y)
		{
			this.x = x;
			this.y = y;
		}

		/// <summary>
		/// Chanches a value of "selected" flag. Selects or diselects ball.
		/// </summary>
		/// <param name="select">The new value to be assigned to "selected" flag.</param>
		/// <remarks>
		/// The selected ball is displayed as a jumping ball on the screen. If ball selected 
		/// it might be moved to another position if there is no other ball currently moving.
		/// </remarks>
		public void Select(bool select)
		{
			selected = select;
		}
	}
}

⌨️ 快捷键说明

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