예제 #1
0
        /// <summary>
        /// display get the NPC to talk to
        /// </summary>
        /// <returns>NPC Id</returns>
        public int DisplayGetNpcToTalkTo()
        {
            int  npcId      = 0;
            bool validNpcId = false;

            //
            // get a list of NPCs in the current map location
            //
            List <Npc> npcsInMapLocation = _gameKingdom.GetNpcsByMapLocationId(_gamePlayer.MapLocationID);

            if (npcsInMapLocation.Count > 0)
            {
                DisplayGamePlayScreen("Choose Character to Speak With", Text.NpcsChooseList(npcsInMapLocation), ActionMenu.NpcMenu, "");

                while (!validNpcId)
                {
                    //
                    // get an integer from the player
                    //
                    GetInteger($"Enter the Id number of the character you wish to speak with: ", 0, 0, out npcId);

                    //
                    // validate integer as a valid NPC id and in current location
                    //
                    if (_gameKingdom.IsValidNpcByLocationId(npcId, _gamePlayer.MapLocationID))
                    {
                        Npc npc = _gameKingdom.GetNpcById(npcId);
                        if (npc is ISpeak)
                        {
                            validNpcId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("It appears this character has nothing to say. Please try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("It appears you entered an invalid NPC id. Please try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Choose Character to Speak With", "It appears there are no NPCs here.", ActionMenu.NpcMenu, "");
            }

            return(npcId);
        }
예제 #2
0
        /// <summary>
        /// process the Talk To action
        /// </summary>
        private void TalkToAction()
        {
            //
            // display a list of NPCs in map location and get a player choice
            //
            int npcToTalkToId = _gameConsoleView.DisplayGetNpcToTalkTo();

            //
            // display NPC's message
            //
            if (npcToTalkToId != 0)
            {
                //
                // get the NPC from the kingdom
                //
                Npc npc = _gameKingdom.GetNpcById(npcToTalkToId);

                //
                // display information for the object chosen
                //
                _gameConsoleView.DisplayTalkTo(npc);
            }
        }