示例#1
0
		//Check all list needed
		public void checkMatch()
		{
			int length = blockNeedChecks.Count;
			for(int i = 0; i< length; i++)
			{
				BlockNeedCheck block = blockNeedChecks[i];
				//Check block
				this.checkMatchAt(block);

				//Check destroys
				int H = block.left + block.right -1;
				int V = block.top + block.bottom -1;
				int j = 0;
				if(H >=3)
				{
					j = block.left -1;
					while (j>0)
					{
						blockNeedDestroys.Add(new BlockNeedDestroy(block.x-j,block.y));
						j--;
					}
					j = block.right -1;
					while (j>0)
					{
						blockNeedDestroys.Add(new BlockNeedDestroy(block.x+j,block.y));
						j--;
					}
				}

				if(V >=3)
				{
					j = block.top -1;
					while (j>0)
					{
						blockNeedDestroys.Add(new BlockNeedDestroy(block.x,block.y-j));
						j--;
					}
					j = block.bottom -1;
					while (j>0)
					{
						blockNeedDestroys.Add(new BlockNeedDestroy(block.x,block.y+j));
						j--;
					}
				}

				if(V >=3 || H >= 3)
				{
					blockNeedDestroys.Add(new BlockNeedDestroy(block.x,block.y));
				}

				if(H>4 || V>4)
				{
					//scores.turn ++;
				}
			}
			//Clean list need check
			blockNeedChecks.Clear ();
		}
示例#2
0
		//check match H
		public int checkMatchHorizontal(BlockNeedCheck block) {
			int x = block.x;
			int y = block.y;
			int countMatch = 1;
			int numberBlock = 1;
			int typeBlock = this.blocks[x,y];

			//Check left
			while (x >= numberBlock && typeBlock == this.blocks[(x - numberBlock),y]) {
				numberBlock++;
				countMatch++;
			}
			block.left = numberBlock;
			numberBlock = 1;

			//Check right
			while ((x + numberBlock) < 8 && typeBlock == this.blocks[(x + numberBlock),y]) {
				numberBlock++;
				countMatch++;
			}
			block.right = numberBlock;
			return countMatch;
		}
示例#3
0
		//check match V
		public int checkMatchVertical(BlockNeedCheck block) {
			int x = block.x;
			int y = block.y;

			int countMatch = 1;
			int numberBlock = 1;
			int typeBlock = this.blocks[x,y];

			//Check bot
			while (y >= numberBlock && typeBlock == this.blocks[x,(y - numberBlock)]) {
				numberBlock++;
				countMatch++;
			}
			block.top = numberBlock;
			numberBlock = 1;

			//Check top
			while ((y + numberBlock) < 8 && typeBlock == this.blocks[x,(y + numberBlock)]) {
				numberBlock++;
				countMatch++;
			}
			block.bottom = numberBlock;
			return countMatch;
		}
示例#4
0
		public void checkMatchAt(BlockNeedCheck block)
		{
			//check top ...
			checkMatchVertical(block);
			checkMatchHorizontal(block);
		}
示例#5
0
		private BlockCanMove checkCanMove(int x1, int y1, int x2, int y2) {
			if(this.blocks[x1,y1] == this.blocks[x1,y1]
			{
			    return null;
			}

			if(x2 > 8 || y2 >8)
            {
                return null;
            }

            //swap
            this.swapBlock(x1,y1,x2,y2);

            BlockNeedCheck block1 = new BlockNeedCheck(x1,y1));
            BlockNeedCheck block2 = new BlockNeedCheck(x2,y2));

            int H1 = block1.left + block1.right -1;
            int V1 = block1.top + block1.bottom -1;

            int H2 = block2.left + block2.right -1;
            int V2 = block2.top + block2.bottom -1;
            int point = 0;
            if(V1 > 3 || H1 > 3)
            {
                point+=1;
            }

            if(V1 > 3 || H1 > 3)
            {
                point+=1;
            }

            if(H1>4 || V1>4 )
            {
               point+=1;
            }

            if(H2>4 || V2>4 )
            {
               point+=1;
            }

            if(H1>5 || V1>5 )
            {
               point+=1;
            }

            if(H2>5 || V2>5 )
            {
               point+=1;
            }


            //Re swap
            this.swapBlock(x1,y1,x2,y2);
            if(point > 0)
            {
                BlockCanMove blockCanMove = new BlockCanMove();
                blockCanMove.x1 = x1;
                blockCanMove.y1 = y1;
                blockCanMove.x2 = x2;
                blockCanMove.y2 = y2;
                blockCanMove.point = point;

                return blockCanMove;
            }
            else
            {
                return null;
            }
		}