Esempio n. 1
0
        public override void OnBodiesSelected(List <GameComponent> bodies, InputManager.MouseButton button)
        {
            foreach (GameComponent other in bodies)
            {
                var creature = other.EnumerateAll().OfType <Creature>().FirstOrDefault();
                if (creature == null)
                {
                    continue;
                }

                if (World.Overworld.GetPolitics(creature.Faction.ParentFaction, World.PlayerFaction.ParentFaction).GetCurrentRelationship() == Relationship.Loving)
                {
                    World.UserInterface.ShowToolPopup("We refuse to attack allies.");
                    continue;
                }

                Drawer3D.DrawBox(other.BoundingBox, GameSettings.Current.Colors.GetColor("Hunt", Color.Red), 0.1f, false);

                if (button == InputManager.MouseButton.Left)
                {
                    var task = new KillEntityTask(other, KillEntityTask.KillType.Attack);
                    World.TaskManager.AddTask(task);
                    World.UserInterface.ShowToolPopup("Will attack this " + creature.Stats.CurrentClass.Name);
                    OnConfirm(World.PersistentData.SelectedMinions);
                }
                else if (button == InputManager.MouseButton.Right)
                {
                    if (World.PersistentData.Designations.GetEntityDesignation(other, DesignationType.Attack).HasValue(out var designation))
                    {
                        World.TaskManager.CancelTask(designation.Task);
                        World.UserInterface.ShowToolPopup("Attack cancelled for " + creature.Stats.CurrentClass.Name);
                    }
                }
            }
        }
Esempio n. 2
0
        public void Render()
        {
            if (SelectionBuffer.Count <= 0)
            {
                return;
            }

            BoundingBox superset = GetSelectionBox(0.1f);

            if (DrawBox)
            {
                Drawer3D.DrawBox(superset, Mouse.GetState().LeftButton == ButtonState.Pressed ? SelectionColor : DeleteColor, SelectionWidth, false);

                var     screenRect = new Rectangle(0, 0, 5, 5);
                Vector3 half       = Vector3.One * 0.5f;
                Color   dotColor   = Mouse.GetState().LeftButton == ButtonState.Pressed ? SelectionColor : DeleteColor;
                dotColor.A = 90;

                foreach (var v in SelectionBuffer)
                {
                    if (!v.IsValid)
                    {
                        continue;
                    }

                    if (!v.IsExplored || VoxelPassesSelectionCriteria(v))
                    {
                        Drawer2D.DrawRect(World.Renderer.Camera, v.WorldPosition + half, screenRect, dotColor, Color.Transparent, 0.0f);
                    }
                }
            }
        }
Esempio n. 3
0
        public override void OnBodiesSelected(List <Body> bodies, InputManager.MouseButton button)
        {
            if (Mode == FarmMode.Harvesting)
            {
                List <Body> treesPickedByMouse = ComponentManager.FilterComponentsWithTag("Vegetation", bodies);

                foreach (Body tree in treesPickedByMouse)
                {
                    if (!tree.IsVisible || tree.IsAboveCullPlane)
                    {
                        continue;
                    }

                    Drawer3D.DrawBox(tree.BoundingBox, Color.LightGreen, 0.1f, false);
                    if (button == InputManager.MouseButton.Left)
                    {
                        if (!Player.Faction.ChopDesignations.Contains(tree))
                        {
                            Player.Faction.ChopDesignations.Add(tree);
                        }
                    }
                    else if (button == InputManager.MouseButton.Right)
                    {
                        if (Player.Faction.ChopDesignations.Contains(tree))
                        {
                            Player.Faction.ChopDesignations.Remove(tree);
                        }
                    }
                }
            }
        }
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera) // Todo: Camera redundant
        {
            PerformanceMonitor.PushFrame("Component Update");
            PerformanceMonitor.SetMetric("COMPONENTS", NumComponents());


            var playerPoint = World.Renderer.Camera.Position;
            // Todo: Make this a sphere?
            var distanceVec        = new Vector3(GameSettings.Default.EntityUpdateDistance, GameSettings.Default.EntityUpdateDistance, GameSettings.Default.EntityUpdateDistance);
            var updateBox          = new BoundingBox(playerPoint - distanceVec, playerPoint + distanceVec);
            var componentsToUpdate = World.EnumerateIntersectingObjectsLoose(updateBox);

            PerformanceMonitor.SetMetric("COMPONENTS UPDATED", componentsToUpdate.Count);

            foreach (var body in componentsToUpdate)
            {
                body.Update(gameTime, chunks, camera);
                body.ProcessTransformChange();
            }

            if (Debugger.Switches.DrawUpdateBox)
            {
                foreach (var chunk in World.EnumerateChunksInBounds(updateBox))
                {
                    Drawer3D.DrawBox(chunk.GetBoundingBox(), Color.Red, 0.4f, false);
                }
            }

            PerformanceMonitor.PopFrame();

            AddRemove();
            ReceiveMessage();
        }
