Ejemplo n.º 1
0
        public virtual void BoxFillPreview(GridLayout gridLayout, GameObject brushTarget, BoundsInt position)
        {
            if (brushTarget != null)
            {
                var pvmanager = PreviewManager.Instance;
                if (pvmanager == null)
                {
                    return;
                }

                foreach (Vector3Int location in position.allPositionsWithin)
                {
                    Vector3Int local = location - position.min;
                    TilePaletteGridObjectBrush.BrushCell cell = m_GridObjectBrush.cells[m_GridObjectBrush.GetCellIndexWrapAround(local.x, local.y, local.z)];
                    if (cell.gridObject != null)
                    {
                        SetPreviewCell(gridLayout, location, cell);
                    }
                }
            }

            m_LastGrid        = gridLayout;
            m_LastBounds      = position;
            m_LastBrushTarget = brushTarget;
            m_LastTool        = GridBrushBase.Tool.Box;
        }
Ejemplo n.º 2
0
        public virtual void PaintPreview(GridLayout gridLayout, GameObject brushTarget, Vector3Int position)
        {
            Vector3Int min    = position - m_GridObjectBrush.pivot;
            Vector3Int max    = min + m_GridObjectBrush.size;
            BoundsInt  bounds = new BoundsInt(min, max - min);

            var pvmanager = PreviewManager.Instance;

            if (pvmanager == null)
            {
                return;
            }

            if (brushTarget != null && gridLayout != null)
            {
                foreach (Vector3Int location in bounds.allPositionsWithin)
                {
                    Vector3Int brushPosition = location - min;
                    TilePaletteGridObjectBrush.BrushCell cell = m_GridObjectBrush.cells[m_GridObjectBrush.GetCellIndex(brushPosition)];
                    if (cell.gridObject != null)
                    {
                        SetPreviewCell(gridLayout, location, cell);
                    }
                }
            }

            m_LastGrid        = gridLayout;
            m_LastBounds      = bounds;
            m_LastBrushTarget = brushTarget;
            m_LastTool        = GridBrushBase.Tool.Paint;
        }
Ejemplo n.º 3
0
        private static void SetPreviewCell(GridLayout grid, Vector3Int position, TilePaletteGridObjectBrush.BrushCell cell)
        {
            if (cell.gridObject == null || grid == null)
            {
                return;
            }

            var pvmanager = PreviewManager.Instance;

            if (pvmanager == null)
            {
                return;
            }

            PreviewManager.Instance.InstantiatePreviewGridObjectAtPosition(cell.gridObject, position.ToVector2IntXY(), Vector3.zero, cell.orientation);
        }