コード例 #1
0
        void DrawOverlayData(GridDungeonConfig config, GridDungeonModel model, bool mode2D)
        {
            var mode                 = target as DungeonPaintModeGrid;
            var opacity              = mode.overlayOpacity;
            var gridSize             = config.GridCellSize;
            var cellColorProcedural  = Color.blue;
            var cellColorUserDefined = Color.cyan;

            // Visualize the user defined cells defined by the paint tool
            foreach (var cell in model.Cells)
            {
                var size     = Vector3.Scale(DMathUtils.ToVector3(cell.Bounds.Size), gridSize);
                var location = Vector3.Scale(DMathUtils.ToVector3(cell.Bounds.Location), gridSize);
                var color    = cell.UserDefined ? cellColorUserDefined : cellColorProcedural;
                DrawRect(location, size, color, opacity, 0.3f, mode2D);
            }
        }
コード例 #2
0
        void DrawRect(Vector3 position, Vector3 size, Color color, float faceOpacity, float outlineOpacity, bool mode2D)
        {
            var verts = new Vector3[] {
                position,
                position + new Vector3(size.x, 0, 0),
                position + new Vector3(size.x, 0, size.z),
                position + new Vector3(0, 0, size.z)
            };

            if (mode2D)
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    verts[i] = DMathUtils.FlipYZ(verts[i]);
                }
            }
            Color faceColor    = new Color(color.r, color.g, color.b, faceOpacity);
            Color outlineColor = new Color(color.r, color.g, color.b, outlineOpacity);

            Handles.DrawSolidRectangleWithOutline(verts, faceColor, outlineColor);
        }
コード例 #3
0
        void UpdateCursorPosition(DungeonPaintModeGrid mode)
        {
            float distance;
            var   e = Event.current;
            Plane plane;

            if (mode.mode2D)
            {
                var planePoint = Vector3.zero;
                plane = new Plane(new Vector3(0, 0, 1), planePoint);
            }
            else
            {
                var cursorHeight = mode.GetCursorHeight();
                var planePoint   = new Vector3(0, cursorHeight, 0);
                plane = new Plane(Vector3.up, planePoint);
            }

            var ray = HandleUtility.GUIPointToWorldRay(e.mousePosition);

            if (plane.Raycast(ray, out distance))
            {
                var hitpoint = ray.GetPoint(distance);
                if (mode.mode2D)
                {
                    hitpoint = DMathUtils.FlipYZ(hitpoint);
                }
                hitpoint       = SnapToGrid(hitpoint);
                cursorPosition = hitpoint;

                if (!mode.mode2D)
                {
                    if (e.type == EventType.ScrollWheel)
                    {
                        var delta = (int)Mathf.Sign(e.delta.y);
                        mode.SetElevationDelta(delta);
                    }
                }
            }
        }