亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? figure.cs

?? game tetris :), this file is a little too big but it s run well, besides, it also has file descripti
?? CS
字號:
using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace GATetrisControl
{
	#region Enums

	public enum RotateDirection
	{
		ClockWise,
		AntiClockWise
	}

	public enum RotateAngle
	{
		Deg0,
		Deg90,
		Deg180,
		Deg270
	}

	public enum MoveDirection
	{
		Left,
		Right,
		Down,
		Rotate
	}
	#endregion

	public class Figure
	{
		#region Constructor

		public Figure(TetrisGrid grid)
		{
			parent = grid;
			columns = parent.settings.columns;
			rows = parent.settings.rows;

			angle = RotateAngle.Deg0;
			direction = RotateDirection.ClockWise;
		}

		#endregion

        #region Property

        public int Range
        {
            get { return range; }
            set { range = value; }
        }

        public int XPosition
        {
            get { return xPosition; }
            set { xPosition = value; }
        }

        public int YPosition
        {
            get { return yPosition; }
            set { yPosition = value; }
        }

        public int GetAngle()
        {
            int returnValue;
            if (angle == RotateAngle.Deg0)
            {
                returnValue = 0;
                return returnValue;
            }
            if (angle == RotateAngle.Deg90)
            {
                returnValue = 1;
                return returnValue;
            }
            if (angle == RotateAngle.Deg180)
            {
                returnValue = 2;
                return returnValue;
            }
            return 3;
        }

        public void SetAngle(int angleValue)
        {
            if (angleValue == 0)
            {
                angle = RotateAngle.Deg0;               
            }
            if (angleValue == 1)
            {
                angle = RotateAngle.Deg90; 
            }
            if (angleValue == 2)
            {
                angle = RotateAngle.Deg180; 
            }
            if (angleValue == 3)
            {
                angle = RotateAngle.Deg270; 
            }
        }
	
        #endregion

		#region Virtual Methods

        /// <summary>
        /// Gets the indexes of the SingleSquare objects the figure has currently occupied.
        /// </summary>
        /// <returns></returns>
		protected virtual ArrayList GetRectsIndexes()
		{
			return null;
		}

        internal virtual void DrawPreview(Graphics g)
		{
		}

		#endregion

		#region Internal Methods

       	internal void Move(MoveDirection dir)
		{
			if(!CanMove(dir))
			{
				//if we tried to move figure down and we failed, so we need new figure
				if(dir == MoveDirection.Down)
					parent.newFigure = true;
				return;
			}
			//first clear previous location of the figure
			ClearFigure();
			switch(dir)
			{
				case MoveDirection.Left:
					xPosition -= 1;
					break;
				case MoveDirection.Right:
					xPosition += 1;
					break;
				case MoveDirection.Down:
					yPosition += 1;
					break;
				case MoveDirection.Rotate:
					ChangeRotateAngle();
					break;
			}
			//draw the figure at the new location
			DrawFigure();

			//refresh the tetris grid
			parent.SmartRefresh();
		}
		
		internal bool CanDraw()
		{
			//get the indexes of the figure and if twe have at least one which is filled
			//return false
			foreach(int i in GetRectsIndexes())
			{
				if(parent.squares[i].filled)
					return false;
			}

			return true;
		}


		#endregion		

		#region Drawing Methods

        internal void DrawFigure()
		{
			//get the indexes of the squares this figure occupies
			foreach(int index in GetRectsIndexes())
			{
				//add the rect in the invalid rects of the parent grid
				parent.invalidRects.Add(parent.squares[index]);
				//set the color for the square
				parent.squares[index].color = color;
				//set it to 'filled'
				parent.squares[index].filled = true;
			}
		}

		internal void DrawPreviewSquare(Rectangle r, Graphics g, Color c)
		{					
			r.Width -= 2;
			r.Height -= 2;

			g.FillRectangle(new SolidBrush(c),r);
			g.DrawLine(new Pen(parent.settings.lightBorder),r.Left,r.Bottom,r.Left,r.Top);
			g.DrawLine(new Pen(parent.settings.lightBorder),r.Left,r.Top,r.Right,r.Top);
			g.DrawLine(new Pen(parent.settings.darkBorder),r.Right,r.Top,r.Right,r.Bottom);
			g.DrawLine(new Pen(parent.settings.darkBorder),r.Right,r.Bottom,r.Left,r.Bottom);			
		}

		internal void ClearFigure()
		{
			//get the indexes of the squares thid figure occupies
			foreach(int index in GetRectsIndexes())
			{
				//add the square to the parent's invalid rects
				parent.invalidRects.Add(parent.squares[index]);
				//drop the flag 'filled'
				parent.squares[index].filled = false;
			}
		}

		#endregion

		#region Private Methods

        /// <summary>
        /// changes the rotation angle according to the rotate direction
        /// </summary>
		private void ChangeRotateAngle()
		{
			switch(angle)
			{
				case RotateAngle.Deg0:
					switch(direction)
					{
						case RotateDirection.ClockWise:
							angle = RotateAngle.Deg90;
							break;
						case RotateDirection.AntiClockWise:
							angle = RotateAngle.Deg270;
							break;
					}
					break;
				case RotateAngle.Deg90:
					switch(direction)
					{
						case RotateDirection.ClockWise:
							angle = RotateAngle.Deg180;
							break;
						case RotateDirection.AntiClockWise:
							angle = RotateAngle.Deg0;
							break;
					}
					break;
				case RotateAngle.Deg180:
					switch(direction)
					{
						case RotateDirection.ClockWise:
							angle = RotateAngle.Deg270;
							break;
						case RotateDirection.AntiClockWise:
							angle = RotateAngle.Deg90;
							break;
					}
					break;
				case RotateAngle.Deg270:
					switch(direction)
					{
						case RotateDirection.ClockWise:
							angle = RotateAngle.Deg0;
							break;
						case RotateDirection.AntiClockWise:
							angle = RotateAngle.Deg180;
							break;
					}
					break;
			}
		}

		private ArrayList GetDifferentIndexes(ArrayList oldIndexes, ArrayList newIndexes)
		{
			//the different indexes
			ArrayList different = new ArrayList();
			foreach(int i in newIndexes)
			{
				if(oldIndexes.Contains(i))
					continue;
				different.Add(i);
			}

			return different;
		}

		private bool CanMove(MoveDirection dir)
		{
			ArrayList oldIndexes = GetRectsIndexes();
			ArrayList newIndexes = new ArrayList();

            switch(dir)
			{
				case MoveDirection.Down:
					//if we have reached the end of the rows - do nothing
					if(yPosition + height == rows)
						return false;
					//perform fake offset
					yPosition += 1;
					//get the indexes with the new offset
					newIndexes = GetRectsIndexes();
					//restore previous position
					yPosition -= 1;
					break;
				case MoveDirection.Left:
					//if we are at the left side of the grid - do nothing
					if(xPosition == 0)
						return false;
					//perform fake offset
					xPosition -= 1;
					//get the indexes with the new offset
					newIndexes = GetRectsIndexes();
					//restore previous location
					xPosition += 1;
					break;
				case MoveDirection.Right:
					//if we are at the right side of the grid - do nothing
					if(xPosition + width == columns)
						return false;
					xPosition += 1;
					newIndexes = GetRectsIndexes();
					xPosition -= 1;
					break;
				case MoveDirection.Rotate:
					RotateAngle oldAngle = angle;
					ChangeRotateAngle();
					newIndexes = GetRectsIndexes();
					angle = oldAngle;
					//do not allow rotating if we are going to exceed the bounds of the grid
					if(yPosition + height > rows || xPosition + width > columns)
						return false;
					break;
			}

            //get the different indexes
			ArrayList different = GetDifferentIndexes(oldIndexes, newIndexes);

			foreach(int i in different)
			{
				//if we have at least one filled square in the different indexes, so we cannot
				//move the figure in the desired location
				if(parent.squares[i].filled)
					return false;
			}

            //no other conditions, so return true
			return true;
		}

		#endregion

		#region Fields

		internal int xPosition;
		internal int yPosition;
		internal int columns;
		internal int rows;
        internal int range;
		internal TetrisGrid parent;
		internal Color color;

		internal int width;
		internal int height;
		internal RotateAngle angle;
		internal RotateDirection direction;

		#endregion
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91浏览器打开| 宅男在线国产精品| 午夜精品久久久久| 久久久亚洲精品一区二区三区| 成年人国产精品| 日本不卡一区二区| 国产精品嫩草99a| 欧美一区二区三区系列电影| 91香蕉视频在线| 国产在线一区观看| 婷婷丁香久久五月婷婷| 成人欧美一区二区三区白人 | 亚洲动漫第一页| 国产婷婷色一区二区三区四区| 精品视频在线免费看| 丰满岳乱妇一区二区三区| 日本欧美韩国一区三区| 亚洲男同性视频| 国产精品青草综合久久久久99| 4438x亚洲最大成人网| 色婷婷精品久久二区二区蜜臂av| 国产一区二区三区不卡在线观看 | 日韩经典一区二区| 一区二区三区视频在线看| 中文一区二区在线观看| 久久伊99综合婷婷久久伊| 欧美一级淫片007| 欧美高清视频不卡网| 色视频欧美一区二区三区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美人动与zoxxxx乱| 色婷婷精品久久二区二区蜜臂av| 成人av资源网站| 成人污视频在线观看| 国产丶欧美丶日本不卡视频| 精品一区二区国语对白| 蜜桃视频免费观看一区| 蜜桃av一区二区在线观看| 日本欧美一区二区| 美日韩一区二区| 麻豆成人久久精品二区三区红 | 国产91精品露脸国语对白| 国模无码大尺度一区二区三区| 美脚の诱脚舐め脚责91| 久久激情综合网| 激情小说亚洲一区| 国内精品免费在线观看| 国产一区二区三区免费观看| 国产乱子伦一区二区三区国色天香| 精品无人区卡一卡二卡三乱码免费卡| 日本伊人精品一区二区三区观看方式| 麻豆视频一区二区| 韩日欧美一区二区三区| 国产成人自拍网| 99久久婷婷国产综合精品| 91麻豆精品在线观看| 欧美最猛黑人xxxxx猛交| 欧美日韩在线免费视频| 日韩欧美你懂的| 国产网站一区二区| 亚洲欧美日韩在线不卡| 色综合一个色综合亚洲| 色综合久久综合网| 91麻豆精品国产自产在线| 欧美一级一级性生活免费录像| 26uuu久久天堂性欧美| 国产精品免费av| 亚洲一区二区三区四区在线观看| 偷窥国产亚洲免费视频| 国产一区美女在线| 91麻豆国产香蕉久久精品| 欧美精品久久久久久久多人混战| 日韩三级免费观看| 国产精品污网站| 亚洲国产欧美日韩另类综合| 久久99久国产精品黄毛片色诱| 国产a久久麻豆| 欧美男女性生活在线直播观看| 精品美女被调教视频大全网站| 国产精品麻豆一区二区| 午夜视频在线观看一区| 国产一区二区网址| 色天使色偷偷av一区二区| 精品少妇一区二区三区免费观看| 中文av一区二区| 肉色丝袜一区二区| 成人丝袜视频网| 3d成人动漫网站| 综合久久久久久久| 精品无人区卡一卡二卡三乱码免费卡| av在线不卡观看免费观看| 91精品婷婷国产综合久久 | 午夜久久久久久电影| 国产麻豆精品theporn| 欧美在线999| 国产亚洲一二三区| 日日夜夜一区二区| eeuss鲁一区二区三区| 欧美大胆一级视频| 亚洲精品免费在线| 国产a精品视频| 精品久久久网站| 偷拍一区二区三区| 在线观看中文字幕不卡| 26uuu久久天堂性欧美| 丝袜美腿亚洲综合| 色菇凉天天综合网| 国产精品网曝门| 国内国产精品久久| 日韩精品一区二区三区在线观看 | 久久嫩草精品久久久精品| 亚洲午夜精品网| 99国产精品久久久| 久久久久高清精品| 久久av资源网| 欧美一级在线视频| 婷婷丁香久久五月婷婷| 欧美自拍丝袜亚洲| 亚洲欧美日韩中文字幕一区二区三区 | 国产精品久久久久影院老司 | 91蝌蚪porny| 中文字幕av不卡| 国产精品一二三四| 欧美变态凌虐bdsm| 日本强好片久久久久久aaa| 欧美亚洲高清一区| 亚洲欧美国产毛片在线| 波多野结衣精品在线| 国产精品国产三级国产三级人妇 | 亚洲人成网站精品片在线观看| 国产精品一区二区三区99| 精品国产不卡一区二区三区| 麻豆成人91精品二区三区| 欧美一区二区三区视频在线| 日日夜夜免费精品| 91精品国产综合久久小美女| 亚洲成av人片在www色猫咪| 欧美中文字幕一区| 亚洲在线视频免费观看| 欧美日韩国产综合一区二区| 亚洲国产精品久久不卡毛片| 欧美日韩精品系列| 日韩av电影天堂| 精品欧美乱码久久久久久1区2区| 蜜桃视频一区二区三区在线观看 | 国产精品久久久爽爽爽麻豆色哟哟 | 日韩不卡手机在线v区| 欧美另类久久久品| 男人的天堂久久精品| 日韩一二三区不卡| 国内精品第一页| 国产精品久久久久久久久动漫| youjizz久久| 一区二区三区在线视频观看| 欧美三级中文字幕在线观看| 日韩专区欧美专区| 精品国产髙清在线看国产毛片 | 激情欧美一区二区| 久久九九全国免费| a4yy欧美一区二区三区| 亚洲一区影音先锋| 91精品国产91久久久久久一区二区 | 欧美亚洲动漫精品| 蜜臀国产一区二区三区在线播放| 欧美精品一区二区三区四区| 成人免费电影视频| 一区二区在线观看视频| 91精品在线免费| 国产精品资源在线观看| 国产精品国产自产拍高清av王其 | 成人黄色小视频| 亚洲高清在线视频| 久久久久久久久免费| 91视频xxxx| 日本视频免费一区| 国产精品久久久久久久第一福利| 欧美日韩一区成人| 国产精品亚洲专一区二区三区| 成人免费在线视频| 欧美一区二区免费观在线| 国产成人aaa| 亚洲最色的网站| 337p粉嫩大胆噜噜噜噜噜91av | 久久久不卡影院| 91久久国产综合久久| 久久99精品久久久久久动态图| 国产精品福利一区二区三区| 91精品国产一区二区三区香蕉| 国产激情视频一区二区在线观看| 亚洲一级二级三级| 日本一区二区三区免费乱视频| 欧美三级三级三级| 大胆欧美人体老妇| 免费成人av资源网| 一区二区三区精密机械公司| www久久久久| 欧美精品三级在线观看| www.欧美亚洲| 国产一区二区三区av电影| 日韩电影一区二区三区四区|