void CreateCharCustomClassWindow_OnClose() { characterDocument.career = createCharCustomClassWindow.CreatedClass; characterDocument.career.Name = createCharCustomClassWindow.ClassName; // Determine the most similar class so that we can choose the biography quiz characterDocument.classIndex = BiogFile.GetClassAffinityIndex(characterDocument.career, createCharClassSelectWindow.ClassList); // Set reputation adjustments characterDocument.reputationMerchants = createCharCustomClassWindow.MerchantsRep; characterDocument.reputationCommoners = createCharCustomClassWindow.PeasantsRep; characterDocument.reputationScholars = createCharCustomClassWindow.ScholarsRep; characterDocument.reputationNobility = createCharCustomClassWindow.NobilityRep; characterDocument.reputationUnderworld = createCharCustomClassWindow.UnderworldRep; // Set attributes characterDocument.career.Strength = createCharCustomClassWindow.Stats.WorkingStats.LiveStrength; characterDocument.career.Intelligence = createCharCustomClassWindow.Stats.WorkingStats.LiveIntelligence; characterDocument.career.Willpower = createCharCustomClassWindow.Stats.WorkingStats.LiveWillpower; characterDocument.career.Agility = createCharCustomClassWindow.Stats.WorkingStats.LiveAgility; characterDocument.career.Endurance = createCharCustomClassWindow.Stats.WorkingStats.LiveEndurance; characterDocument.career.Personality = createCharCustomClassWindow.Stats.WorkingStats.LivePersonality; characterDocument.career.Speed = createCharCustomClassWindow.Stats.WorkingStats.LiveSpeed; characterDocument.career.Luck = createCharCustomClassWindow.Stats.WorkingStats.LiveLuck; SetChooseBioWindow(); }
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(); } }
protected override void Setup() { if (IsSetup) { return; } // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharBiography: Could not load native texture."); } // Load question data biogFile = new BiogFile(Document); // Set background NativePanel.BackgroundTexture = nativeTexture; // Set question text questionLabels[0] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(questionLeft, questionTop), string.Empty, NativePanel); questionLabels[1] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(questionLeft, questionTop + questionLineSpace), string.Empty, NativePanel); // Setup buttons for (int i = 0; i < buttonCount; i++) { int left = i % 2 == 0 ? buttonsLeft : buttonsLeft + buttonWidth; answerButtons[i] = DaggerfallUI.AddButton(new Rect((float)left, (float)(buttonsTop + (i / 2) * buttonHeight), (float)buttonWidth, (float)buttonHeight), NativePanel); answerButtons[i].Tag = i; answerButtons[i].OnMouseClick += AnswerButton_OnMouseClick; answerLabels[i] = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(21f, 5f), string.Empty, answerButtons[i]); } PopulateControls(biogFile.Questions[questionIndex]); IsSetup = true; }
void SetCharacterSheet(CharacterDocument characterDocument) { this.characterDocument = characterDocument; this.textBox.Text = characterDocument.name; this.statsRollout.StartingStats = characterDocument.startingStats; this.statsRollout.WorkingStats = characterDocument.workingStats; this.statsRollout.BonusPool = 0; this.skillsRollout.SetClassSkills(characterDocument.career); this.skillsRollout.StartingSkills = characterDocument.startingSkills; this.skillsRollout.WorkingSkills = characterDocument.workingSkills; this.skillsRollout.SkillBonuses = BiogFile.GetSkillEffects(characterDocument.biographyEffects); this.skillsRollout.PrimarySkillBonusPoints = 0; this.skillsRollout.MajorSkillBonusPoints = 0; this.skillsRollout.MinorSkillBonusPoints = 0; this.facePicker.FaceIndex = characterDocument.faceIndex; this.facePicker.SetFaceTextures(characterDocument.raceTemplate, characterDocument.gender); this.reflexPicker.PlayerReflexes = characterDocument.reflexes; }
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 SetAddBonusSkillsWindow() { if (createCharAddBonusSkillsWindow == null) { createCharAddBonusSkillsWindow = new CreateCharAddBonusSkills(uiManager); createCharAddBonusSkillsWindow.OnClose += AddBonusSkillsWindow_OnClose; createCharAddBonusSkillsWindow.DFClass = characterDocument.career; createCharAddBonusSkillsWindow.SkillBonuses = BiogFile.GetSkillEffects(characterDocument.biographyEffects); } // Update class if player changes class selection if (createCharAddBonusSkillsWindow.DFClass != characterDocument.career) { createCharAddBonusSkillsWindow.DFClass = characterDocument.career; } wizardStage = WizardStages.AddBonusSkills; uiManager.PushWindow(createCharAddBonusSkillsWindow); }
// Start new character to location specified in INI void StartNewCharacter() { DaggerfallUnity.ResetUID(); QuestMachine.Instance.ClearState(); RaiseOnNewGameEvent(); DaggerfallUI.Instance.PopToHUD(); ResetWeaponManager(); SaveLoadManager.ClearSceneCache(true); GameManager.Instance.GuildManager.ClearMembershipData(); // Must have a character document if (characterDocument == null) { characterDocument = new CharacterDocument(); } // Assign character sheet PlayerEntity playerEntity = FindPlayerEntity(); playerEntity.AssignCharacter(characterDocument); // Set game time DaggerfallUnity.Instance.WorldTime.Now.SetClassicGameStartTime(); // Set time tracked in playerEntity playerEntity.LastGameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); // Get start parameters DFPosition mapPixel = new DFPosition(DaggerfallUnity.Settings.StartCellX, DaggerfallUnity.Settings.StartCellY); bool startInDungeon = DaggerfallUnity.Settings.StartInDungeon; // Read location if any DFLocation location = new DFLocation(); ContentReader.MapSummary mapSummary; bool hasLocation = DaggerfallUnity.Instance.ContentReader.HasLocation(mapPixel.X, mapPixel.Y, out mapSummary); if (hasLocation) { if (!DaggerfallUnity.Instance.ContentReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex, out location)) { hasLocation = false; } } if (NoWorld) { playerEnterExit.DisableAllParents(); } else { // Start at specified location StreamingWorld streamingWorld = FindStreamingWorld(); if (hasLocation && startInDungeon && location.HasDungeon) { if (streamingWorld) { streamingWorld.TeleportToCoordinates(mapPixel.X, mapPixel.Y); streamingWorld.suppressWorld = true; } playerEnterExit.EnableDungeonParent(); playerEnterExit.StartDungeonInterior(location); } else { playerEnterExit.EnableExteriorParent(); if (streamingWorld) { streamingWorld.SetAutoReposition(StreamingWorld.RepositionMethods.Origin, Vector3.zero); streamingWorld.suppressWorld = false; } } } // Assign starting gear to player entity DaggerfallUnity.Instance.ItemHelper.AssignStartingGear(playerEntity, characterDocument.classIndex, characterDocument.isCustom); // Assign starting spells to player entity SetStartingSpells(playerEntity); // Apply biography effects to player entity BiogFile.ApplyEffects(characterDocument.biographyEffects, playerEntity); // Setup bank accounts and houses Banking.DaggerfallBankManager.SetupAccounts(); Banking.DaggerfallBankManager.SetupHouses(); // Initialize region data playerEntity.InitializeRegionData(); // Randomize weathers GameManager.Instance.WeatherManager.SetClimateWeathers(); // Start game GameManager.Instance.PauseGame(false); DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack(); DaggerfallUI.PostMessage(PostStartMessage); lastStartMethod = StartMethods.NewCharacter; // Offer main quest during pre-alpha QuestMachine.Instance.InstantiateQuest("__MQSTAGE00"); // Launch startup optional quest if (!string.IsNullOrEmpty(LaunchQuest)) { QuestMachine.Instance.InstantiateQuest(LaunchQuest); LaunchQuest = string.Empty; } // Launch any InitAtGameStart quests GameManager.Instance.QuestListsManager.InitAtGameStartQuests(); if (OnStartGame != null) { OnStartGame(this, null); } }