コード例 #1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput()
        {
            int oldSelectedEntry = selectedEntry;

            foreach (MenuEntry entry in MenuEntries)
            {
                Rectangle entryRecg = new Rectangle((int)entry.Position.X, (int)entry.Position.Y,
                                                    entry.Texture.Width, entry.Texture.Height);

                if (InputManager.IsButtonClicked(entryRecg))
                {
                    entry.OnSelectEntry();
                    return;
                }
            }

            if (InputManager.IsActionTriggered(InputManager.Action.Back) ||
                InputManager.IsActionTriggered(InputManager.Action.ExitGame))
            {
                OnCancel();
            }
            else if (selectedEntry != oldSelectedEntry)
            {
                AudioManager.PlayCue("MenuMove");
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool resumeClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)(backPosition.X),
                                                 (int)(backPosition.Y),
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                resumeClicked = true;
            }


            if (InputManager.IsActionTriggered(InputManager.Action.Back) || resumeClicked &&
                Session.IsActive)
            {
                Session.MapCache.Clear();
                AudioManager.PopMusic();
                ExitScreen();
                return;
            }

            base.HandleInput();
        }
コード例 #3
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool okClicked   = false;
            bool backclicked = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectButtonPosition.X, (int)selectButtonPosition.Y,
                                                 selectButtonTexture.Width, selectButtonTexture.Height)))
            {
                okClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backButtonPosition.X, (int)backButtonPosition.Y,
                                                 backButtonTexture.Width, backButtonTexture.Height)))
            {
                backclicked = true;
            }

            // view the player's statistics
            if (InputManager.IsActionTriggered(InputManager.Action.TakeView))
            {
                ScreenManager.AddScreen(new StatisticsScreen(character as Player));
                return;
            }

            if (isIntroduction)
            {
                // accept the invitation
                if (okClicked)
                {
                    isIntroduction = false;
                    Player player = character as Player;
                    Session.Party.JoinParty(player);
                    Session.RemovePlayerNpc(mapEntry);
                    this.DialogueText = player.JoinAcceptedDialogue;
                    this.BackText     = "Back";
                    this.SelectText   = "Continue";
                }
                // reject the invitation
                if (backclicked)
                {
                    isIntroduction = false;
                    Player player = character as Player;
                    this.DialogueText = player.JoinRejectedDialogue;
                    this.BackText     = "Back";
                    this.SelectText   = "Continue";
                }
            }
            else
            {
                // exit the screen
                if (okClicked || backclicked)
                {
                    ExitScreen();
                    return;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool okClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectIconPosition.X, (int)selectIconPosition.Y,
                                                 (int)(selectIconTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(selectIconTexture.Height * ScaledVector2.DrawFactor))))
            {
                okClicked = true;
            }

            // exit without bothering to see the rest
            if (InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
            }
            // advance to the next player to have leveled up
            else if (okClicked)
            {
                if (leveledUpPlayers.Count <= 0)
                {
                    // no players at all
                    ExitScreen();
                    return;
                }
                if (index < leveledUpPlayers.Count - 1)
                {
                    // move to the next player
                    index++;
                    GetSpellList();
                }
                else
                {
                    // no more players
                    ExitScreen();
                    return;
                }
            }
            // Scroll up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (startIndex > 0)
                {
                    startIndex--;
                    endIndex--;
                }
            }
            // Scroll down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (startIndex < spellList.Count - maxLines)
                {
                    endIndex++;
                    startIndex++;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool upperClicked = false;
            bool lowerClicked = false;
            bool backClicked  = false;

            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)scrollUpPosition.X - scrollUpTexture.Width,
                                                 (int)scrollUpPosition.Y - scrollUpTexture.Height,
                                                 scrollUpTexture.Width * 2, scrollUpTexture.Height * 2)))
            {
                upperClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)scrollDownPosition.X - scrollDownTexture.Width,
                                                 (int)scrollDownPosition.Y - scrollDownTexture.Height,
                                                 scrollDownTexture.Width * 2, scrollDownTexture.Height * 2)))
            {
                lowerClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)backPosition.X, (int)backPosition.Y,
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }


            // exits the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                ExitScreen();
                return;
            }
            // scroll down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) ||
                     lowerClicked)
            {
                // Traverse down the help text
                if (startIndex + maxLineDisplay < textLines.Count)
                {
                    startIndex += 1;
                }
            }
            // scroll up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) ||
                     upperClicked)
            {
                // Traverse up the help text
                if (startIndex > 0)
                {
                    startIndex -= 1;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Handles user input to the dialog.
        /// </summary>
        public override void HandleInput()
        {
            bool upperClicked = false;
            bool lowerClicked = false;

            if (InputManager.IsButtonClicked(upperArrow))
            {
                upperClicked = true;
            }

            if (InputManager.IsButtonClicked(lowerArrow))
            {
                lowerClicked = true;
            }



            // Scroll up
            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) || upperClicked)
            {
                if (startIndex > 0)
                {
                    startIndex--;
                    endIndex--;
                }
            }
            // Scroll down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) || lowerClicked)
            {
                if (startIndex < dialogueList.Count - drawMaxLines)
                {
                    endIndex++;
                    startIndex++;
                }
            }

            // Press Select or back
            else if (InputManager.IsActionTriggered(InputManager.Action.Back) ||
                     InputManager.IsButtonClicked(new Rectangle(
                                                      (int)backButtonPosition.X,
                                                      (int)backButtonPosition.Y,
                                                      (int)(backButtonTexture.Width * ScaledVector2.DrawFactor),
                                                      (int)(backButtonTexture.Height * ScaledVector2.DrawFactor))) ||
                     InputManager.IsButtonClicked(new Rectangle(
                                                      (int)selectButtonPosition.X,
                                                      (int)selectButtonPosition.Y,
                                                      (int)(selectButtonTexture.Width * ScaledVector2.DrawFactor),
                                                      (int)(selectButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                ExitScreen();
                return;
            }
        }
コード例 #7
0
 public void HandleInput()
 {
     if (!CombatEngine.IsActive)
     {
         if (InputManager.IsButtonClicked(new Rectangle
                                              ((int)yButtonPosition.X,
                                              (int)yButtonPosition.Y,
                                              yButtonTexture.Width, yButtonTexture.Height)))
         {
             if (StatClicked != null)
             {
                 StatClicked(this, EventArgs.Empty);
             }
         }
     }
 }
コード例 #8
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput()
        {
            bool confirmationClicked = false;
            bool backClicked         = false;


            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectPosition.X,
                                                 (int)selectPosition.Y,
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                confirmationClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)backPosition.X,
                                                 (int)backPosition.Y,
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }


            if (confirmationClicked)
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                {
                    Accepted(this, EventArgs.Empty);
                }

                ExitScreen();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                {
                    Cancelled(this, EventArgs.Empty);
                }

                ExitScreen();
            }
        }
