示例#1
0
    private int[] SearchSameShape(BlownUpStatus[,] blownUpStatus, int start_row, int start_col)
    {
        BlownUpStatus.EffectShape shape = blownUpStatus[start_row, start_col].mShape;
        Queue <int[]>             q     = new Queue <int[]>();

        int[] maxPath = new int[2] {
            -1, -1
        };
        int maxMovingTime = -1;

        q.Enqueue((new int[2] {
            start_row, start_col
        }));
        int[] now;
        int[,] index = new int[4, 2] {
            { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }
        };
        int start, end;

        while (q.Count != 0)
        {
            now = q.Dequeue();
            mTilesDestroyed[now[0], now[1]] = true;
            if (mTiles[now[0], now[1]].Status.MoveTime > maxMovingTime)
            {
                if (mTiles[now[0], now[1]].Status.CountToDestroy == 1)
                {
                    maxMovingTime = mTiles[now[0], now[1]].Status.MoveTime;
                    maxPath[0]    = now[0];
                    maxPath[1]    = now[1];
                }
            }
            start = blownUpStatus[now[0], now[1]].mHorizontal? 0:2;
            end   = blownUpStatus[now[0], now[1]].mVertical? 4:2;
            for (int i = start; i < end; i++)
            {
                if (SearchSameShapeIs(blownUpStatus, now[0] + index[i, 0], now[1] + index[i, 1], shape) && !mCheckToDestroyed[now[0] + index[i, 0], now[1] + index[i, 1]])
                {
                    mCheckToDestroyed[now[0] + index[i, 0], now[1] + index[i, 1]] = true;
                    q.Enqueue((new int[2] {
                        now[0] + index[i, 0], now[1] + index[i, 1]
                    }));
                }
            }
        }
        return(maxPath);
    }
示例#2
0
 private bool SearchSameShapeIs(BlownUpStatus[,] blownUpStatus, int now_row, int now_col, BlownUpStatus.EffectShape shape)
 {
     if (now_row < 0 || now_row >= MAX_ROW_COUNT || now_col < 0 || now_col >= MAX_COL_COUNT)
     {
         return(false);
     }
     if (blownUpStatus[now_row, now_col].mShape != shape)
     {
         return(false);
     }
     return(true);
 }