void CreateCharChooseBioWindow_OnClose() { if (!createCharChooseBioWindow.ChoseQuestions) { // Choose answers at random System.Random rand = new System.Random(System.DateTime.Now.Millisecond); if (!characterDocument.isCustom) { characterDocument.classIndex = createCharClassSelectWindow.SelectedClassIndex; } BiogFile autoBiog = new BiogFile(characterDocument); for (int i = 0; i < autoBiog.Questions.Length; i++) { List <BiogFile.Answer> answers; answers = autoBiog.Questions[i].Answers; int index = rand.Next(0, answers.Count); for (int j = 0; j < answers[index].Effects.Count; j++) { autoBiog.AddEffect(answers[index].Effects[j], i); } } characterDocument.biographyEffects = autoBiog.AnswerEffects; characterDocument.backStory = autoBiog.GenerateBackstory(characterDocument.classIndex); SetNameSelectWindow(); } else { SetBiographyWindow(); } }
void CreateCharChooseBioWindow_OnClose() { if (!createCharChooseBioWindow.Cancelled) { // Pick a biography template, 0 by default // Classic only has a T0 template for each class, but mods can add more Regex reg = new Regex($"BIOG{characterDocument.classIndex:D2}T([0-9]+).TXT"); IEnumerable <Match> biogMatches = Directory.EnumerateFiles(BiogFile.BIOGSourceFolder, "*.TXT") .Select(FilePath => reg.Match(FilePath)) .Where(FileMatch => FileMatch.Success); // For now, we choose at random between all available ones // Maybe eventually, have a window for selecting a biography template when more than 1 is available? int biogCount = biogMatches.Count(); int selectedBio = UnityEngine.Random.Range(0, biogCount); Match selectedMatch = biogMatches.ElementAt(selectedBio); characterDocument.biographyIndex = int.Parse(selectedMatch.Groups[1].Value); if (!createCharChooseBioWindow.ChoseQuestions) { // Choose answers at random System.Random rand = new System.Random(System.DateTime.Now.Millisecond); BiogFile autoBiog = new BiogFile(characterDocument); for (int i = 0; i < autoBiog.Questions.Length; i++) { List <BiogFile.Answer> answers; answers = autoBiog.Questions[i].Answers; int index = rand.Next(0, answers.Count); for (int j = 0; j < answers[index].Effects.Count; j++) { autoBiog.AddEffect(answers[index].Effects[j], i); } } // Show reputation changes autoBiog.DigestRepChanges(); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, createCharChooseBioWindow); messageBox.SetTextTokens(CreateCharBiography.reputationToken, autoBiog); messageBox.ClickAnywhereToClose = true; messageBox.Show(); messageBox.OnClose += ReputationBox_OnClose; characterDocument.biographyEffects = autoBiog.AnswerEffects; characterDocument.backStory = autoBiog.GenerateBackstory(); } else { SetBiographyWindow(); } } else { SetClassSelectWindow(); } }
void CreateCharChooseBioWindow_OnClose() { if (!createCharChooseBioWindow.Cancelled) { if (!createCharChooseBioWindow.ChoseQuestions) { // Choose answers at random System.Random rand = new System.Random(System.DateTime.Now.Millisecond); if (!characterDocument.isCustom) { characterDocument.classIndex = createCharClassSelectWindow.SelectedClassIndex; } BiogFile autoBiog = new BiogFile(characterDocument); for (int i = 0; i < autoBiog.Questions.Length; i++) { List <BiogFile.Answer> answers; answers = autoBiog.Questions[i].Answers; int index = rand.Next(0, answers.Count); for (int j = 0; j < answers[index].Effects.Count; j++) { autoBiog.AddEffect(answers[index].Effects[j], i); } } // Show reputation changes autoBiog.DigestRepChanges(); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, createCharChooseBioWindow); messageBox.SetTextTokens(CreateCharBiography.reputationToken, autoBiog); messageBox.ClickAnywhereToClose = true; messageBox.Show(); messageBox.OnClose += ReputationBox_OnClose; characterDocument.biographyEffects = autoBiog.AnswerEffects; characterDocument.backStory = autoBiog.GenerateBackstory(characterDocument.classIndex); } else { SetBiographyWindow(); } } else { SetClassSelectWindow(); } }
void AnswerButton_OnMouseClick(BaseScreenComponent sender, Vector2 pos) { int answerIndex = (int)sender.Tag; List <BiogFile.Answer> curAnswers = biogFile.Questions[questionIndex].Answers; if (answerIndex >= curAnswers.Count) { return; // not an answer for this question } else if (questionIndex < biogFile.Questions.Length - 1) { foreach (string effect in curAnswers[answerIndex].Effects) { biogFile.AddEffect(effect, questionIndex); } questionIndex++; PopulateControls(biogFile.Questions[questionIndex]); } else { // Add final effects foreach (string effect in curAnswers[answerIndex].Effects) { biogFile.AddEffect(effect, questionIndex); } // Create text biography BackStory = biogFile.GenerateBackstory(Document.classIndex); // Show reputation changes biogFile.DigestRepChanges(); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(reputationToken, biogFile); messageBox.ClickAnywhereToClose = true; messageBox.Show(); CloseWindow(); } }