Esempio n. 5
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            foreach (BuildOrder d in Player.Faction.GuardDesignations)
            {
                Voxel v = d.Vox;

                if (v.IsEmpty)
                {
                    continue;
                }

                BoundingBox box = v.GetBoundingBox();


                Color drawColor = GuardDesignationColor;

                if (d.NumCreaturesAssigned == 0)
                {
                    drawColor = UnreachableColor;
                }

                drawColor.R = (byte)(Math.Min(drawColor.R * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * GuardDesignationGlowRate)) + 50, 255));
                drawColor.G = (byte)(Math.Min(drawColor.G * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * GuardDesignationGlowRate)) + 50, 255));
                drawColor.B = (byte)(Math.Min(drawColor.B * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * GuardDesignationGlowRate)) + 50, 255));
                Drawer3D.DrawBox(box, drawColor, 0.05f, true);
            }
        }
Esempio n. 6
0
        public override void OnBodiesSelected(List <Body> bodies, InputManager.MouseButton button)
        {
            List <Body> resourcesPickedByMouse = ComponentManager.FilterComponentsWithTag("Resource", bodies);
            List <Task> assignments            = new List <Task>();

            foreach (Body resource in resourcesPickedByMouse.Where(resource => resource.IsActive && resource.IsVisible && resource.Parent == PlayState.ComponentManager.RootComponent))
            {
                if (!resource.IsVisible || resource.IsAboveCullPlane)
                {
                    continue;
                }
                Drawer3D.DrawBox(resource.BoundingBox, Color.LightGoldenrodYellow, 0.05f, true);

                if (button == InputManager.MouseButton.Left)
                {
                    Player.Faction.AddGatherDesignation(resource);

                    assignments.Add(new GatherItemTask(resource));
                }
                else
                {
                    if (!Player.Faction.GatherDesignations.Contains(resource))
                    {
                        continue;
                    }

                    Player.Faction.GatherDesignations.Remove(resource);
                }
            }

            TaskManager.AssignTasks(assignments, Faction.FilterMinionsWithCapability(PlayState.Master.SelectedMinions, GameMaster.ToolMode.Gather));
        }
Esempio n. 7
0
        public override void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            IsAboveCullPlane = GlobalTransform.Translation.Y - GetBoundingBox().Extents().Y > (chunks.ChunkData.MaxViewingLevel + 5);
            if (DrawScreenRect)
            {
                Drawer2D.DrawRect(GetScreenRect(camera), Color.Transparent, Color.White, 1);
            }

            if (DrawBoundingBox)
            {
                Drawer3D.DrawBox(BoundingBox, Color.White, 0.02f);
                Drawer3D.DrawBox(GetRotatedBoundingBox(), Color.Red, 0.02f);
            }

            if (DrawReservation && IsReserved)
            {
                Drawer3D.DrawBox(BoundingBox, Color.White, 0.02f);
            }

            if (AnimationQueue.Count > 0)
            {
                MotionAnimation anim = AnimationQueue[0];
                anim.Update(gameTime);

                LocalTransform = anim.GetTransform();

                if (anim.IsDone())
                {
                    AnimationQueue.RemoveAt(0);
                }
            }

            base.Update(gameTime, chunks, camera);
        }