コード例 #9
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool backClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)backPosition.X - backTexture.Width,
                                                 (int)backPosition.Y,
                                                 backTexture.Width * 6, backTexture.Height * 2)))
            {
                backClicked = true;
            }
            // exit the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                ExitScreen();
            }
            // toggle between keyboard and gamepad controls
            else if (InputManager.IsActionTriggered(InputManager.Action.PageLeft) ||
                     InputManager.IsActionTriggered(InputManager.Action.PageRight))
            {
                isShowControlPad = !isShowControlPad;
            }
            // scroll through the keyboard controls
            if (isShowControlPad == false)
            {
                if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
                {
                    if (startIndex < keyboardInfo.totalActionList.Length -
                        maxActionDisplay)
                    {
                        startIndex++;
                        keyboardInfo.selectedIndex++;
                    }
                }
                if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
                {
                    if (startIndex > 0)
                    {
                        startIndex--;
                        keyboardInfo.selectedIndex--;
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool backClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectIconPosition.X, (int)selectIconPosition.Y,
                                                 selectIconTexture.Width, selectIconTexture.Height)))
            {
                backClicked = true;
            }

            // exit the screen
            if (backClicked ||
                InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
                // give the rewards to the party
                Session.Party.PartyGold += goldReward;
                foreach (Gear gear in gearReward)
                {
                    Session.Party.AddToInventory(gear, 1);
                }
                Session.Party.GiveExperience(experienceReward);
            }
            // Scroll up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (startIndex > 0)
                {
                    startIndex--;
                    endIndex--;
                }
            }
            // Scroll down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (startIndex < gearReward.Count - maxLines)
                {
                    endIndex++;
                    startIndex++;
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool backClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backgroundPosition.X, (int)backgroundPosition.Y,
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }

            if (backClicked ||
                InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
                ScreenManager.AddScreen(new MainMenuScreen());
                return;
            }
        }
