private void BuyButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick); const int tradeMessageBaseId = 260; const int notEnoughGoldId = 454; int tradePrice = GetTradePrice(); int msgOffset = 0; if (!GameManager.Instance.PlayerEntity.Items.Contains(Items.ItemGroups.MiscItems, (int)Items.MiscItems.Spellbook)) { DaggerfallUI.MessageBox(noSpellBook); } else if (GameManager.Instance.PlayerEntity.GetGoldAmount() < tradePrice) { DaggerfallUI.MessageBox(notEnoughGoldId); } else { if (presentedCost >> 1 <= tradePrice) { if (presentedCost - (presentedCost >> 2) <= tradePrice) { msgOffset = 2; } else { msgOffset = 1; } } DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTrade_OnButtonClick; uiManager.PushWindow(messageBox); } }
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(); } }
// Show a popup such as accept/reject message close guild window protected virtual void ShowQuestPopupMessage(Quest quest, int id, bool exitOnClose = true) { // Get message resource Message message = quest.GetMessage(id); if (message == null) return; // Setup popup message TextFile.Token[] tokens = message.GetTextTokens(); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager); messageBox.SetTextTokens(tokens, this.offeredQuest.ExternalMCP); messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = true; messageBox.ParentPanel.BackgroundColor = Color.clear; // Exit menu on close if requested if (exitOnClose) messageBox.OnClose += QuestPopupMessage_OnClose; // Present popup message messageBox.Show(); }
void ShowTradePopup() { const int tradeMessageBaseId = 260; const int notEnoughGoldId = 454; int msgOffset = 0; int tradePrice = GetTradePrice(); if (windowMode != WindowModes.Sell && windowMode != WindowModes.SellMagic && PlayerEntity.GetGoldAmount() < tradePrice) { DaggerfallUI.MessageBox(notEnoughGoldId); } else { if (cost >> 1 <= tradePrice) { if (cost - (cost >> 2) <= tradePrice) { msgOffset = 2; } else { msgOffset = 1; } } if (windowMode == WindowModes.Sell || windowMode == WindowModes.SellMagic) { msgOffset += 3; } DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTrade_OnButtonClick; uiManager.PushWindow(messageBox); } }
public override void OnPush() { base.OnPush(); buildingDiscoveryData = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData; // Check guild advancement TextFile.Token[] updatedRank = guild.UpdateRank(playerEntity); if (updatedRank != null) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(updatedRank, guild); messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); } // Check for free healing (Temple members) if (guild.FreeHealing() && playerEntity.CurrentHealth < playerEntity.MaxHealth) { playerEntity.SetHealth(playerEntity.MaxHealth); DaggerfallUI.MessageBox(350); } // TODO: Check for magicka restoration (sorcerers) }
void DaggerfallClassSelectWindow_OnItemPicked(int index, string className) { if (index == classList.Count) // "Custom" option selected { selectedClass = null; CloseWindow(); } else { selectedClass = classList[index]; TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(startClassDescriptionID + index); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(textTokens); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); noButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); messageBox.OnButtonClick += ConfirmClassPopup_OnButtonClick; uiManager.PushWindow(messageBox); AudioClip clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip(SoundClips.SelectClassDrums); DaggerfallUI.Instance.AudioSource.PlayOneShot(clip); } }
protected virtual void TrainingSkill_OnItemPicked(int index, string skillName) { CloseWindow(); List <DFCareer.Skills> trainingSkills = GetTrainingSkills(); DFCareer.Skills skillToTrain = trainingSkills[index]; if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > Guild.GetTrainingMax(skillToTrain)) { // Inform player they're too skilled to train TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens, Guild); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { // Take payment. playerEntity.DeductGoldAmount(Guild.GetTrainingPrice()); // Train the skill TrainSkill(skillToTrain); } }
protected virtual DaggerfallMessageBox CreateDialogBox(string entryStr, string baseKey) { string heading = TextManager.Instance.GetLocalizedText(baseKey + "Head"); string action = TextManager.Instance.GetLocalizedText(baseKey); string explanation = TextManager.Instance.GetLocalizedText(baseKey + "2"); TextFile.Token[] tokens = new TextFile.Token[] { TextFile.CreateTextToken(heading), TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken, TextFile.CreateTextToken(action), TextFile.NewLineToken, TextFile.NewLineToken, new TextFile.Token() { text = entryStr, formatting = TextFile.Formatting.TextHighlight }, TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken, TextFile.CreateTextToken(explanation), TextFile.CreateFormatToken(TextFile.Formatting.EndOfRecord) }; DaggerfallMessageBox dialogBox = new DaggerfallMessageBox(uiManager, this); dialogBox.SetHighlightColor(Color.white); dialogBox.SetTextTokens(tokens); dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); return(dialogBox); }
public void TrainingSkill_OnItemPicked(int index, string skillName) { CloseWindow(); List <DFCareer.Skills> trainingSkills; if (guildTrainingSkills.TryGetValue(service, out trainingSkills)) { DFCareer.Skills skillToTrain = trainingSkills[index]; if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > 50) { // Inform player they're too skilled to train TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens, this); messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); } else { // Train the skill DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime(); now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3); playerEntity.DeductGoldAmount(GetServicePrice()); playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180); int skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain); short tallyAmount = (short)(Random.Range(10, 21) * skillAdvancementMultiplier); playerEntity.TallySkill(skillToTrain, tallyAmount); DaggerfallUI.MessageBox(TrainSkillId); } } else { Debug.LogError("Invalid skill selected for training."); } }
protected virtual void TrainingService() { // Check enough time has passed since last trained DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now; if ((now.ToClassicDaggerfallTime() - playerEntity.TimeOfLastSkillTraining) < 720) { TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingToSoonId); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(tokens); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { // Offer training price DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId); messageBox.SetTextTokens(tokens, Guild); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTraining_OnButtonClick; messageBox.Show(); } }
private void ServiceButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { // Check access to service if (!guild.CanAccessService(service)) { if (guild.IsMember()) { DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(InsufficientRankId)); msgBox.ClickAnywhereToClose = true; msgBox.Show(); } else { DaggerfallUI.MessageBox(HardStrings.serviceMembersOnly); } return; } // Handle known service switch (service) { case GuildServices.Quests: GetQuest(); break; case GuildServices.Identify: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Identify, this, guild)); break; case GuildServices.Repair: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Repair, this, guild)); break; case GuildServices.Training: TrainingService(); break; case GuildServices.Donate: DonationService(); break; case GuildServices.CureDisease: CureDiseaseService(); break; case GuildServices.BuyPotions: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild) { MerchantItems = GetMerchantPotions() }); break; case GuildServices.MakePotions: CloseWindow(); uiManager.PushWindow(DaggerfallUI.Instance.DfPotionMakerWindow); break; /* case GuildServices.BuySpells: * uiManager.PushWindow(new DaggerfallBankingWindow(uiManager, this)); * break; */ case GuildServices.MakeSpells: CloseWindow(); uiManager.PushWindow(DaggerfallUI.Instance.DfSpellMakerWindow); break; case GuildServices.BuyMagicItems: // TODO: switch items depending on npcService? CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild) { MerchantItems = GetMerchantMagicItems() }); break; case GuildServices.MakeMagicItems: CloseWindow(); uiManager.PushWindow(DaggerfallUI.Instance.DfItemMakerWindow); break; /* case GuildServices.SellMagicItems: * CloseWindow(); * uiManager.PushWindow(DaggerfallUI.Instance.DfPotionMakerWindow); * break; */ case GuildServices.Teleport: CloseWindow(); DaggerfallUI.Instance.DfTravelMapWindow.ActivateTeleportationTravel(); uiManager.PushWindow(DaggerfallUI.Instance.DfTravelMapWindow); break; case GuildServices.ReceiveArmor: ReceiveArmorService(); break; case GuildServices.ReceiveHouse: ReceiveHouseService(); break; case GuildServices.Spymaster: const int spyMasterGreetingTextId = 402; DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(spyMasterGreetingTextId)); msgBox.ClickAnywhereToClose = true; msgBox.OnClose += SpyMasterGreetingPopUp_OnClose; msgBox.Show(); break; default: CloseWindow(); Services.CustomGuildService customService; if (Services.GetCustomGuildService((int)service, out customService)) { customService(); } else { DaggerfallUI.MessageBox("Guild service not yet implemented."); } break; } }
public override void Update() { base.Update(); if (state == 0) // Starting { regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex; int crimeType = (int)playerEntity.CrimeCommitted - 1; int legalRep = playerEntity.RegionData[regionIndex].LegalRep; // Get whether punishment is normal (fine/prison) or a severe punishment (banishment/execution) int threshold1 = 0; int threshold2 = 0; if (legalRep < 0) { threshold1 = -legalRep; if (threshold1 > 75) { threshold1 = 75; } threshold2 = -legalRep / 2; if (threshold2 > 75) { threshold2 = 75; } } if (UnityEngine.Random.Range(1, 101) > threshold2 && UnityEngine.Random.Range(1, 101) > threshold1) { punishmentType = 2; // fine/prison } else { punishmentType = 0; // banishment or execution } // Calculate penalty amount int penaltyAmount = 0; if (legalRep >= 0) { penaltyAmount = PenaltyPerLegalRepPoint[crimeType] * legalRep + BasePenaltyAmounts[crimeType]; } else { penaltyAmount = BasePenaltyAmounts[crimeType] - PenaltyPerLegalRepPoint[crimeType] * legalRep; } if (penaltyAmount > MaximumPenaltyAmounts[crimeType]) { penaltyAmount = MaximumPenaltyAmounts[crimeType]; } else if (penaltyAmount < MinimumPenaltyAmounts[crimeType]) { penaltyAmount = MinimumPenaltyAmounts[crimeType]; } penaltyAmount /= 40; // Calculate days of prison and fine daysInPrison = 0; fine = 0; for (int i = 0; i < penaltyAmount; i++) { if ((DFRandom.rand() & 1) != 0) { fine += 40; } else { daysInPrison += 3; } } // If player can't pay fine, limit fine and add to prison sentence int playerGold = playerEntity.GetGoldAmount(); if (playerGold < fine) { daysInPrison += (fine - playerGold) / 40; fine = playerGold; } DaggerfallMessageBox messageBox; if (crimeType == 4 || crimeType == 3) // Assault or murder { // If player is a member of the Dark Brotherhood, they may be rescued for a violent crime Guilds.Guild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Dark_Brotherhood); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextDB)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } if (crimeType <= 2 || crimeType == 11) // Attempted breaking and entering, trespassing, breaking and entering, pickpocketing { // If player is a member of the Thieves Guild, they may be rescued for a thieving crime Guilds.Guild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Thieves_Guild); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextTG)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } messageBox = new DaggerfallMessageBox(uiManager, this, false, 105); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextStart)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Guilty); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.NotGuilty); messageBox.OnButtonClick += GuiltyNotGuilty_OnButtonClick; messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; uiManager.PushWindow(messageBox); state = 1; // Done with initial message } else if (state == 2) // Found guilty { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFoundGuilty)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); state = 3; } else if (state == 3) // Serve prison sentence { PositionPlayerAtLocationEntrance(); ServeTime(daysInPrison); playerEntity.RaiseReputationForDoingSentence(); state = 100; } else if (state == 4) // Banished { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextBanished)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 1; PositionPlayerAtLocationEntrance(); state = 100; } // Note: Seems like an execution sentence can't be given in classic. It can't be given here, either. else if (state == 5) // Execution { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextExecuted)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 2; state = 6; } else if (state == 6) // Reposition player at entrance { PositionPlayerAtLocationEntrance(); state = 100; } else if (state == 100) // Done { ReleaseFromJail(); } }
private void DebateLie_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { sender.CloseWindow(); int playerSkill = 0; if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Debate) { playerSkill = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Etiquette); playerEntity.TallySkill(DFCareer.Skills.Etiquette, 1); } else { playerSkill = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Streetwise); playerEntity.TallySkill(DFCareer.Skills.Streetwise, 1); } int chanceToGoFree = playerEntity.RegionData[regionIndex].LegalRep + (playerSkill + playerEntity.Stats.GetLiveStatValue(DFCareer.Stats.Personality)) / 2; if (chanceToGoFree > 95) { chanceToGoFree = 95; } else if (chanceToGoFree < 5) { chanceToGoFree = 5; } if (UnityEngine.Random.Range(1, 101) > chanceToGoFree) { // Banishment if (punishmentType == 0) { state = 4; } // Execution else if (punishmentType == 1) { state = 5; } // Prison/Fine else { int roll = playerEntity.RegionData[regionIndex].LegalRep + UnityEngine.Random.Range(1, 101); if (roll < 25) { fine *= 2; } else if (roll > 75) { fine >>= 1; } state = 2; } } else { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFreeToGo)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); // Oversight in classic: Does not refill vital signs when releasing in this case, so player is left with 1 health. // Also does not repair reputation. playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 6; } Update(); }
private void ConfirmSummon_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { sender.CloseWindow(); if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; int summonCost = FormulaHelper.CalculateDaedraSummoningCost(summonerFactionData.rep); if (playerEntity.GetGoldAmount() >= summonCost) { playerEntity.DeductGoldAmount(summonCost); WeatherManager weatherManager = GameManager.Instance.WeatherManager; // Sheogorath has a 5% (15% if stormy) chance to replace selected daedra. int sheoChance = (weatherManager.IsStorming) ? 15 : 5; if (Dice100.Roll() <= sheoChance) { daedraToSummon = daedraData[8]; } // Default 30% bonus is only applicable to some Daedra in specific weather conditions. int bonus = 0; if (daedraToSummon.bonusCond == Weather.WeatherType.Rain && weatherManager.IsRaining || daedraToSummon.bonusCond == Weather.WeatherType.Thunder && weatherManager.IsStorming || daedraToSummon.bonusCond == Weather.WeatherType.None) { bonus = 30; } // Get summoning chance for selected daedra and roll. int chance = FormulaHelper.CalculateDaedraSummoningChance(playerEntity.FactionData.GetReputation(daedraToSummon.factionId), bonus); int roll = Dice100.Roll(); Debug.LogFormat("Summoning {0} with chance = {1}%, Sheogorath chance = {2}%, roll = {3}, summoner rep = {4}, cost: {5}", daedraToSummon.vidFile.Substring(0, daedraToSummon.vidFile.Length - 4), chance, sheoChance, roll, summonerFactionData.rep, summonCost); if (roll > chance) { // Daedra stood you up! DaggerfallUI.MessageBox(SummonFailed, this); // Spawn daedric foes if failed at a witches coven. if (summonerFactionData.ggroup == (int)FactionFile.GuildGroups.Witches) { GameObjectHelper.CreateFoeSpawner(true, daedricFoes[Random.Range(0, 5)], Random.Range(1, 4), 4, 64); } return; } // Has this Daedra already been summoned by the player? if (playerEntity.FactionData.GetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned)) { // Close menu and push DaggerfallDaedraSummoningWindow here for video and dismissal.. CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, SummonBefore, this })); } else { // Record the summoning. playerEntity.FactionData.SetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned); // Offer the quest to player. offeredQuest = GameManager.Instance.QuestListsManager.GetQuest(daedraToSummon.quest, summonerFactionData.id); if (offeredQuest != null) { // Close menu and push DaggerfallDaedraSummoningWindow here for video and custom quest offer.. CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, offeredQuest })); } } } else { // Display customised not enough gold message so players don't need to guess the cost. TextFile.Token[] notEnoughGold = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(DaggerfallTradeWindow.NotEnoughGoldId); TextFile.Token[] msg = new TextFile.Token[] { new TextFile.Token() { formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost1") }, new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, new TextFile.Token() { formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost2") + summonCost + TextManager.Instance.GetLocalizedText("serviceSummonCost3") }, new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, new TextFile.Token() { formatting = TextFile.Formatting.NewLine }, notEnoughGold[0], new TextFile.Token() { formatting = TextFile.Formatting.JustifyCenter }, }; DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); messageBox.SetTextTokens(msg, this); messageBox.ClickAnywhereToClose = false; messageBox.Show(); } } }
protected override void ShowTradePopup() { const int tradeMessageBaseId = 260; const int notEnoughGoldId = 454; int msgOffset = 0; int tradePrice = GetTradePrice(); int currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey; int goldSupply = 0; int shopAttitude = 0; // For now, 0 = Nice Attitude and 1 = Bad Attitude. LimitedGoldShops.ShopData sd; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { goldSupply = sd.CurrentGoldSupply; shopAttitude = sd.ShopAttitude; } if (WindowMode == WindowModes.Sell && goldSupply <= 0) { int buildQual = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.quality; TextFile.Token[] tokens = LGSTextTokenHolder.ShopTextTokensNice(4); if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) // Possibly could add the "shop type" to the save-data as well, and use that to determine some other things. { tokens = LGSTextTokenHolder.ShopTextTokensNice(5); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(4); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(6); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(5); } } else if (buildQual <= 13) // 08 - 13 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(4); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(6); } } else if (buildQual <= 17) // 14 - 17 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(7); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(7); } } else // 18 - 20 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(8); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(8); } } DaggerfallMessageBox noGoldShop = new DaggerfallMessageBox(DaggerfallUI.UIManager, this); noGoldShop.SetTextTokens(tokens, this); noGoldShop.ClickAnywhereToClose = true; uiManager.PushWindow(noGoldShop); } else if (WindowMode == WindowModes.Sell && goldSupply < tradePrice) { TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.CreateTokens( TextFile.Formatting.JustifyCenter, "I can't afford your offer.", "Would you be willing to settle", "for the " + goldSupply.ToString() + " gold that I have left?"); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmPoorTrade_OnButtonClick; uiManager.PushWindow(messageBox); } else if (WindowMode != WindowModes.Sell && WindowMode != WindowModes.SellMagic && PlayerEntity.GetGoldAmount() < tradePrice) { DaggerfallUI.MessageBox(notEnoughGoldId); } else { if (cost >> 1 <= tradePrice) { if (cost - (cost >> 2) <= tradePrice) { msgOffset = 2; } else { msgOffset = 1; } } if (WindowMode == WindowModes.Sell || WindowMode == WindowModes.SellMagic) { msgOffset += 3; } DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTrade_OnButtonClick; uiManager.PushWindow(messageBox); } }
public static DaggerfallMessageBox MessageBox(int id) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(Instance.uiManager, Instance.uiManager.TopWindow); messageBox.SetTextTokens(id); messageBox.ClickAnywhereToClose = true; messageBox.Show(); return messageBox; }
void CureDiseaseService() { CloseWindow(); int numberOfDiseases = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (playerEntity.TimeToBecomeVampireOrWerebeast != 0) { numberOfDiseases++; } // Check holidays for free / cheaper curing uint minutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); int holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex); if (numberOfDiseases > 0 && (holidayId == (int)DFLocation.Holidays.South_Winds_Prayer || holidayId == (int)DFLocation.Holidays.First_Harvest || holidayId == (int)DFLocation.Holidays.Second_Harvest)) { GameManager.Instance.PlayerEffectManager.CureAllDiseases(); playerEntity.TimeToBecomeVampireOrWerebeast = 0; DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "freeHolidayCuring")); } else if (numberOfDiseases > 0) { // Get base cost int baseCost = 250 * numberOfDiseases; // Apply rank-based discount if this is an Arkay temple baseCost = guild.ReducedCureCost(baseCost); // Apply temple quality and regional price modifiers int costBeforeBargaining = FormulaHelper.CalculateCost(baseCost, buildingDiscoveryData.quality); // Halve the price on North Winds Prayer holiday if (holidayId == (int)DFLocation.Holidays.North_Winds_Festival) { costBeforeBargaining /= 2; } // Apply bargaining to get final price curingCost = FormulaHelper.CalculateTradePrice(costBeforeBargaining, buildingDiscoveryData.quality, false); // Index correct message const int tradeMessageBaseId = 260; int msgOffset = 0; if (costBeforeBargaining >> 1 <= curingCost) { if (costBeforeBargaining - (costBeforeBargaining >> 2) <= curingCost) { msgOffset = 2; } else { msgOffset = 1; } } // Offer curing at the calculated price. DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmCuring_OnButtonClick; messageBox.Show(); } else { // Not diseased DaggerfallUI.MessageBox(30); } }
protected void InvestMessageBox_OnGotUserInput(DaggerfallInputMessageBox sender, string input) { int playerIntell = player.Stats.LiveIntelligence; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { investedFlag = sd.InvestedIn; shopAttitude = sd.ShopAttitude; } bool result = int.TryParse(input, out investOffer); if (!result || investOffer < 500) { tokens = LGSTextTokenHolder.ShopTextTokensNeutral(5); DaggerfallUI.MessageBox(tokens); return; } DaggerfallMessageBox investConfimBox = new DaggerfallMessageBox(uiManager, this); if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(11, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(14, investOffer); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(3, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(10, investOffer); } } else if (buildQual <= 17) // 08 - 17 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(15, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(18, investOffer); } } else // 18 - 20 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(19, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(22, investOffer); } } if (investedFlag) { if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(13, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(16, investOffer); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(9, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(12, investOffer); } } else if (buildQual <= 17) // 08 - 17 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(17, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(20, investOffer); } } else // 18 - 20 { if (shopAttitude == 0) { tokens = LGSTextTokenHolder.ShopTextTokensNice(21, investOffer); } else { tokens = LGSTextTokenHolder.ShopTextTokensMean(24, investOffer); } } } investConfimBox.SetTextTokens(tokens); investConfimBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); investConfimBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); investConfimBox.OnButtonClick += ConfirmInvestment_OnButtonClick; uiManager.PushWindow(investConfimBox); }
public override void Update() { base.Update(); // Close immediately if no crime assigned to player if (playerEntity.CrimeCommitted == Entity.PlayerEntity.Crimes.None) { CloseWindow(); return; } if (state == 0) // Starting { regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex; int crimeType = (int)playerEntity.CrimeCommitted - 1; int legalRep = playerEntity.RegionData[regionIndex].LegalRep; // Get whether punishment is normal (fine/prison) or a severe punishment (banishment/execution) int threshold1 = 0; int threshold2 = 0; if (legalRep < 0) { threshold1 = -legalRep; if (threshold1 > 75) { threshold1 = 75; } threshold2 = -legalRep / 2; if (threshold2 > 75) { threshold2 = 75; } } if (Dice100.FailedRoll(threshold2) && Dice100.FailedRoll(threshold1)) { punishmentType = 2; // fine/prison } else { punishmentType = 0; // banishment or execution } // Calculate penalty amount int penaltyAmount = 0; if (legalRep >= 0) { penaltyAmount = PenaltyPerLegalRepPoint[crimeType] * legalRep + BasePenaltyAmounts[crimeType]; } else { penaltyAmount = BasePenaltyAmounts[crimeType] - PenaltyPerLegalRepPoint[crimeType] * legalRep; } if (penaltyAmount > MaximumPenaltyAmounts[crimeType]) { penaltyAmount = MaximumPenaltyAmounts[crimeType]; } else if (penaltyAmount < MinimumPenaltyAmounts[crimeType]) { penaltyAmount = MinimumPenaltyAmounts[crimeType]; } penaltyAmount /= 40; // Calculate days of prison and fine daysInPrison = 0; fine = 0; for (int i = 0; i < penaltyAmount; i++) { if ((DFRandom.rand() & 1) != 0) { fine += 40; } else { daysInPrison += 3; } } // If player can't pay fine, limit fine and add to prison sentence int playerGold = playerEntity.GetGoldAmount(); if (playerGold < fine) { daysInPrison += (fine - playerGold) / 40; fine = playerGold; } DaggerfallMessageBox messageBox; if (crimeType == 4 || crimeType == 3) // Assault or murder { // If player is a member of the Dark Brotherhood, they may be rescued for a violent crime Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Dark_Brotherhood); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextDB)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } if (crimeType <= 2 || crimeType == 11) // Attempted breaking and entering, trespassing, breaking and entering, pickpocketing { // If player is a member of the Thieves Guild, they may be rescued for a thieving crime Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Thieves_Guild); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextTG)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } messageBox = new DaggerfallMessageBox(uiManager, this, false, 105); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextStart)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Guilty); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.NotGuilty); messageBox.OnButtonClick += GuiltyNotGuilty_OnButtonClick; messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); state = 1; // Done with initial message } else if (state == 2) // Found guilty { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFoundGuilty)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); if (daysInPrison > 0) { state = 3; } else { // Give the reputation raise here if no prison time will be served. playerEntity.RaiseReputationForDoingSentence(); repositionPlayer = true; playerEntity.FillVitalSigns(); ReleaseFromPrison(); state = 100; } } else if (state == 3) // Serve prison sentence { playerEntity.InPrison = true; SwitchToPrisonScreen(); daysInPrisonLeft = daysInPrison; playerEntity.RaiseReputationForDoingSentence(); repositionPlayer = true; state = 100; } else if (state == 4) // Banished { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextBanished)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 1; repositionPlayer = true; // Refill player vitals after banishment, otherwise player left with 1HP outside city gates playerEntity.FillVitalSigns(); state = 100; } // Note: Seems like an execution sentence can't be given in classic. It can't be given here, either. else if (state == 5) // Execution { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextExecuted)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 2; state = 6; } else if (state == 6) // Reposition player at entrance { repositionPlayer = true; state = 100; } else if (state == 100) // Done { if (playerEntity.InPrison) { if (Input.GetKey(exitKey)) // Speed up prison day countdown. Not in classic. { prisonUpdateInterval = 0.001f; } else { prisonUpdateInterval = 0.3f; } if (prisonUpdateTimer == 0) { prisonUpdateTimer = Time.realtimeSinceStartup; } if (Time.realtimeSinceStartup < prisonUpdateTimer + prisonUpdateInterval) { return; } else { prisonUpdateTimer = Time.realtimeSinceStartup; UpdatePrisonScreen(); } } else { ReleaseFromPrison(); } } }
private void StatButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens((int)sender.Tag); messageBox.ClickAnywhereToClose = true; messageBox.Show(); }
void ShowSkillsDialog(List<DFCareer.Skills> skills, bool twoColumn = false) { bool secondColumn = false; List<TextFile.Token> tokens = new List<TextFile.Token>(); for (int i = 0; i < skills.Count; i++) { if (!twoColumn) { tokens.AddRange(CreateSkillTokens(skills[i])); if (i < skills.Count - 1) tokens.Add(TextFile.NewLineToken); } else { tokens.AddRange(CreateSkillTokens(skills[i])); if (!secondColumn) { secondColumn = !secondColumn; tokens.Add(TextFile.TabToken); } else { secondColumn = !secondColumn; if (i < skills.Count - 1) tokens.Add(TextFile.NewLineToken); } } } DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(tokens.ToArray()); messageBox.ClickAnywhereToClose = true; messageBox.Show(); }
void DaggerfallClassSelectWindow_OnItemPicked(int index, string className) { selectedClass = classList[index]; TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(startClassDescriptionID + index); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(textTokens); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); noButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); messageBox.OnButtonClick += ConfirmClassPopup_OnButtonClick; uiManager.PushWindow(messageBox); AudioClip clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip(SoundClips.SelectClassDrums); DaggerfallUI.Instance.AudioSource.PlayOneShot(clip); }
/// <summary> /// 11 /// Pop-up text /// </summary> /// <param name="obj"></param> /// <param name="thisAction"></param> public static void ShowText(GameObject obj, DaggerfallAction thisAction) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallWorkshop.Game.DaggerfallUI.UIManager, null); messageBox.SetTextTokens(thisAction.Index + TYPE_11_TEXT_INDEX); messageBox.ClickAnywhereToClose = true; messageBox.ParentPanel.BackgroundColor = Color.clear; messageBox.Show(); }
/// <summary> /// Handles events from Find Location pop-up. /// </summary> void HandleLocationFindEvent(DaggerfallInputMessageBox inputMessageBox, string locationName) { //locationSelected = false; if (string.IsNullOrEmpty(locationName) || !FindLocation(locationName)) { TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(13); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(textTokens); messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); return; } else //place flashing crosshair over location { locationSelected = true; findingLocation = true; CreateCrossHair(MapsFile.GetPixelFromPixelID(locationSummary.ID), locationSummary.RegionIndex); StartRegionIdentify(); } }
void ShowInfoPopup(DaggerfallUnityItem item) { const int armorTextId = 1000; const int weaponTextId = 1001; const int miscTextId = 1003; TextFile.Token[] tokens = null; if (item.ItemGroup == ItemGroups.Armor) tokens = DaggerfallUnity.TextProvider.GetRSCTokens(armorTextId); else if (item.ItemGroup == ItemGroups.Weapons) tokens = DaggerfallUnity.TextProvider.GetRSCTokens(weaponTextId); else tokens = DaggerfallUnity.TextProvider.GetRSCTokens(miscTextId); if (tokens != null && tokens.Length > 0) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(tokens); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } }
void ClickHandler(BaseScreenComponent sender, Vector2 position) { int offset = (int)position.y * racePickerBitmap.Width + (int)position.x; if (offset < 0 || offset >= racePickerBitmap.Data.Length) return; int id = racePickerBitmap.Data[offset]; if (raceDict.ContainsKey(id)) { promptLabel.Enabled = false; selectedRace = raceDict[id]; TextFile.Token[] textTokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(selectedRace.DescriptionID); DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(textTokens); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); Button noButton = messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); noButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); messageBox.OnButtonClick += ConfirmRacePopup_OnButtonClick; messageBox.OnCancel += ConfirmRacePopup_OnCancel; uiManager.PushWindow(messageBox); AudioClip clip = DaggerfallUnity.Instance.SoundReader.GetAudioClip((uint)selectedRace.ClipID); DaggerfallUI.Instance.AudioSource.PlayOneShot(clip); } }
private void ServiceButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { // Check access to service if (!guild.CanAccessService(service)) { if (guild.IsMember()) { DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(InsufficientRankId)); msgBox.ClickAnywhereToClose = true; msgBox.Show(); } else { DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "serviceMembersOnly")); } return; } // Handle known service switch (service) { case GuildServices.Quests: GetQuest(); break; case GuildServices.Identify: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Identify, this, guild)); break; case GuildServices.Repair: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Repair, this, guild)); break; case GuildServices.Training: TrainingService(); break; case GuildServices.Donate: DonationService(); break; case GuildServices.CureDisease: CureDiseaseService(); break; case GuildServices.BuyPotions: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild) { MerchantItems = GetMerchantPotions() }); break; case GuildServices.MakePotions: MakePotionService(); break; case GuildServices.BuySpells: case GuildServices.BuySpellsMages: CloseWindow(); uiManager.PushWindow(new DaggerfallSpellBookWindow(uiManager, this, true)); break; case GuildServices.MakeSpells: CloseWindow(); if (GameManager.Instance.PlayerEntity.Items.Contains(Items.ItemGroups.MiscItems, (int)Items.MiscItems.Spellbook)) { uiManager.PushWindow(DaggerfallUI.Instance.DfSpellMakerWindow); } else { DaggerfallUI.MessageBox(TextManager.Instance.GetText("ClassicEffects", "noSpellbook")); } break; case GuildServices.BuyMagicItems: // TODO: switch items depending on npcService? CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild) { MerchantItems = GetMerchantMagicItems() }); break; case GuildServices.MakeMagicItems: CloseWindow(); uiManager.PushWindow(DaggerfallUI.Instance.DfItemMakerWindow); break; case GuildServices.SellMagicItems: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.SellMagic, this, guild)); break; case GuildServices.Teleport: CloseWindow(); DaggerfallUI.Instance.DfTravelMapWindow.ActivateTeleportationTravel(); uiManager.PushWindow(DaggerfallUI.Instance.DfTravelMapWindow); break; case GuildServices.DaedraSummoning: DaedraSummoningService((int)npcService); break; case GuildServices.ReceiveArmor: ReceiveArmorService(); break; case GuildServices.ReceiveHouse: ReceiveHouseService(); break; case GuildServices.Spymaster: const int spyMasterGreetingTextId = 402; DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(spyMasterGreetingTextId)); msgBox.ClickAnywhereToClose = true; msgBox.OnClose += SpyMasterGreetingPopUp_OnClose; msgBox.Show(); break; case GuildServices.BuySoulgems: CloseWindow(); uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild) { MerchantItems = GetMerchantMagicItems(true) }); break; default: CloseWindow(); Services.CustomGuildService customService; if (Services.GetCustomGuildService((int)service, out customService)) { customService(this); } else { DaggerfallUI.MessageBox("Guild service not yet implemented."); } break; } }
protected virtual void DoGuildService() { // Check access to service if (!guild.CanAccessService(service)) { if (guild.IsMember()) { DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(InsufficientRankId)); msgBox.ClickAnywhereToClose = true; msgBox.Show(); } else { DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("serviceMembersOnly")); } return; } // Handle known service DaggerfallTradeWindow tradeWindow; switch (service) { case GuildServices.Quests: GetQuest(); break; case GuildServices.Identify: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.Identify, guild })); break; case GuildServices.Repair: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.Repair, guild })); break; case GuildServices.Training: CloseWindow(); UIWindowFactory.GetInstanceWithArgs(UIWindowType.GuildServiceTraining, new object[] { uiManager, npcService, guild }); break; case GuildServices.Donate: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.GuildServiceDonation, new object[] { uiManager, buildingFactionId })); break; case GuildServices.CureDisease: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.GuildServiceCureDisease, new object[] { uiManager, buildingFactionId, guild })); break; case GuildServices.BuyPotions: CloseWindow(); tradeWindow = (DaggerfallTradeWindow)UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.Buy, guild }); tradeWindow.MerchantItems = GetMerchantPotions(); uiManager.PushWindow(tradeWindow); break; case GuildServices.MakePotions: MakePotionService(); break; case GuildServices.BuySpells: case GuildServices.BuySpellsMages: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.SpellBook, new object[] { uiManager, this, true })); break; case GuildServices.MakeSpells: CloseWindow(); if (GameManager.Instance.PlayerEntity.Items.Contains(ItemGroups.MiscItems, (int)MiscItems.Spellbook)) { uiManager.PushWindow(DaggerfallUI.Instance.DfSpellMakerWindow); } else { DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("noSpellbook")); } break; case GuildServices.BuyMagicItems: CloseWindow(); tradeWindow = (DaggerfallTradeWindow)UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.Buy, guild }); tradeWindow.MerchantItems = GetMerchantMagicItems(); uiManager.PushWindow(tradeWindow); break; case GuildServices.MakeMagicItems: CloseWindow(); uiManager.PushWindow(DaggerfallUI.Instance.DfItemMakerWindow); break; case GuildServices.SellMagicItems: CloseWindow(); uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.SellMagic, guild })); break; case GuildServices.Teleport: CloseWindow(); DaggerfallUI.Instance.DfTravelMapWindow.ActivateTeleportationTravel(); uiManager.PushWindow(DaggerfallUI.Instance.DfTravelMapWindow); break; case GuildServices.DaedraSummoning: DaedraSummoningService((int)npcService); break; case GuildServices.ReceiveArmor: ReceiveArmorService(); break; case GuildServices.ReceiveHouse: ReceiveHouseService(); break; case GuildServices.Spymaster: const int spyMasterGreetingTextId = 402; DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this); msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(spyMasterGreetingTextId)); msgBox.ClickAnywhereToClose = true; msgBox.OnClose += SpyMasterGreetingPopUp_OnClose; msgBox.Show(); break; case GuildServices.BuySoulgems: CloseWindow(); tradeWindow = (DaggerfallTradeWindow)UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { uiManager, this, DaggerfallTradeWindow.WindowModes.Buy, guild }); tradeWindow.MerchantItems = GetMerchantMagicItems(true); uiManager.PushWindow(tradeWindow); break; default: CloseWindow(); Services.CustomGuildService customService; if (Services.GetCustomGuildService((int)service, out customService)) { customService(this); } else { DaggerfallUI.MessageBox("Guild service not yet implemented."); } break; } }
void OkButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (statsRollout.BonusPool > 0) { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(strYouMustDistributeYourBonusPoints); messageBox.ClickAnywhereToClose = true; messageBox.Show(); } else { CloseWindow(); } }
void CreateConfirmationPopUp() { if (!locationSelected) return; TextFile.Token[] textTokens = new TextFile.Token[2]; //int index = currentRegion.MapIdLookup[locationSummary.MapIndex]; textTokens[0].text = string.Format("Travel to {0} : {1} ?", currentDFRegion.Name, currentDFRegion.MapNames[locationSummary.MapIndex]); textTokens[0].formatting = TextFile.Formatting.Text; textTokens[1].text = null; textTokens[1].formatting = TextFile.Formatting.NewLine; DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this); messageBox.SetTextTokens(textTokens); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmTravelPopupButtonClick; uiManager.PushWindow(messageBox); }