void m_gc_SwapEnd(Tile a, Tile b)
 {
     m_redrawBackBuffer = true;
     Invalidate();
 }
        void m_gc_SwapStart(Tile a, Tile b)
        {
            Point t1 = new Point(a.tileLoc.X * m_tiles[0].Width, a.tileLoc.Y * m_tiles[0].Height);
            Point t2 = new Point(b.tileLoc.X * m_tiles[0].Width, b.tileLoc.Y * m_tiles[0].Height);

            m_animHandler.Add(new Animation(m_tiles[a.tileInd], t2, t1, m_gc.SwapSpeed));
            m_animHandler.Add(new Animation(m_tiles[b.tileInd], t1, t2, m_gc.SwapSpeed));

            m_redrawBackBuffer = true;
            Invalidate();
        }
示例#3
0
        public bool Swap(Point a, Point b)
        {
            if ((m_swapLock || (Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y)) != 1))
            {
                return false;
            }
            else
            {
                SwapTiles(b,a);
                if (IsMatch(b) || IsMatch(a))
                {
                    Tile[] p = new Tile[2];
                    p[0].tileInd = m_grid[a.X,a.Y];
                    p[0].tileLoc = a;
                    p[1].tileInd = m_grid[b.X,b.Y];
                    p[1].tileLoc = b;

                    m_swapLock = true;
                    m_grid[a.X, a.Y] = -1;
                    m_grid[b.X, b.Y] = -1;
                    if (SwapStart != null)
                        SwapStart(p[0], p[1]);
                    Thread th = new Thread(new ParameterizedThreadStart(SwapTimerCallback));
                    th.Start(p);
                    /*

                    if (IsMatch(b))
                        ClearMatch(b, false);
                    if (IsMatch(a))
                        ClearMatch(a, false);
                    for (int i = 0; i < m_cols; i++)
                        DropTiles(i);
                    do
                        FillBlanks();
                    while (CheckandClear());
                     */
                }
                else
                {
                    SwapTiles(a, b);
                    return false;
                }
            }
            return true;
        }