Example #1
0
        /// <summary>
        /// Starts a new conversation with one participant.
        /// </summary>
        /// <param name="participant1">
        /// Participant in the conversation.
        /// </param>
        /// <returns>
        /// Returns a new <see cref="Conversation"/> object containing
        /// a single participant.
        /// </returns>
        public static Conversation Start(IConversationParticipant participant1)
        {
            var conversation = new Conversation();

            conversation.Join(participant1);
            return(conversation);
        }
Example #2
0
        public void Hear(Conversation conversation, IConversationParticipant source, string dialogText)
        {
            if (!(source is Player))
            {
                return;
            }

            if (dialogText.Contains("good girl"))
            {
                conversation.Say(this.Name, "Of course I am!");
            }
            else if (dialogText.Contains("follow"))
            {
                conversation.Say(this.Name, "Oh Boy Oh Boy Oh Boy Oh Boy!!!!");
                var leader = source as ILeader;
                if (leader != null)
                {
                    leader.Follow(this);
                }
            }
            else if (dialogText.Contains("attack"))
            {
                conversation.Say(this.Name, "Wimper, wimper, wimper...right behind you boss - way behind you");
                var leader = source as ILeader;
                if (leader != null)
                {
                    leader.Follow(this);
                }
            }
            else
            {
                var responseNum = DateTime.Now.Second % 5;
                if (responseNum == 0)
                {
                    conversation.Say(this.Name, "Woof!");
                }
                else if (responseNum == 1)
                {
                    conversation.Say(this.Name, "Grrrr!");
                }
                else if (responseNum == 3)
                {
                    conversation.Say(this.Name, "Barkity bark bark!");
                }
                else if (responseNum == 4)
                {
                    conversation.Say(this.Name, "Wazzup!!");
                }
            }
        }
Example #3
0
        /// <summary>
        /// Adds the specified participant to the conversation.
        /// </summary>
        /// <param name="participant">Participant to add</param>
        public void Join(IConversationParticipant participant)
        {
            if (participant == null)
            {
                throw new ArgumentNullException("participant");
            }
            var existingParticipant = (from p in this.participants
                                       where p.Name == participant.Name
                                       select p).FirstOrDefault();

            if (existingParticipant != null)
            {
                var msg = string.Format("{0} is already participating in this conversation", participant.Name);
                throw new ArgumentNullException(msg);
            }

            this.participants.Add(participant);
        }
        public void Hear(Conversation conversation, IConversationParticipant source, string dialogText)
        {
            if (!(source is Player))
            {
                return;
            }

            if (dialogText.Contains("help"))
            {
                if (dialogText.Contains("rune"))
                {
                    this.GiveClue(conversation);
                }
                else
                {
                    conversation.Say(this.Name, "Help will be given to those who help themselves");
                }
            }
            else
            {
                conversation.Say(this.Name, "Read the runes to discover the password to the exit portal");
            }
        }
Example #5
0
        public void Hear(Conversation conversation, IConversationParticipant source, string dialogText)
        {
            if (!(source is Player))
            {
                return;
            }

            if (dialogText.Contains("rune"))
            {
                var runes = this.GetAllItems <Rune>();
                if (runes.Count() > 1)
                {
                    var strBuilder = new StringBuilder();
                    strBuilder.Append("Yes, I have some runes with the following markings on them - ");
                    foreach (var curRune in runes)
                    {
                        strBuilder.Append(curRune.Name);
                        strBuilder.Append(" ");
                    }
                    strBuilder.Append("\rYou are welcome to take them my friend.");
                    conversation.Say(this.Name, strBuilder.ToString());
                }
                else if (runes.Count() > 0)
                {
                    var strBuilder = new StringBuilder();
                    strBuilder.Append("Yes, I have a rune with the following markings on it - ");
                    foreach (var curRune in runes)
                    {
                        strBuilder.Append(curRune.Name);
                        strBuilder.Append(" ");
                    }
                    strBuilder.Append("\rYou are welcome to take it my friend.");
                    conversation.Say(this.Name, strBuilder.ToString());
                }
                else
                {
                    conversation.Say(this.Name, "I'm sorry friend, but I don't know anything about the runes you speak of!");
                }
            }
            else if (dialogText.Contains("help"))
            {
                conversation.Say(this.Name, "I will do my best!");
            }
            else if (dialogText.Contains("follow"))
            {
                conversation.Say(this.Name, "I will stay by your side through thick and thin!");
                var leader = source as ILeader;
                if (leader != null)
                {
                    leader.Follow(this);
                }
            }
            else if (dialogText.ToLower().StartsWith("use"))
            {
                var tokens = dialogText.ToLower().Split(new char[] { ' ' });
                if (tokens.Length > 1 && tokens[0] == "use")
                {
                    var itemName = tokens[1];
                    var item     = this.UseItem <InventoryItem>(itemName);
                    if (item == null)
                    {
                        conversation.Say(this.Name, string.Format("Sorry boss, I don't have a {0}!", itemName));
                    }
                    else
                    {
                        conversation.Say(this.Name, string.Format("Aye, my {0} is at the ready!", itemName));
                    }
                }
            }
            else if (dialogText.Contains("attack"))
            {
                conversation.Say(this.Name, "Charge!");
            }
            else
            {
                var responseNum = DateTime.Now.Second % 5;
                if (responseNum == 0)
                {
                    conversation.Say(this.Name, "Do you have any gold?");
                }
                else if (responseNum == 1)
                {
                    conversation.Say(this.Name, "If you keep talking like that I won't be your friend anymore!");
                }
                else if (responseNum == 3)
                {
                    conversation.Say(this.Name, "That makes my beard itchy!");
                }
                else if (responseNum == 4)
                {
                    conversation.Say(this.Name, "Wazzup!!");
                }
            }
        }
Example #6
0
        public void Hear(Conversation conversation, IConversationParticipant source, string dialogText)
        {
            var msg = string.Format("{0} says - {1}", source.Name, dialogText);

            this.consoleOut.WriteLine(msg);
        }