Esempio n. 8
0
 void IRenderableComponent.Render(DwarfTime gameTime, ChunkManager chunks, Camera camera, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, Shader effect, bool renderingForWater)
 {
     if (GamePerformance.DebugVisualizationEnabled)
     {
         Drawer3D.DrawBox(BoundingBox, Color.Blue, 0.02f, false);
     }
 }
Esempio n. 9
0
        public void Render()
        {
            if (SelectionBuffer.Count <= 0)
            {
                return;
            }

            BoundingBox superset = GetSelectionBox(0.1f);

            Drawer3D.DrawBox(superset, Mouse.GetState().LeftButton == ButtonState.Pressed ? SelectionColor : DeleteColor,
                             SelectionWidth, false);

            var     screenRect = new Rectangle(0, 0, 5, 5);
            Vector3 half       = Vector3.One * 0.5f;
            Color   dotColor   = Mouse.GetState().LeftButton == ButtonState.Pressed ? SelectionColor : DeleteColor;

            dotColor.A = 90;
            foreach (Voxel v in SelectionBuffer)
            {
                if ((SelectionType == VoxelSelectionType.SelectFilled && !v.IsEmpty) ||
                    (SelectionType == VoxelSelectionType.SelectEmpty && v.IsEmpty))
                {
                    Drawer2D.DrawRect(v.Position + half, screenRect, dotColor, Color.Transparent, 0.0f);
                }
            }
        }
Esempio n. 10
0
        public Voxel GetFirstVisibleBlockHitByRay(Vector3 rayStart, Vector3 rayEnd, Voxel ignore, bool draw, bool selectEmpty = false)
        {
            Vector3 delta  = rayEnd - rayStart;
            float   length = delta.Length();

            delta.Normalize();
            Voxel atPos = new Voxel();
            Voxel prev  = new Voxel();

            foreach (Point3 coord in MathFunctions.RasterizeLine(rayStart, rayEnd))
            //for(float dn = 0.0f; dn < length; dn += 0.2f)
            {
                Vector3 pos = new Vector3(coord.X, coord.Y, coord.Z);

                bool success = GetNonNullVoxelAtWorldLocationCheckFirst(null, pos, ref atPos);
                if (draw)
                {
                    Drawer3D.DrawBox(new BoundingBox(pos, pos + new Vector3(1f, 1f, 1f)), Color.White, 0.01f);
                }

                if (success && atPos.IsVisible)
                {
                    return(selectEmpty ? prev : atPos);
                }
                prev.Chunk        = atPos.Chunk;
                prev.GridPosition = atPos.GridPosition;
            }

            return(null);
        }
Esempio n. 11
0
        public override void OnBodiesSelected(List <Body> bodies, InputManager.MouseButton button)
        {
            foreach (Body other in bodies)
            {
                var creature = other.EnumerateAll().OfType <Creature>().FirstOrDefault();
                if (creature == null)
                {
                    continue;
                }

                if (Player.World.Diplomacy.GetPolitics(creature.Faction, Player.Faction).GetCurrentRelationship() == Relationship.Loving)
                {
                    Player.Faction.World.ShowToolPopup("We refuse to attack allies.");
                    continue;
                }

                Drawer3D.DrawBox(other.BoundingBox, Color.Red, 0.1f, false);

                if (button == InputManager.MouseButton.Left)
                {
                    if (Player.Faction.Designations.AddEntityDesignation(other, DesignationType.Attack) == DesignationSet.AddDesignationResult.Added)
                    {
                        Player.TaskManager.AddTask(new KillEntityTask(other, KillEntityTask.KillType.Attack));
                        Player.Faction.World.ShowToolPopup("Will attack this " + creature.Species);
                        OnConfirm(Player.Faction.SelectedMinions);
                    }
                }
                else if (button == InputManager.MouseButton.Right)
                {
                    Player.Faction.World.ShowToolPopup("Attack cancelled for " + creature.Species);
                    Player.Faction.Designations.RemoveEntityDesignation(other, DesignationType.Attack);
                }
            }
        }
