Пример #1
0
        public override void Update(DwarfTime time, VoxelSelector voxSelector, BodySelector bodySelector)
        {
            SelectionTimer.Update(time);
            if (SelectionTimer.HasTriggered)
            {
                if (Type == InspectType.InspectEntity)
                {
                    MouseState  mouse    = Mouse.GetState();
                    List <Body> selected = bodySelector.SelectBodies(new Rectangle(mouse.X - 10, mouse.Y - 10, 20, 20));

                    if (selected.Count > 0)
                    {
                        OnEntitiesSelected(PlayState.Master.Spells, selected);
                    }
                }
                else
                {
                    Voxel vox = new Voxel();
                    PlayState.ChunkManager.ChunkData.GetNonNullVoxelAtWorldLocation(PlayState.CursorLightPos, ref vox);

                    OnVoxelsSelected(PlayState.Master.Spells, new List <Voxel>()
                    {
                        vox
                    });
                }
            }
            base.Update(time, voxSelector, bodySelector);
        }
Пример #2
0
        public void Render(DwarfGame game, DwarfTime time, GraphicsDevice g)
        {
            CurrentTool.Render(game, g, time);
            VoxSelector.Render();

            foreach (CreatureAI creature in Faction.SelectedMinions)
            {
                //Drawer2D.DrawZAlignedRect(creature.Position + Vector3.Down * 0.5f, 0.25f, 0.25f, 2, new Color(255, 255, 255, 50));
                creature.Creature.SelectionCircle.IsVisible = true;
                foreach (Task task in creature.Tasks)
                {
                    task.Render(time);
                }

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


            DwarfGame.SpriteBatch.Begin();
            BodySelector.Render(DwarfGame.SpriteBatch);
            DwarfGame.SpriteBatch.End();
        }
Пример #3
0
        public override void Update(DwarfTime time, VoxelSelector voxSelector, BodySelector bodySelector)
        {
            SelectionTimer.Update(time);
            if (SelectionTimer.HasTriggered)
            {
                if (Type == InspectType.InspectEntity)
                {
                    MouseState  mouse    = Mouse.GetState();
                    List <Body> selected = bodySelector.SelectBodies(new Rectangle(mouse.X - 10, mouse.Y - 10, 20, 20));

                    if (selected.Count > 0)
                    {
                        OnEntitiesSelected(World.Master.Spells, selected);
                    }
                }
                else
                {
                    var vox = new VoxelHandle(World.ChunkManager.ChunkData,
                                              GlobalVoxelCoordinate.FromVector3(World.CursorLightPos));
                    if (vox.IsValid)
                    {
                        OnVoxelsSelected(World.Master.Spells, new List <VoxelHandle>()
                        {
                            vox
                        });
                    }
                }
            }
            base.Update(time, voxSelector, bodySelector);
        }
Пример #4
0
        public void Initialize(DwarfGame game, ComponentManager components, ChunkManager chunks, OrbitCamera camera, GraphicsDevice graphics)
        {
            CameraController = camera;
            VoxSelector      = new VoxelSelector(World);
            BodySelector     = new BodySelector(CameraController, GameState.Game.GraphicsDevice, components);
            SelectedMinions  = new List <CreatureAI>();

            CreateTools();

            //InputManager.KeyReleasedCallback += OnKeyReleased;
            //InputManager.KeyPressedCallback += OnKeyPressed;
        }
Пример #5
0
        public void UpdateInput(DwarfGame game, DwarfTime time)
        {
            KeyboardState keyState   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();


            if (!IsMouseOverGui())
            {
                UpdateMouse(Mouse.GetState(), Keyboard.GetState(), game, time);
                VoxSelector.Update();
                BodySelector.Update();
            }
        }
Пример #6
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);
                }
            }
        }
Пример #7
0
        public void Initialize(DwarfGame game, ComponentManager components, ChunkManager chunks, Camera camera, GraphicsDevice graphics, DwarfGUI gui)
        {
            RoomLibrary.InitializeStatics();

            CameraController = camera;
            VoxSelector      = new VoxelSelector(World, CameraController, chunks.Graphics, chunks);
            BodySelector     = new BodySelector(CameraController, chunks.Graphics, components);
            GUI             = gui;
            SelectedMinions = new List <CreatureAI>();
            Spells          = SpellLibrary.CreateSpellTree(components.World);
            CreateTools();

            InputManager.KeyReleasedCallback += OnKeyReleased;

            Debugger = new AIDebugger(GUI, this);
        }
Пример #8
0
        public void Initialize(DwarfGame game, ComponentManager components, ChunkManager chunks, OrbitCamera camera, GraphicsDevice graphics)
        {
            RoomLibrary.InitializeStatics();

            CameraController = camera;
            VoxSelector      = new VoxelSelector(World, CameraController, GameState.Game.GraphicsDevice, chunks);
            BodySelector     = new BodySelector(CameraController, GameState.Game.GraphicsDevice, components);
            SelectedMinions  = new List <CreatureAI>();

            if (Spells == null)
            {
                Spells = SpellLibrary.CreateSpellTree(components.World);
            }
            CreateTools();

            //InputManager.KeyReleasedCallback += OnKeyReleased;
            //InputManager.KeyPressedCallback += OnKeyPressed;
        }
