Ejemplo n.º 1
0
        private static void ShowMessageBox(string message, bool clickAnywhereToClose = true, string[] buttons = null)
        {
            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);

            messageBox.ClickAnywhereToClose        = clickAnywhereToClose;
            messageBox.ParentPanel.BackgroundColor = Color.clear;
            messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);

            messageBox.SetText(message);

            if (buttons != null)
            {
                for (int i = 0; i < buttons.Length; i++)
                {
                    messageBox.AddCustomButton(99 + i, buttons[i], false);
                }
                messageBox.OnCustomButtonClick += Tent_messageBox_OnButtonClick;
            }

            messageBox.Show();
        }
Ejemplo n.º 2
0
        public void ShowHolidayText()
        {
            const int holidaysStartID = 8349;

            uint minutes   = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            int  holidayId = Formulas.FormulaHelper.GetHolidayId(minutes, holidayTextLocation.RegionIndex);

            if (holidayId != 0)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(holidaysStartID + holidayId);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                messageBox.ScreenDimColor = new Color32(0, 0, 0, 0);
                messageBox.Show();
            }

            // Set holiday text timer to a somewhat large value so it doesn't show again and again if the player is repeatedly crossing the
            // border of a city.
            holidayTextTimer = 10f;
        }
Ejemplo n.º 3
0
        private void EffectActionPrompt_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Anchor)
            {
                SetAnchor();
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Teleport)
            {
                if (GameManager.Instance.PlayerEntity.AnchorPosition == null)
                {
                    DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);
                    mb.SetTextTokens(achorMustBeSet);
                    mb.ClickAnywhereToClose = true;
                    mb.Show();
                    return;
                }
                TeleportPlayer();
            }
        }
Ejemplo n.º 4
0
 private void AvoidEncounter_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons button)
 {
     sender.CloseWindow();
     if (button == DaggerfallMessageBox.MessageBoxButtons.Yes)
     {
         if (AttemptAvoid())
         {
             delayCombat = delayCombatTime;
             StartFastTravel(destinationSummary);
         }
         else
         {
             travelUi.CloseWindow();
             DaggerfallUI.MessageBox("You fail to avoid the encounter!");
         }
     }
     else
     {
         travelUi.CloseWindow();
     }
 }
Ejemplo n.º 5
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);
        }
 // Creates the custom text-box after repairing an item.
 public void ShowCustomTextBox(bool toolBroke, DaggerfallUnityItem itemToRepair, bool cantRepair)
 {
     if (cantRepair)
     {
         TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.CreateTokens(
             TextFile.Formatting.JustifyCenter,
             "This " + itemToRepair.LongName + " is damaged beyond your abilities.",
             "You would be best to seek the skills of a professional at this point.");
         DaggerfallMessageBox itemTooDamagedText = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);
         itemTooDamagedText.SetTextTokens(tokens);
         itemTooDamagedText.ClickAnywhereToClose = true;
         uiManager.PushWindow(itemTooDamagedText);
     }
     else
     {
         TextFile.Token[]     tokens           = RTTextTokenHolder.ItemRepairTextTokens(GetItemID(), toolBroke, itemToRepair);
         DaggerfallMessageBox itemRepairedText = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);
         itemRepairedText.SetTextTokens(tokens);
         itemRepairedText.ClickAnywhereToClose = true;
         uiManager.PushWindow(itemRepairedText);
     }
 }
Ejemplo n.º 7
0
        public void ReceiveArmor(PlayerEntity playerEntity)
        {
            int armorMask = ArmorFlagStart << rank;

            if ((flags & armorMask) > 0)
            {
                DaggerfallUI.MessageBox(NoArmorId);
            }
            else
            {   // Give a random armor piece, allowing player to choose one out of 3-6
                ItemCollection     rewardArmor = new ItemCollection();
                ArmorMaterialTypes material    = ArmorMaterialTypes.Iron + rank;
                for (int i = UnityEngine.Random.Range(3, 7); i >= 0; i--)
                {
                    Armor armor = (Armor)UnityEngine.Random.Range(102, 108 + 1);
                    rewardArmor.AddItem(ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, armor, material));
                }
                DaggerfallMessageBox mb = DaggerfallUI.MessageBox(ArmorId);
                DaggerfallUI.Instance.InventoryWindow.SetChooseOne(rewardArmor, item => flags = flags | armorMask);
                mb.OnClose += ReceiveArmorPopup_OnClose;
            }
        }
Ejemplo n.º 8
0
 private static void CampPopUp_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
 {
     if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
     {
         sender.CloseWindow();
         if (GameManager.Instance.AreEnemiesNearby())
         {
             DaggerfallUI.MessageBox("There are enemies nearby.");
         }
         else
         {
             IUserInterfaceManager uiManager = DaggerfallUI.UIManager;
             ClimateCalories.camping = true;
             uiManager.PushWindow(new DaggerfallRestWindow(uiManager, true));
         }
     }
     else
     {
         sender.CloseWindow();
         PackOrLeaveCamp();
     }
 }
Ejemplo n.º 9
0
    void ShowModDescriptionPopUp_OnMouseClick(BaseScreenComponent sender, Vector2 position)
    {
        if (modSettings == null || modSettings.Length < 1)
        {
            return;
        }
        else if (string.IsNullOrWhiteSpace(modSettings[currentSelection].modInfo.ModDescription))
        {
            return;
        }

        ModDescriptionMessageBox                               = new DaggerfallMessageBox(uiManager, this, true);
        ModDescriptionMessageBox.AllowCancel                   = true;
        ModDescriptionMessageBox.ClickAnywhereToClose          = true;
        ModDescriptionMessageBox.ParentPanel.BackgroundTexture = null;

        Mod mod = ModManager.Instance.GetMod(modSettings[currentSelection].modInfo.ModTitle);

        string[] modDescription = (mod.TryLocalize("Mod", "Description") ?? mod.ModInfo.ModDescription).Split('\n');
        ModDescriptionMessageBox.SetText(modDescription);
        uiManager.PushWindow(ModDescriptionMessageBox);
    }
