Ejemplo n.º 1
0
 public void SwipeData(string dir)
 {
     if (dir == "Left")
     {
         GameObject T = GetAdjacent(Vector2.left);
         if (T != null)
         {
             ConnectTile TT = T.GetComponent <ConnectTile>();
             SwapSprite(TT.render); // 2
             TT.ClearAllMatches(false, gameObject);
             temp = TT;
             TT.Deselect();
             ClearAllMatches(true, gameObject);
             Deselect();
         }
     }
     else if (dir == "Right")
     {
         GameObject T = GetAdjacent(Vector2.right);
         if (T != null)
         {
             ConnectTile TT = T.GetComponent <ConnectTile>();
             SwapSprite(TT.render); // 2
             TT.ClearAllMatches(false, gameObject);
             temp = TT;
             TT.Deselect();
             ClearAllMatches(true, gameObject);
             Deselect();
         }
     }
     else if (dir == "Up")
     {
         GameObject T = GetAdjacent(Vector2.up);
         if (T != null)
         {
             ConnectTile TT = T.GetComponent <ConnectTile>();
             SwapSprite(TT.render); // 2
             TT.ClearAllMatches(false, gameObject);
             temp = TT;
             TT.Deselect();
             ClearAllMatches(true, gameObject);
             Deselect();
         }
     }
     else if (dir == "Down")
     {
         GameObject T = GetAdjacent(Vector2.down);
         if (T != null)
         {
             ConnectTile TT = T.GetComponent <ConnectTile>();
             SwapSprite(TT.render); // 2
             TT.ClearAllMatches(false, gameObject);
             temp = TT;
             TT.Deselect();
             ClearAllMatches(true, gameObject);
             Deselect();
         }
     }
 }
Ejemplo n.º 2
0
    void OnMouseDown()
    {
        // 1
        if (render.sprite == null || BoardManager.instance.IsShifting || !Started)
        {
            return;
        }

        if (isSelected)
        { // 2 Is it already selected?
            Deselect();
        }
        else
        {
            if (previousSelected == null)
            { // 3 Is it the first tile selected?
                Select();
            }
            else
            {
                if (GetAllAdjacentTiles().Contains(previousSelected.gameObject))
                {                                        // 1
                    SwapSprite(previousSelected.render); // 2
                    previousSelected.ClearAllMatches(false, gameObject);
                    temp = previousSelected;
                    previousSelected.Deselect();
                    ClearAllMatches(true, gameObject);
                }
                else
                { // 3
                    previousSelected.GetComponent <ConnectTile>().Deselect();
                    Select();
                }
            }
        }
    }