Esempio n. 1
0
        public override void Render3D(DwarfGame game, DwarfTime time)
        {
            NamedImageFrame frame = new NamedImageFrame("newgui/pointers", 32, 5, 0);

            foreach (GameComponent tree in World.UserInterface.BodySelector.CurrentBodies)
            {
                if (tree.Tags.Contains("Vegetation"))
                {
                    Drawer3D.DrawBox(tree.BoundingBox, Color.LightGreen, 0.1f, false);
                    Drawer2D.DrawSprite(frame, tree.BoundingBox.Center(), Vector2.One * 0.5f, Vector2.Zero, new Color(255, 255, 255, 100));
                }
            }
        }
Esempio n. 2
0
        public virtual void Render()
        {
            switch (Mode)
            {
            case IndicatorMode.Indicator3D:
                Drawer2D.DrawSprite(Image, Position, new Vector2(Scale, Scale), Offset, Tint, Flip);
                break;

            case IndicatorMode.Indicator2D:
                DwarfGame.SpriteBatch.Draw(Image.Image, new Vector2(Position.X, Position.Y), Image.SourceRect, Tint, 0.0f, Offset, new Vector2(Scale, Scale), Flip ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0.0f);
                break;
            }
        }
Esempio n. 3
0
        public override void Render3D(DwarfGame game, DwarfTime time)
        {
            NamedImageFrame frame = new NamedImageFrame("newgui/pointers", 32, 6, 0);

            foreach (var body in World.UserInterface.BodySelector.CurrentBodies)
            {
                if (body.Tags.Contains("Resource"))
                {
                    Drawer2D.DrawText(body.Name, body.Position, Color.White, Color.Black);
                    BoundingBox bounds = body.BoundingBox;
                    Drawer3D.DrawBox(bounds, Color.Orange, 0.02f, false);
                    Drawer2D.DrawSprite(frame, body.Position + Vector3.One * 0.5f, Vector2.One * 0.5f, Vector2.Zero, new Color(255, 255, 255, 100));
                }
            }
        }
Esempio n. 4
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            NamedImageFrame frame = new NamedImageFrame("newgui/pointers", 32, 6, 0);

            // Draw a bounding box around the currently selected bodies.
            foreach (Body body in Player.BodySelector.CurrentBodies)
            {
                if (body.Tags.Contains("Resource"))
                {
                    Drawer2D.DrawText(body.Name, body.Position, Color.White, Color.Black);
                    BoundingBox bounds = body.BoundingBox;
                    bounds.Min += Vector3.Up * 0.5f;
                    bounds.Max += Vector3.Up * 0.5f;
                    bounds      = bounds.Expand(0.25f);
                    Drawer3D.DrawBox(bounds, Color.Orange, 0.02f, false);
                    Drawer2D.DrawSprite(frame, bounds.Center(), Vector2.One, Vector2.Zero, new Color(255, 255, 255, 100));
                }
            }
        }
Esempio n. 5
0
 public virtual void Render()
 {
     Drawer2D.DrawSprite(Image, Position, new Vector2(Scale, Scale), Offset, Tint, Flip);
 }
Esempio n. 6
0
        public void DrawHilites(
            DesignationSet Set,
            Action <Vector3, Vector3, Color, float, bool> DrawBoxCallback,
            Action <Vector3, VoxelType> DrawPhantomCallback)
        {
            var colorModulation = Math.Abs(Math.Sin(DwarfTime.LastTime.TotalGameTime.TotalSeconds * 2.0f));

            foreach (var properties in DesignationProperties)
            {
                properties.Value.ModulatedColor = new Color(
                    (byte)(MathFunctions.Clamp((float)(properties.Value.Color.R * colorModulation + 50), 0.0f, 255.0f)),
                    (byte)(MathFunctions.Clamp((float)(properties.Value.Color.G * colorModulation + 50), 0.0f, 255.0f)),
                    (byte)(MathFunctions.Clamp((float)(properties.Value.Color.B * colorModulation + 50), 0.0f, 255.0f)),
                    255);
            }

            foreach (var voxel in Set.EnumerateDesignations())
            {
                if ((voxel.Type & VisibleTypes) == voxel.Type)
                {
                    var props = DefaultProperties;
                    if (DesignationProperties.ContainsKey(voxel.Type))
                    {
                        props = DesignationProperties[voxel.Type];
                    }

                    var v = voxel.Voxel.Coordinate.ToVector3();
                    if (props.Icon != null)
                    {
                        Drawer2D.DrawSprite(props.Icon, v + Vector3.One * 0.5f, Vector2.One * 0.5f, Vector2.Zero, new Color(255, 255, 255, 100));
                    }

                    if (voxel.Type == DesignationType.Put) // Hate this.
                    {
                        DrawPhantomCallback(v, VoxelLibrary.GetVoxelType((voxel.Tag as short?).Value));
                    }
                    else
                    {
                        DrawBoxCallback(v, Vector3.One, props.ModulatedColor, props.LineWidth, true);
                    }
                }
            }

            foreach (var entity in Set.EnumerateEntityDesignations())
            {
                if ((entity.Type & VisibleTypes) == entity.Type)
                {
                    var props = DefaultProperties;
                    if (DesignationProperties.ContainsKey(entity.Type))
                    {
                        props = DesignationProperties[entity.Type];
                    }

                    entity.Body.SetTintRecursive(props.ModulatedColor);

                    // Todo: More consistent drawing?
                    if (entity.Type == DesignationType.Craft)
                    {
                        entity.Body.SetFlagRecursive(GameComponent.Flag.Visible, true);
                    }
                    else
                    {
                        var box = entity.Body.GetBoundingBox();
                        DrawBoxCallback(box.Min, box.Max - box.Min, props.ModulatedColor, props.LineWidth, false);
                    }

                    if (props.Icon != null)
                    {
                        Drawer2D.DrawSprite(props.Icon, entity.Body.Position + Vector3.One * 0.5f, Vector2.One * 0.5f, Vector2.Zero, new Color(255, 255, 255, 100));
                    }
                }
                else if (entity.Type == DesignationType.Craft) // Make the ghost object invisible if these designations are turned off.
                {
                    entity.Body.SetFlagRecursive(GameComponent.Flag.Visible, false);
                }
            }
        }