Пример #1
0
    void createGrid()
    {
        Vector2    gridSize   = calcGridSize();
        GameObject cellGridGO = new GameObject("CellGrid");

        Debug.Log("GridManager createGrid. GridSize X : " + gridSize.x + " GridSize Y: " + gridSize.y);
        for (float y = 0; y < gridSize.y; y++)
        {
            List <CollabCell> current_list = new List <CollabCell>();
            for (float x = 0; x < gridSize.x; x++)
            {
                GameObject cell    = (GameObject)Instantiate(Cell);
                Vector2    gridPos = new Vector2(x, y);
                cell.transform.position = calcWorldCoord(gridPos);
                cell.transform.parent   = cellGridGO.transform;
                CellPassthrough cell_pass = cell.GetComponent <CellPassthrough>();
                if (!cell_pass.CanPass())
                {
                    Debug.Log("FOOO");
                }
                int score = cell_pass.CanPass() ? CollabCell.BASE_SCORE : CollabCell.IMPASS_SCORE;
                // Debug.Log("Gridmanager creategrid current score for x, y {" + x + ","  + y + "} is "+ score);
                CollabCell store_cell = new CollabCell(cell, score, cell_pass.CanPass());
                current_list.Add(store_cell);
            }
            _cells.Add(current_list);
        }
    }
Пример #2
0
 public void UpdateGrid(List <Cell> newCells)
 {
     CellGrid.Clear();
     foreach (Cell cell in newCells)
     {
         CellGrid.Add(cell);
     }
 }