コード例 #12
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            if (InputManager.IsButtonClicked(new Rectangle((int)textPosition.X, (int)textPosition.Y,
                                                           120, 40)))
            {
                ScreenManager.AddScreen(new StoreBuyScreen(store));
                currentCursor = 0;
                return;
            }
            if (InputManager.IsButtonClicked(new Rectangle((int)textPosition.X,
                                                           (int)textPosition.Y + (int)interval, 120, 40)))
            {
                currentCursor = 1;
                ScreenManager.AddScreen(new StoreSellScreen(store));
                return;
            }
            if (InputManager.IsButtonClicked(new Rectangle((int)textPosition.X,
                                                           (int)textPosition.Y + (int)(interval * 2), 120, 40)))
            {
                ExitScreen();
                currentCursor = 2;
                return;
            }

            // exits the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
                return;
            }
            // select one of the buttons
            else if (InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                if (currentCursor == 0)
                {
                    ScreenManager.AddScreen(new StoreBuyScreen(store));
                }
                else if (currentCursor == 1)
                {
                    ScreenManager.AddScreen(new StoreSellScreen(store));
                }
                else
                {
                    ExitScreen();
                }
                return;
            }
            // move the cursor up
            else if (InputManager.IsActionTriggered(InputManager.Action.MoveCharacterUp))
            {
                currentCursor--;
                if (currentCursor < 0)
                {
                    currentCursor = 0;
                }
            }
            // move the cursor down
            else if (InputManager.IsActionTriggered(InputManager.Action.MoveCharacterDown))
            {
                currentCursor++;
                if (currentCursor > 2)
                {
                    currentCursor = 2;
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Handles user input.
        /// </summary>
        public override void HandleInput()
        {
            bool upperClicked = false;
            bool lowerClicked = false;
            bool backClicked  = false;

            if (InputManager.IsButtonClicked(upperArrow))
            {
                upperClicked = true;
            }

            if (InputManager.IsButtonClicked(lowerArrow))
            {
                lowerClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backIconPosition.X, (int)backIconPosition.Y,
                                                 backIconTexture.Width, backIconTexture.Height)))
            {
                backClicked = true;
            }


            // scroll up
            if (upperClicked)
            {
                if (startIndex > 0)
                {
                    startIndex--;
                    endIndex--;
                }
            }
            // scroll up
            else if (lowerClicked)
            {
                if (endIndex < currentDialogue.Count)
                {
                    startIndex++;
                    endIndex++;
                }
            }
            // scroll Down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (endIndex < currentDialogue.Count)
                {
                    startIndex++;
                    endIndex++;
                }
            }
            // scroll Down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                if (startIndex > 0)
                {
                    startIndex--;
                    endIndex--;
                }
            }
            // exit the screen
            else if (InputManager.IsActionTriggered(InputManager.Action.Back) ||
                     backClicked)
            {
                ExitScreen();
                return;
            }
        }