Esempio n. 12
0
        public void Update()
        {
            MouseState    mouse    = Mouse.GetState();
            KeyboardState keyboard = Keyboard.GetState();

            var currentHoverVoxel = GetVoxelUnderMouse();

            if (!currentHoverVoxel.IsValid)
            {
                return;
            }

            bool isNewVoxelUnderMouse = currentHoverVoxel.IsValid && currentHoverVoxel != VoxelUnderMouse;

            // Prevent selection of top layer because building here causes graphical glitches.
            if (SelectionType == VoxelSelectionType.SelectEmpty && currentHoverVoxel.Coordinate.Y == World.WorldSizeInVoxels.Y - 1)
            {
                return;
            }

            VoxelUnderMouse = currentHoverVoxel;
            World.Renderer.CursorLightPos = currentHoverVoxel.WorldPosition + new Vector3(0.5f, 0.5f, 0.5f);

            if (!Enabled)
            {
                return;
            }

            // Get the type of the voxel and display it to the player.
            if (Enabled && !currentHoverVoxel.IsEmpty && currentHoverVoxel.IsExplored)
            {
                string info = currentHoverVoxel.Type.Name;

                // If it belongs to a room, display that information.
                if (World.IsInZone(currentHoverVoxel))
                {
                    var room = World.GetMostLikelyZone(currentHoverVoxel);

                    if (room != null)
                    {
                        info += " (" + room.ID + ")";
                    }
                }

                World.UserInterface.ShowInfo(info);
            }


            bool altPressed = HandleAltPressed(mouse, keyboard, ref isNewVoxelUnderMouse);

            // Draw a box around the current voxel under the mouse.
            if (currentHoverVoxel.IsValid && DrawVoxel)
            {
                BoundingBox box = currentHoverVoxel.GetBoundingBox().Expand(0.05f);
                Drawer3D.DrawBox(box, CurrentColor, CurrentWidth, true);
            }

            HandleMouseButton(mouse.LeftButton, currentHoverVoxel, isNewVoxelUnderMouse, altPressed, ref isLeftPressed, InputManager.MouseButton.Left);
            HandleMouseButton(mouse.RightButton, currentHoverVoxel, isNewVoxelUnderMouse, altPressed, ref isRightPressed, InputManager.MouseButton.Right);
        }
Esempio n. 13
0
        public override void OnBodiesSelected(List <GameComponent> bodies, InputManager.MouseButton button)
        {
            var tasks = new List <Task>();

            foreach (GameComponent animal in bodies.Where(c => c.Tags.Contains("DomesticAnimal")))
            {
                Drawer3D.DrawBox(animal.BoundingBox, Color.Tomato, 0.1f, false);

                switch (button)
                {
                case InputManager.MouseButton.Left:
                    if (CanCatch(animal, true) && animal.GetRoot().GetComponent <Creature>().HasValue(out var creature))
                    {
                        tasks.Add(new WrangleAnimalTask(creature)
                        {
                            Priority = TaskPriority.Medium
                        });
                    }
                    break;

                case InputManager.MouseButton.Right:
                    if (World.PersistentData.Designations.GetEntityDesignation(animal, DesignationType.Wrangle).HasValue(out var existingOrder))
                    {
                        World.TaskManager.CancelTask(existingOrder.Task);
                    }
                    break;
                }
            }

            if (tasks.Count > 0)
            {
                World.TaskManager.AddTasks(tasks);
                OnConfirm(World.PersistentData.SelectedMinions);
            }
        }
Esempio n. 14
0
 void IRenderableComponent.Render(DwarfTime gameTime, ChunkManager chunks, Camera camera, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice, Shader effect, bool renderingForWater)
 {
     if (GamePerformance.DebugVisualizationEnabled)
     {
         Drawer3D.DrawBox(GetBoundingBox(), Color.DarkRed, 0.02f, false);
     }
 }