Ejemplo n.º 10
0
        void PromptPlayer()
        {
            // Get peered entity gameobject
            DaggerfallEntityBehaviour entityBehaviour = GetPeeredEntityBehaviour(manager);

            if (!entityBehaviour)
            {
                return;
            }

            // Target must be player - no effect on other entities
            if (entityBehaviour != GameManager.Instance.PlayerEntityBehaviour)
            {
                return;
            }

            // Prompt for outcome
            DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallMessageBox.CommonMessageBoxButtons.AnchorTeleport, teleportOrSetAnchor, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);

            mb.OnButtonClick += EffectActionPrompt_OnButtonClick;
            mb.Show();
        }
Ejemplo n.º 11
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();
            }
        }
Ejemplo n.º 12
0
        private void EffectActionPrompt_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Anchor)
            {
                SetAnchor();
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Teleport)
            {
                if (!anchorSet)
                {
                    DaggerfallMessageBox mb = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, DaggerfallUI.Instance.UserInterfaceManager.TopWindow);
                    mb.SetTextTokens(achorMustBeSet);
                    mb.ClickAnywhereToClose = true;
                    mb.Show();
                    forcedRoundsRemaining = 0;
                    ResignAsIncumbent();
                    return;
                }
                TeleportPlayer();
            }
        }
Ejemplo n.º 13
0
        private void MessageBox_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            // Start selected task
            if (messageBoxButton == (DaggerfallMessageBox.MessageBoxButtons)opt1button)
            {
                ParentQuest.StartTask(opt1TaskSymbol);
            }
            else if (messageBoxButton == (DaggerfallMessageBox.MessageBoxButtons)opt2button)
            {
                ParentQuest.StartTask(opt2TaskSymbol);
            }
            else if (messageBoxButton == (DaggerfallMessageBox.MessageBoxButtons)opt3button)
            {
                ParentQuest.StartTask(opt3TaskSymbol);
            }
            else if (messageBoxButton == (DaggerfallMessageBox.MessageBoxButtons)opt4button)
            {
                ParentQuest.StartTask(opt4TaskSymbol);
            }

            // Close prompt
            sender.CloseWindow();
        }
Ejemplo n.º 14
0
 private static void NewWagonPopup_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
 {
     if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
     {
         sender.CloseWindow();
         DestroyWagon();
         WagonDeployed = false;
         GameManager.Instance.PlayerEntity.WagonItems.Clear();
     }
     else
     {
         sender.CloseWindow();
         ItemCollection playerItems = GameManager.Instance.PlayerEntity.Items;
         for (int i = 0; i < playerItems.Count; i++)
         {
             DaggerfallUnityItem item = playerItems.GetItem(i);
             if (item != null && item.IsOfTemplate(ItemGroups.Transportation, (int)Transportation.Small_cart))
             {
                 playerItems.RemoveItem(item);
             }
         }
     }
 }
Ejemplo n.º 15
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();
        }
Ejemplo n.º 16
0
 protected void ConfirmTrainingPayment_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
 {
     CloseWindow();
     if (skillToTrain != DFCareer.Skills.None)
     {
         if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
         {
             if (playerEntity.GetGoldAmount() >= trainingCost)
             {
                 // Take payment
                 playerEntity.DeductGoldAmount(trainingCost);
                 // Train the skill
                 TrainSkill(skillToTrain);
             }
             else
             {
                 DaggerfallUI.MessageBox(DaggerfallTradeWindow.NotEnoughGoldId);
             }
         }
         else if (messageBoxButton == weekButton)
         {
             UnityEngine.Debug.Log("Train for a week!");
             if (playerEntity.GetGoldAmount() >= intensiveCost)
             {
                 // Take payment
                 playerEntity.DeductGoldAmount(intensiveCost);
                 // Train the skill
                 TrainSkillIntense(skillToTrain);
             }
             else
             {
                 DaggerfallUI.MessageBox(DaggerfallTradeWindow.NotEnoughGoldId);
             }
         }
     }
 }
Ejemplo n.º 17
0
        private static void MountWagon(RaycastHit hit)
        {
            DaggerfallMessageBox wagonPopUp = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallUI.UIManager.TopWindow);

            if (hit.transform.gameObject.GetInstanceID() == Wagon.GetInstanceID())
            {
                if (GameManager.Instance.PlayerActivate.CurrentMode == PlayerActivateModes.Info)
                {
                    DaggerfallUI.AddHUDText("You see your wagon");
                }
                else if (!transportManager.HasHorse())
                {
                    //DaggerfallUI.MessageBox("You have no horse to pull your wagon.");
                    DaggerfallUI.Instance.InventoryWindow.AllowDungeonWagonAccess();
                    DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenInventoryWindow);
                }
                else if (!GameManager.Instance.PlayerController.isGrounded)
                {
                    DaggerfallUI.MessageBox("You are unable to levitate your wagon.");
                }
                else
                {
                    DaggerfallUnityItem WagonItem = ItemBuilder.CreateItem(ItemGroups.Transportation, (int)Transportation.Small_cart);
                    DestroyWagon();
                    GameManager.Instance.PlayerEntity.Items.AddItem(WagonItem);
                    WagonDeployed = false;
                    WagonMatrix   = new Matrix4x4();
                    transportManager.TransportMode = TransportModes.Cart;
                    DaggerfallUI.MessageBox("You hitch your wagon.");
                }
            }
            else
            {
                DaggerfallUI.MessageBox("This is not your wagon.");
            }
        }
    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 !UNITY_EDITOR
        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
#endif
        {
            moveNextStage = true;
        }
    }
Ejemplo n.º 19
0
        void Update()
        {
            if (mainCamera == null)
            {
                return;
            }

            // Change activate mode
            if (InputManager.Instance.ActionStarted(InputManager.Actions.StealMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Steal);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.GrabMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Grab);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.InfoMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Info);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.TalkMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Talk);
            }

            // Fire ray into scene
            if (InputManager.Instance.ActionStarted(InputManager.Actions.ActivateCenterObject))
            {
                // TODO: Clean all this up

                // Ray origin is slightly below camera height to ensure it originates inside player's own collider
                // This prevents ray from intersecting with player's own collider and blocking looting or low triggers
                Ray        ray = new Ray(transform.position + Vector3.up * 0.7f, mainCamera.transform.forward);
                RaycastHit hit;
                RayDistance = 75f; // Approximates classic at full view distance (default setting). Classic seems to do raycasts for as far as it can render objects.
                bool hitSomething = Physics.Raycast(ray, out hit, RayDistance);
                if (hitSomething)
                {
                    bool hitBuilding      = false;
                    bool buildingUnlocked = false;
                    DFLocation.BuildingTypes buildingType = DFLocation.BuildingTypes.AllValid;
                    StaticBuilding           building     = new StaticBuilding();

                    #region Hit Checks

                    // Trigger quest resource behaviour click on anything but NPCs
                    QuestResourceBehaviour questResourceBehaviour;
                    if (QuestResourceBehaviourCheck(hit, out questResourceBehaviour))
                    {
                        if (!(questResourceBehaviour.TargetResource is Person))
                        {
                            if (hit.distance > (DefaultActivationDistance * MeshReader.GlobalScale))
                            {
                                DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                return;
                            }

                            // Only trigger click when not in info mode
                            if (currentMode != PlayerActivateModes.Info)
                            {
                                TriggerQuestResourceBehaviourClick(questResourceBehaviour);
                            }
                        }
                    }

                    // Check for a static building hit
                    Transform buildingOwner;
                    DaggerfallStaticBuildings buildings = GetBuildings(hit.transform, out buildingOwner);
                    if (buildings)
                    {
                        if (buildings.HasHit(hit.point, out building))
                        {
                            hitBuilding = true;

                            // Get building directory for location
                            BuildingDirectory buildingDirectory = GameManager.Instance.StreamingWorld.GetCurrentBuildingDirectory();
                            if (!buildingDirectory)
                            {
                                return;
                            }

                            // Get detailed building data from directory
                            BuildingSummary buildingSummary;
                            if (!buildingDirectory.GetBuildingSummary(building.buildingKey, out buildingSummary))
                            {
                                return;
                            }

                            // Check if door is unlocked
                            buildingUnlocked = BuildingIsUnlocked(buildingSummary);

                            // Store building type
                            buildingType = buildingSummary.BuildingType;

                            if (currentMode == PlayerActivateModes.Info)
                            {
                                // Discover building
                                GameManager.Instance.PlayerGPS.DiscoverBuilding(building.buildingKey);

                                // Get discovered building
                                PlayerGPS.DiscoveredBuilding db;
                                if (GameManager.Instance.PlayerGPS.GetDiscoveredBuilding(building.buildingKey, out db))
                                {
                                    // TODO: Check against quest system for an overriding quest-assigned display name for this building
                                    DaggerfallUI.AddHUDText(db.displayName);

                                    if (!buildingUnlocked && buildingType < DFLocation.BuildingTypes.Temple &&
                                        buildingType != DFLocation.BuildingTypes.HouseForSale)
                                    {
                                        string storeClosedMessage = HardStrings.storeClosed;
                                        storeClosedMessage = storeClosedMessage.Replace("%d1", openHours[(int)buildingType].ToString());
                                        storeClosedMessage = storeClosedMessage.Replace("%d2", closeHours[(int)buildingType].ToString());
                                        DaggerfallUI.Instance.PopupMessage(storeClosedMessage);
                                    }
                                }
                            }
                        }
                    }

                    // Check for a static door hit
                    Transform             doorOwner;
                    DaggerfallStaticDoors doors = GetDoors(hit.transform, out doorOwner);
                    if (doors && playerEnterExit)
                    {
                        StaticDoor door;
                        if (doors.HasHit(hit.point, out door))
                        {
                            // Check if close enough to activate
                            if (hit.distance > (DoorActivationDistance * MeshReader.GlobalScale))
                            {
                                DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                return;
                            }

                            if (door.doorType == DoorTypes.Building && !playerEnterExit.IsPlayerInside)
                            {
                                // Discover building
                                GameManager.Instance.PlayerGPS.DiscoverBuilding(building.buildingKey);

                                // TODO: Implement lockpicking and door bashing for exterior doors
                                // For now, any locked building door can be entered by using steal mode
                                if (!buildingUnlocked)
                                {
                                    if (currentMode != PlayerActivateModes.Steal)
                                    {
                                        string Locked = "Locked.";
                                        DaggerfallUI.Instance.PopupMessage(Locked);
                                        return;
                                    }
                                    else     // Breaking into building
                                    {
                                        PlayerEntity player = GameManager.Instance.PlayerEntity;
                                        //player.TallyCrimeGuildRequirements(true, 1);
                                    }
                                }

                                // If entering a shop let player know the quality level
                                // If entering an open home, show greeting
                                if (hitBuilding)
                                {
                                    const int houseGreetingsTextId = 256;

                                    DaggerfallMessageBox mb;

                                    if (buildingUnlocked && buildingType >= DFLocation.BuildingTypes.House1 &&
                                        buildingType <= DFLocation.BuildingTypes.House4)
                                    {
                                        string greetingText = DaggerfallUnity.Instance.TextProvider.GetRandomText(houseGreetingsTextId);
                                        mb = DaggerfallUI.MessageBox(greetingText);
                                    }
                                    else
                                    {
                                        mb = PresentShopQuality(building);
                                    }

                                    if (mb != null)
                                    {
                                        // Defer transition to interior to after user closes messagebox
                                        deferredInteriorDoorOwner = doorOwner;
                                        deferredInteriorDoor      = door;
                                        mb.OnClose += Popup_OnClose;
                                        return;
                                    }
                                }

                                // Hit door while outside, transition inside
                                TransitionInterior(doorOwner, door, true);
                                return;
                            }
                            else if (door.doorType == DoorTypes.Building && playerEnterExit.IsPlayerInside)
                            {
                                // Hit door while inside, transition outside
                                playerEnterExit.TransitionExterior(true);
                                return;
                            }
                            else if (door.doorType == DoorTypes.DungeonEntrance && !playerEnterExit.IsPlayerInside)
                            {
                                if (playerGPS)
                                {
                                    // Hit dungeon door while outside, transition inside
                                    playerEnterExit.TransitionDungeonInterior(doorOwner, door, playerGPS.CurrentLocation, true);
                                    return;
                                }
                            }
                            else if (door.doorType == DoorTypes.DungeonExit && playerEnterExit.IsPlayerInside)
                            {
                                // Hit dungeon exit while inside, ask if access wagon or transition outside
                                if (GameManager.Instance.PlayerEntity.Items.Contains(ItemGroups.Transportation, (int)Transportation.Small_cart))
                                {
                                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager, DaggerfallMessageBox.CommonMessageBoxButtons.YesNo, 38, DaggerfallUI.UIManager.TopWindow);
                                    messageBox.OnButtonClick += DungeonWagonAccess_OnButtonClick;
                                    DaggerfallUI.UIManager.PushWindow(messageBox);
                                    return;
                                }
                                else
                                {
                                    playerEnterExit.TransitionDungeonExterior(true);
                                }
                            }
                        }
                    }

                    // Check for an action door hit
                    DaggerfallActionDoor actionDoor;
                    if (ActionDoorCheck(hit, out actionDoor))
                    {
                        // Check if close enough to activate
                        if (hit.distance > (DoorActivationDistance * MeshReader.GlobalScale))
                        {
                            DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                            return;
                        }

                        if (currentMode == PlayerActivateModes.Steal && actionDoor.IsLocked && !actionDoor.IsOpen)
                        {
                            actionDoor.AttemptLockpicking();
                        }
                        else
                        {
                            actionDoor.ToggleDoor(true);
                        }
                    }

                    // Check for action record hit
                    DaggerfallAction action;
                    if (ActionCheck(hit, out action))
                    {
                        if (hit.distance <= (DefaultActivationDistance * MeshReader.GlobalScale))
                        {
                            action.Receive(this.gameObject, DaggerfallAction.TriggerTypes.Direct);
                        }
                    }

                    // Check for lootable object hit
                    DaggerfallLoot loot;
                    if (LootCheck(hit, out loot))
                    {
                        switch (currentMode)
                        {
                        case PlayerActivateModes.Info:
                            if (loot.ContainerType == LootContainerTypes.CorpseMarker && !string.IsNullOrEmpty(loot.entityName))
                            {
                                string message = string.Empty;
                                if (loot.isEnemyClass)
                                {
                                    message = HardStrings.youSeeADeadPerson;
                                }
                                else
                                {
                                    message = HardStrings.youSeeADead;
                                    message = message.Replace("%s", loot.entityName);
                                }
                                DaggerfallUI.Instance.PopupMessage(message);
                            }
                            break;

                        case PlayerActivateModes.Grab:
                        case PlayerActivateModes.Talk:
                        case PlayerActivateModes.Steal:
                            // Check if close enough to activate
                            if (loot.ContainerType == LootContainerTypes.CorpseMarker)
                            {
                                if (hit.distance > CorpseActivationDistance * MeshReader.GlobalScale)
                                {
                                    DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                    break;
                                }
                            }
                            else if (hit.distance > TreasureActivationDistance * MeshReader.GlobalScale)
                            {
                                DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                break;
                            }

                            // For bodies, check has treasure first
                            if (loot.ContainerType == LootContainerTypes.CorpseMarker && loot.Items.Count == 0)
                            {
                                DaggerfallUI.AddHUDText(HardStrings.theBodyHasNoTreasure);
                                break;
                            }

                            // Open inventory window with loot as remote target
                            DaggerfallUI.Instance.InventoryWindow.LootTarget = loot;
                            DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenInventoryWindow);
                            break;
                        }
                    }

                    // Check for static NPC hit
                    StaticNPC npc;
                    if (NPCCheck(hit, out npc))
                    {
                        switch (currentMode)
                        {
                        case PlayerActivateModes.Info:
                            PresentNPCInfo(npc);
                            break;

                        case PlayerActivateModes.Grab:
                        case PlayerActivateModes.Talk:
                        case PlayerActivateModes.Steal:
                            if (hit.distance > (StaticNPCActivationDistance * MeshReader.GlobalScale))
                            {
                                DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                break;
                            }
                            StaticNPCClick(npc);
                            break;
                        }
                    }

                    // Check for mobile NPC hit
                    MobilePersonNPC mobileNpc = null;
                    if (MobilePersonMotorCheck(hit, out mobileNpc))
                    {
                        switch (currentMode)
                        {
                        case PlayerActivateModes.Info:
                        case PlayerActivateModes.Grab:
                        case PlayerActivateModes.Talk:
                            if (hit.distance > (MobileNPCActivationDistance * MeshReader.GlobalScale))
                            {
                                DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                break;
                            }
                            GameManager.Instance.TalkManager.TalkToMobileNPC(mobileNpc);
                            break;

                        case PlayerActivateModes.Steal:
                            if (!mobileNpc.PickpocketByPlayerAttempted)
                            {
                                if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale))
                                {
                                    DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                    break;
                                }
                                mobileNpc.PickpocketByPlayerAttempted = true;
                                Pickpocket();
                            }
                            break;
                        }
                    }

                    // Check for mobile enemy hit
                    DaggerfallEntityBehaviour mobileEnemyBehaviour;
                    if (MobileEnemyCheck(hit, out mobileEnemyBehaviour))
                    {
                        EnemyEntity enemyEntity = mobileEnemyBehaviour.Entity as EnemyEntity;
                        switch (currentMode)
                        {
                        case PlayerActivateModes.Info:
                        case PlayerActivateModes.Grab:
                        case PlayerActivateModes.Talk:
                            if (enemyEntity != null)
                            {
                                MobileEnemy mobileEnemy     = enemyEntity.MobileEnemy;
                                bool        startsWithVowel = "aeiouAEIOU".Contains(mobileEnemy.Name[0].ToString());
                                string      message;
                                if (startsWithVowel)
                                {
                                    message = HardStrings.youSeeAn;
                                }
                                else
                                {
                                    message = HardStrings.youSeeA;
                                }
                                message = message.Replace("%s", mobileEnemy.Name);
                                DaggerfallUI.Instance.PopupMessage(message);
                            }
                            break;

                        case PlayerActivateModes.Steal:
                            // Classic allows pickpocketing of NPC mobiles and enemy mobiles.
                            // In early versions the only enemy mobiles that can be pickpocketed are classes,
                            // but patch 1.07.212 allows pickpocketing of creatures.
                            // For now, the only enemy mobiles being allowed by DF Unity are classes.
                            if (mobileEnemyBehaviour && (mobileEnemyBehaviour.EntityType != EntityTypes.EnemyClass))
                            {
                                break;
                            }
                            // Classic doesn't set any flag when pickpocketing enemy mobiles, so infinite attempts are possible
                            if (enemyEntity != null && !enemyEntity.PickpocketByPlayerAttempted)
                            {
                                if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale))
                                {
                                    DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                                    break;
                                }
                                enemyEntity.PickpocketByPlayerAttempted = true;
                                Pickpocket(mobileEnemyBehaviour);
                            }
                            break;
                        }
                    }

                    // Trigger ladder hit
                    DaggerfallLadder ladder = hit.transform.GetComponent <DaggerfallLadder>();
                    if (ladder)
                    {
                        if (hit.distance > (DefaultActivationDistance * MeshReader.GlobalScale))
                        {
                            DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway);
                            return;
                        }

                        ladder.ClimbLadder();
                    }

                    #endregion
                }
            }
        }
