Ejemplo n.º 1
0
        private static void CharacterInteraction(NonPlayableCharacter character)
        {
            String conversationTypeResponse = PlayerInteractionResponse("Would you like to check " + character + "'s [I]nventory,  [Q]uestion them or [A]ccuse them!", new [] { "I", "Q", "A" });

            switch (conversationTypeResponse)
            {
            case "I":
                SlowType(character.Respond(ConversationType.INVENTORY));
                break;

            case "Q":
                SlowType(character.Respond(ConversationType.QUESTION));
                break;

            case "A":

                if (character is KillerNonPlayableCharacter)
                {
                    SlowType(character.Respond(ConversationType.CONFESSION));
                    _gameOver = true;
                }
                break;
            }

            _numberOfInteractions++;
            if (_numberOfInteractions == 2)
            {
                SlowType(_room.Kill());
                _numberOfInteractions = 0;
            }
        }
        private NonPlayableCharacter KillCharacter(int leftCharacterIndex, int rightCharacterIndex, RandomList <NonPlayableCharacter> characters)
        {
            // Finding Characters That It Can Kill (Left and Right)

            NonPlayableCharacter leftCharacter  = characters[leftCharacterIndex];
            NonPlayableCharacter rightCharacter = characters[rightCharacterIndex];

            // Making List with Two Potential Characters

            RandomList <NonPlayableCharacter> possibleKillableCharacters = new RandomList <NonPlayableCharacter> {
                leftCharacter, rightCharacter
            };

            // Generating Character That Dies

            NonPlayableCharacter killedCharacter = possibleKillableCharacters.Roll();

            // Killing Character

            characters.Remove(killedCharacter);

            // Returning Character (To Use For Printing)

            return(killedCharacter);
        }
        /// <summary>
        /// Kills The Character Adjacent To The Killer.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="characters"></param>
        /// <returns></returns>
        public string Kill(RandomList <NonPlayableCharacter> characters)
        {
            NonPlayableCharacter killedCharacter;
            int index = characters.IndexOf(this);

            // Handling First Character Case
            if (index == 0)
            {
                killedCharacter = KillCharacter(characters.Count - 1, index + 1, characters);
            }
            // Handling Boundary Case
            else if (index == characters.Count - 1)
            {
                // Finding Characters

                NonPlayableCharacter leftCharacter  = characters[index - 1];
                NonPlayableCharacter rightCharacter = characters[0];

                killedCharacter = KillCharacter(index - 1, 0, characters);
            }
            else
            {
                killedCharacter = KillCharacter(index - 1, index + 1, characters);
            }

            return(killedCharacter + " dropped dead... Who is the killer...");
        }
 public NonPlayableCharacter(NonPlayableCharacter nonPlayableCharacter)
 {
     Name             = nonPlayableCharacter.Name;
     Age              = nonPlayableCharacter.Age;
     _characteristics = nonPlayableCharacter._characteristics;
     Inventory        = nonPlayableCharacter.Inventory;
     Title            = nonPlayableCharacter.Title;
     ID = nonPlayableCharacter.ID;
 }
Ejemplo n.º 5
0
 static void GameplayLoop()
 {
     while (true)
     {
         RevealRoom();
         NonPlayableCharacter selectedCharacter = CharacterSelection();
         CharacterInteraction(selectedCharacter);
         if (_gameOver)
         {
             break;
         }
     }
 }
        public KillerNonPlayableCharacter(NonPlayableCharacter nonPlayableCharacter) : base(nonPlayableCharacter)
        {
            Responses = nonPlayableCharacter.Responses;
            Responses.Remove(ConversationType.INVENTORY);
            Item knife = new Item("Knife");

            Inventory.Add(knife);


            Responses.Add(ConversationType.INVENTORY, new RandomList <string>
            {
                "I am currently carrying the following: " + Inventory,
                "In my bag I have: " + Inventory,
                Inventory + " is all I have.",
                "I have :" + Inventory + ". And money ain't a problem."
            });

            // Removes an item to make sure all characters have the same number of items
            //Inventory.RemoveAt(0);
        }