Пример #1
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled)
            {
                return;
            }

            if (ActorHost == null)
            {
                return;
            }

            ActorHost.Head = HeadInput;
            HeadInput      = Vector2.Zero;

            ActorHost.Move = MoveInput;
            MoveInput      = Vector2.Zero;

            if (JumpInput)
            {
                ActorHost.Jump();
            }
            JumpInput = false;

            if (InteractInput && SelectedBox.HasValue)
            {
                ActorHost.Interact(SelectedBox.Value);
            }
            InteractInput = false;

            if (ApplyInput && SelectedBox.HasValue)
            {
                ActorHost.Apply(SelectedBox.Value, SelectedSide);
            }
            ApplyInput = false;

            if (FlymodeInput)
            {
                ActorHost.Player.FlyMode = !ActorHost.Player.FlyMode;
            }
            FlymodeInput = false;

            if (ActorHost.Player.Tools != null && ActorHost.Player.Tools.Length > 0)
            {
                if (ActorHost.ActiveTool == null)
                {
                    ActorHost.ActiveTool = ActorHost.Player.Tools[0];
                }
                for (int i = 0; i < Math.Min(ActorHost.Player.Tools.Length, SlotInput.Length); i++)
                {
                    if (SlotInput[i])
                    {
                        ActorHost.ActiveTool = ActorHost.Player.Tools[i];
                    }
                    SlotInput[i] = false;
                }
            }

            // Index des aktiven Werkzeugs ermitteln
            int        activeTool  = -1;
            List <int> toolIndices = new List <int>();

            if (ActorHost.Player.Tools != null)
            {
                for (int i = 0; i < ActorHost.Player.Tools.Length; i++)
                {
                    if (ActorHost.Player.Tools[i] != null)
                    {
                        toolIndices.Add(i);
                    }

                    if (ActorHost.Player.Tools[i] == ActorHost.ActiveTool)
                    {
                        activeTool = toolIndices.Count - 1;
                    }
                }
            }

            if (SlotLeftInput)
            {
                if (activeTool > -1)
                {
                    activeTool--;
                }
                else if (toolIndices.Count > 0)
                {
                    activeTool = toolIndices[toolIndices.Count - 1];
                }
            }
            SlotLeftInput = false;

            if (SlotRightInput)
            {
                if (activeTool > -1)
                {
                    activeTool++;
                }
                else if (toolIndices.Count > 0)
                {
                    activeTool = toolIndices[0];
                }
            }
            SlotRightInput = false;

            if (activeTool > -1)
            {
                activeTool           = (activeTool + toolIndices.Count) % toolIndices.Count;
                ActorHost.ActiveTool = ActorHost.Player.Tools[toolIndices[activeTool]];
            }
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled)
            {
                return;
            }

            if (ActorHost == null)
            {
                return;
            }

            Tools.Clear();
            Tools.AddRange(ActorHost.Player.Inventory);

            ActorHost.Head = HeadInput;
            HeadInput      = Vector2.Zero;

            ActorHost.Move = MoveInput;
            MoveInput      = Vector2.Zero;

            if (JumpInput)
            {
                ActorHost.Jump();
            }
            JumpInput = false;

            if (InteractInput && SelectedBox.HasValue)
            {
                ActorHost.Interact(SelectedBox.Value);
            }
            InteractInput = false;

            if (ApplyInput && SelectedBox.HasValue)
            {
                ActorHost.Apply(SelectedBox.Value, SelectedSide);
            }
            ApplyInput = false;

            if (FlymodeInput)
            {
                ActorHost.Player.FlyMode = !ActorHost.Player.FlyMode;
            }
            FlymodeInput = false;

            if (Tools != null && Tools.Count > 0)
            {
                if (ActorHost.ActiveTool == null)
                {
                    ActorHost.ActiveTool = Tools[0];
                }
                for (int i = 0; i < Math.Min(Tools.Count, SlotInput.Length); i++)
                {
                    if (SlotInput[i])
                    {
                        ActorHost.ActiveTool = Tools[i];
                    }
                    SlotInput[i] = false;
                }
            }

            // Index des aktiven Werkzeugs ermitteln
            int activeTool = -1;

            if (Tools != null && ActorHost.ActiveTool != null)
            {
                for (int i = 0; i < Tools.Count; i++)
                {
                    if (Tools[i] == ActorHost.ActiveTool)
                    {
                        activeTool = i;
                        break;
                    }
                }
            }

            if (activeTool > -1)
            {
                if (SlotLeftInput)
                {
                    activeTool--;
                }
                SlotLeftInput = false;

                if (SlotRightInput)
                {
                    activeTool++;
                }
                SlotRightInput = false;

                activeTool           = (activeTool + Tools.Count) % Tools.Count;
                ActorHost.ActiveTool = Tools[activeTool];
            }
        }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            Tools.Clear();
            Tools.AddRange(ActorHost.Player.Inventory);

            ActorHost.Head = new Vector2(input.HeadX, input.HeadY);
            ActorHost.Move = new Vector2(input.MoveX, input.MoveY);

            if (input.JumpTrigger)
            {
                ActorHost.Jump();
            }
            if (input.InteractTrigger && SelectedBox.HasValue)
            {
                ActorHost.Interact(SelectedBox.Value);
            }
            if (input.ApplyTrigger && SelectedBox.HasValue)
            {
                ActorHost.Apply(SelectedBox.Value, SelectedSide);
            }
            if (input.ToggleFlyMode)
            {
                ActorHost.Player.FlyMode = !ActorHost.Player.FlyMode;
            }

            if (Tools != null && Tools.Count > 0 && input.SlotTrigger != null)
            {
                for (int i = 0; i < Math.Min(Tools.Count, input.SlotTrigger.Length); i++)
                {
                    if (input.SlotTrigger[i])
                    {
                        ActorHost.ActiveTool = Tools[i];
                    }
                }
            }

            // Index des aktiven Werkzeugs ermitteln
            int activeTool = -1;

            if (Tools != null && ActorHost.ActiveTool != null)
            {
                for (int i = 0; i < Tools.Count; i++)
                {
                    if (Tools[i] == ActorHost.ActiveTool)
                    {
                        activeTool = i;
                        break;
                    }
                }
            }

            if (activeTool > -1)
            {
                if (input.SlotLeftTrigger)
                {
                    activeTool--;
                }

                if (input.SlotRightTrigger)
                {
                    activeTool++;
                }

                activeTool           = (activeTool + Tools.Count) % Tools.Count;
                ActorHost.ActiveTool = Tools[activeTool];
            }
        }