Пример #9
0
        public void Initialize(DwarfGame game, ComponentManager components, ChunkManager chunks, Camera camera, GraphicsDevice graphics, DwarfGUI gui)
        {
            RoomLibrary.InitializeStatics();

            CameraController = camera;
            VoxSelector      = new VoxelSelector(CameraController, chunks.Graphics, chunks);
            BodySelector     = new BodySelector(CameraController, chunks.Graphics, components);
            GUI             = gui;
            SelectedMinions = new List <CreatureAI>();
            Spells          = SpellLibrary.CreateSpellTree();
            CreateTools();

            InputManager.KeyReleasedCallback += OnKeyReleased;
            ToolBar = new MasterControls(GUI, GUI.RootComponent, this, TextureManager.GetTexture(ContentPaths.GUI.icons), graphics, game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default))
            {
                Master = this
            };

            Debugger = new AIDebugger(GUI, this);
        }
Пример #10
0
        public void Render(DwarfGame game, DwarfTime time, GraphicsDevice g)
        {
            CurrentTool.Render(game, g, 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();
        }
Пример #11
0
        public virtual void Update(DwarfTime time, VoxelSelector voxSelector, BodySelector bodySelector)
        {
            if (Recharges)
            {
                RechargeTimer.Update(time);
            }

            switch (Mode)
            {
            case SpellMode.Button:
                break;

            case SpellMode.Continuous:
                OnContinuousUpdate(time);
                break;

            case SpellMode.SelectEmptyVoxels:
                voxSelector.SelectionType = VoxelSelectionType.SelectEmpty;
                voxSelector.Enabled       = true;
                bodySelector.Enabled      = false;
                break;

            case SpellMode.SelectFilledVoxels:
                voxSelector.SelectionType = VoxelSelectionType.SelectFilled;
                voxSelector.Enabled       = true;
                bodySelector.Enabled      = false;
                break;

            case SpellMode.SelectEntities:
                bodySelector.Enabled = true;
                break;
            }

            if (!Recharges || RechargeTimer.HasTriggered)
            {
                World.ParticleManager.Trigger("star_particle", World.CursorLightPos + Vector3.Up * 0.5f, Color.White, 2);
            }
        }
Пример #12
0
        public void Initialize(DwarfGame game, ComponentManager components, ChunkManager chunks, Camera camera, GraphicsDevice graphics, DwarfGUI gui)
        {
            RoomLibrary.InitializeStatics();

            CameraController = camera;
            VoxSelector = new VoxelSelector(CameraController, chunks.Graphics, chunks);
            BodySelector = new BodySelector(CameraController, chunks.Graphics, components);
            GUI = gui;
            SelectedMinions = new List<CreatureAI>();
            Spells = SpellLibrary.CreateSpellTree();
            CreateTools();

            InputManager.KeyReleasedCallback += OnKeyReleased;
            ToolBar = new MasterControls(GUI, GUI.RootComponent, this, TextureManager.GetTexture(ContentPaths.GUI.icons), graphics, game.Content.Load<SpriteFont>(ContentPaths.Fonts.Default))
            {
                Master = this
            };

            Debugger = new AIDebugger(GUI, this);
        }
Пример #13
0
        public virtual void Update(DwarfTime time, VoxelSelector voxSelector, BodySelector bodySelector)
        {
            if(Recharges)
                RechargeTimer.Update(time);

            switch (Mode)
            {
                case SpellMode.Button:
                    break;
                case SpellMode.Continuous:
                    OnContinuousUpdate(time);
                    break;
                case SpellMode.SelectEmptyVoxels:
                    voxSelector.SelectionType = VoxelSelectionType.SelectEmpty;
                    voxSelector.Enabled = true;
                    bodySelector.Enabled = false;
                    break;
                case SpellMode.SelectFilledVoxels:
                    voxSelector.SelectionType = VoxelSelectionType.SelectFilled;
                    voxSelector.Enabled = true;
                    bodySelector.Enabled = false;
                    break;
                case SpellMode.SelectEntities:
                    bodySelector.Enabled = true;
                    break;
            }

            if (!Recharges || RechargeTimer.HasTriggered)
            {
                PlayState.ParticleManager.Trigger("star_particle", PlayState.CursorLightPos + Vector3.Up * 0.5f, Color.White, 2);
            }
        }
Пример #14
0
        public override void Update(DwarfTime time, VoxelSelector voxSelector, BodySelector bodySelector)
        {
            SelectionTimer.Update(time);
            if (SelectionTimer.HasTriggered)
            {
                if (Type == InspectType.InspectEntity)
                {
                    MouseState mouse = Mouse.GetState();
                    List<Body> selected = bodySelector.SelectBodies(new Rectangle(mouse.X - 10, mouse.Y - 10, 20, 20));

                    if (selected.Count > 0)
                    {
                        OnEntitiesSelected(PlayState.Master.Spells, selected);
                    }
                }
                else
                {
                    Voxel vox = new Voxel();
                    PlayState.ChunkManager.ChunkData.GetNonNullVoxelAtWorldLocation(PlayState.CursorLightPos, ref vox);

                    OnVoxelsSelected(PlayState.Master.Spells, new List<Voxel>(){vox});
                }
            }
            base.Update(time, voxSelector, bodySelector);
        }