Esempio n. 15
0
 public void Render(DwarfTime gameTime, ChunkManager chunks, Camera camera, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, Shader effect, bool renderingForWater)
 {
     if (GamePerformance.DebugVisualizationEnabled)
     {
         //Drawer3D.DrawBox(this.GetBoundingBox(), Color.Yellow, 0.1f, false);
         Drawer3D.DrawBox(this.EnumerateChildren().OfType <NewVoxelListener>().First().GetBoundingBox(), Color.Orange, 0.1f, false);
     }
 }
Esempio n. 16
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            switch (Mode)
            {
            case FarmMode.Tilling:
            {
                Color drawColor = Color.PaleGoldenrod;

                float alpha = (float)Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 2.0f));
                drawColor.R = (byte)(Math.Min(drawColor.R * alpha + 50, 255));
                drawColor.G = (byte)(Math.Min(drawColor.G * alpha + 50, 255));
                drawColor.B = (byte)(Math.Min(drawColor.B * alpha + 50, 255));

                foreach (BoundingBox box in FarmTiles.Where(tile => !tile.IsTilled()).Select(tile => tile.Vox.GetBoundingBox()))
                {
                    Drawer3D.DrawBox(box, drawColor, 0.05f * alpha + 0.05f, true);
                }

                break;
            }

            case FarmMode.Planting:
            {
                Color drawColor = Color.LimeGreen;

                float alpha = (float)Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 2.0f));
                drawColor.R = (byte)(Math.Min(drawColor.R * alpha + 50, 255));
                drawColor.G = (byte)(Math.Min(drawColor.G * alpha + 50, 255));
                drawColor.B = (byte)(Math.Min(drawColor.B * alpha + 50, 255));


                foreach (BoundingBox box in FarmTiles.Where(tile => tile.IsTilled() && !tile.PlantExists() && tile.Farmer == null).Select(tile => tile.Vox.GetBoundingBox()))
                {
                    Drawer3D.DrawBox(box, drawColor, 0.05f * alpha + 0.05f, true);
                }

                break;
            }

            case FarmMode.Harvesting:
            {
                Color drawColor = Color.LimeGreen;

                float alpha = (float)Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 2.0f));
                drawColor.R = (byte)(Math.Min(drawColor.R * alpha + 50, 255));
                drawColor.G = (byte)(Math.Min(drawColor.G * alpha + 50, 255));
                drawColor.B = (byte)(Math.Min(drawColor.B * alpha + 50, 255));

                foreach (BoundingBox box in Player.Faction.ChopDesignations.Select(d => d.GetBoundingBox()))
                {
                    Drawer3D.DrawBox(box, drawColor, 0.05f * alpha + 0.05f, true);
                }
                break;
            }
            }
        }
Esempio n. 17
0
        new public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            //if (DrawBoundingBox)
            //{
            Drawer3D.DrawBox(BoundingBox, Color.White, 0.02f, false);
            Drawer3D.DrawBox(GetRotatedBoundingBox(), Color.Red, 0.02f, false);
            //}

            base.Update(gameTime, chunks, camera);
        }
Esempio n. 18
0
 public override void Render(DwarfGame game, DwarfTime time)
 {
     foreach (var animal in Player.BodySelector.CurrentBodies)
     {
         if (animal.Tags.Contains("DomesticAnimal"))
         {
             Drawer3D.DrawBox(animal.BoundingBox, Color.LightGreen, 0.1f, false);
         }
     }
 }
Esempio n. 19
0
 public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
 {
     foreach (var farmtile in Player.Faction.Designations.EnumerateDesignations(DesignationType._InactiveFarm))
     {
         if (farmtile.Tag is FarmTile && (farmtile.Tag as FarmTile).IsFree())
         {
             Drawer3D.DrawBox(farmtile.Voxel.GetBoundingBox(), Color.White, 0.1f, true);
         }
     }
 }