コード例 #14
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        public override void HandleInput()
        {
            bool backClicked = false;
            bool okClicked   = false;

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backButtonPosition.X, (int)backButtonPosition.Y,
                                                 backButton.Width, backButton.Height)))
            {
                backClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectButtonPosition.X, (int)selectButtonPosition.Y,
                                                 selectButton.Width, selectButton.Height)))
            {
                okClicked = true;
            }

            // exit the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                ExitScreen();
                return;
            }
            // use the item or close the screen
            else if (isUseAllowed && okClicked)
            {
                if (isGearUsed)
                {
                    ExitScreen();
                    return;
                }
                else
                {
                    if (usedGear is Equipment)
                    {
                        Equipment equipment    = usedGear as Equipment;
                        Equipment oldEquipment = null;
                        if (Session.Party.Players[selectionMark].Equip(equipment,
                                                                       out oldEquipment))
                        {
                            Session.Party.RemoveFromInventory(usedGear, 1);
                            if (oldEquipment != null)
                            {
                                Session.Party.AddToInventory(oldEquipment, 1);
                            }
                            isGearUsed = true;
                        }
                    }
                    else if (usedGear is Item)
                    {
                        Item item = usedGear as Item;
                        if ((item.Usage & Item.ItemUsage.NonCombat) > 0)
                        {
                            if (Session.Party.RemoveFromInventory(item, 1))
                            {
                                Session.Party.Players[selectionMark].
                                StatisticsModifiers +=
                                    item.TargetEffectRange.GenerateValue(Session.Random);
                                Session.Party.Players[selectionMark].StatisticsModifiers.
                                ApplyMaximum(new StatisticsValue());
                                isGearUsed = true;
                            }
                            else
                            {
                                ExitScreen();
                                return;
                            }
                        }
                    }
                }
                return;
            }
            // cursor up
            else if (!isGearUsed &&
                     InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                if (selectionMark > 0)
                {
                    ResetFromPreview();
                    selectionMark--;

                    if (selectionMark < startIndex)
                    {
                        startIndex--;
                        endIndex--;
                    }
                    isUseAllowed = true;
                    if (usedGear != null)
                    {
                        isUseAllowed = usedGear.CheckRestrictions(
                            Session.Party.Players[selectionMark]);
                    }

                    CalculateSelectedPlayers();
                    CalculateForPreview();
                }
            }
            // cursor down
            else if (!isGearUsed &&
                     InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                isGearUsed = false;
                if (selectionMark < Session.Party.Players.Count - 1)
                {
                    ResetFromPreview();

                    selectionMark++;

                    if (selectionMark == endIndex)
                    {
                        endIndex++;
                        startIndex++;
                    }
                    isUseAllowed = true;
                    if (usedGear != null)
                    {
                        isUseAllowed = usedGear.CheckRestrictions(
                            Session.Party.Players[selectionMark]);
                    }

                    CalculateSelectedPlayers();
                    CalculateForPreview();
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        public override void HandleInput()
        {
            Vector2 position = listEntryStartPosition + new Vector2(0f, listLineSpacing / 2);

            if (startIndex >= 0)
            {
                for (int index = startIndex; index < endIndex; index++)
                {
                    if (InputManager.IsButtonClicked(new Rectangle((int)position.X, (int)position.Y,
                                                                   250, 50)))
                    {
                        selectedIndex = index;
                        var dataList = GetDataList();
                        SelectTriggered(dataList[index]);
                        return;
                    }

                    position.Y += listLineSpacing;
                }
            }


            bool backClicked    = false;
            bool okClicked      = false;
            bool lowerClicked   = false;
            bool upperClicked   = false;
            bool buttonXClicked = false;
            bool buttonYClicked = false;

            if (InputManager.IsButtonClicked(lowerArrow))
            {
                lowerClicked = true;
            }

            if (InputManager.IsButtonClicked(upperArrow))
            {
                upperClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backButtonTexturePosition.X,
                                                 (int)backButtonTexturePosition.Y,
                                                 (int)(backButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }


            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectButtonTexturePosition.X,
                                                 (int)selectButtonTexturePosition.Y,
                                                 (int)(selectButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(selectButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                okClicked = true;
            }

            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)xButtonTexturePosition.X,
                                                 (int)xButtonTexturePosition.Y,
                                                 (int)(xButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(xButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                buttonXClicked = true;
            }
            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)yButtonTexturePosition.X,
                                                 (int)yButtonTexturePosition.Y,
                                                 (int)(yButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(yButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                buttonYClicked = true;
            }

            if (InputManager.IsActionTriggered(InputManager.Action.PageLeft))
            {
                PageScreenLeft();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.PageRight))
            {
                PageScreenRight();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) || upperClicked)
            {
                MoveCursorUp();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) || lowerClicked)
            {
                MoveCursorDown();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.IncreaseAmount))
            {
                MoveCursorRight();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.DecreaseAmount))
            {
                MoveCursorLeft();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                BackTriggered();
            }
            else if (okClicked)
            {
                ReadOnlyCollection <T> dataList = GetDataList();
                if ((selectedIndex >= 0) && (selectedIndex < dataList.Count))
                {
                    SelectTriggered(dataList[selectedIndex]);
                }
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) || buttonXClicked)
            {
                ReadOnlyCollection <T> dataList = GetDataList();
                if ((selectedIndex >= 0) && (selectedIndex < dataList.Count))
                {
                    ButtonXPressed(dataList[selectedIndex]);
                }
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.TakeView) || buttonYClicked)
            {
                ReadOnlyCollection <T> dataList = GetDataList();
                if ((selectedIndex >= 0) && (selectedIndex < dataList.Count))
                {
                    ButtonYPressed(dataList[selectedIndex]);
                }
            }
            base.HandleInput();
        }
