Пример #1
0
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {
            bool isMenuItemPressed = false;
            if (firstCombatMenuPosition != Rectangle.Empty)
            {
                int x = firstCombatMenuPosition.X;
                for (int playerCount = 0; playerCount < CombatEngine.Players.Count; playerCount++)
                {
                    for (int actionIndex = 0; actionIndex < actionList.Length; actionIndex++)
                    {
                        float yPosition = firstCombatMenuPosition.Y;
                        if (actionIndex + 1 > 1)
                        {
                            yPosition = yPosition + (heightInterval * actionIndex + 1);
                        }
                        Rectangle currentActionPosition = new Rectangle(x, (int)yPosition,
                            (int)(firstCombatMenuPosition.Width * ScaledVector2.ScaleFactor),
                            (int)(firstCombatMenuPosition.Height * ScaledVector2.ScaleFactor));
                        if (InputManager.IsButtonClicked(currentActionPosition))
                        {
                            highlightedAction = actionIndex;
                            isMenuItemPressed = true;
                            break;
                        }
                    }
                    x += (int)(activeCharInfoTexture.Width * ScaledVector2.DrawFactor - 6f * ScaledVector2.ScaleFactor);
                }
            }

            // select an action
            if (isMenuItemPressed)
            {
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Spell":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                        }
                        break;

                    case "Item":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }
Пример #2
0
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {

            
            Vector2 position =startingInfoPosition;
            position.Y -= 150f;
            float height = 25f;
            bool clickedOK = false;
            // check mouse over
          //  if (InputManager.MouseMoved())
      //      {

                // action count 4
                for (int i = 0; i < 5; i++)
                {
                    Rectangle rect = new Rectangle(ActionMenuRect.X, (int)position.Y, ActionMenuRect.Width, (int)height);
                    if (InputManager.IsButtonHovered(rect))
                    {
                        highlightedAction = i;
                    }
                    if (InputManager.IsButtonClicked(rect))
                    {
                        highlightedAction = i;
                        clickedOK = true;
                      //  Session.Hud.UpdateActionsMenu();
                        //if (!clickedOK)
                        //{
                        //    clickedOK = InputManager.IsButtonClicked(rect);
                        //    //if (clickedOK)
                        //    //    // System.Diagnostics.Debug.WriteLine("Clicked");
                        //    if (clickedOK)
                        //        break;

                        //}
                        break;
                    }
                    position.Y += height;
           //     }
                
            }

            // cursor up
            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (highlightedAction > 0)
                {
                    highlightedAction--;
                }
                return;
            }
            // cursor down
            if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (highlightedAction < actionList.Length - 1)
                {
                    highlightedAction++;
                }
                return;
            }
            // select an action
            if (InputManager.IsActionTriggered(InputManager.Action.Ok) || clickedOK)
            {
                InputManager.IsHubActive = false;
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Fancy":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                            InputManager.IsInAction = true;
                        }
                        break;

                    case "Junk":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                            InputManager.IsInAction = true;
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }
Пример #3
0
Файл: Hud.cs Проект: plhearn/pet
        /// <summary>
        /// Handle user input to the actions menu.
        /// </summary>
        public void UpdateActionsMenu()
        {
            // cursor up
            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (highlightedAction > 0)
                {
                    highlightedAction--;
                }
                return;
            }
            // cursor down
            if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (highlightedAction < actionList.Length - 1)
                {
                    highlightedAction++;
                }
                return;
            }
            // select an action
            if (InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                switch (actionList[highlightedAction])
                {
                    case "Attack":
                        {
                            ActionText = "Performing a Melee Attack";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new MeleeCombatAction(CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Target =
                                CombatEngine.FirstEnemyTarget;
                        }
                        break;

                    case "Spell":
                        {
                            SpellbookScreen spellbookScreen = new SpellbookScreen(
                                CombatEngine.HighlightedCombatant.Character,
                                CombatEngine.HighlightedCombatant.Statistics);
                            spellbookScreen.SpellSelected +=
                                new SpellbookScreen.SpellSelectedHandler(
                                spellbookScreen_SpellSelected);
                            Session.ScreenManager.AddScreen(spellbookScreen);
                        }
                        break;

                    case "Item":
                        {
                            InventoryScreen inventoryScreen = new InventoryScreen(true);
                            inventoryScreen.GearSelected +=
                                new InventoryScreen.GearSelectedHandler(
                                inventoryScreen_GearSelected);
                            Session.ScreenManager.AddScreen(inventoryScreen);
                        }
                        break;

                    case "Defend":
                        {
                            ActionText = "Defending";
                            CombatEngine.HighlightedCombatant.CombatAction =
                                new DefendCombatAction(
                                CombatEngine.HighlightedCombatant);
                            CombatEngine.HighlightedCombatant.CombatAction.Start();
                        }
                        break;

                    case "Flee":
                        CombatEngine.AttemptFlee();
                        break;
                }
                return;
            }
        }