Esempio n. 20
0
 public virtual void Render(DwarfTime gameTime, ChunkManager chunks, Camera camera, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, Shader effect, bool renderingForWater)
 {
     if (Debugger.Switches.DrawBoundingBoxes)
     {
         Drawer3D.DrawBox(BoundingBox, Color.Blue, 0.02f, false);
         Drawer3D.DrawLine(GlobalTransform.Translation, GlobalTransform.Translation + Vector3.UnitX, Color.Red, 0.02f);
         Drawer3D.DrawLine(GlobalTransform.Translation, GlobalTransform.Translation + Vector3.UnitY, Color.Blue, 0.02f);
         Drawer3D.DrawLine(GlobalTransform.Translation, GlobalTransform.Translation + Vector3.UnitZ, Color.Green, 0.02f);
     }
 }
Esempio n. 21
0
        public void Render()
        {
            if (SelectionBuffer.Count <= 0)
            {
                return;
            }

            BoundingBox superset = GetSelectionBox(0.1f);

            Drawer3D.DrawBox(superset, Mouse.GetState().LeftButton == ButtonState.Pressed ? SelectionColor : DeleteColor, SelectionWidth, false);
        }
Esempio n. 22
0
        public void GenerateThread()
        {
            EventWaitHandle[] waitHandles =
            {
                NeedsGenerationEvent,
                Program.ShutdownEvent
            };

#if CREATE_CRASH_LOGS
            try
#endif
            {
                while (!ExitThreads)
                {
                    EventWaitHandle wh = Datastructures.WaitFor(waitHandles);

                    //GeneratorLock.WaitOne();

                    if (!PauseThreads && ToGenerate != null && ToGenerate.Count > 0)
                    {
                        Point3 box = ToGenerate[0];

                        if (!ChunkData.ChunkMap.ContainsKey(box))
                        {
                            Vector3 worldPos = new Vector3(box.X * ChunkData.ChunkSizeX, box.Y * ChunkData.ChunkSizeY, box.Z * ChunkData.ChunkSizeZ);
                            VoxelChunk chunk = ChunkGen.GenerateChunk(worldPos, (int)ChunkData.ChunkSizeX, (int)ChunkData.ChunkSizeY, (int)ChunkData.ChunkSizeZ, Components, Content, Graphics);
                            Drawer3D.DrawBox(chunk.GetBoundingBox(), Color.Red, 0.1f);
                            chunk.ShouldRebuild = true;
                            chunk.ShouldRecalculateLighting = true;
                            GeneratedChunks.Enqueue(chunk);
                        }

                        ToGenerate.Remove(box);
                    }


                    //GeneratorLock.ReleaseMutex();
                    if (wh == Program.ShutdownEvent)
                    {
                        break;
                    }
                }
            }
#if CREATE_CRASH_LOGS
            catch (Exception exception)
            {
                ProgramData.WriteExceptionLog(exception);
            }
#endif

           
        }
Esempio n. 23
0
        public override void Render(DwarfGame game, DwarfTime time)
        {
            var v = Player.VoxSelector.VoxelUnderMouse;

            if (v.IsValid && !v.IsEmpty)
            {
                var room = Faction.RoomBuilder.GetRoomThatContainsVoxel(v);
                if (room != null)
                {
                    Drawer3D.DrawBox(room.GetBoundingBox(), GameSettings.Default.Colors.GetColor("Positive", Color.Green), 0.2f, true);
                }
            }
        }
Esempio n. 24
0
        public override void Render3D(DwarfGame game, DwarfTime time)
        {
            var v = World.UserInterface.VoxSelector.VoxelUnderMouse;

            if (v.IsValid && !v.IsEmpty)
            {
                var room = World.GetZoneThatContainsVoxel(v);
                if (room != null)
                {
                    Drawer3D.DrawBox(room.GetBoundingBox(), GameSettings.Current.Colors.GetColor("Positive", Color.Green), 0.2f, true);
                }
            }
        }