Ejemplo n.º 20
0
        private static void BribePopup()
        {
            int regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
            int crimeType   = (int)playerEntity.CrimeCommitted - 1;
            int legalRep    = playerEntity.RegionData[regionIndex].LegalRep;
            int streetwise  = playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.Streetwise) + (playerEntity.Stats.LiveLuck / 10) - 5;
            int crimeLevel  = 1;

            //Legalrep = 0 common. -11 gives chance of Criminal Conspiracy, -80 is hated.

            //1 = minor, 2 = major, 3 = high
            if ((crimeType >= 4 && crimeType <= 7) || crimeType == 9)
            {
                crimeLevel = 2;
            }
            else if (crimeType == 10 || crimeType == 11 || crimeType == 14)
            {
                crimeLevel = 3;
            }

            int cost = CalculateBribeCost(crimeLevel);

            if (cost > playerEntity.GoldPieces)
            {
                DaggerfallUI.MessageBox("You are not carrying enough gold to pay the guard.");
            }

            bool charmGuard  = UnityEngine.Random.Range(10, 100) * crimeLevel < streetwise + legalRep;
            bool affordBribe = cost <= playerEntity.GoldPieces;


            if (charmGuard)
            {
                if (cost == 0)
                {
                    playerEntity.CrimeCommitted = PlayerEntity.Crimes.None;
                    playerEntity.SpawnCityGuards(false);
                    string[] message =
                    {
                        "You manage to talk yourself out of the situation.",
                        " ",
                        "The guard leaves you alone without even taking a bribe."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
                if (affordBribe)
                {
                    playerEntity.CrimeCommitted = PlayerEntity.Crimes.None;
                    playerEntity.SpawnCityGuards(false);
                    string[] message =
                    {
                        "You come to an agreement with the guard.",
                        " ",
                        cost.ToString() + " gold changes hands and you part ways."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
                else
                {
                    ArrestPrompt();
                    string[] message =
                    {
                        "You almost come to an agreement with the guard.",
                        " ",
                        "But you do not have the " + cost.ToString() + " gold he demands."
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                    messageBox.SetText(message);
                    messageBox.ClickAnywhereToClose        = true;
                    messageBox.AllowCancel                 = true;
                    messageBox.ParentPanel.BackgroundColor = Color.clear;
                    messageBox.Show();
                }
            }
            else
            {
                ArrestPrompt();
                DaggerfallUI.MessageBox("The guard is not interested in your attempts at a conversation.");
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Schedule a quest message popup at end of task execution.
        /// Message may be split into multiple chunks to display on screen.
        /// </summary>
        /// <param name="id">ID of message,</param>
        /// <param name="immediate">Break quest execution at point of popup to display it immediately.</param>
        /// <returns>MessageBox. Will be top of display stack for chunked messages. Always null after using immediate flag.</returns>
        public DaggerfallMessageBox ShowMessagePopup(int id, bool immediate = false)
        {
            const int chunkSize = 22;

            // Get message resource
            Message message = GetMessage(id);

            if (message == null)
            {
                return(null);
            }

            // Get all message tokens
            TextFile.Token[] tokens = message.GetTextTokens();
            if (tokens == null || tokens.Length == 0)
            {
                return(null);
            }

            // Split token lines into chunks for display
            // This break huge blocks of text into multiple popups
            int lineCount = 0;
            List <TextFile.Token>   currentChunk = new List <TextFile.Token>();
            List <TextFile.Token[]> chunks       = new List <TextFile.Token[]>();

            for (int i = 0; i < tokens.Length; i++)
            {
                // Add current token
                currentChunk.Add(tokens[i]);

                // Count new lines and start a new chunk at max size
                if (tokens[i].formatting == TextFile.Formatting.JustifyCenter ||
                    tokens[i].formatting == TextFile.Formatting.JustifyLeft ||
                    tokens[i].formatting == TextFile.Formatting.Nothing)
                {
                    if (++lineCount > chunkSize)
                    {
                        chunks.Add(currentChunk.ToArray());
                        currentChunk.Clear();
                        lineCount = 0;
                    }
                }
            }

            // Add final chunk only if not empty
            if (currentChunk.Count > 0)
            {
                chunks.Add(currentChunk.ToArray());
            }

            // Push message boxes to stack
            for (int i = 0; i < chunks.Count; i++)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(chunks[i], ExternalMCP);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.AllowCancel                 = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                pendingMessageBoxStack.Push(messageBox);
            }

            // Show messages immediately if requested
            if (immediate)
            {
                QuestBreak = true;
                ShowPendingTaskMessages();
                return(null);
            }

            return(pendingMessageBoxStack.Peek());
        }
Ejemplo n.º 22
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;
        }
    }
Ejemplo n.º 23
0
    void ExtractFilesButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
    {
        if (modSettings.Length < 1)
        {
            return;
        }

        Mod mod = ModManager.Instance.GetMod(modSettings[modList.SelectedIndex].modInfo.ModTitle);

        if (mod == null)
        {
            return;
        }

        string[] assets = mod.AssetNames;
        if (assets == null)
        {
            return;
        }

        string path = Path.Combine(Application.persistentDataPath, "Mods", "ExtractedFiles", mod.FileName);

        Directory.CreateDirectory(path);

        for (int i = 0; i < assets.Length; i++)
        {
            string extension = Path.GetExtension(assets[i]);
            if (!ModManager.textExtensions.Contains(extension))
            {
                continue;
            }

            var asset = mod.GetAsset <TextAsset>(assets[i]);
            if (asset == null)
            {
                continue;
            }

            if (assets[i].EndsWith(".bytes", StringComparison.Ordinal))
            {
                // Export binary asset without .bytes extension
                File.WriteAllBytes(Path.Combine(path, asset.name), asset.bytes);
            }
            else if (assets[i].EndsWith(".cs.txt", StringComparison.Ordinal))
            {
                // Export C# script without .txt extension
                File.WriteAllText(Path.Combine(path, asset.name), asset.text);
            }
            else
            {
                // Export text asset with original extension
                File.WriteAllText(Path.Combine(path, asset.name + extension), asset.text);
            }
        }

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

        messageBox.AllowCancel                   = true;
        messageBox.ClickAnywhereToClose          = true;
        messageBox.ParentPanel.BackgroundTexture = null;
        messageBox.SetText(string.Format(ModManager.GetText("extractTextConfirmation"), path));
        uiManager.PushWindow(messageBox);
    }
Ejemplo n.º 24
0
        internal void DisplayLocationInfo()
        {
            if (LocationSummary.LocationType == DFRegion.LocationTypes.Coven ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonKeep ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonLabyrinth ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonRuin ||
                LocationSummary.LocationType == DFRegion.LocationTypes.Graveyard ||
                LocationSummary.LocationType == DFRegion.LocationTypes.None)
            {
                return;
            }

            Dictionary <int, PlayerGPS.DiscoveredLocation> discoveryData = GameManager.Instance.PlayerGPS.GetDiscoverySaveData();

            if (discoveryData.ContainsKey(LocationSummary.ID))
            {
                PlayerGPS.DiscoveredLocation discoveredLocation             = discoveryData[locationSummary.ID];
                Dictionary <int, PlayerGPS.DiscoveredBuilding> locBuildings = discoveredLocation.discoveredBuildings;
                if (locBuildings != null && locBuildings.Count > 0)
                {
                    IDictionary <DFLocation.BuildingTypes, int> buildingTypeCounts = new SortedDictionary <DFLocation.BuildingTypes, int>();
                    List <string> guildNames = new List <string>();
                    foreach (PlayerGPS.DiscoveredBuilding building in locBuildings.Values)
                    {
                        if (RMBLayout.IsNamedBuilding(building.buildingType))
                        {
                            string guildName = building.displayName.StartsWith("The ") ? building.displayName.Substring(4) : building.displayName;
                            if (building.buildingType == DFLocation.BuildingTypes.GuildHall && !guildNames.Contains(guildName))
                            {
                                guildNames.Add(guildName);
                            }

                            if (building.buildingType != DFLocation.BuildingTypes.GuildHall)
                            {
                                if (buildingTypeCounts.ContainsKey(building.buildingType))
                                {
                                    buildingTypeCounts[building.buildingType]++;
                                }
                                else
                                {
                                    buildingTypeCounts.Add(building.buildingType, 1);
                                }
                            }
                        }
                    }
                    List <TextFile.Token> tokens = new List <TextFile.Token>();
                    tokens.Add(new TextFile.Token()
                    {
                        text       = GetLocationNameInCurrentRegion(locationSummary.MapIndex, true),
                        formatting = TextFile.Formatting.TextHighlight
                    });
                    tokens.Add(newLine);
                    tokens.Add(newLine);

                    guildNames.Sort();
                    string guilds = "";
                    foreach (string guildName in guildNames)
                    {
                        if (!string.IsNullOrWhiteSpace(guilds))
                        {
                            guilds += ", ";
                        }
                        guilds += guildName;
                    }
                    TextFile.Token tab1 = TextFile.TabToken;
                    tab1.x = 45;
                    TextFile.Token tab2 = TextFile.TabToken;
                    tab2.x = 100;
                    TextFile.Token tab3 = TextFile.TabToken;
                    tab3.x = 145;
                    if (!string.IsNullOrWhiteSpace(guilds))
                    {
                        tokens.Add(TextFile.CreateTextToken("Guild Halls:    " + guilds));
                    }
                    tokens.Add(newLine);
                    tokens.Add(TextFile.NewLineToken);

                    bool secondColumn = false;
                    foreach (DFLocation.BuildingTypes buildingType in buildingTypeCounts.Keys)
                    {
                        tokens.Add(TextFile.CreateTextToken(buildingType.ToString()));
                        tokens.Add(!secondColumn ? tab1 : tab3);
                        tokens.Add(TextFile.CreateTextToken(buildingTypeCounts[buildingType].ToString()));
                        if (!secondColumn)
                        {
                            tokens.Add(tab2);
                        }
                        else
                        {
                            tokens.Add(TextFile.NewLineToken);
                        }
                        secondColumn = !secondColumn;
                    }

                    infoBox = new DaggerfallMessageBox(uiManager, this);
                    infoBox.ClickAnywhereToClose = true;
                    infoBox.SetHighlightColor(Color.white);
                    infoBox.SetTextTokens(tokens.ToArray());
                    infoBox.OnClose += InfoBox_Close;
                    infoBox.Show();

                    return;
                }
            }
            DaggerfallUI.MessageBox("You have no knowledge of " + GetLocationNameInCurrentRegion(locationSummary.MapIndex, true) + ".");
        }
Ejemplo n.º 25
0
        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();
                }
            }
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
0
        public DaggerfallMessageBox ShowMessagePopup(int id)
        {
            const int chunkSize = 22;

            // Get message resource
            Message message = GetMessage(id);

            if (message == null)
            {
                return(null);
            }

            // Get all message tokens
            TextFile.Token[] tokens = message.GetTextTokens();
            if (tokens == null || tokens.Length == 0)
            {
                return(null);
            }

            // Split token lines into chunks for display
            // This break huge blocks of text into multiple popups
            int lineCount = 0;
            List <TextFile.Token>   currentChunk = new List <TextFile.Token>();
            List <TextFile.Token[]> chunks       = new List <TextFile.Token[]>();

            for (int i = 0; i < tokens.Length; i++)
            {
                // Add current token
                currentChunk.Add(tokens[i]);

                // Count new lines and start a new chunk at max size
                if (tokens[i].formatting == TextFile.Formatting.JustifyCenter ||
                    tokens[i].formatting == TextFile.Formatting.JustifyLeft ||
                    tokens[i].formatting == TextFile.Formatting.Nothing)
                {
                    if (++lineCount > chunkSize)
                    {
                        chunks.Add(currentChunk.ToArray());
                        currentChunk.Clear();
                        lineCount = 0;
                    }
                }
            }

            // Add final chunk only if not empty
            if (currentChunk.Count > 0)
            {
                chunks.Add(currentChunk.ToArray());
            }

            // Display message boxes in reverse order - this is the previous way of showing stacked popups
            DaggerfallMessageBox rootMessageBox = null;

            for (int i = chunks.Count - 1; i >= 0; i--)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
                messageBox.SetTextTokens(chunks[i]);
                messageBox.ClickAnywhereToClose        = true;
                messageBox.AllowCancel                 = true;
                messageBox.ParentPanel.BackgroundColor = Color.clear;
                messageBox.Show();

                if (i == 0)
                {
                    rootMessageBox = messageBox;
                }
            }

            //// Compose root message box and use AddNextMessageBox() - this is a new technique added by Hazelnut
            //// TODO: Currently when linking more than two message boxes the final two boxes loop between each other
            //// Will return to this later to check, for now just want to continue with quest work
            //DaggerfallMessageBox rootMessageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
            //rootMessageBox.SetTextTokens(chunks[0]);
            //rootMessageBox.ClickAnywhereToClose = true;
            //rootMessageBox.AllowCancel = true;
            //rootMessageBox.ParentPanel.BackgroundColor = Color.clear;

            //// String together remaining message boxes (if any)
            //DaggerfallMessageBox lastMessageBox = rootMessageBox;
            //for (int i = 1; i < chunks.Count; i++)
            //{
            //    DaggerfallMessageBox thisMessageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
            //    thisMessageBox.SetTextTokens(chunks[i]);
            //    thisMessageBox.ClickAnywhereToClose = true;
            //    thisMessageBox.AllowCancel = true;
            //    thisMessageBox.ParentPanel.BackgroundColor = Color.clear;
            //    lastMessageBox.AddNextMessageBox(thisMessageBox);
            //    lastMessageBox = thisMessageBox;
            //}
            //rootMessageBox.Show();

            // Set a quest break so popup will display immediately
            questBreak = true;

            return(rootMessageBox);
        }
