Esempio n. 1
0
        /// <summary>
        /// Return a NPC id based on user's selection
        /// </summary>
        /// <param name="searched"></param>
        /// <returns></returns>
        public int DisplayGetNpcToTalkTo(bool searched)
        {
            int  npcId      = 0;
            bool validNpcId = false;

            if (searched == true)
            {
                //Get a list of npcs in the current location
                List <Npc> npcsInCurrentLocation = _gameUniverse.GetNpcByLocation(_gamePlayer.LocationID);

                if (npcsInCurrentLocation.Count() > 0)
                {
                    DisplayGamePlayScreen("Select a NPC", Text.NpcInteractWithList(npcsInCurrentLocation), ActionMenu.NpcMenu, "");

                    while (!validNpcId)
                    {
                        //Get int from user
                        GetInt("Enter the ID of the NPC: ", 0, 0, out npcId);

                        //validate int as a valid NPC id and in the current location
                        if (_gameUniverse.IsValidNpcByLocationId(npcId, _gamePlayer.LocationID))
                        {
                            Npc npc = _gameUniverse.GetNpcById(npcId);

                            if (npc is ISpeak)
                            {
                                validNpcId = true;
                            }
                            else
                            {
                                ClearInputBox();
                                DisplayInputErrorMessage("This character does not speak.");
                            }
                        }
                        else
                        {
                            ClearInputBox();
                            DisplayInputErrorMessage("Invalid NPC id. Please try again.");
                        }
                    }
                }
                else
                {
                    DisplayGamePlayScreen("Select a NPC: ", "There are no NPCs at this location.", ActionMenu.NpcMenu, "");
                }
            }
            else
            {
                DisplayGamePlayScreen("Game Object", "--You must search the room before interacting with NPCs--", ActionMenu.NpcMenu, "");
            }

            return(npcId);
        }
Esempio n. 2
0
        /// <summary>
        /// NPC Talk To Main Method
        /// </summary>
        private void TalkToAction()
        {
            Location location = _gameUniverse.GetLocationById(_gamePlayer.LocationID);

            int npcToTalkToId;

            //Get a NPC
            if (location.Searched == true)
            {
                npcToTalkToId = _gameConsoleView.DisplayGetNpcToTalkTo(true);
            }
            else
            {
                npcToTalkToId = _gameConsoleView.DisplayGetNpcToTalkTo(false);
            }

            if (npcToTalkToId != 0)
            {
                //Get the npc
                Npc npc = _gameUniverse.GetNpcById(npcToTalkToId);

                //If player is not ready, we display a custom message
                bool ready = IsPlayerReady();

                if (ready == true)
                {
                    Npc    spiritNpc = _gameUniverse.GetNpcById(6);
                    Spirit spirit    = (Spirit)spiritNpc;
                    spirit.Ready = true;
                }

                //Display the Message
                _gameConsoleView.DisplayTalkTo(npc, _illusion);

                //Raise the NPC Interaction Event
                NpcInteraction(npc.Id);
            }
        }