Exemplo n.º 1
0
    void InitBoard()
    {
        grid                 = boardRect.GetComponent <GridLayoutGroup>();
        grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        grid.constraintCount = boardColumnCount;

        boardWidth  = boardRect.sizeDelta.x;
        boardHeight = boardRect.sizeDelta.y;

        int numCells = boardColumnCount * boardRowCount;

        for (int i = 0; i < numCells; i++)
        {
            CellSlot cellSlot = Instantiate(cellSlotPrefab, boardRect);
            slotList.Add(cellSlot);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }

        BoardGenerator bg = GetComponent <BoardGenerator>();

        if (bg != null)
        {
            bg.GenerateBoard();
        }
    }
Exemplo n.º 2
0
    public void LoadBoard(List <CellData> cells)
    {
        if (slotList != null)
        {
            for (int i = 0; i < cells.Count; i++)
            {
                if ((cells[i] != null) && (slotList.Count > i))
                {
                    CombatantCell combatCell = SpawnCombatCell(cells[i], slotList[i]);
                    slotList[i].LoadCell(combatCell, combatCell.GetCellData(), false);
                }
            }
        }

        if (health != null)
        {
            int cellCount = slotList.Count;
            health.InitHealth(cellCount);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }
    }