コード例 #16
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        public override void HandleInput()
        {
            bool equClicked   = false;
            bool backClicked  = false;
            bool spellClicked = false;


            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)(backButtonPosition.X),
                                                 (int)(backButtonPosition.Y),
                                                 (int)(backButton.Width * ScaledVector2.DrawFactor),
                                                 (int)(backButton.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }
            if (InputManager.IsButtonClicked(equipmentRecangle))
            {
                equClicked = true;
            }
            if (InputManager.IsButtonClicked(spellRecangle))
            {
                spellClicked = true;
            }
            // exit the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                ExitScreen();
                return;
            }
            // shows the spells for this player
            else if (spellClicked) //InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                ScreenManager.AddScreen(new SpellbookScreen(player,
                                                            player.CharacterStatistics));
                return;
            }
            // show the equipment for this player, allowing the user to unequip
            else if (InputManager.IsActionTriggered(InputManager.Action.TakeView) || equClicked)
            {
                ScreenManager.AddScreen(new EquipmentScreen(player));
                return;
            }
            else if (Session.Party.Players.Contains(player)) // player is in the party
            {
                // move to the previous screen
                if (InputManager.IsActionTriggered(InputManager.Action.PageLeft))
                {
                    ExitScreen();
                    ScreenManager.AddScreen(new QuestLogScreen(null));
                    return;
                }
                // move to the next screen
                else if (InputManager.IsActionTriggered(InputManager.Action.PageRight))
                {
                    ExitScreen();
                    ScreenManager.AddScreen(new InventoryScreen(true));
                    return;
                }
                // move to the previous party member
                else if (InputManager.IsActionTriggered(InputManager.Action.TargetUp))
                {
                    playerIndex--;
                    if (playerIndex < 0)
                    {
                        playerIndex = Session.Party.Players.Count - 1;
                    }
                    Player newPlayer = Session.Party.Players[playerIndex];
                    if (newPlayer != player)
                    {
                        player          = newPlayer;
                        screenAnimation = new AnimatingSprite();
                        screenAnimation.FrameDimensions =
                            player.MapSprite.FrameDimensions;
                        screenAnimation.FramesPerRow = player.MapSprite.FramesPerRow;
                        screenAnimation.SourceOffset = player.MapSprite.SourceOffset;
                        screenAnimation.Texture      = player.MapSprite.Texture;
                        screenAnimation.AddAnimation(
                            new Animation("Idle", 43, 48, 150, true));
                        screenAnimation.PlayAnimation(0);
                    }
                }
                // move to the next party member
                else if (InputManager.IsActionTriggered(InputManager.Action.TargetDown))
                {
                    playerIndex++;
                    if (playerIndex >= Session.Party.Players.Count)
                    {
                        playerIndex = 0;
                    }
                    Player newPlayer = Session.Party.Players[playerIndex];
                    if (newPlayer != player)
                    {
                        player          = newPlayer;
                        screenAnimation = new AnimatingSprite();
                        screenAnimation.FrameDimensions =
                            player.MapSprite.FrameDimensions;
                        screenAnimation.FramesPerRow = player.MapSprite.FramesPerRow;
                        screenAnimation.SourceOffset = player.MapSprite.SourceOffset;
                        screenAnimation.Texture      = player.MapSprite.Texture;
                        screenAnimation.AddAnimation(
                            new Animation("Idle", 43, 48, 150, true));
                        screenAnimation.PlayAnimation(0);
                    }
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Respond to user input.
        /// </summary>
        public override void HandleInput()
        {
            bool backClicked   = false;
            bool selectClicked = false;
            bool deleteClicked = false;

            foreach (var item in ItemPositionMapping)
            {
                if (InputManager.IsButtonClicked(item.Key))
                {
                    currentSlot = item.Value;
                    break;
                }
            }


            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)(backPosition.X),
                                                 (int)backPosition.Y,
                                                 (int)(backTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }
            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)selectPosition.X,
                                                 (int)selectPosition.Y,
                                                 (int)(selectTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(selectTexture.Height * ScaledVector2.DrawFactor))))
            {
                selectClicked = true;
            }
            if (InputManager.IsButtonClicked(new Rectangle
                                                 ((int)deletePosition.X,
                                                 (int)deletePosition.Y,
                                                 (int)(deleteTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(deleteTexture.Height * ScaledVector2.DrawFactor))))
            {
                deleteClicked = true;
            }

            // handle exiting the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                ExitScreen();
                return;
            }

            // handle selecting a save game
            if (selectClicked &&
                (Session.SaveGameDescriptions != null))
            {
                switch (mode)
                {
                case SaveLoadScreenMode.Load:
                    if ((currentSlot >= 0) &&
                        (currentSlot < Session.SaveGameDescriptions.Count) &&
                        (Session.SaveGameDescriptions[currentSlot] != null))
                    {
                        if (Session.IsActive)
                        {
                            MessageBoxScreen messageBoxScreen = new MessageBoxScreen(
                                "Are you sure you want to load this game?");
                            messageBoxScreen.Accepted +=
                                ConfirmLoadMessageBoxAccepted;
                            ScreenManager.AddScreen(messageBoxScreen);
                        }
                        else
                        {
                            ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty);
                        }
                    }
                    break;

                case SaveLoadScreenMode.Save:
                    if ((currentSlot >= 0) &&
                        (currentSlot <= Session.SaveGameDescriptions.Count))
                    {
                        if (currentSlot == Session.SaveGameDescriptions.Count)
                        {
                            ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty);
                        }
                        else
                        {
                            MessageBoxScreen messageBoxScreen = new MessageBoxScreen(
                                "Are you sure you want to overwrite this save game?");
                            messageBoxScreen.Accepted +=
                                ConfirmSaveMessageBoxAccepted;
                            ScreenManager.AddScreen(messageBoxScreen);
                        }
                    }
                    break;
                }
            }
            // handle deletion
            else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) || deleteClicked &&
                     (Session.SaveGameDescriptions != null))
            {
                if ((currentSlot >= 0) &&
                    (currentSlot < Session.SaveGameDescriptions.Count) &&
                    (Session.SaveGameDescriptions[currentSlot] != null))
                {
                    MessageBoxScreen messageBoxScreen = new MessageBoxScreen(
                        "Are you sure you want to delete this save game?");
                    messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted;
                    ScreenManager.AddScreen(messageBoxScreen);
                }
            }
            // handle cursor-down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) &&
                     (Session.SaveGameDescriptions != null))
            {
                int maximumSlot = Session.SaveGameDescriptions.Count;
                if (mode == SaveLoadScreenMode.Save)
                {
                    maximumSlot = Math.Min(maximumSlot + 1,
                                           Session.MaximumSaveGameDescriptions);
                }
                if (currentSlot < maximumSlot - 1)
                {
                    currentSlot++;
                }
            }
            // handle cursor-up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) &&
                     (Session.SaveGameDescriptions != null))
            {
                if (currentSlot >= 1)
                {
                    currentSlot--;
                }
            }
        }
