Exemplo n.º 1
0
        private void TalkToAction()
        {
            //display list of NPCs in location and get a player choice
            int npcToTalkToId = _gameConsoleView.DisplayGetNpcToTalkTo();

            //display npc messages
            if (npcToTalkToId != 0)
            {
                //get NPC from universe
                Npc npc = _worldContents.GetNpcById(npcToTalkToId);
                npc.TalkedTo = true;

                //display info for object chosen
                _gameConsoleView.DisplayTalkTo(npc);
            }
        }
Exemplo n.º 2
0
        public int DisplayGetNpcToTalkTo()
        {
            int  npcId      = 0;
            bool validNpcId = false;

            //get list of npcs in current location
            List <Npc> npcInCurrentLocation = _worldContents.GetNpcsByLocationId(_gameSurvivor.LocationId);

            if (npcInCurrentLocation.Count > 0)
            {
                DisplayGamePlayScreen("Choose character to speak with", Text.NpcsChooseList(npcInCurrentLocation), ActionMenu.NpcMenu, "");

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

                    //validate integer as valid NPC id and in current location
                    if (_worldContents.IsValidNpcByLocationId(npcId, _gameSurvivor.LocationId))
                    {
                        Npc npc = _worldContents.GetNpcById(npcId);
                        if (npc is ISpeak)
                        {
                            validNpcId = true;
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("It appears this character has nothing to say. Try again.");
                        }
                    }
                    else
                    {
                        ClearInputBox();
                        DisplayInputErrorMessage("Invalid NPC Id, try again.");
                    }
                }
            }
            else
            {
                DisplayGamePlayScreen("Choose character to speak with", "It appears there are no NPCs here.", ActionMenu.NpcMenu, "");
            }

            return(npcId);
        }