コード例 #1
0
 private void button1_Click_restart(object sender, EventArgs e)
 {
     //restrart
     l = RandomCreate();
     mGrid.clear();
     mnScroe     = 0;
     mbPaused    = false;
     label7.Text = mnScroe.ToString();
 }
コード例 #2
0
 public void SetGridBlock(ActiveGameObject nActiveGameObject)
 {
     for (int i = 0; i < 4; i++)
     {
         Blocks lTempBlocks = nActiveGameObject.GetBlocks(i);
         int    bx          = nActiveGameObject.mPosX + lTempBlocks.mRelatedX + 1;
         int    by          = nActiveGameObject.mPosY + lTempBlocks.mRelatedY + 1;
         mListBlocks[by * Constants.PREVIEW_WINDOW_X + bx].mbValid = true;
         mListBlocks[by * Constants.PREVIEW_WINDOW_X + bx].mColor  = lTempBlocks.mColor;
     }
 }
コード例 #3
0
 public int GetMostDetla(ActiveGameObject nActiveGameObject)
 {
     for (int y = 0; y < Constants.PREVIEW_WINDOW_Y; y++)
     {
         if (CheckCollision(0, y, nActiveGameObject))
         {
             return(y - 1);;
         }
     }
     return(0);
 }
コード例 #4
0
        public int CheckScore(ActiveGameObject nActiveGameObject)
        {
            SortedSet <int> lScoreList = new SortedSet <int>();

            for (int i = 0; i < 4; i++)
            {
                Blocks lTempBlocks = nActiveGameObject.GetBlocks(i);
                int    y           = nActiveGameObject.mPosY + lTempBlocks.mRelatedY + 1;
                bool   bScore      = true;
                for (int j = 0; j < Constants.PREVIEW_WINDOW_X; j++)
                {
                    if (mListBlocks[y * Constants.PREVIEW_WINDOW_X + j].mbValid == false)
                    {
                        bScore = false;
                        break;
                    }
                }
                if (bScore)
                {
                    lScoreList.Add(y);
                }
            }


            foreach (int y in lScoreList)
            {
                for (int j = 0; j < Constants.PREVIEW_WINDOW_X; j++)
                {
                    mListBlocks[y * Constants.PREVIEW_WINDOW_X + j].mbValid = false;
                }
                //Move all blocks above this line
                for (int ii = y - 1; ii >= 0; ii--)
                {
                    for (int j = 0; j < Constants.PREVIEW_WINDOW_X; j++)
                    {
                        mListBlocks[(ii + 1) * Constants.PREVIEW_WINDOW_X + j].mbValid = mListBlocks[(ii) * Constants.PREVIEW_WINDOW_X + j].mbValid;
                        mListBlocks[(ii + 1) * Constants.PREVIEW_WINDOW_X + j].mColor  = mListBlocks[(ii) * Constants.PREVIEW_WINDOW_X + j].mColor;
                        mListBlocks[(ii) * Constants.PREVIEW_WINDOW_X + j].mbValid     = false;
                    }
                }
            }


            return(lScoreList.Count);
        }
コード例 #5
0
        public bool CheckRatate(ActiveGameObject nActiveGameObject, bool bClock)
        {
            List <int> lt = new List <int>();

            nActiveGameObject.PreRotate(bClock, ref lt);
            for (int i = 0; i < 4; i++)
            {
                int bx = nActiveGameObject.mPosX + lt[i * 2] + 1;
                int by = nActiveGameObject.mPosY + lt[i * 2 + 1] + 1;
                if (bx < 0 || bx >= Constants.PREVIEW_WINDOW_X ||
                    by < 0 || by >= Constants.PREVIEW_WINDOW_Y ||
                    mListBlocks[by * Constants.PREVIEW_WINDOW_X + bx].mbValid)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #6
0
        public bool CheckCollision(int x, int y, ActiveGameObject nActiveGameObject)
        {
            int npx = nActiveGameObject.mPosX + x;
            int npy = nActiveGameObject.mPosY + y;

            for (int i = 0; i < 4; i++)
            {
                Blocks lTempBlocks = nActiveGameObject.GetBlocks(i);
                int    bx          = npx + lTempBlocks.mRelatedX + 1;
                int    by          = npy + lTempBlocks.mRelatedY + 1;
                if (bx < 0 || bx >= Constants.PREVIEW_WINDOW_X ||
                    by < 0 || by >= Constants.PREVIEW_WINDOW_Y ||
                    mListBlocks[by * Constants.PREVIEW_WINDOW_X + bx].mbValid)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #7
0
        private bool Check(int x, int y)
        {
            if (false != mGrid.CheckCollision(x, y, l))
            {
                if (y != 0)
                {
                    mGrid.SetGridBlock(l);
                    //Check Score
                    int lnTempScrore = mGrid.CheckScore(l);
                    if (lnTempScrore > 0)
                    {
                        if (lnTempScrore == 1)
                        {
                            mnScroe += 100;
                        }
                        else if (lnTempScrore == 2)
                        {
                            mnScroe += 300;
                        }
                        else if (lnTempScrore == 3)
                        {
                            mnScroe += 600;
                        }
                        else if (lnTempScrore == 4)
                        {
                            mnScroe += 1000;
                        }
                        label7.Text = mnScroe.ToString();
                    }

                    l     = lNext;
                    lNext = RandomCreate();
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }