Exemple #1
0
 void OkButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     if (statsRollout.BonusPool > 0 ||
         skillsRollout.PrimarySkillBonusPoints > 0 ||
         skillsRollout.MajorSkillBonusPoints > 0 ||
         skillsRollout.MinorSkillBonusPoints > 0)
     {
         DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
         messageBox.SetTextTokens(strYouMustDistributeYourBonusPoints);
         messageBox.ClickAnywhereToClose = true;
         messageBox.Show();
     }
     else
     {
         CloseWindow();
     }
 }
        protected override void GetQuest()
        {
            // Just exit if this NPC already involved in an active quest
            // If quest conditions are complete the quest system should pickup ending
            if (QuestMachine.Instance.IsLastNPCClickedAnActiveQuestor(guild))
            {
                CloseWindow();
                return;
            }

            // Get member status, including temple specific statuses
            MembershipStatus status = guild.IsMember() ? MembershipStatus.Member : MembershipStatus.Nonmember;

            if (guild.IsMember() && guildGroup == FactionFile.GuildGroups.HolyOrder)
            {
                status = (MembershipStatus)Enum.Parse(typeof(MembershipStatus), ((Temple)guild).Deity.ToString());
            }

            // Get the faction id for affecting reputation on success/failure
            int factionId = (guildGroup == FactionFile.GuildGroups.HolyOrder || guildGroup == FactionFile.GuildGroups.KnightlyOrder) ? buildingFactionId : guildManager.GetGuildFactionId(guildGroup);

            // Select a quest at random from appropriate pool
            offeredQuest = GameManager.Instance.QuestListsManager.GetGuildQuest(guildGroup, status, factionId, guild.GetReputation(playerEntity), guild.Rank);
            if (offeredQuest != null)
            {
                // Log offered quest
                Debug.LogFormat("Offering quest {0} from Guild {1} affecting factionId {2}", offeredQuest.QuestName, guildGroup, offeredQuest.FactionId);

                // Offer the quest to player, setting external context provider to guild if a member
                if (guild.IsMember())
                {
                    offeredQuest.ExternalMCP = guild;
                }
                DaggerfallMessageBox messageBox = QuestMachine.Instance.CreateMessagePrompt(offeredQuest, (int)QuestMachine.QuestMessages.QuestorOffer);
                if (messageBox != null)
                {
                    messageBox.OnButtonClick += OfferQuest_OnButtonClick;
                    messageBox.Show();
                }
            }
            else
            {
                ShowFailGetQuestMessage();
            }
        }
Exemple #3
0
        protected void DaedraSummoningService(int npcFactionId)
        {
            if (!GameManager.Instance.PlayerEntity.FactionData.GetFactionData(npcFactionId, out summonerFactionData))
            {
                DaggerfallUnity.LogMessage("Error no faction data for NPC FactionId: " + npcFactionId);
                return;
            }
            // Select appropriate Daedra for summoning attempt.
            if (summonerFactionData.id == (int)FactionFile.FactionIDs.The_Glenmoril_Witches)
            {   // Always Hircine at Glenmoril witches.
                daedraToSummon = daedraData[0];
            }
            else if ((FactionFile.FactionTypes)summonerFactionData.type == FactionFile.FactionTypes.WitchesCoven)
            {   // Witches covens summon a random Daedra.
                daedraToSummon = daedraData[Random.Range(1, daedraData.Length)];
            }
            else
            {   // Is this a summoning day?
                int dayOfYear = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.DayOfYear;
                foreach (DaedraData dd in daedraData)
                {
                    if (dd.dayOfYear == dayOfYear)
                    {
                        daedraToSummon = dd;
                        break;
                    }
                }
            }
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);

            if (daedraToSummon.factionId == 0)
            {   // Display not summoning day message.
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(SummonNotToday);
                messageBox.SetTextTokens(tokens, this);
                messageBox.ClickAnywhereToClose = true;
            }
            else
            {   // Ask player if they really want to risk the summoning.
                messageBox.SetTextTokens(SummonAreYouSure, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmSummon_OnButtonClick;
            }
            messageBox.Show();
        }
        protected override void GetQuest()
        {
            // Just exit if this NPC already involved in an active quest
            // If quest conditions are complete the quest system should pickup ending
            if (QuestMachine.Instance.IsLastNPCClickedAnActiveQuestor(guild))
            {
                CloseWindow();
                return;
            }

            // Get member status, including temple specific statuses
            MembershipStatus status = guild.IsMember() ? MembershipStatus.Member : MembershipStatus.Nonmember;

            if (guild.IsMember() && guildGroup == FactionFile.GuildGroups.HolyOrder)
            {
                status = (MembershipStatus)Enum.Parse(typeof(MembershipStatus), ((Temple)guild).Deity.ToString());
            }

            // Get the faction id for affecting reputation on success/failure
            int factionId = GetFactionIdForGuild();

            // Select a quest at random from appropriate pool
            QuestListsManager questListsManager = GameManager.Instance.QuestListsManager;

            questPool = GameManager.Instance.QuestListsManager.GetGuildQuestPool(guildGroup, status, factionId, guild.GetReputation(playerEntity), guild.Rank);

            if (DaggerfallUnity.Settings.GuildQuestListBox)
            {
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.CreateTokens(
                    TextFile.Formatting.JustifyCenter,
                    TextManager.Instance.GetText(textDatabase, "gettingQuests1"),
                    TextManager.Instance.GetText(textDatabase, "gettingQuests2"));

                DaggerfallMessageBox gettingQuestsBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, this);
                gettingQuestsBox.ClickAnywhereToClose = true;
                gettingQuestsBox.SetTextTokens(tokens);
                gettingQuestsBox.OnClose += GettingQuestsBox_OnClose;
                gettingQuestsBox.Show();
            }
            else
            {
                offeredQuest = questListsManager.SelectQuest(questPool, factionId);
                OfferQuest();
            }
        }
 bool CheckIfDoneLeveling()
 {
     if (statsRollout.BonusPool > 0)
     {
         DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
         messageBox.SetText(HardStrings.mustDistributeBonusPoints);
         messageBox.ClickAnywhereToClose = true;
         messageBox.Show();
         return(false);
     }
     else
     {
         leveling           = false;
         PlayerEntity.Stats = statsRollout.WorkingStats;
         NativePanel.Components.Remove(statsRollout);
         return(true);
     }
 }
        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 ExitButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallMessageBox messageBox;

            // Is the class name set?
            if (nameTextBox.Text.Length == 0)
            {
                messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(strNameYourClass);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
                return;
            }

            // Are all skills set?
            for (int i = 0; i < skillLabels.Length; i++)
            {
                if (skillLabels [i].Text == string.Empty)
                {
                    messageBox = new DaggerfallMessageBox(uiManager, this);
                    messageBox.SetTextTokens(strSetSkills);
                    messageBox.ClickAnywhereToClose = true;
                    messageBox.Show();
                    return;
                }
            }

            // Are all attribute points distributed?
            if (statsRollout.BonusPool > 0)
            {
                messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(strDistributeStats);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
                return;
            }

            // Set advantages/disadvantages
            createCharSpecialAdvantageWindow.ParseCareerData();
            createCharSpecialDisadvantageWindow.ParseCareerData();

            CloseWindow();
        }
        // Show a basic popup message, no Quest data involved
        void ShowQuestPopupMessage(int id, bool exitOnClose = true)
        {
            // Setup popup message
            TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(id);
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.SetTextTokens(tokens);
            messageBox.ClickAnywhereToClose        = true;
            messageBox.AllowCancel                 = true;
            messageBox.ParentPanel.BackgroundColor = Color.clear;

            // Exit on close if requested
            if (exitOnClose)
            {
                messageBox.OnClose += QuestPopupMessage_OnClose;
            }

            // Present popup message
            messageBox.Show();
        }
        protected virtual void ShowAffiliationsDialog()
        {
            List <TextFile.Token> tokens           = new List <TextFile.Token>();
            List <IGuild>         guildMemberships = GameManager.Instance.GuildManager.GetMemberships();

            if (guildMemberships.Count == 0)
            {
                DaggerfallUI.MessageBox(noAffiliationsMsgId);
            }
            else
            {
                TextFile.Token tab = TextFile.TabToken;
                tab.x = 125;
                tokens.Add(new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("affiliation"),
                    formatting = TextFile.Formatting.TextHighlight
                });
                tokens.Add(tab);
                tokens.Add(new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("rank"),
                    formatting = TextFile.Formatting.TextHighlight
                });
                tokens.Add(TextFile.NewLineToken);

                foreach (IGuild guild in guildMemberships)
                {
                    tokens.Add(TextFile.CreateTextToken(guild.GetAffiliation()));
                    tokens.Add(tab);
                    tokens.Add(TextFile.CreateTextToken(guild.GetTitle() //)); DEBUG rep:
                                                        + " (rep:" + guild.GetReputation(playerEntity).ToString() + ")"));
                    tokens.Add(TextFile.NewLineToken);
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(tokens.ToArray(), null, false);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
        }
Exemple #10
0
        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();
        }
Exemple #11
0
        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();
        }
        protected override void GetQuest()
        {
            // Just exit if this NPC already involved in an active quest
            // If quest conditions are complete the quest system should pickup ending
            if (QuestMachine.Instance.IsLastNPCClickedAnActiveQuestor())
            {
                CloseWindow();
                return;
            }

            // Get the faction id for affecting reputation on success/failure, and current rep
            int     factionId  = questorNPC.factionID;
            Genders gender     = questorNPC.gender;
            int     reputation = GameManager.Instance.PlayerEntity.FactionData.GetReputation(factionId);
            int     level      = GameManager.Instance.PlayerEntity.Level;

            // Select a quest at random from appropriate pool
            offeredQuest = GameManager.Instance.QuestListsManager.GetSocialQuest(socialGroup, factionId, gender, reputation, level);
            if (offeredQuest != null)
            {
                // Log offered quest
                Debug.LogFormat("Offering quest {0} from Social group {1} affecting factionId {2}", offeredQuest.QuestName, socialGroup, offeredQuest.FactionId);

                // Offer the quest to player
                DaggerfallMessageBox messageBox = QuestMachine.Instance.CreateMessagePrompt(offeredQuest, (int)QuestMachine.QuestMessages.QuestorOffer);// TODO - need to provide an mcp for macros?
                if (messageBox != null)
                {
                    messageBox.OnButtonClick += OfferQuest_OnButtonClick;
                    messageBox.Show();
                }
            }
            else if (!GameManager.Instance.IsPlayerInsideCastle) // Failed get quest messages do not appear inside castles in classic.
            {
                ShowFailGetQuestMessage();
            }
        }
        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();
            }
        }
        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 void OfferQuest()
        {
            if (offeredQuest != null)
            {
                // Log offered quest
                Debug.LogFormat("Offering quest {0} from Guild {1} affecting factionId {2}", offeredQuest.QuestName, guildGroup, offeredQuest.FactionId);

                // Offer the quest to player, setting external context provider to guild if a member
                if (guild.IsMember())
                {
                    offeredQuest.ExternalMCP = guild;
                }
                DaggerfallMessageBox messageBox = QuestMachine.Instance.CreateMessagePrompt(offeredQuest, (int)QuestMachine.QuestMessages.QuestorOffer);
                if (messageBox != null)
                {
                    messageBox.OnButtonClick += OfferQuest_OnButtonClick;
                    messageBox.Show();
                }
            }
            else
            {
                ShowFailGetQuestMessage();
            }
        }
        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();
        }
 private void StatButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
     messageBox.SetTextTokens((int)sender.Tag);
     messageBox.ClickAnywhereToClose = true;
     messageBox.Show();
 }
 /// <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();
 }
 private void ExitButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     DaggerfallMessageBox confirmExitBox = new DaggerfallMessageBox(uiManager, DaggerfallMessageBox.CommonMessageBoxButtons.YesNo, strAreYouSure, this);
     confirmExitBox.OnButtonClick += ConfirmExitBox_OnButtonClick;
     confirmExitBox.Show();
 }
        void OfferCuratedGuildQuest()
        {
            // Load quests table each time so player can edit their local file at runtime
            Table  table     = null;
            string questName = string.Empty;

            try
            {
                if (currentGuild == TempGuilds.Fighter)
                {
                    table = new Table(QuestMachine.Instance.GetTableSourceText(tempFightersQuestsFilename));
                }
                else if (currentGuild == TempGuilds.Mage)
                {
                    table = new Table(QuestMachine.Instance.GetTableSourceText(tempMagesQuestsFilename));
                }
                else
                {
                    throw new Exception("Could not load quests table for this guild.");
                }
            }
            catch (Exception ex)
            {
                DaggerfallUI.Instance.PopupMessage(ex.Message);
                return;
            }

            // Select a quest name at random from table
            try
            {
                if (table == null || table.RowCount == 0)
                {
                    throw new Exception("Quests table is empty.");
                }

                questName = table.GetRow(UnityEngine.Random.Range(0, table.RowCount))[0];
            }
            catch (Exception ex)
            {
                DaggerfallUI.Instance.PopupMessage(ex.Message);
                return;
            }

            // Log offered quest
            Debug.LogFormat("Offering quest {0} from TempGuild {1}", questName, currentGuild.ToString());

            // Parse quest
            try
            {
                offeredQuest = QuestMachine.Instance.ParseQuest(questName, questorNPC);
            }
            catch (Exception ex)
            {
                // Log exception, show random flavour text, and exit
                Debug.LogErrorFormat("Exception during quest compile: {0}", ex.Message);
                ShowFailCompileMessage();
                return;
            }

            // Offer the quest to player
            DaggerfallMessageBox messageBox = QuestMachine.Instance.CreateMessagePrompt(offeredQuest, (int)QuestMachine.QuestMessages.QuestorOffer);

            if (messageBox != null)
            {
                messageBox.OnButtonClick += OfferQuest_OnButtonClick;
                messageBox.Show();
            }
        }
Exemple #22
0
        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;
            }
        }
Exemple #23
0
        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;
            }
        }
 public static DaggerfallMessageBox MessageBox(string[] message)
 {
     DaggerfallMessageBox messageBox = new DaggerfallMessageBox(Instance.uiManager, Instance.uiManager.TopWindow);
     messageBox.SetText(message);
     messageBox.ClickAnywhereToClose = true;
     messageBox.Show();
     return messageBox;
 }
 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 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);
            }
        }
        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();
            }
        }
        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;
            }
        }
        private void BuyButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            const int notEnoughGold = 1702;
            //const int noSpellBook = 1703;
            const int youMustChooseAName    = 1704;
            const int spellHasBeenInscribed = 1705;

            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);

            /*// Presence of spellbook is also checked earlier
             * if (!GameManager.Instance.PlayerEntity.Items.Contains(Items.ItemGroups.MiscItems, (int)Items.MiscItems.Spellbook))
             * {
             *  DaggerfallUI.MessageBox(noSpellBook);
             *  return;
             * }*/

            // Spell must have at least one effect - adding custom message
            List <EffectEntry> effects = GetEffectEntries();

            if (effects.Count == 0)
            {
                DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("noEffectsError"));
                return;
            }

            // Enough money?
            var moneyAvailable = GameManager.Instance.PlayerEntity.GetGoldAmount();

            if (moneyAvailable < totalGoldCost)
            {
                DaggerfallUI.MessageBox(notEnoughGold);
                return;
            }

            // Spell must have a name; Only bother the player if everything else is correct
            if (string.IsNullOrEmpty(spellNameLabel.Text))
            {
                DaggerfallUI.MessageBox(youMustChooseAName);
                return;
            }

            GameManager.Instance.PlayerEntity.DeductGoldAmount(totalGoldCost);

            // Create effect bundle settings
            EffectBundleSettings spell = new EffectBundleSettings();

            spell.Version     = EntityEffectBroker.CurrentSpellVersion;
            spell.BundleType  = BundleTypes.Spell;
            spell.TargetType  = selectedTarget;
            spell.ElementType = selectedElement;
            spell.Name        = spellNameLabel.Text;
            spell.IconIndex   = selectedIcon.index;
            spell.Icon        = selectedIcon;
            spell.Effects     = effects.ToArray();

            // Add to player entity spellbook
            GameManager.Instance.PlayerEntity.AddSpell(spell);

            DaggerfallUI.Instance.PlayOneShot(inscribeGrimoire);

            // Notify player and exit when this messagebox is dismissed
            DaggerfallMessageBox mbComplete = DaggerfallUI.MessageBox(spellHasBeenInscribed);

            mbComplete.ClickAnywhereToClose = true;
            mbComplete.PreviousWindow       = this;
            mbComplete.OnClose += SpellHasBeenInscribed_OnClose;
            mbComplete.Show();
        }
