Example #1
0
        public Prologue()
        {
            _sentances = new List <Sentance>();
            LoadPrologue();

            History         = "1";
            CurrentSentance = GetSentanceByIndex(History);
        }
Example #2
0
        private void LoadPrologue()
        {
            //Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))}\DankSouls\NPC\{Name}.txt"
            string file = Properties.Resources.ResourceManager.GetString("Prologue");

            string[] chat = file.Split('#');

            foreach (string str in chat)
            {
                if (str != String.Empty)
                {
                    string check = str;

                    if (str.StartsWith("\r\n"))
                    {
                        check = str.Substring(2);
                    }

                    //Sentance
                    string[] bits = check.Split('|');

                    if (bits.Length > 1)
                    {
                        if (bits[0] != String.Empty && bits[1] != String.Empty && bits[2] != String.Empty &&
                            bits[3] != String.Empty)
                        {
                            Dictionary <string, string> actions = new Dictionary <string, string>();
                            if (bits[1] != "!")
                            {
                                foreach (string bit in bits[1].Split(','))
                                {
                                    string[] action = bit.Split('>');
                                    actions.Add(action[1], action[0]);
                                }
                            }
                            else
                            {
                                actions.Add("!", "!");
                            }


                            Dictionary <string, string> choices = new Dictionary <string, string>();
                            foreach (string bit in bits[3].Split('<'))
                            {
                                string[] choice = bit.Split('>');
                                choices.Add(choice[1], choice[0]);
                            }



                            Sentance sentance = new Sentance(bits[0], actions, bits[2], choices);
                            _sentances.Add(sentance);
                        }
                    }
                }
            }
        }
Example #3
0
        public NPC(string name)
        {
            _sentances = new List <Sentance>();
            Name       = name;
            LoadChat();

            History         = "1";
            CurrentSentance = GetSentanceByIndex(History);
        }
Example #4
0
        public string UpdateText()
        {
            CurrentSentance = GetSentanceByIndex(History);
            string choices = String.Empty;

            foreach (string choice in CurrentSentance._choices.Values)
            {
                choices += $"{choice}\n";
            }

            Text = $"{CurrentSentance._info.Replace("\\n", "\n")}\n\n{choices}\n\n";

            if (CommandFailed)
            {
                Text += $"DOES NOT COMPUTE, please try again.";
            }
            else
            {
                Text += $"Type here:";
            }
            return(Text);
        }