コード例 #18
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;
            }
        }
コード例 #19
0
        /// <summary>
        /// Allows the screen to handle user input.
        /// </summary>
        public override void HandleInput()
        {
            // if the chestEntry.Content is empty, exit immediately
            if (chestEntry.Content.IsEmpty)
            {
                BackTriggered();
                return;
            }

            bool takeAllClicked = false;
            bool backClicked    = false;
            bool okClicked      = false;


            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)yButtonTexturePosition.X,
                                                 (int)yButtonTexturePosition.Y,
                                                 (int)(yButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(yButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                takeAllClicked = true;
            }
            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)backButtonTexturePosition.X,
                                                 (int)backButtonTexturePosition.Y,
                                                 (int)(backButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(backButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                backClicked = true;
            }


            if (InputManager.IsButtonClicked(new Rectangle(
                                                 (int)selectButtonTexturePosition.X,
                                                 (int)selectButtonTexturePosition.Y,
                                                 (int)(selectButtonTexture.Width * ScaledVector2.DrawFactor),
                                                 (int)(selectButtonTexture.Height * ScaledVector2.DrawFactor))))
            {
                okClicked = true;
            }



            if (InputManager.IsActionTriggered(InputManager.Action.CursorUp))
            {
                MoveCursorUp();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown))
            {
                MoveCursorDown();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.IncreaseAmount))
            {
                MoveCursorRight();
            }
            else if (InputManager.IsActionTriggered(InputManager.Action.DecreaseAmount))
            {
                MoveCursorLeft();
            }
            // Close is pressed
            else if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked)
            {
                BackTriggered();
            }
            // Take All is pressed
            else if (InputManager.IsActionTriggered(InputManager.Action.TakeView) || takeAllClicked)
            {
                ButtonYPressed(null); // take-all doesn't need an entry
            }
            // Take is pressed
            else if (okClicked)
            {
                if (IsGoldSelected)
                {
                    SelectTriggered(null);
                }
                else
                {
                    ReadOnlyCollection <ContentEntry <Gear> > dataList = GetDataList();
                    SelectTriggered(dataList[SelectedGearIndex]);
                }
            }
        }