Esempio n. 25
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. 26
0
        private bool CanPlace(VoxelHandle Location, Rail.JunctionPiece Piece, RailPiece PreviewEntity)
        {
            var actualPosition = new VoxelHandle(Location.Chunk.Manager.ChunkData, Location.Coordinate + new GlobalVoxelOffset(Piece.Offset.X, 0, Piece.Offset.Y));

            if (!actualPosition.IsValid)
            {
                return(false);
            }
            if (!actualPosition.IsEmpty)
            {
                return(false);
            }

            if (actualPosition.Coordinate.Y == 0)
            {
                return(false);                                  // ???
            }
            var local      = actualPosition.Coordinate.GetLocalVoxelCoordinate();
            var voxelUnder = new VoxelHandle(actualPosition.Chunk, new LocalVoxelCoordinate(local.X, local.Y - 1, local.Z));

            if (voxelUnder.IsEmpty)
            {
                return(false);
            }

            foreach (var entity in  Player.World.CollisionManager.EnumerateIntersectingObjects(actualPosition.GetBoundingBox().Expand(-0.2f), CollisionManager.CollisionType.Static))
            {
                if (Object.ReferenceEquals(entity, PreviewEntity))
                {
                    continue;
                }
                if (entity is NewVoxelListener)
                {
                    continue;
                }

                if (FindPossibleCombination(Piece, entity) != null)
                {
                    return(true);
                }

                if (GamePerformance.DebugVisualizationEnabled)
                {
                    Drawer3D.DrawBox(entity.GetBoundingBox(), Color.Yellow, 0.1f, false);
                }

                return(false);
            }

            return(true);
        }
Esempio n. 27
0
        public void Render(DwarfGame game, DwarfTime time)
        {
            CurrentTool.Render(game, time);
            VoxSelector.Render();

            foreach (var m in Faction.Minions)
            {
                if (m.Creature.SelectionCircle != null)
                {
                    m.Creature.SelectionCircle.IsVisible = false;
                }
                m.Creature.Sprite.DrawSilhouette = false;
            }
            ;

            foreach (CreatureAI creature in Faction.SelectedMinions)
            {
                if (creature.Creature.SelectionCircle != null)
                {
                    creature.Creature.SelectionCircle.IsVisible = true;
                }
                creature.Creature.Sprite.DrawSilhouette = true;

                foreach (Task task in creature.Tasks)
                {
                    if (task.IsFeasible(creature.Creature) == Task.Feasibility.Feasible)
                    {
                        task.Render(time);
                    }
                }

                if (creature.CurrentTask != null)
                {
                    creature.CurrentTask.Render(time);
                }
            }

            DwarfGame.SpriteBatch.Begin();
            BodySelector.Render(DwarfGame.SpriteBatch);
            DwarfGame.SpriteBatch.End();

            foreach (var obj in SelectedObjects)
            {
                if (obj.IsVisible && !obj.IsDead)
                {
                    Drawer3D.DrawBox(obj.GetBoundingBox(), Color.White, 0.01f, true);
                }
            }
        }
Esempio n. 28
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. 29
0
        public override void Render(DwarfTime time)
        {
            BoundingBox box = VoxelToGuard.GetBoundingBox();


            Color drawColor = Color.LightBlue;



            drawColor.R = (byte)(Math.Min(drawColor.R * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 0.5f)) + 50, 255));
            drawColor.G = (byte)(Math.Min(drawColor.G * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 0.5f)) + 50, 255));
            drawColor.B = (byte)(Math.Min(drawColor.B * Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * 0.5f)) + 50, 255));
            Drawer3D.DrawBox(box, drawColor, 0.05f, true);
            base.Render(time);
        }
Esempio n. 30
0
        public override void Render(DwarfGame game, GraphicsDevice graphics, DwarfTime time)
        {
            Color drawColor = DesignationColor;

            float alpha = (float)Math.Abs(Math.Sin(time.TotalGameTime.TotalSeconds * GlowRate));

            drawColor.R = (byte)(Math.Min(drawColor.R * alpha + 50, 255));
            drawColor.G = (byte)(Math.Min(drawColor.G * alpha + 50, 255));
            drawColor.B = (byte)(Math.Min(drawColor.B * alpha + 50, 255));

            foreach (BoundingBox box in Player.Faction.AttackDesignations.Select(d => d.GetBoundingBox()))
            {
                Drawer3D.DrawBox(box, drawColor, 0.05f * alpha + 0.05f, true);
            }
        }