Beispiel #1
0
    private Transform OnCreateNewBlock(int x, int y)
    {
        //TODO: 需要一个对象池或者工厂?
        var blcok = Instantiate(blockVisualNode, grid.Cell2WorldPos(x, y), quaternion.identity);

        VisualNodeArray[x, y] = blcok;
        blcok.DOScale(new Vector3(5, 5), 1f)
        .From();
        SetupVisualNode(x, y);
        return(blcok);
    }
Beispiel #2
0
    public void Setup(Grid2D <MapObject> grid2D)
    {
        _grid2D     = grid2D;
        _vNodeArray = new Transform[_grid2D.GetWidth(), _grid2D.GetHeight()];
        for (var x = 0; x < _vNodeArray.GetLength(0); x++)
        {
            for (var y = 0; y < _vNodeArray.GetLength(1); y++)
            {
                var visualNode = CreatVisualNode(_grid2D.Cell2WorldPos(x, y));
                _vNodeArray[x, y] = visualNode;
                _visualNodeList.Add(visualNode);
            }
        }

        HideNodeVisual();
        UpdateVisual(_grid2D);

        _grid2D.OnGridMapValueChangeEvent += OnGrid2DObjectChangedHandel;
    }