Ejemplo n.º 28
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, false, 0, weapon);

            // 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 (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);
        }
Ejemplo n.º 29
0
        void Update()
        {
            if (mainCamera == null)
            {
                return;
            }

            // Change activate mode
            if (InputManager.Instance.ActionStarted(InputManager.Actions.StealMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Steal);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.GrabMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Grab);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.InfoMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Info);
            }
            else if (InputManager.Instance.ActionStarted(InputManager.Actions.TalkMode))
            {
                ChangeInteractionMode(PlayerActivateModes.Talk);
            }

            // Fire ray into scene
            if (InputManager.Instance.ActionStarted(InputManager.Actions.ActivateCenterObject))
            {
                // TODO: Clean all this up and support mobile enemy info-clicks

                // Using RaycastAll as hits can be blocked by decorations or other models
                // When this happens activation feels unresponsive to player
                // Also processing hit detection in order of priority
                Ray          ray = new Ray(mainCamera.transform.position, mainCamera.transform.forward);
                RaycastHit[] hits;
                hits = Physics.RaycastAll(ray, RayDistance);
                if (hits != null)
                {
                    // Check each hit in range for action, exit on first valid action processed
                    bool           hitBuilding = false;
                    StaticBuilding building    = new StaticBuilding();
                    for (int i = 0; i < hits.Length; i++)
                    {
                        #region Hit Checks

                        // Check for a static building hit
                        Transform buildingOwner;
                        DaggerfallStaticBuildings buildings = GetBuildings(hits[i].transform, out buildingOwner);
                        if (buildings)
                        {
                            if (buildings.HasHit(hits[i].point, out building))
                            {
                                hitBuilding = true;

                                // Show building info
                                if (currentMode == PlayerActivateModes.Info)
                                {
                                    PresentBuildingInfo(building);
                                }
                            }
                        }

                        // Check for a static door hit
                        Transform             doorOwner;
                        DaggerfallStaticDoors doors = GetDoors(hits[i].transform, out doorOwner);
                        if (doors && playerEnterExit)
                        {
                            StaticDoor door;
                            if (doors.HasHit(hits[i].point, out door))
                            {
                                if (door.doorType == DoorTypes.Building && !playerEnterExit.IsPlayerInside)
                                {
                                    // If entering a shop let player know the quality level
                                    if (hitBuilding)
                                    {
                                        DaggerfallMessageBox mb = PresentShopQuality(building);
                                        if (mb != null)
                                        {
                                            // Defer transition to interior to after user closes messagebox
                                            deferredInteriorDoorOwner = doorOwner;
                                            deferredInteriorDoor      = door;
                                            mb.OnClose += ShopQualityPopup_OnClose;
                                            return;
                                        }
                                    }

                                    // Hit door while outside, transition inside
                                    playerEnterExit.TransitionInterior(doorOwner, door, true);
                                    return;
                                }
                                else if (door.doorType == DoorTypes.Building && playerEnterExit.IsPlayerInside)
                                {
                                    // Hit door while inside, transition outside
                                    playerEnterExit.TransitionExterior(true);
                                    return;
                                }
                                else if (door.doorType == DoorTypes.DungeonEntrance && !playerEnterExit.IsPlayerInside)
                                {
                                    if (playerGPS)
                                    {
                                        // Hit dungeon door while outside, transition inside
                                        playerEnterExit.TransitionDungeonInterior(doorOwner, door, playerGPS.CurrentLocation, true);
                                        return;
                                    }
                                }
                                else if (door.doorType == DoorTypes.DungeonExit && playerEnterExit.IsPlayerInside)
                                {
                                    // Hit dungeon exit while inside, transition outside
                                    playerEnterExit.TransitionDungeonExterior(true);
                                    return;
                                }
                            }
                        }

                        // Check for an action door hit
                        DaggerfallActionDoor actionDoor;
                        if (ActionDoorCheck(hits[i], out actionDoor))
                        {
                            if (currentMode == PlayerActivateModes.Steal && actionDoor.IsLocked)
                            {
                                if (actionDoor.IsNoLongerPickable)
                                {
                                    return;
                                }
                                else
                                {
                                    actionDoor.AttemptLockpicking();
                                }
                            }
                            else
                            {
                                actionDoor.ToggleDoor();
                            }
                        }

                        // Check for action record hit
                        DaggerfallAction action;
                        if (ActionCheck(hits[i], out action))
                        {
                            action.Receive(this.gameObject, DaggerfallAction.TriggerTypes.Direct);
                        }

                        // Check for lootable object hit
                        DaggerfallLoot loot;
                        if (LootCheck(hits[i], out loot))
                        {
                            // For bodies, check has treasure first
                            if (loot.ContainerType == LootContainerTypes.CorpseMarker && loot.Items.Count == 0)
                            {
                                DaggerfallUI.AddHUDText(HardStrings.theBodyHasNoTreasure);
                                return;
                            }

                            // Open inventory window with loot as remote target
                            DaggerfallUI.Instance.InventoryWindow.LootTarget = loot;
                            DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenInventoryWindow);
                        }

                        // Check for static NPC hit
                        StaticNPC npc;
                        if (NPCCheck(hits[i], out npc))
                        {
                            switch (currentMode)
                            {
                            case PlayerActivateModes.Info:
                                PresentNPCInfo(npc);
                                break;

                            case PlayerActivateModes.Grab:
                            case PlayerActivateModes.Talk:
                                SpecialNPCClick(npc);
                                QuestorCheck(npc);
                                break;
                            }
                        }

                        // Trigger general quest resource behaviour click
                        // Note: This will cause a second click on special NPCs, look into a way to unify this handling
                        QuestResourceBehaviour questResourceBehaviour;
                        if (QuestResourceBehaviourCheck(hits[i], out questResourceBehaviour))
                        {
                            TriggerQuestResourceBehaviourClick(questResourceBehaviour);
                        }

                        #endregion
                    }
                }
            }
        }
Ejemplo n.º 30
0
 protected void InfoBox_Close()
 {
     infoBox = null;
 }