예제 #1
0
        public static void RestOrPackFire(RaycastHit hit)
        {
            DaggerfallMessageBox campPopUp = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            if (Fire != null)
            {
                if (hit.transform.gameObject.GetInstanceID() == Fire.GetInstanceID())
                {
                    string[] message = { "Do you wish to rest?" };
                    campPopUp.SetText(message);
                    campPopUp.OnButtonClick += CampPopUp_OnButtonClick;
                    campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                    campPopUp.Show();
                }
                else
                {
                    ClimateCalories.camping = true;
                    DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenRestWindow);
                }
            }
            else
            {
                ClimateCalories.camping = true;
                DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenRestWindow);
            }
        }
예제 #2
0
        public override void Update(Task caller)
        {
            Message message = ParentQuest.GetMessage(id);

            TextFile.Token[] tokens = message.GetTextTokens();

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

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

            messageBox.AddButton((DaggerfallMessageBox.MessageBoxButtons)opt1button, true);
            messageBox.AddButton((DaggerfallMessageBox.MessageBoxButtons)opt2button);
            if (opt3TaskSymbol != null)
            {
                messageBox.ButtonSpacing = 28;
                messageBox.AddButton((DaggerfallMessageBox.MessageBoxButtons)opt3button);
            }
            if (opt4TaskSymbol != null)
            {
                messageBox.ButtonSpacing = 24;
                messageBox.AddButton((DaggerfallMessageBox.MessageBoxButtons)opt4button);
            }

            messageBox.OnButtonClick += MessageBox_OnButtonClick;
            messageBox.Show();

            SetComplete();
        }
예제 #3
0
        private void AttemptAvoid()
        {
            int playerSkillRunning = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Running);
            int playerSkillStealth = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth);

            int successChance = Mathf.Max(playerSkillRunning, playerSkillStealth);

            successChance = successChance * maxSuccessChance / 100;

            if (avoidEncounters == AvoidEncounterChoice.ALWAYS)
            {
                MakeAvoidAttempt(successChance);
            }
            else
            {
                DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager);
                mb.SetText("You approach a hostile encounter. Attempt to avoid it?");
                mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes, true);
                mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                mb.ParentPanel.BackgroundColor = Color.clear;

                mb.OnButtonClick += (_sender, button) =>
                {
                    _sender.CloseWindow();
                    if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
                    {
                        MakeAvoidAttempt(successChance);
                    }
                };
                mb.Show();
            }
        }
예제 #4
0
        private void AttemptAvoid()
        {
            int playerSkillRunning = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Running);
            int playerSkillStealth = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Stealth);

            int successChance = Mathf.Max(playerSkillRunning, playerSkillStealth);

            successChance = successChance * maxSuccessChance / 100;

            DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager);

            mb.SetText("You approach a hostile encounter. Attempt to avoid it?");
            mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes, true);
            mb.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
            mb.ParentPanel.BackgroundColor = Color.clear;

            mb.OnButtonClick += (_sender, button) =>
            {
                _sender.CloseWindow();
                if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
                {
                    if (Dice100.SuccessRoll(successChance))
                    {
                        delayCombat     = true;
                        delayCombatTime = DaggerfallUnity.Instance.WorldTime.Now.ToClassicDaggerfallTime() + 10;
                        StartFastTravel(destinationSummary);
                    }
                    else
                    {
                        DaggerfallUI.MessageBox("You failed to avoid the encounter!");
                    }
                }
            };
            mb.Show();
        }
예제 #5
0
        /// <summary>
        /// preset confirmation.
        /// </summary>
        /// <param name="index">Preset index.</param>
        /// <param name="preset">Preset name.</param>
        private void HandlePresetPickEvent(int index, string preset)
        {
            // Selected preset
            currentPresetIndex = index;

            // Open confirmation message box
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
            string message = "Import settings from " + preset + " ?";

            try
            {
                string description = presets[currentPresetIndex][ModSettingsReader.internalSection]["Description"];
                if (description != null)
                {
                    messageBox.SetText(new string[] { description, "", message });
                }
                else
                {
                    messageBox.SetText(message);
                }
            }
            catch
            {
                messageBox.SetText(message);
            }
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Cancel);
            messageBox.OnButtonClick += ConfirmPreset_OnButtonClick;
            uiManager.PushWindow(messageBox);
        }
예제 #6
0
    private void CleanConfigurationDirectory()
    {
        var unknownDirectories = Directory.GetDirectories(ModManager.Instance.ModDataDirectory)
                                 .Select(x => new DirectoryInfo(x))
                                 .Where(x => ModManager.Instance.GetModFromGUID(x.Name) == null)
                                 .ToArray();

        if (unknownDirectories.Length > 0)
        {
            var cleanConfigMessageBox = new DaggerfallMessageBox(uiManager, this);
            cleanConfigMessageBox.ParentPanel.BackgroundTexture = null;
            cleanConfigMessageBox.SetText(ModManager.GetText("cleanConfigurationDir"));
            cleanConfigMessageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            cleanConfigMessageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            cleanConfigMessageBox.OnButtonClick += (messageBox, messageBoxButton) =>
            {
                if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
                {
                    foreach (var directory in unknownDirectories)
                    {
                        directory.Delete(true);
                    }
                }

                messageBox.CancelWindow();
                moveNextStage = true;
            };
            uiManager.PushWindow(cleanConfigMessageBox);
        }
        else
        {
            moveNextStage = true;
        }
    }
예제 #7
0
 private void CheckDependencies()
 {
     foreach (Mod mod in ModManager.Instance.Mods.Where(x => x.Enabled))
     {
         string errorMessage = ModManager.Instance.CheckModDependencies(mod);
         if (errorMessage != null)
         {
             string message    = string.Format(ModManager.GetText("dependencyErrorMessage"), mod.Title, errorMessage);
             var    messageBox = new DaggerfallMessageBox(uiManager, this, true);
             messageBox.ClickAnywhereToClose = true;
             messageBox.SetText(message);
             messageBox.SetText(new[] { message, ModManager.GetText("sortModsQuestion") });
             messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
             messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
             messageBox.OnButtonClick += (_, button) =>
             {
                 if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
                 {
                     ModManager.Instance.AutoSortMods();
                     ModManager.WriteModSettings();
                     Debug.Log("Mods have been sorted automatically");
                 }
             };
             uiManager.PushWindow(messageBox);
             Debug.LogError(message);
         }
     }
 }
예제 #8
0
        private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
        {
            const int doYouSurrenderToGuardsTextID = 15;

            EnemyEntity  entity       = entityBehaviour.Entity as EnemyEntity;
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            // Calculate damage
            damage = FormulaHelper.CalculateAttackDamage(entity, playerEntity, weapon, -1);

            // Break any "normal power" concealment effects on enemy
            if (entity.IsMagicallyConcealedNormalPower && damage > 0)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(entityBehaviour);
            }

            // Tally player's dodging skill
            playerEntity.TallySkill(DFCareer.Skills.Dodging, 1);

            if (damage > 0)
            {
                if (entity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch)
                {
                    // If hit by a guard, lower reputation and show the surrender dialogue
                    if (!playerEntity.HaveShownSurrenderToGuardsDialogue && playerEntity.CrimeCommitted != PlayerEntity.Crimes.None)
                    {
                        playerEntity.LowerRepForCrime();

                        DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                        messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(doYouSurrenderToGuardsTextID));
                        messageBox.ParentPanel.BackgroundColor = Color.clear;
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                        messageBox.OnButtonClick += SurrenderToGuardsDialogue_OnButtonClick;
                        messageBox.Show();

                        playerEntity.HaveShownSurrenderToGuardsDialogue = true;
                    }
                    // Surrender dialogue has been shown and player refused to surrender
                    // Guard damages player if player can survive hit, or if hit is fatal but guard rejects player's forced surrender
                    else if (playerEntity.CurrentHealth > damage || !playerEntity.SurrenderToCityGuards(false))
                    {
                        SendDamageToPlayer();
                    }
                }
                else
                {
                    SendDamageToPlayer();
                }
            }
            else
            {
                sounds.PlayMissSound(weapon);
            }

            return(damage);
        }
 /// <summary>
 /// Ask confirmation for setting default values.
 /// </summary>
 private void ResetButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
 {
     // Open confirmation message box
     DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
     messageBox.SetText(ModManager.GetText("resetConfirmation"));
     messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
     messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Cancel);
     messageBox.OnButtonClick += ConfirmReset_OnButtonClick;
     uiManager.PushWindow(messageBox);
 }
예제 #10
0
        private static void NewWagonPopUp()
        {
            DaggerfallMessageBox newWagonPopup = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            string[] message = { "Do you wish to abandon your old wagon and start using your new wagon?" };
            newWagonPopup.SetText(message);
            newWagonPopup.OnButtonClick += NewWagonPopup_OnButtonClick;
            newWagonPopup.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            newWagonPopup.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            newWagonPopup.Show();
        }
예제 #11
0
        public static void PackOrLeaveCamp()
        {
            DaggerfallMessageBox packPopUp = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            string[] message = { "Do you wish to pack up your camp?" };
            packPopUp.SetText(message);
            packPopUp.OnButtonClick += PackPopUp_OnButtonClick;
            packPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            packPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            packPopUp.Show();
        }
예제 #12
0
        private static void ArrestPrompt()
        {
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(15));
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            messageBox.OnButtonClick += SurrenderToGuardsDialogue_OnButtonClick;
            messageBox.Show();
        }
예제 #13
0
        protected override void InputMessageBox_OnGotUserInput(DaggerfallInputMessageBox sender, string input)
        {
            daysToRent = 0;
            bool result = int.TryParse(input, out daysToRent);

            if (!result || daysToRent < 1)
            {
                return;
            }

            int daysAlreadyRented = 0;

            if (rentedRoom != null)
            {
                daysAlreadyRented = (int)((rentedRoom.expiryTime - DaggerfallUnity.Instance.WorldTime.Now.ToSeconds()) / DaggerfallDateTime.SecondsPerDay);
                if (daysAlreadyRented < 0)
                {
                    daysAlreadyRented = 0;
                }
            }

            if (daysToRent + daysAlreadyRented > 350)
            {
                DaggerfallUI.MessageBox(tooManyDaysFutureId);
            }
            else if (GameManager.Instance.GuildManager.GetGuild(FactionFile.GuildGroups.KnightlyOrder).FreeTavernRooms())
            {
                DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("roomFreeForKnightSuchAsYou"));
                RentRoom();
            }
            else
            {
                int quality = Mathf.Max((buildingData.quality / 2) - 3, 3);
                int cost    = FormulaHelper.CalculateRoomCost(daysToRent) * quality;

                tradePrice = FormulaHelper.CalculateTradePrice(cost, buildingData.quality, false);

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(offerPriceId);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmRenting_OnButtonClick;
                uiManager.PushWindow(messageBox);
            }
        }
예제 #14
0
        private static void BribePrompt()
        {
            string[] message =
            {
                "Halt! You are under arrest for " + playerEntity.CrimeCommitted.ToString() + ".",
                " ",
                "Do you attempt to bribe the guard?"
            };
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.SetText(message);
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
            messageBox.OnButtonClick += Bribe_OnButtonClick;
            messageBox.Show();
        }
예제 #15
0
        public static void RestOrPackTent(RaycastHit hit)
        {
            DaggerfallMessageBox campPopUp = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            if (hit.transform.gameObject.GetInstanceID() == Tent.GetInstanceID())
            {
                string[] message = { "Do you wish to rest?" };
                campPopUp.SetText(message);
                campPopUp.OnButtonClick += CampPopUp_OnButtonClick;
                campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                campPopUp.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                campPopUp.Show();
            }
            else
            {
                DaggerfallUI.MessageBox("This is not your camp.");
            }
        }
예제 #16
0
        protected override void ExitButtonClickHandler(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);

            if (RegionSelected)
            {
                CloseRegionPanel();
            }
            else if (changed)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetText("Do you want to save changes?");
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += SaveBoxClick;
                uiManager.PushWindow(messageBox);
            }
            else
            {
                CloseTravelWindows();
            }
        }
예제 #17
0
        private void ExportButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            Preset preset   = settings.Presets[listBox.SelectedIndex];
            string fileName = string.Join("_", preset.Title.Split(Path.GetInvalidFileNameChars())) + ".json";

            string dirPath  = ModManager.CombinePaths(Application.persistentDataPath, "Mods", "ExportedPresets", mod.FileName);
            string filePath = Path.Combine(dirPath, fileName);

            var messageBox = new DaggerfallMessageBox(uiManager, this, true);

            messageBox.AllowCancel = true;
            messageBox.SetText(string.Format(ModManager.GetText("exportMessage"), preset.Title, filePath));
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.OK, true);
            messageBox.OnButtonClick += (source, messageBoxButton) =>
            {
                Directory.CreateDirectory(dirPath);
                File.WriteAllText(filePath, SaveLoadManager.Serialize(typeof(Preset), preset, true));
                source.PopWindow();
            };
            uiManager.PushWindow(messageBox);
        }
        //generates pop-ups, either to indicate failed transaction
        //or to prompt with yes / no option
        void GeneratePopup(TransactionResult result, int amount = 0)
        {
            if (result == TransactionResult.NONE)
            {
                return;
            }

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);

            messageBox.ClickAnywhereToClose = true;
            this.amount = amount;

            if (result == TransactionResult.TOO_HEAVY)
            {
                messageBox.SetText(TextManager.Instance.GetLocalizedText("cannotCarryGold"));
            }
            else
            {
                messageBox.SetTextTokens((int)result, this);
            }

            if (result == TransactionResult.DEPOSIT_LOC) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += DepositLOC_messageBox_OnButtonClick;
            }

            else if (result == TransactionResult.SELL_HOUSE_OFFER) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellHouse_messageBox_OnButtonClick;
            }
            else if (result == TransactionResult.SELL_SHIP_OFFER)
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellShip_messageBox_OnButtonClick;
            }

            messageBox.Show();
        }
예제 #19
0
        //generates pop-ups, either to indicate failed transaction
        //or to prompt with yes / no option
        void GeneratePopup(TransactionResult result, long amount = 0)
        {
            if (result == TransactionResult.NONE)
            {
                return;
            }

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);

            messageBox.ClickAnywhereToClose = true;
            messageBox.SetTextTokens((int)result);

            if (result == TransactionResult.DEPOSIT_LOC) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += DepositLOC_messageBox_OnButtonClick;
            }

            else if (result == TransactionResult.SELL_HOUSE_OFFER) //show messagebox window w/ yes no buttons
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellHouse_messageBox_OnButtonClick;
            }
            else if (result == TransactionResult.SELL_SHIP_OFFER)
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.ClickAnywhereToClose = false;
                messageBox.OnButtonClick       += SellShip_messageBox_OnButtonClick;
            }

            messageBox.Show();
        }
예제 #20
0
    private void CheckDependencies()
    {
        bool          hasSortIssues    = false;
        List <string> errorMessages    = null;
        var           modErrorMessages = new List <string>();

        foreach (Mod mod in ModManager.Instance.Mods.Where(x => x.Enabled))
        {
            bool?isGameVersionSatisfied = mod.IsGameVersionSatisfied();
            if (!isGameVersionSatisfied.HasValue)
            {
                Debug.LogErrorFormat("Mod {0} requires unknown game version ({1}).", mod.Title, mod.ModInfo.DFUnity_Version);
            }
            else if (!isGameVersionSatisfied.Value)
            {
                modErrorMessages.Add(string.Format(ModManager.GetText("gameVersionUnsatisfied"), mod.ModInfo.DFUnity_Version));
            }

            ModManager.Instance.CheckModDependencies(mod, modErrorMessages, ref hasSortIssues);
            if (modErrorMessages.Count > 0)
            {
                if (errorMessages == null)
                {
                    errorMessages = new List <string>();
                    errorMessages.Add(ModManager.GetText("dependencyErrorMessage"));
                    errorMessages.Add(string.Empty);
                }

                errorMessages.Add(string.Format("- {0}", mod.Title));
                errorMessages.AddRange(modErrorMessages);
                errorMessages.Add(string.Empty);
                modErrorMessages.Clear();
            }
        }

        if (errorMessages != null && errorMessages.Count > 0)
        {
            if (hasSortIssues)
            {
                errorMessages.Add(ModManager.GetText("sortModsQuestion"));
            }

            var messageBox = new DaggerfallMessageBox(uiManager, this);
            messageBox.EnableVerticalScrolling(80);
            messageBox.SetText(errorMessages.ToArray());
            if (hasSortIssues)
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                messageBox.OnButtonClick += (sender, button) =>
                {
                    if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
                    {
                        ModManager.Instance.AutoSortMods();
                        Debug.Log("Mods have been sorted automatically");
                    }

                    sender.CancelWindow();
                    moveNextStage = true;
                };
            }
            else
            {
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.OK, true);
                messageBox.OnButtonClick += (sender, button) =>
                {
                    sender.CancelWindow();
                    moveNextStage = true;
                };
            }
            messageBox.Show();
        }
        else
        {
            moveNextStage = true;
        }
    }