コード例 #20
0
ファイル: InnScreen.cs プロジェクト: nusisschad/XNAGameStudio
        /// <summary>
        /// Handle user input.
        /// </summary>
        public override void HandleInput()
        {
            bool stayClicked  = false;
            bool leaveClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle((int)stayPosition.X, (int)stayPosition.Y,
                                                           120, 40)))
            {
                int partyCharge = GetChargeForParty(Session.Party);
                if (Session.Party.PartyGold >= partyCharge)
                {
                    AudioManager.PlayCue("Money");
                    Session.Party.PartyGold -= partyCharge;
                    selectionMark            = 2;
                    ChangeDialogue(serviceRenderedMessage);
                    HealParty(Session.Party);
                }
                else
                {
                    selectionMark = 2;
                    ChangeDialogue(noGoldMessage);
                }
            }

            if (InputManager.IsButtonClicked(new Rectangle((int)leavePosition.X, (int)leavePosition.Y,
                                                           120, 40)))
            {
                ExitScreen();
            }
            // exit the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
                return;
            }
            // move the cursor up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) || stayClicked)
            {
                if (selectionMark == 2)
                {
                    selectionMark = 1;
                }
            }
            // move the cursor down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) || leaveClicked)
            {
                if (selectionMark == 1)
                {
                    selectionMark = 2;
                }
            }
            // select an option
            else if (InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                if (selectionMark == 1)
                {
                    int partyCharge = GetChargeForParty(Session.Party);
                    if (Session.Party.PartyGold >= partyCharge)
                    {
                        AudioManager.PlayCue("Money");
                        Session.Party.PartyGold -= partyCharge;
                        selectionMark            = 2;
                        ChangeDialogue(serviceRenderedMessage);
                        HealParty(Session.Party);
                    }
                    else
                    {
                        selectionMark = 2;
                        ChangeDialogue(noGoldMessage);
                    }
                }
                else
                {
                    ExitScreen();
                    return;
                }
            }
        }