Esempio n. 1
0
    void InstantiateBoard()
    {
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Node node = getNodeAtPoint(new Point(x, y));

                //int val = board[x, y].value;
                int val = node.value;
                if (val <= 0)
                {
                    continue;
                }
                GameObject    p     = Instantiate(nodePiece, gameBoard);
                NodePiece     piece = p.GetComponent <NodePiece>();
                RectTransform rect  = p.GetComponent <RectTransform>();
                //rect.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                rect.anchoredPosition = new Vector2(tileSize / 2 + (tileSize * x), -(tileSize / 2) - (tileSize * y));
                //Debug.Log("size: " + val);
                piece.Initialize(val, new Point(x, y), pieces[val - 1]);
                node.SetPiece(piece);
            }
        }
    }
 void InstantiateBoard()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             int val = board[x, y].value;
             if (val <= 0)
             {
                 continue;
             }
             GameObject    p    = Instantiate(nodePiece, gameBoard);
             NodePiece     node = p.GetComponent <NodePiece>();
             RectTransform rect = p.GetComponent <RectTransform>();
             rect.anchoredPosition = new Vector2(32 + (78 * x), -32 - (80 * y));
             node.Initialize(val, new Point(x, y), pieces[val - 1]);
         }
     }
 }
Esempio n. 3
0
 void InstantiateBoard()
 {
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             Node node = getNodeAtPoint(new Point(x, y));
             int  val  = board[x, y].value;
             if (val <= 0)
             {
                 continue;
             }
             GameObject    p     = Instantiate(nodePiece, gameBoard);
             NodePiece     piece = p.GetComponent <NodePiece>();
             RectTransform rect  = p.GetComponent <RectTransform>();
             rect.anchoredPosition = new Vector2(50 + (100 * x), -50 - (100 * y));
             piece.Initialize(val, new Point(x, y), pieces[val - 1]);
             node.SetPiece(piece);
         }
     }
 }
 private void InstantiateBoard()
 {
     for (int x = 0; x < Width; x++)
     {
         for (int y = 0; y < Height; y++)
         {
             Node node  = GetNodeAtPoint(new Point(x, y));
             int  value = node.value;
             if (value <= 0)
             {
                 continue;
             }
             GameObject    p     = Instantiate(nodePiece, gameBoard);
             NodePiece     piece = p.GetComponent <NodePiece>();
             RectTransform rect  = p.GetComponent <RectTransform>();
             rect.anchoredPosition = new Vector2(-258 + (40 * x), 158 - (40 * y));
             piece.Initialize(value, new Point(x, y), pieces[value - 1]);
             node.SetPiece(piece);
         }
     }
 }
Esempio n. 5
0
    void InstantiateBoard()
    {
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Node node = getNodeAtPoint(new Point(x, y));

                int val = node.value;
                if (val <= 0)
                {
                    continue;
                }
                GameObject    p     = Instantiate(nodePiece, gameBoard);
                NodePiece     piece = p.GetComponent <NodePiece>();
                RectTransform rect  = p.GetComponent <RectTransform>();
                rect.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                piece.Initialize(val, new Point(x, y), pieces[val - 1]); // Why is val random? WHAT THE HELL!?
                node.SetPiece(piece);
            }
        }
    }
Esempio n. 6
0
    void InstantiateBoard()
    {
        for (int column = 0; column < width; column++)
        {
            for (int line = 0; line < height; line++)
            {
                Node node = getNodeAtCoord(new Coord(column, line));
                int  type = node.type;
                if (type <= 0)
                {
                    continue;
                }

                GameObject    node_object = Instantiate(nodePiece, gameBoard);
                NodePiece     piece       = node_object.GetComponent <NodePiece>();
                RectTransform rect        = node_object.GetComponent <RectTransform>();
                rect.anchoredPosition = new Vector2(32 + (64 * column), -32 - (64 * line));
                piece.Initialize(type, new Coord(column, line), sprites[type - 1]);
                node.SetPiece(piece);
            }
        }
    }
Esempio n. 7
0
    void InstantiateBoard() // Отрисовка доступного для игры поля
    {
        for (int x = 1; x < width - 1; x++)
        {
            for (int y = 1; y < height - 1; y++)
            {
                if (!boardLayout.rows[y].row[x])
                {
                    GameObject    s     = Instantiate(slot[0], slotBoard);
                    RectTransform rects = s.GetComponent <RectTransform>();
                    rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));

                    if (boardLayout.rows[y].row[x - 1])
                    {
                        s     = Instantiate(slot[1], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                    }

                    if (boardLayout.rows[y].row[x + 1])
                    {
                        s     = Instantiate(slot[1], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 180);
                    }

                    if (boardLayout.rows[y + 1].row[x])
                    {
                        s     = Instantiate(slot[1], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 90);
                    }

                    if (boardLayout.rows[y - 1].row[x])
                    {
                        s     = Instantiate(slot[1], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 270);
                    }

                    if (boardLayout.rows[y].row[x - 1] && boardLayout.rows[y - 1].row[x])
                    {
                        s     = Instantiate(slot[2], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                    }

                    if (boardLayout.rows[y].row[x + 1] && boardLayout.rows[y - 1].row[x])
                    {
                        s     = Instantiate(slot[2], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 270);
                    }

                    if (boardLayout.rows[y].row[x - 1] && boardLayout.rows[y + 1].row[x])
                    {
                        s     = Instantiate(slot[2], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 90);
                    }

                    if (boardLayout.rows[y].row[x + 1] && boardLayout.rows[y + 1].row[x])
                    {
                        s     = Instantiate(slot[2], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 180);
                    }

                    if (boardLayout.rows[y - 1].row[x] && boardLayout.rows[y + 1].row[x] && boardLayout.rows[y].row[x - 1])
                    {
                        s     = Instantiate(slot[3], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                    }

                    if (boardLayout.rows[y - 1].row[x] && boardLayout.rows[y].row[x + 1] && boardLayout.rows[y].row[x - 1])
                    {
                        s     = Instantiate(slot[3], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 270);
                    }

                    if (boardLayout.rows[y - 1].row[x] && boardLayout.rows[y + 1].row[x] && boardLayout.rows[y].row[x + 1])
                    {
                        s     = Instantiate(slot[3], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 180);
                    }

                    if (boardLayout.rows[y + 1].row[x] && boardLayout.rows[y].row[x - 1] && boardLayout.rows[y].row[x + 1])
                    {
                        s     = Instantiate(slot[3], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                        rects.localRotation    = Quaternion.Euler(0, 0, 90);
                    }

                    if (boardLayout.rows[y + 1].row[x] && boardLayout.rows[y].row[x - 1] && boardLayout.rows[y].row[x + 1] && boardLayout.rows[y - 1].row[x])
                    {
                        s     = Instantiate(slot[4], slotBoard);
                        rects = s.GetComponent <RectTransform>();
                        rects.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                    }
                }
                else
                {
                    continue;
                }
            }
        }

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Node node = GetNodeAtPoint(new Point(x, y));
                int  val  = node.value;
                if (val <= 0)
                {
                    continue;
                }
                GameObject    p     = Instantiate(nodePiece, gameBoard);
                NodePiece     piece = p.GetComponent <NodePiece>();
                RectTransform rect  = p.GetComponent <RectTransform>();
                rect.anchoredPosition = new Vector2(32 + (64 * x), -32 - (64 * y));
                piece.Initialize(val, new Point(x, y), pieces[val - 1]);
                node.SetPiece(piece);
            }
        }
    }