예제 #21
0
        protected void TrainingSkillPicker_OnItemPicked(int index, string skillName)
        {
            Mod  rrMod       = ModManager.Instance.GetMod("RoleplayRealism");
            bool skillPrices = rrMod.GetSettings().GetBool("RefinedTraining", "variableTrainingPrice");
            bool intensive   = rrMod.GetSettings().GetBool("RefinedTraining", "intensiveTraining");

            CloseWindow();
            List <DFCareer.Skills> trainingSkills = GetTrainingSkills();

            skillToTrain = trainingSkills[index];
            int trainingMax = Guild.GetTrainingMax(skillToTrain);
            int skillValue  = playerEntity.Skills.GetPermanentSkillValue(skillToTrain);

            if (skillValue > trainingMax)
            {
                // 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
            {
                // Calculate training price, modifying based on current skill value as well as player level if enabled
                trainingCost = Guild.GetTrainingPrice();
                if (skillPrices)
                {
                    float skillOfMax = 1 - ((float)skillValue / trainingMax);
                    trainingCost -= (int)(trainingCost * skillOfMax / 2);
                }

                // Offer training and cost to player
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId);
                int pos = tokens[0].text.IndexOf(" ");
                tokens[0].text = tokens[0].text.Substring(0, pos) + " " + skillToTrain + tokens[0].text.Substring(pos);

                intensiveCost = (trainingCost + (playerEntity.Level * 8) + 72) * 5;
                TextFile.Token[] trainingTokens =
                {
                    TextFile.CreateTextToken("Training your " + skillToTrain + " skill will cost %a gold for a single session."),      newLine, newLine,
                    TextFile.CreateTextToken("You can also pay extra to train intensively for five days if you wish,"),                newLine,
                    TextFile.CreateTextToken("with a training session each day, this will cost " + intensiveCost + " gold in total."), newLine, newLine,
                    TextFile.CreateTextToken("So, would you like to train your " + skillToTrain + " skill with me?"),                  newLine,
                };

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                if (intensive && skillValue < trainingMax - 4)
                {
                    messageBox.SetTextTokens(trainingTokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    messageBox.AddButton(weekButton);
                }
                else
                {
                    messageBox.SetTextTokens(tokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                }
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrainingPayment_OnButtonClick;
                messageBox.Show();
            }
        }
예제 #22
0
        private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
        {
            const int doYouSurrenderToGuardsTextID = 15;

            EnemyEntity  entity       = entityBehaviour.Entity as EnemyEntity;
            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

            int enemyDamType = EnemyDamageTypeUsed(entity, weapon); // Returns an integer value that corresponds to a specific damage type that this type of enemy can use, will use later on in combat formula.

            // Calculate damage
            damage = FormulaHelper.CalculateAttackDamage(entity, playerEntity, -1, 0, weapon, out bool shieldBlockSuccess, out int mainDamType, out bool critStrikeSuccess, out bool armorPartAbsorbed, out bool armorCompleteAbsorbed, out Items.DaggerfallUnityItem addedAIWeapon, out bool hitSuccess, out bool metalShield, out bool metalArmor, enemyDamType);

            // Break any "normal power" concealment effects on enemy
            if (entity.IsMagicallyConcealedNormalPower && damage > 0)
            {
                EntityEffectManager.BreakNormalPowerConcealmentEffects(entityBehaviour);
            }

            // Tally player's dodging skill
            playerEntity.TallySkill(DFCareer.Skills.Dodging, 1);

            // Handle Strikes payload from enemy to player target - this could change damage amount
            if (damage > 0 && weapon != null && weapon.IsEnchanted)
            {
                EntityEffectManager effectManager = GetComponent <EntityEffectManager>();
                if (effectManager)
                {
                    damage = effectManager.DoItemEnchantmentPayloads(EnchantmentPayloadFlags.Strikes, weapon, entity.Items, playerEntity.EntityBehaviour, damage);
                }
            }

            // If the AI was given a weapon through the damage formula, this gives them that weapon for this part of the calling method for later use.
            if (weapon == null)
            {
                weapon = addedAIWeapon;
            }

            // Play associated sound when armor/shield was responsible for absorbing damage completely.
            if (damage <= 0)
            {
                if (hitSuccess && shieldBlockSuccess)
                {
                    sounds.PlayShieldBlockSound(weapon, metalShield);
                }
                else if (hitSuccess && armorCompleteAbsorbed)
                {
                    sounds.PlayArmorAbsorbSound(weapon, metalArmor);
                }
                else
                {
                    sounds.PlayMissSound(weapon);
                }
            }

            if (damage > 0)
            {
                if (entity.MobileEnemy.ID == (int)MobileTypes.Knight_CityWatch)
                {
                    // If hit by a guard, lower reputation and show the surrender dialogue
                    if (!playerEntity.HaveShownSurrenderToGuardsDialogue && playerEntity.CrimeCommitted != PlayerEntity.Crimes.None)
                    {
                        playerEntity.LowerRepForCrime();

                        DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                        messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(doYouSurrenderToGuardsTextID));
                        messageBox.ParentPanel.BackgroundColor = Color.clear;
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                        messageBox.OnButtonClick += SurrenderToGuardsDialogue_OnButtonClick;
                        messageBox.Show();

                        playerEntity.HaveShownSurrenderToGuardsDialogue = true;
                    }
                    // Surrender dialogue has been shown and player refused to surrender
                    // Guard damages player if player can survive hit, or if hit is fatal but guard rejects player's forced surrender
                    else if (playerEntity.CurrentHealth > damage || !playerEntity.SurrenderToCityGuards(false))
                    {
                        if (shieldBlockSuccess && armorPartAbsorbed)
                        {
                            sounds.PlayShieldBlockSound(weapon, metalShield);
                        }
                        SendDamageToPlayer();
                    }
                }
                else
                {
                    if (shieldBlockSuccess && armorPartAbsorbed)
                    {
                        sounds.PlayShieldBlockSound(weapon, metalShield);
                    }
                    SendDamageToPlayer();
                }
            }

            return(damage);
        }
        public static void RepairMarkService(IUserInterfaceWindow window)
        {
            Debug.Log("Repair Recall Mark service.");

            DaggerfallUnityItem markOfRecall = FindRecallMark();

            if (markOfRecall == null)
            {
                if (GameManager.Instance.PlayerEntity.GetGoldAmount() < replaceMarkCost)
                {
                    DaggerfallUI.MessageBox(new string[] {
                        "You don't appear to have your Mark of Recall on you, or enough",
                        "for a replacement. If you have been careless and lost or broken",
                        "it, I can replace it for a price of 10,000 gold pieces. They're",
                        "expensive, and the guild only provides one free Mark per member."
                    });
                }
                else
                {
                    DaggerfallMessageBox replaceMarkBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, window, true);
                    string[]             message        =
                    {
                        "   You don't appear to have your Mark of Recall on you.",
                        "   If you have been careless and lost or broken it, then",
                        "      I can replace it at a cost of 10,000 gold.",
                        "",
                        "      Would you like a replacement Mark of Recall?"
                    };
                    replaceMarkBox.SetText(message);
                    replaceMarkBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    replaceMarkBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                    replaceMarkBox.OnButtonClick += ReplaceMarkBox_OnButtonClick;
                    replaceMarkBox.Show();
                }
            }
            else
            {
                int cost = CalculateRepairCost(markOfRecall);
                if (GameManager.Instance.PlayerEntity.GetGoldAmount() < cost)
                {
                    DaggerfallUI.MessageBox(notEnoughGoldId);
                }
                else if (cost == 0)
                {
                    if (HasLocationsBook())
                    {
                        DaggerfallUI.MessageBox("Your Mark of Recall shows no signs of wear that I can see.");
                    }
                    else
                    {
                        DaggerfallMessageBox replaceBookBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, window, true);
                        string[]             message        =
                        {
                            "Your Mark of Recall shows no signs of wear that I can see.",
                            "",
                            "  However, you do appear to have misplaced your guild hall",
                            "      locations book. Would you like a replacement?"
                        };
                        replaceBookBox.SetText(message);
                        replaceBookBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                        replaceBookBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No, true);
                        replaceBookBox.OnButtonClick += ReplaceBookBox_OnButtonClick;
                        replaceBookBox.Show();
                    }
                }
                else
                {
                    string message = "Repairing your Mark of Recall will cost " + cost + " gp, okay?";
                    DaggerfallMessageBox confirmRepairBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallMessageBox.CommonMessageBoxButtons.YesNo, message, window);
                    confirmRepairBox.OnButtonClick += ConfirmRepairBox_OnButtonClick;
                    confirmRepairBox.Show();
                }
            }
        }