Esempio n. 1
0
    public void Setup(GridArray <TileArrayObject> grid)
    {
        this.grid       = grid;
        visualNodeList  = new List <Transform>();
        visualNodeArray = new Transform[grid.GetHeight(), grid.GetWidth()];

        // Initialize
        for (int row = 0; row < grid.GetHeight(); row++)
        {
            for (int col = 0; col < grid.GetWidth(); col++)
            {
                Vector3 gridPosition = grid.GetWorldPosition(row, col) +
                                       0.5f * new Vector3(grid.GetCellSize(), grid.GetCellSize());
                Transform visualNode = CreateVisualNode(gridPosition);
                visualNodeArray[row, col] = visualNode;
                visualNodeList.Add(visualNode);
            }
        }

        UpdateVisual(grid);

        grid.OnGridObjectChanged += (object sender, GridArray <TileArrayObject> .OnGridObjectChangedEventArgs eventArgs) => {
            updateVisual = true;
        };
    }
Esempio n. 2
0
    // Update display
    public void UpdateVisual(GridArray <TileArrayObject> grid)
    {
        HideNodeVisuals();

        for (int row = 0; row < grid.GetHeight(); row++)
        {
            for (int col = 0; col < grid.GetWidth(); col++)
            {
                TileArrayObject gridObject = grid.GetGridObject(row, col);

                Transform visualNode = visualNodeArray[row, col];
                visualNode.gameObject.SetActive(true);
                SetupVisualNode(visualNode, gridObject);
            }
        }
    }