Exemplo n.º 1
0
        SnapGizmoRenderCommandTile CreateTileRenderCommand(Vector3 worldPosition)
        {
            var command = new SnapGizmoRenderCommandTile();

            command.worldPosition = worldPosition;
            command.drawColor     = Color.white;
            command.drawWireframe = false;
            command.CalculateDistanceToCamera(EditorData.worldToCamera);
            return(command);
        }
Exemplo n.º 2
0
        void RenderScene()
        {
            var renderCommands = new List <SnapGizmoRenderCommand>();

            foreach (var entry in MarkerRegistry.MarkerStates)
            {
                var position = entry.Key;
                var state    = entry.Value;
                if (state.GroundTiles.Contains(DungeonConstants.ST_GROUND))
                {
                    var worldPosition = position * GridCellSize;
                    var command       = CreateTileRenderCommand(worldPosition);
                    command.CalculateDistanceToCamera(EditorData.worldToCamera);
                    renderCommands.Add(command);
                }
            }

            // Cursor command
            {
                var cursorWorldPos = EditorData.cursorPosition * GridCellSize;
                var cursorCommand  = CreateTileRenderCommand(cursorWorldPos);
                cursorCommand.drawColor     = Color.red;
                cursorCommand.drawWireframe = true;
                cursorCommand.CalculateDistanceToCamera(EditorData.worldToCamera);
                renderCommands.Add(cursorCommand);

                // Create an overlay for blocked cursor region
                var cursorOverlayCommand = new SnapGizmoRenderCommandTile();
                cursorOverlayCommand.worldPosition    = EditorData.cursorPosition * GridCellSize;
                cursorOverlayCommand.drawColor        = new Color(1, 0, 0, .25f);
                cursorOverlayCommand.drawWireframe    = true;
                cursorOverlayCommand.DistanceToCamera = 0;  // Force a draw on top of everything
                renderCommands.Add(cursorOverlayCommand);
            }

            // Sort based on depth from camera
            var depthSortedCommands = renderCommands.OrderByDescending(o => o.DistanceToCamera).ToArray();

            // Draw the commands
            foreach (var command in depthSortedCommands)
            {
                command.Draw(this);
            }
        }