Exemple #30
0
        private void BuyButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            //const int notEnoughGold = 1702;
            //const int noSpellBook = 1703;
            const int youMustChooseAName    = 1704;
            const int spellHasBeenInscribed = 1705;

            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);

            // TODO:
            //   Implement costs and remove gold from player and block if user does not have enough gold (message 1702)
            //   Spells will be free (both gold and spell points) during build-out of effect system.

            // NOTES:
            //  In classic, player must have a spellbook item in their inventory (message 1703).
            //  In Daggerfall Unity, the spellbook is a permanent item that all players own and cannot be removed.
            //  This is to prevent player accidentally dropping or selling their spellbook.
            //  So not performing spellbook check at this time and 1703 is never shown.

            // Spell must have at least one effect - adding custom message
            List <EffectEntry> effects = GetEffectEntries();

            if (effects.Count == 0)
            {
                DaggerfallMessageBox mbNoEffects = DaggerfallUI.MessageBox(TextManager.Instance.GetText("SpellmakerUI", "noEffectsError"));
                mbNoEffects.ClickAnywhereToClose = true;
                mbNoEffects.PreviousWindow       = this;
                mbNoEffects.Show();
                return;
            }

            // Spell must have a name
            if (string.IsNullOrEmpty(spellNameLabel.Text))
            {
                DaggerfallMessageBox mbNoName = DaggerfallUI.MessageBox(youMustChooseAName);
                mbNoName.ClickAnywhereToClose = true;
                mbNoName.PreviousWindow       = this;
                mbNoName.Show();
                return;
            }

            // Create effect bundle settings
            EffectBundleSettings spell = new EffectBundleSettings();

            spell.Version     = EntityEffectBroker.CurrentSpellVersion;
            spell.BundleType  = BundleTypes.Spell;
            spell.TargetType  = selectedTarget;
            spell.ElementType = selectedElement;
            spell.Name        = spellNameLabel.Text;
            spell.IconIndex   = selectedIcon.index;
            spell.Icon        = selectedIcon;
            spell.Effects     = effects.ToArray();

            // Add to player entity spellbook
            GameManager.Instance.PlayerEntity.AddSpell(spell);

            DaggerfallUI.Instance.PlayOneShot(inscribeGrimoire);

            // Notify player and exit when this messagebox is dismissed
            DaggerfallMessageBox mbComplete = DaggerfallUI.MessageBox(spellHasBeenInscribed);

            mbComplete.ClickAnywhereToClose = true;
            mbComplete.PreviousWindow       = this;
            mbComplete.OnClose += SpellHasBeenInscribed_OnClose;
            mbComplete.Show();
        }
        private void GoldButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallMessageBox bankingStatusBox = DaggerfallBankingWindow.CreateBankingStatusBox(this);

            bankingStatusBox.Show();
        }
        private void HealthButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallMessageBox healthBox = DaggerfallUI.Instance.CreateHealthStatusBox(this);

            healthBox.Show();
        }
        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();
                }
            }
        }
 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;
 }