コード例 #1
0
        private List <BoxIndex> checkRow(int index_y)
        {
            int             Count      = 1;
            BoxType         LastFound  = Boxes[0, index_y].Type;
            List <BoxIndex> RemoveList = new List <BoxIndex>();
            bool            IsChange   = false;

            for (int x = 1; x < PuzzleWeight + 1; x++)
            {
                if (LastFound == Boxes[x, index_y].Type)
                {
                    Count++;
                }
                else
                {
                    LastFound = Boxes[x, index_y].Type;
                    IsChange  = true;
                }
                if (IsChange)
                {
                    if (Boxes[x - 1, index_y].Type != BoxType.Empty)
                    {
                        if (Count >= 3)
                        {
                            for (int i = 0; i < Count; i++)
                            {
                                BoxIndex RemoveIndex = new BoxIndex {
                                    Index_X = x - i - 1, Index_Y = index_y
                                };
                                RemoveList.Add(RemoveIndex);
                            }
                        }
                    }
                    Count    = 1;
                    IsChange = false;
                }
            }
            return(RemoveList);
        }
コード例 #2
0
        private List <BoxIndex> checkCol(int index_x)
        {
            int             Count      = 1;
            BoxType         LastFound  = Boxes[index_x, 0].Type;
            List <BoxIndex> RemoveList = new List <BoxIndex>();
            bool            IsChange   = false;

            for (int y = 1; y < PuzzleHeight + 1; y++)
            {
                if (LastFound == Boxes[index_x, y].Type)
                {
                    Count++;
                }
                else
                {
                    LastFound = Boxes[index_x, y].Type;
                    IsChange  = true;
                }
                if (IsChange)
                {
                    if (Boxes[index_x, y - 1].Type != BoxType.Empty)
                    {
                        if (Count >= 3)
                        {
                            for (int i = 0; i < Count; i++)
                            {
                                BoxIndex RemoveIndex = new BoxIndex {
                                    Index_X = index_x, Index_Y = y - i - 1
                                };
                                RemoveList.Add(RemoveIndex);
                            }
                        }
                    }
                    Count    = 1;
                    IsChange = false;
                }
            }
            return(RemoveList);
        }