Пример #1
0
    private void MarkNeighbors(Color color)
    {
        GameBoard            board     = GameBoard.GAME_BOARD;
        List <GameBoardTile> neighbors = new List <GameBoardTile>();

        if (board.GetTile((int)x - 1, (int)y) != null)
        {
            neighbors.Add(board.GetTile((int)x - 1, (int)y));
        }
        if (board.GetTile((int)x + 1, (int)y) != null)
        {
            neighbors.Add(board.GetTile((int)x + 1, (int)y));
        }
        if (board.GetTile((int)x, (int)y - 1) != null)
        {
            neighbors.Add(board.GetTile((int)x, (int)y - 1));
        }
        if (board.GetTile((int)x, (int)y + 1) != null)
        {
            neighbors.Add(board.GetTile((int)x, (int)y + 1));
        }
        foreach (GameBoardTile tile in neighbors)
        {
            if (!IsTileOccupated(tile))
            {
                if (tile.GetComponent <SwappingTileBehavior>() != null)
                {
                    tile.GetComponent <SwappingTileBehavior>().Mark(color);
                }
            }
            else
            {
                if (tile.GetComponent <SwappingTileBehavior>() != null)
                {
                    tile.GetComponent <SwappingTileBehavior>().Unmark();
                }
            }
        }
    }
Пример #2
0
 public bool OnRelease()
 {
     if (board.FindAndReplace(tile))
     {
         tile.GetComponent <DraggableObject>().enabled = false;
         if (sounds != null)
         {
             sounds[2].Play();
         }
         return(true);
     }
     return(false);
 }