Пример #1
0
    public void SwipeElement(MoveDir dir)
    {
        if (m_Pause)
        {
            return;
        }
        if (m_TouchElement == null)
        {
            return;
        }
        BoxElementControl curControl = m_TouchElement.GetComponent <BoxElementControl>();

        GameObject nbObj = curControl.GetNeighbor(dir);

        if (nbObj == null)
        {
            return;
        }

        BoxElementControl nbControl = nbObj.GetComponent <BoxElementControl>();
        MoveDir           opDir     = BoxElementControl.OppositeDir(dir);

        if (curControl.GetState() == BoxState.FIX && nbControl.GetState() == BoxState.FIX)
        {
            curControl.SwipeTo(dir);
            nbControl.SwipeTo(opDir);
        }
        m_TouchElement = null;
    }
Пример #2
0
    bool FindNextTarget()
    {
        m_CurBounce++;
        if (m_CurBounce >= m_BounceNum)
        {
            return(false);
        }

        int w = m_BG.GetCoordW();
        int h = m_BG.GetCoordH();

        for (int x = 0; x < w; x++)
        {
            for (int y = 0; y < h; y++)
            {
                Coord2D    coord = new Coord2D((x + m_TargetCoord.x) % w, y);
                GameObject obj   = m_BG.GetElementByCoord(coord);
                if (obj == null)
                {
                    continue;
                }
                BoxElementControl objControl = obj.GetComponent <BoxElementControl>();
                if (objControl.m_Type == m_TargetType && objControl.GetState() != BoxState.ELIMINATE)
                {
                    m_Target      = obj;
                    m_TargetCoord = coord;
                    return(true);
                }
            }
        }
        return(false);
    }
Пример #3
0
    public bool IsReachTop()
    {
        int w = m_BG.GetCoordW();
        int h = m_BG.GetCoordH();

        for (int x = 0; x < w; x++)
        {
            GameObject obj = m_BG.GetElementByCoord(new Coord2D(x, h - 1));
            if (obj)
            {
                BoxElementControl bec = obj.GetComponent <BoxElementControl>();
                if (bec.GetState() == BoxState.FIX)
                {
                    return(true);                                  //element fixed at top
                }
            }
        }
        return(false);
    }