Пример #1
0
        private void FoodButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            CloseWindow();
            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            if ((gameMinutes - (GameManager.Instance.PlayerEntity.LastTimePlayerAteOrDrankAtTavern)) >= 240)
            {
                DaggerfallListPickerWindow foodAndDrinkPicker = new DaggerfallListPickerWindow(uiManager, this);
                foodAndDrinkPicker.OnItemPicked += FoodAndDrink_OnItemPicked;

                foreach (string menuItem in tavernMenu)
                {
                    foodAndDrinkPicker.ListBox.AddItem(menuItem);
                }

                uiManager.PushWindow(foodAndDrinkPicker);
            }
            else
            {
                DaggerfallUI.MessageBox(HardStrings.youAreNotHungry);
            }
        }
Пример #2
0
        private void SaveLoadEventHandler(BaseScreenComponent sender, Vector2 position)
        {
            if (mode == Modes.SaveGame)
            {
                // Must have a save name
                if (saveNameTextBox.Text.Length == 0)
                {
                    DaggerfallUI.MessageBox(HardStrings.youMustEnterASaveName);
                    return;
                }

                // Get save key and confirm if already exists
                int key = GameManager.Instance.SaveLoadManager.FindSaveFolderByNames(currentPlayerName, saveNameTextBox.Text);
                if (key != -1)
                {
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                    messageBox.SetText(new string[] { HardStrings.confirmOverwriteSave, "" });
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                    messageBox.OnButtonClick += ConfirmOverwrite_OnButtonClick;
                    uiManager.PushWindow(messageBox);
                }
                else
                {
                    SaveGame();
                }
            }
            else if (mode == Modes.LoadGame)
            {
                // Must have a save name
                if (saveNameTextBox.Text.Length == 0)
                {
                    DaggerfallUI.MessageBox(HardStrings.youMustSelectASaveName);
                    return;
                }

                LoadGame();
            }
        }
        private void BuyButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
            const int tradeMessageBaseId = 260;
            const int notEnoughGoldId    = 454;
            int       tradePrice         = GetTradePrice();
            int       msgOffset          = 0;

            if (!GameManager.Instance.PlayerEntity.Items.Contains(Items.ItemGroups.MiscItems, (int)Items.MiscItems.Spellbook))
            {
                DaggerfallUI.MessageBox(noSpellBook);
            }
            else if (GameManager.Instance.PlayerEntity.GetGoldAmount() < tradePrice)
            {
                DaggerfallUI.MessageBox(notEnoughGoldId);
            }
            else
            {
                if (presentedCost >> 1 <= tradePrice)
                {
                    if (presentedCost - (presentedCost >> 2) <= tradePrice)
                    {
                        msgOffset = 2;
                    }
                    else
                    {
                        msgOffset = 1;
                    }
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrade_OnButtonClick;
                uiManager.PushWindow(messageBox);
            }
        }
Пример #4
0
        void ShowTradePopup()
        {
            const int tradeMessageBaseId = 260;
            const int notEnoughGoldId    = 454;
            int       msgOffset          = 0;
            int       tradePrice         = GetTradePrice();

            if (windowMode != WindowModes.Sell && windowMode != WindowModes.SellMagic && PlayerEntity.GetGoldAmount() < tradePrice)
            {
                DaggerfallUI.MessageBox(notEnoughGoldId);
            }
            else
            {
                if (cost >> 1 <= tradePrice)
                {
                    if (cost - (cost >> 2) <= tradePrice)
                    {
                        msgOffset = 2;
                    }
                    else
                    {
                        msgOffset = 1;
                    }
                }
                if (windowMode == WindowModes.Sell || windowMode == WindowModes.SellMagic)
                {
                    msgOffset += 3;
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrade_OnButtonClick;
                uiManager.PushWindow(messageBox);
            }
        }
Пример #5
0
        private void ServiceButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            CloseWindow();
            switch (service)
            {
            case GuildServices.MG_Identify:
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Identify, this));
                break;

            case GuildServices.MG_Training:
            case GuildServices.FG_Training:
            case GuildServices.TG_Training:
            case GuildServices.DB_Training:
            case GuildServices.TAk_Training:
            case GuildServices.TAr_Training:
            case GuildServices.TDi_Training:
            case GuildServices.TJu_Training:
            case GuildServices.TKy_Training:
            case GuildServices.TMa_Training:
            case GuildServices.TSt_Training:
            case GuildServices.TZe_Training:
                TrainingService();
                break;

            case GuildServices.MG_Buy_Magic_Items:
                DaggerfallTradeWindow tradeWindow = new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this);
                tradeWindow.MerchantItems = GetMerchantItems();
                uiManager.PushWindow(tradeWindow);
                break;

            case GuildServices.MG_Buy_Spells:
            //uiManager.PushWindow(new DaggerfallBankingWindow(uiManager, this));
            //break;
            default:
                DaggerfallUI.MessageBox("Guild service not yet implemented.");
                break;
            }
        }
Пример #6
0
        public override void OnPush()
        {
            base.OnPush();

            buildingDiscoveryData = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData;

            // Check guild advancement
            TextFile.Token[] updatedRank = guild.UpdateRank(playerEntity);
            if (updatedRank != null)
            {
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                messageBox.SetTextTokens(updatedRank, guild);
                messageBox.ClickAnywhereToClose = true;
                uiManager.PushWindow(messageBox);
            }
            // Check for free healing (Temple members)
            if (guild.FreeHealing() && playerEntity.CurrentHealth < playerEntity.MaxHealth)
            {
                playerEntity.SetHealth(playerEntity.MaxHealth);
                DaggerfallUI.MessageBox(350);
            }
            // TODO: Check for magicka restoration (sorcerers)
        }
Пример #7
0
 private void QuestMachine_OnQuestStarted(Quest quest)
 {
     // If quest is from archaeologists and involves a dungeon place, give player a locator device
     if (quest.FactionId == ArchaeologistsGuild.FactionId)
     {
         QuestResource[] foundResources = quest.GetAllResources(typeof(Place));
         foreach (Place place in foundResources)
         {
             if (place.SiteDetails.siteType == SiteTypes.Dungeon)
             {
                 if (DaggerfallUnity.Settings.SmallerDungeons)
                 {
                     DaggerfallUI.MessageBox(SMALLDUNGEON_MSG);
                 }
                 else
                 {
                     GameManager.Instance.PlayerEntity.Items.AddItem(new LocatorItem(), ItemCollection.AddPosition.DontCare, true);
                 }
                 break;
             }
         }
     }
 }
Пример #8
0
        static private void EatRation()
        {
            List <DaggerfallUnityItem> sacks = GameManager.Instance.PlayerEntity.Items.SearchItems(ItemGroups.UselessItems2, ClimateCalories.templateIndex_Rations);

            foreach (DaggerfallUnityItem sack in sacks)
            {
                if (sack.weightInKg > 0.1)
                {
                    sack.weightInKg -= 0.1f;
                    playerEntity.LastTimePlayerAteOrDrankAtTavern = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime() - 250;
                    if (!GameManager.IsGamePaused)
                    {
                        DaggerfallUI.AddHUDText("You eat some rations.");
                    }
                    if (sack.weightInKg <= 0.1)
                    {
                        GameManager.Instance.PlayerEntity.Items.RemoveItem(sack);
                        DaggerfallUI.MessageBox(string.Format("You empty your sack of rations."));
                    }
                    break;
                }
            }
        }
Пример #9
0
        protected void ConfirmGettingScammed_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            int playerIntell = player.Stats.LiveIntelligence;

            if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd))
            {
                investedFlag = sd.InvestedIn;
                shopAttitude = sd.ShopAttitude;
            }

            CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
                if (playerEntity.GetGoldAmount() >= investOffer)
                {
                    playerEntity.DeductGoldAmount(investOffer);
                    DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces);
                    tokens = LGSTextTokenHolder.ShopTextTokensNeutral(3);
                    if (investedFlag)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNeutral(4);
                    }
                    DaggerfallUI.MessageBox(tokens);
                    investOffer = 0;
                    LimitedGoldShops.LimitedGoldShops.UpdateInvestAmount(investOffer);
                }
                else
                {
                    DaggerfallUI.MessageBox("Good joke there, you really got me there, ya jerk...");
                }
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.No)
            {
                DaggerfallUI.MessageBox("Yeah, I was just joking as well, haha...");
            }
        }
Пример #10
0
        void AddRecipeToCauldron(int index, string recipeName)
        {
            PotionRecipe recipe = recipes[index];
            Dictionary <int, DaggerfallUnityItem> recipeIngreds = new Dictionary <int, DaggerfallUnityItem>();

            foreach (PotionRecipe.Ingredient ingred in recipe.Ingredients)
            {
                recipeIngreds.Add(ingred.id, null);
            }

            // Find matching items for the recipe ingredients
            foreach (ItemCollection playerItems in new ItemCollection[] { GameManager.Instance.PlayerEntity.Items, GameManager.Instance.PlayerEntity.WagonItems })
            {
                for (int i = 0; i < playerItems.Count; i++)
                {
                    DaggerfallUnityItem item = playerItems.GetItem(i);
                    if (item.IsIngredient && recipeIngreds.ContainsKey(item.TemplateIndex) && recipeIngreds[item.TemplateIndex] == null)
                    {
                        recipeIngreds[item.TemplateIndex] = item;
                    }
                }
            }
            // If player doesn't have all the required ingredients, display message else move ingredients into cauldron.
            if (recipeIngreds.ContainsValue(null))
            {
                DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("reqIngredients"));
            }
            else
            {
                ClearCauldron();
                foreach (DaggerfallUnityItem item in recipeIngreds.Values)
                {
                    AddToCauldron(item);
                }
                nameLabel.Text = recipeName;
            }
        }
Пример #11
0
        protected override void CallFastTravelGoldCheck()
        {
            // Hidden Map Locations: Check if player has visited before allowing fast travel.
            if (TravelOptionsMod.Instance.HiddenMapLocationsEnabled && !IsPlayerControlledTravel())
            {
                bool hasVisitedLocation = false;
                ModManager.Instance.SendModMessage(TravelOptionsMod.HIDDEN_MAP_LOCATIONS_MODNAME, "hasVisitedLocation",
                                                   new Tuple <int, int, bool>(EndPos.X, EndPos.Y, TravelShip),
                                                   (string _, object result) => { hasVisitedLocation = (bool)result; });

                if (!hasVisitedLocation)
                {
                    DaggerfallUI.MessageBox(MsgNotVisited);
                    return;
                }
            }

            if (!travelWindowTO.LocationSelected)
            {
                CloseWindow();
                TravelWindow.CloseTravelWindows(true);

                Debug.LogFormat("Start travel to MP coords: {0},{1}", EndPos.X, EndPos.Y);
                TravelOptionsMod.Instance.BeginTravelToCoords(EndPos, SpeedCautious);
            }
            else if (IsPlayerControlledTravel())
            {
                CloseWindow();
                TravelWindow.CloseTravelWindows(true);

                TravelOptionsMod.Instance.BeginTravel(TravelWindow.LocationSummary, SpeedCautious);
            }
            else
            {
                base.CallFastTravelGoldCheck();
            }
        }
Пример #12
0
        public void TrainingSkill_OnItemPicked(int index, string skillName)
        {
            CloseWindow();
            List <DFCareer.Skills> trainingSkills;

            if (guildTrainingSkills.TryGetValue(service, out trainingSkills))
            {
                DFCareer.Skills skillToTrain = trainingSkills[index];

                if (playerEntity.Skills.GetPermanentSkillValue(skillToTrain) > 50)
                {
                    // Inform player they're too skilled to train
                    TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId);
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                    messageBox.SetTextTokens(tokens, this);
                    messageBox.ClickAnywhereToClose = true;
                    uiManager.PushWindow(messageBox);
                }
                else
                {   // Train the skill
                    DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;
                    playerEntity.TimeOfLastSkillTraining = now.ToClassicDaggerfallTime();
                    now.RaiseTime(DaggerfallDateTime.SecondsPerHour * 3);
                    playerEntity.DeductGoldAmount(GetServicePrice());
                    playerEntity.DecreaseFatigue(PlayerEntity.DefaultFatigueLoss * 180);
                    int   skillAdvancementMultiplier = DaggerfallSkills.GetAdvancementMultiplier(skillToTrain);
                    short tallyAmount = (short)(Random.Range(10, 21) * skillAdvancementMultiplier);
                    playerEntity.TallySkill(skillToTrain, tallyAmount);
                    DaggerfallUI.MessageBox(TrainSkillId);
                }
            }
            else
            {
                Debug.LogError("Invalid skill selected for training.");
            }
        }
Пример #13
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.");
            }
        }
Пример #14
0
        public static int CalculateRoomCost(int daysToRent)
        {
            int cost      = 0;
            int dayOfYear = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.DayOfYear;

            if (dayOfYear <= 46 && dayOfYear + daysToRent > 46)
            {
                cost = 7 * (daysToRent - 1);  // No charge for Heart's Day
            }
            else
            {
                cost = 7 * daysToRent;
            }

            // If player is member of region's knightly order, or rank 4 or higher in any knightly order
            // DaggerfallUI.MessageBox(UserInterfaceWindows.HardStrings.roomFreeForKnightSuchAsYou);
            // cost = 0;
            if (cost == 0) // Only renting for Heart's Day
            {
                DaggerfallUI.MessageBox(UserInterfaceWindows.HardStrings.roomFreeDueToHeartsDay);
            }

            return(cost);
        }
Пример #15
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);
             }
         }
     }
 }
Пример #16
0
        static void TavernFood(uint cals)
        {
            DaggerfallUI.Instance.FadeBehaviour.SmashHUDToBlack();
            PassTime(1800);
            DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();

            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            uint hunger      = gameMinutes - playerEntity.LastTimePlayerAteOrDrankAtTavern;

            if (hunger >= cals)
            {
                if (hunger > cals + 240)
                {
                    playerEntity.LastTimePlayerAteOrDrankAtTavern = gameMinutes - 240;
                }
                playerEntity.LastTimePlayerAteOrDrankAtTavern += cals;
            }
            else
            {
                DaggerfallUI.MessageBox("You are too full to finish your meal. The rest goes to waste.");
                playerEntity.LastTimePlayerAteOrDrankAtTavern = gameMinutes;
            }
            DaggerfallUI.AddHUDText("You feel invigorated by the meal.");
        }
        private void ConfirmTraining_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                if (playerEntity.GetGoldAmount() >= guild.GetTrainingPrice())
                {
                    // Show skill picker loaded with guild training skills
                    DaggerfallListPickerWindow skillPicker = new DaggerfallListPickerWindow(uiManager, this);
                    skillPicker.OnItemPicked += TrainingSkill_OnItemPicked;

                    foreach (DFCareer.Skills skill in GetTrainingSkills())
                    {
                        skillPicker.ListBox.AddItem(DaggerfallUnity.Instance.TextProvider.GetSkillName(skill));
                    }

                    uiManager.PushWindow(skillPicker);
                }
                else
                {
                    DaggerfallUI.MessageBox(NotEnoughGoldId);
                }
            }
        }
        void StartFromClassicSave()
        {
            DaggerfallUnity.ResetUID();
            QuestMachine.Instance.ClearState();
            RaiseOnNewGameEvent();
            ResetWeaponManager();

            // Save index must be in range
            if (classicSaveIndex < 0 || classicSaveIndex >= 6)
            {
                throw new IndexOutOfRangeException("classicSaveIndex out of range.");
            }

            // Open saves in parent path of Arena2 folder
            string    path      = SaveLoadManager.Instance.DaggerfallSavePath;
            SaveGames saveGames = new SaveGames(path);

            if (!saveGames.IsPathOpen)
            {
                throw new Exception(string.Format("Could not open Daggerfall saves path {0}", path));
            }

            // Open save index
            if (!saveGames.TryOpenSave(classicSaveIndex))
            {
                string error = string.Format("Could not open classic save index {0}.", classicSaveIndex);
                DaggerfallUI.MessageBox(error);
                DaggerfallUnity.LogMessage(string.Format(error), true);
                return;
            }

            // Get required save data
            SaveTree saveTree = saveGames.SaveTree;
            SaveVars saveVars = saveGames.SaveVars;

            SaveTreeBaseRecord positionRecord = saveTree.FindRecord(RecordTypes.CharacterPositionRecord);

            if (NoWorld)
            {
                playerEnterExit.DisableAllParents();
            }
            else
            {
                // Set player to world position
                playerEnterExit.EnableExteriorParent();
                StreamingWorld streamingWorld = FindStreamingWorld();
                int            worldX         = positionRecord.RecordRoot.Position.WorldX;
                int            worldZ         = positionRecord.RecordRoot.Position.WorldZ;
                streamingWorld.TeleportToWorldCoordinates(worldX, worldZ);
                streamingWorld.suppressWorld = false;
            }

            GameObject      cameraObject = GameObject.FindGameObjectWithTag("MainCamera");
            PlayerMouseLook mouseLook    = cameraObject.GetComponent <PlayerMouseLook>();

            if (mouseLook)
            {
                // Classic save value ranges from -256 (looking up) to 256 (looking down).
                // The maximum up and down range of view in classic is similar to 45 degrees up and down in DF Unity.
                float pitch = positionRecord.RecordRoot.Pitch;
                if (pitch != 0)
                {
                    pitch = (pitch * 45 / 256);
                }
                mouseLook.Pitch = pitch;

                float yaw = positionRecord.RecordRoot.Yaw;
                // In classic saves 2048 units of yaw is 360 degrees.
                if (yaw != 0)
                {
                    yaw = (yaw * 360 / 2048);
                }
                mouseLook.Yaw = yaw;
            }

            // Set whether the player's weapon is drawn
            WeaponManager weaponManager = GameManager.Instance.WeaponManager;

            weaponManager.Sheathed = (!saveVars.WeaponDrawn);

            // Set game time
            DaggerfallUnity.Instance.WorldTime.Now.FromClassicDaggerfallTime(saveVars.GameTime);

            // Get character record
            List <SaveTreeBaseRecord> records = saveTree.FindRecords(RecordTypes.Character);

            if (records.Count != 1)
            {
                throw new Exception("SaveTree CharacterRecord not found.");
            }

            // Get prototypical character document data
            CharacterRecord characterRecord = (CharacterRecord)records[0];

            characterDocument = characterRecord.ToCharacterDocument();

            // Assign data to player entity
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.AssignCharacter(characterDocument, characterRecord.ParsedData.level, characterRecord.ParsedData.maxHealth, false);

            // Assign biography modifiers
            playerEntity.BiographyResistDiseaseMod = saveVars.BiographyResistDiseaseMod;
            playerEntity.BiographyResistMagicMod   = saveVars.BiographyResistMagicMod;
            playerEntity.BiographyAvoidHitMod      = saveVars.BiographyAvoidHitMod;
            playerEntity.BiographyResistPoisonMod  = saveVars.BiographyResistPoisonMod;
            playerEntity.BiographyFatigueMod       = saveVars.BiographyFatigueMod;

            // Assign faction data
            playerEntity.FactionData.ImportClassicReputation(saveVars);

            // Assign global variables
            playerEntity.GlobalVars.ImportClassicGlobalVars(saveVars);

            // Set time of last check for raising skills
            playerEntity.TimeOfLastSkillIncreaseCheck = saveVars.LastSkillCheckTime;

            // Assign items to player entity
            playerEntity.AssignItems(saveTree);

            // Assign guild memberships
            playerEntity.AssignGuildMemberships(saveTree);

            // Assign diseases and poisons to player entity
            playerEntity.AssignDiseasesAndPoisons(saveTree);

            // Assign gold pieces
            playerEntity.GoldPieces = (int)characterRecord.ParsedData.physicalGold;

            // Assign weapon hand being used
            weaponManager.UsingRightHand = !saveVars.UsingLeftHandWeapon;

            // GodMode setting
            playerEntity.GodMode = saveVars.GodMode;

            // Setup bank accounts
            var bankRecords = saveTree.FindRecord(RecordTypes.BankAccount);

            Banking.DaggerfallBankManager.ReadNativeBankData(bankRecords);

            // Get regional data.
            playerEntity.RegionData = saveVars.RegionData;

            // Set time tracked by playerEntity for game minute-based updates
            playerEntity.LastGameMinutes = saveVars.GameTime;

            // Get breath remaining if player was submerged (0 if they were not in the water)
            playerEntity.CurrentBreath = saveVars.BreathRemaining;

            // TODO: Import classic spellbook
            playerEntity.DeserializeSpellbook(null);

            // Get last type of crime committed
            playerEntity.CrimeCommitted = (PlayerEntity.Crimes)saveVars.CrimeCommitted;

            // Get weather
            byte[] climateWeathers = saveVars.ClimateWeathers;

            // Enums for thunder and snow are reversed in classic and Unity, so they are converted here.
            for (int i = 0; i < climateWeathers.Length; i++)
            {
                // TODO: 0x80 flag can be set for snow or rain, to add fog to these weathers. This isn't in DF Unity yet, so
                // temporarily removing the flag.
                climateWeathers[i] &= 0x7f;
                if (climateWeathers[i] == 5)
                {
                    climateWeathers[i] = 6;
                }
                else if (climateWeathers[i] == 6)
                {
                    climateWeathers[i] = 5;
                }
            }
            GameManager.Instance.WeatherManager.PlayerWeather.ClimateWeathers = climateWeathers;

            // Load character biography text
            playerEntity.BackStory = saveGames.BioFile.Lines;

            // Validate spellbook item
            DaggerfallUnity.Instance.ItemHelper.ValidateSpellbookItem(playerEntity);

            // Start game
            DaggerfallUI.Instance.PopToHUD();
            GameManager.Instance.PauseGame(false);
            DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();
            DaggerfallUI.PostMessage(PostStartMessage);

            lastStartMethod = StartMethods.LoadClassicSave;
            SaveIndex       = -1;

            if (OnStartGame != null)
            {
                OnStartGame(this, null);
            }
        }
Пример #19
0
        public static void CustomArmorService(IUserInterfaceWindow window)
        {
            Debug.Log("Custom Armor service.");

            PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
            ItemHelper   itemHelper   = DaggerfallUnity.Instance.ItemHelper;

            if (playerEntity.Level < 9)
            {
                DaggerfallUI.MessageBox("Sorry I have not yet sourced enough rare materials to make you armor.");
                return;
            }
            ItemCollection armorItems = new ItemCollection();
            Array          armorTypes = itemHelper.GetEnumArray(ItemGroups.Armor);

            foreach (ArmorMaterialTypes material in customArmorMaterials)
            {
                if (playerEntity.Level < 9 ||
                    (playerEntity.Level < 12 && material >= ArmorMaterialTypes.Adamantium) ||
                    (playerEntity.Level < 15 && material >= ArmorMaterialTypes.Orcish) ||
                    (playerEntity.Level < 18 && material >= ArmorMaterialTypes.Daedric))
                {
                    break;
                }

                for (int i = 0; i < armorTypes.Length; i++)
                {
                    Armor        armorType    = (Armor)armorTypes.GetValue(i);
                    ItemTemplate itemTemplate = itemHelper.GetItemTemplate(ItemGroups.Armor, i);
                    int          vs           = 0;
                    int          vf           = 0;
                    switch (armorType)
                    {
                    case Armor.Cuirass:
                    case Armor.Left_Pauldron:
                    case Armor.Right_Pauldron:
                        vs = 1;
                        vf = 3;
                        break;

                    case Armor.Greaves:
                        vs = 2;
                        vf = 5;
                        break;

                    case Armor.Gauntlets:
                        vs = 1;
                        vf = 1;
                        break;

                    case Armor.Boots:
                    case Armor.Helm:
                        vs = 1;
                        vf = itemTemplate.variants - 1;
                        break;

                    default:
                        continue;
                    }
                    for (int v = vs; v <= vf; v++)
                    {
                        armorItems.AddItem(ItemBuilder.CreateArmor(playerEntity.Gender, playerEntity.Race, armorType, material, v));
                    }
                }
                int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(ItemGroups.Armor);
                for (int i = 0; i < customItemTemplates.Length; i++)
                {
                    DaggerfallUnityItem item = ItemBuilder.CreateItem(ItemGroups.Armor, customItemTemplates[i]);
                    ItemBuilder.ApplyArmorSettings(item, playerEntity.Gender, playerEntity.Race, material);
                    armorItems.AddItem(item);
                }
            }

            DaggerfallTradeWindow tradeWindow = (DaggerfallTradeWindow)
                                                UIWindowFactory.GetInstanceWithArgs(UIWindowType.Trade, new object[] { DaggerfallUI.UIManager, null, DaggerfallTradeWindow.WindowModes.Buy, null });

            tradeWindow.MerchantItems = armorItems;
            DaggerfallUI.UIManager.PushWindow(tradeWindow);
        }
        void CureDiseaseService()
        {
            CloseWindow();
            int numberOfDiseases = GameManager.Instance.PlayerEffectManager.DiseaseCount;

            if (playerEntity.TimeToBecomeVampireOrWerebeast != 0)
            {
                numberOfDiseases++;
            }

            // Check holidays for free / cheaper curing
            uint minutes   = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            int  holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex);

            if (numberOfDiseases > 0 &&
                (holidayId == (int)DFLocation.Holidays.South_Winds_Prayer ||
                 holidayId == (int)DFLocation.Holidays.First_Harvest ||
                 holidayId == (int)DFLocation.Holidays.Second_Harvest))
            {
                GameManager.Instance.PlayerEffectManager.CureAllDiseases();
                playerEntity.TimeToBecomeVampireOrWerebeast = 0;
                DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "freeHolidayCuring"));
            }
            else if (numberOfDiseases > 0)
            {
                // Get base cost
                int baseCost = 250 * numberOfDiseases;

                // Apply rank-based discount if this is an Arkay temple
                baseCost = guild.ReducedCureCost(baseCost);

                // Apply temple quality and regional price modifiers
                int costBeforeBargaining = FormulaHelper.CalculateCost(baseCost, buildingDiscoveryData.quality);

                // Halve the price on North Winds Prayer holiday
                if (holidayId == (int)DFLocation.Holidays.North_Winds_Festival)
                {
                    costBeforeBargaining /= 2;
                }

                // Apply bargaining to get final price
                curingCost = FormulaHelper.CalculateTradePrice(costBeforeBargaining, buildingDiscoveryData.quality, false);

                // Index correct message
                const int tradeMessageBaseId = 260;
                int       msgOffset          = 0;
                if (costBeforeBargaining >> 1 <= curingCost)
                {
                    if (costBeforeBargaining - (costBeforeBargaining >> 2) <= curingCost)
                    {
                        msgOffset = 2;
                    }
                    else
                    {
                        msgOffset = 1;
                    }
                }
                // Offer curing at the calculated price.
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmCuring_OnButtonClick;
                messageBox.Show();
            }
            else
            {   // Not diseased
                DaggerfallUI.MessageBox(30);
            }
        }
        private void ServiceButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            // Check access to service
            if (!guild.CanAccessService(service))
            {
                if (guild.IsMember())
                {
                    DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this);
                    msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(InsufficientRankId));
                    msgBox.ClickAnywhereToClose = true;
                    msgBox.Show();
                }
                else
                {
                    DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "serviceMembersOnly"));
                }
                return;
            }
            // Handle known service
            switch (service)
            {
            case GuildServices.Quests:
                GetQuest();
                break;

            case GuildServices.Identify:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Identify, this, guild));
                break;

            case GuildServices.Repair:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Repair, this, guild));
                break;

            case GuildServices.Training:
                TrainingService();
                break;

            case GuildServices.Donate:
                DonationService();
                break;

            case GuildServices.CureDisease:
                CureDiseaseService();
                break;

            case GuildServices.BuyPotions:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild)
                {
                    MerchantItems = GetMerchantPotions()
                });
                break;

            case GuildServices.MakePotions:
                MakePotionService();
                break;

            case GuildServices.BuySpells:
            case GuildServices.BuySpellsMages:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallSpellBookWindow(uiManager, this, true));
                break;

            case GuildServices.MakeSpells:
                CloseWindow();
                if (GameManager.Instance.PlayerEntity.Items.Contains(Items.ItemGroups.MiscItems, (int)Items.MiscItems.Spellbook))
                {
                    uiManager.PushWindow(DaggerfallUI.Instance.DfSpellMakerWindow);
                }
                else
                {
                    DaggerfallUI.MessageBox(TextManager.Instance.GetText("ClassicEffects", "noSpellbook"));
                }
                break;

            case GuildServices.BuyMagicItems:       // TODO: switch items depending on npcService?
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild)
                {
                    MerchantItems = GetMerchantMagicItems()
                });
                break;

            case GuildServices.MakeMagicItems:
                CloseWindow();
                uiManager.PushWindow(DaggerfallUI.Instance.DfItemMakerWindow);
                break;

            case GuildServices.SellMagicItems:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.SellMagic, this, guild));
                break;

            case GuildServices.Teleport:
                CloseWindow();
                DaggerfallUI.Instance.DfTravelMapWindow.ActivateTeleportationTravel();
                uiManager.PushWindow(DaggerfallUI.Instance.DfTravelMapWindow);
                break;

            case GuildServices.DaedraSummoning:
                DaedraSummoningService((int)npcService);
                break;

            case GuildServices.ReceiveArmor:
                ReceiveArmorService();
                break;

            case GuildServices.ReceiveHouse:
                ReceiveHouseService();
                break;

            case GuildServices.Spymaster:
                const int            spyMasterGreetingTextId = 402;
                DaggerfallMessageBox msgBox = new DaggerfallMessageBox(uiManager, this);
                msgBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRandomTokens(spyMasterGreetingTextId));
                msgBox.ClickAnywhereToClose = true;
                msgBox.OnClose += SpyMasterGreetingPopUp_OnClose;
                msgBox.Show();
                break;

            case GuildServices.BuySoulgems:
                CloseWindow();
                uiManager.PushWindow(new DaggerfallTradeWindow(uiManager, DaggerfallTradeWindow.WindowModes.Buy, this, guild)
                {
                    MerchantItems = GetMerchantMagicItems(true)
                });
                break;

            default:
                CloseWindow();
                Services.CustomGuildService customService;
                if (Services.GetCustomGuildService((int)service, out customService))
                {
                    customService(this);
                }
                else
                {
                    DaggerfallUI.MessageBox("Guild service not yet implemented.");
                }
                break;
            }
        }
Пример #22
0
        protected void ConfirmInvestment_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            int playerIntell = player.Stats.LiveIntelligence;

            if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd))
            {
                investedFlag = sd.InvestedIn;
                shopAttitude = sd.ShopAttitude;
            }

            CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
                if (playerEntity.GetGoldAmount() >= investOffer)
                {
                    playerEntity.DeductGoldAmount(investOffer);
                    DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces);
                    if (buildQual <= 3) // 01 - 03
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("I'll do my best, partner.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Thanks for the gold, ya nutter.");
                        }
                    }
                    else if (buildQual <= 7) // 04 - 07
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("Ya won't be disappointed, boss.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Really care for those fish, huh?");
                        }
                    }
                    else if (buildQual <= 17) // 08 - 17
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("Not a bad signature, do you practice?");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Your signature is atrocious, by the way.");
                        }
                    }
                    else if (buildQual >= 18) // 18 - 20
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("I never disappoint when it comes to turning a profit.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Wipe your feet next time, you're tracking sludge in, lamprey.");
                        }
                    }
                    LimitedGoldShops.LimitedGoldShops.UpdateInvestAmount(investOffer);
                }
                else
                {
                    if (buildQual <= 3) // 01 - 03
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("I think you counted wrong, you don't have that much.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("I know you don't have that much, stop lyin' ya idiot!");
                        }
                    }
                    else if (buildQual <= 7) // 04 - 07
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("Might want to recount, boss, cause I don't see that amount.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Who ya tryna impress, huh? I know you don't have that much.");
                        }
                    }
                    else if (buildQual <= 17) // 08 - 17
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("Sorry, but it appears your funds are less than you suggest.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("Quit wasting my damn time, you dolt, you don't have that much!");
                        }
                    }
                    else if (buildQual >= 18) // 18 - 20
                    {
                        if (shopAttitude == 0)
                        {
                            DaggerfallUI.MessageBox("I think you need to hire a new accountant, because you don't have that.");
                        }
                        else
                        {
                            DaggerfallUI.MessageBox("I need to charge more for my time, so leeches like you won't waste it so often!");
                        }
                    }
                }
            }
            else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.No)
            {
                if (buildQual <= 3) // 01 - 03
                {
                    if (shopAttitude == 0)
                    {
                        DaggerfallUI.MessageBox("I understand your reluctance, just look around, haha!");
                    }
                    else
                    {
                        DaggerfallUI.MessageBox("Why you gettin' my hopes up, just to dash them down?");
                    }
                }
                else if (buildQual <= 7) // 04 - 07
                {
                    if (shopAttitude == 0)
                    {
                        DaggerfallUI.MessageBox("That's fine, I would not take such a gamble myself either.");
                    }
                    else
                    {
                        DaggerfallUI.MessageBox("Why you tryna bait me in just to pull away the line?");
                    }
                }
                else if (buildQual <= 17) // 08 - 17
                {
                    if (shopAttitude == 0)
                    {
                        DaggerfallUI.MessageBox("Very well, thankfully parchment is cheap around here.");
                    }
                    else
                    {
                        DaggerfallUI.MessageBox("What's with the indecisive always wasting my time in this town?");
                    }
                }
                else if (buildQual >= 18) // 18 - 20
                {
                    if (shopAttitude == 0)
                    {
                        DaggerfallUI.MessageBox("So be it, ask again when you are ready to commit.");
                    }
                    else
                    {
                        DaggerfallUI.MessageBox("The parasite sucks my precious time away once again, a pity.");
                    }
                }
            }
        }
Пример #23
0
        protected void DoFood()
        {
            CloseWindow();
            int hour = DaggerfallUnity.Instance.WorldTime.Now.Hour;

            if ((hour >= DaggerfallDateTime.MidnightHour) && (hour < DaggerfallDateTime.DawnHour))
            {
                DaggerfallUI.MessageBox("Sorry, the kitchen is closed for the night.");
                return;
            }

            int tavernQuality = playerEnterExit.Interior.BuildingData.Quality;

            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            DaggerfallListPickerWindow foodAndDrinkPicker = new DaggerfallListPickerWindow(uiManager, this);

            foodAndDrinkPicker.OnItemPicked += Food_OnItemPicked;

            string menu = regionMenu();

            string[] tavernMenu;
            if (tavernQuality < 5)
            {
                if (menu == "s")
                {
                    tavernMenu = sLow;
                }
                else if (menu == "se")
                {
                    tavernMenu = seLow;
                }
                else if (menu == "ne")
                {
                    tavernMenu = neLow;
                }
                else if (menu == "b")
                {
                    tavernMenu = neLow;
                }
                else if (menu == "o")
                {
                    tavernMenu = neLow;
                }
                else
                {
                    tavernMenu = nLow;
                }
            }
            else if (tavernQuality < 13)
            {
                if (menu == "s")
                {
                    tavernMenu = sMid;
                }
                else if (menu == "se")
                {
                    tavernMenu = seMid;
                }
                else if (menu == "ne")
                {
                    tavernMenu = neMid;
                }
                else if (menu == "b")
                {
                    tavernMenu = neMid;
                }
                else if (menu == "o")
                {
                    tavernMenu = woMid;
                }
                else
                {
                    tavernMenu = nMid;
                }
            }
            else
            {
                if (menu == "s")
                {
                    tavernMenu = sHigh;
                }
                else if (menu == "se")
                {
                    tavernMenu = seHigh;
                }
                else if (menu == "ne")
                {
                    tavernMenu = neHigh;
                }
                else if (menu == "b")
                {
                    tavernMenu = balHigh;
                }
                else if (menu == "o")
                {
                    tavernMenu = neHigh;
                }
                else
                {
                    tavernMenu = nHigh;
                }
            }

            foreach (string menuItem in tavernMenu)
            {
                foodAndDrinkPicker.ListBox.AddItem(menuItem);
            }

            uiManager.PushWindow(foodAndDrinkPicker);
        }
Пример #24
0
        protected void InvestButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
            if (currentService == Services.Sell)
            {
                int mercSkill    = player.Skills.GetLiveSkillValue(DFCareer.Skills.Mercantile);
                int playerIntell = player.Stats.LiveIntelligence;
                if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd))
                {
                    investedFlag = sd.InvestedIn;
                    shopAttitude = sd.ShopAttitude;
                }

                if (playerIntell >= 30 && mercSkill >= 40)
                {
                    DaggerfallInputMessageBox investMessageBox = new DaggerfallInputMessageBox(uiManager, this);
                    if (buildQual <= 3) // 01 - 03
                    {
                        if (shopAttitude == 0)
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensNice(10);
                        }
                        else
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensMean(13);
                        }
                    }
                    else if (buildQual <= 7) // 04 - 07
                    {
                        if (shopAttitude == 0)
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensNice(1);
                        }
                        else
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensMean(9);
                        }
                    }
                    else if (buildQual <= 17) // 08 - 17
                    {
                        if (shopAttitude == 0)
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensNice(14);
                        }
                        else
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensMean(17);
                        }
                    }
                    else                      // 18 - 20
                    {
                        if (shopAttitude == 0)
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensNice(18);
                        }
                        else
                        {
                            tokens = LGSTextTokenHolder.ShopTextTokensMean(21);
                        }
                    }

                    if (investedFlag)
                    {
                        if (buildQual <= 3) // 01 - 03
                        {
                            if (shopAttitude == 0)
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensNice(12);
                            }
                            else
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensMean(15);
                            }
                        }
                        else if (buildQual <= 7) // 04 - 07
                        {
                            if (shopAttitude == 0)
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensNice(2);
                            }
                            else
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensMean(11);
                            }
                        }
                        else if (buildQual <= 17) // 08 - 17
                        {
                            if (shopAttitude == 0)
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensNice(16);
                            }
                            else
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensMean(19);
                            }
                        }
                        else                      // 18 - 20
                        {
                            if (shopAttitude == 0)
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensNice(20);
                            }
                            else
                            {
                                tokens = LGSTextTokenHolder.ShopTextTokensMean(23);
                            }
                        }
                    }
                    investMessageBox.SetTextTokens(tokens);
                    investMessageBox.TextPanelDistanceY    = 0;
                    investMessageBox.InputDistanceX        = 24;
                    investMessageBox.InputDistanceY        = 2;
                    investMessageBox.TextBox.Numeric       = true;
                    investMessageBox.TextBox.MaxCharacters = 9;
                    investMessageBox.TextBox.Text          = "1";
                    investMessageBox.OnGotUserInput       += InvestMessageBox_OnGotUserInput;
                    investMessageBox.Show();
                }
                else if (shopAttitude == 1 && buildQual <= 7 && playerIntell < 30)
                {
                    DaggerfallInputMessageBox scamMessageBox = new DaggerfallInputMessageBox(uiManager, this);
                    tokens = LGSTextTokenHolder.ShopTextTokensMean(1);
                    scamMessageBox.InputDistanceY = 2;
                    if (investedFlag)
                    //if (test == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(2);
                        scamMessageBox.InputDistanceY = 9;
                    }
                    scamMessageBox.SetTextTokens(tokens);
                    scamMessageBox.TextPanelDistanceY    = 0;
                    scamMessageBox.InputDistanceX        = 24;
                    scamMessageBox.TextBox.Numeric       = true;
                    scamMessageBox.TextBox.MaxCharacters = 9;
                    scamMessageBox.TextBox.Text          = "1";
                    scamMessageBox.OnGotUserInput       += ScamMessageBox_OnGotUserInput;
                    scamMessageBox.Show();
                }
                else if (playerIntell < 30)
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNeutral(1);
                    DaggerfallUI.MessageBox(tokens);
                }
                else
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNeutral(2);
                    DaggerfallUI.MessageBox(tokens);
                }
            }
            else
            {
                DaggerfallUI.MessageBox("We don't accept investment offers here, sorry.");
            }
        }
Пример #25
0
        protected void InvestMessageBox_OnGotUserInput(DaggerfallInputMessageBox sender, string input)
        {
            int playerIntell = player.Stats.LiveIntelligence;

            if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd))
            {
                investedFlag = sd.InvestedIn;
                shopAttitude = sd.ShopAttitude;
            }

            bool result = int.TryParse(input, out investOffer);

            if (!result || investOffer < 500)
            {
                tokens = LGSTextTokenHolder.ShopTextTokensNeutral(5);
                DaggerfallUI.MessageBox(tokens);
                return;
            }

            DaggerfallMessageBox investConfimBox = new DaggerfallMessageBox(uiManager, this);

            if (buildQual <= 3) // 01 - 03
            {
                if (shopAttitude == 0)
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNice(11, investOffer);
                }
                else
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensMean(14, investOffer);
                }
            }
            else if (buildQual <= 7) // 04 - 07
            {
                if (shopAttitude == 0)
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNice(3, investOffer);
                }
                else
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensMean(10, investOffer);
                }
            }
            else if (buildQual <= 17) // 08 - 17
            {
                if (shopAttitude == 0)
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNice(15, investOffer);
                }
                else
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensMean(18, investOffer);
                }
            }
            else                      // 18 - 20
            {
                if (shopAttitude == 0)
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensNice(19, investOffer);
                }
                else
                {
                    tokens = LGSTextTokenHolder.ShopTextTokensMean(22, investOffer);
                }
            }
            if (investedFlag)
            {
                if (buildQual <= 3) // 01 - 03
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(13, investOffer);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(16, investOffer);
                    }
                }
                else if (buildQual <= 7) // 04 - 07
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(9, investOffer);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(12, investOffer);
                    }
                }
                else if (buildQual <= 17) // 08 - 17
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(17, investOffer);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(20, investOffer);
                    }
                }
                else                      // 18 - 20
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(21, investOffer);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(24, investOffer);
                    }
                }
            }
            investConfimBox.SetTextTokens(tokens);
            investConfimBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            investConfimBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
            investConfimBox.OnButtonClick += ConfirmInvestment_OnButtonClick;
            uiManager.PushWindow(investConfimBox);
        }
Пример #26
0
        protected override void LocalItemListScroller_OnItemClick(DaggerfallUnityItem item)
        {
            // Handle click based on action & mode
            if (selectedActionMode == ActionModes.Select)
            {
                switch (windowMode)
                {
                case WindowModes.Sell:
                case WindowModes.SellMagic:
                    if (remoteItems != null)
                    {
                        // Are we trying to sell the non empty wagon?
                        if (item.ItemGroup == ItemGroups.Transportation && PlayerEntity.WagonItems.Count > 0)
                        {
                            DaggerfallUnityItem usedWagon = PlayerEntity.Items.GetItem(ItemGroups.Transportation, (int)Transportation.Small_cart);
                            if (usedWagon.Equals(item))
                            {
                                return;
                            }
                        }
                        TransferItem(item, localItems, remoteItems);
                    }
                    break;

                case WindowModes.Buy:
                    if (usingWagon)         // Allows player to get & equip stuff from cart while purchasing.
                    {
                        TransferItem(item, localItems, PlayerEntity.Items, CanCarryAmount(item), equip: !item.IsAStack());
                    }
                    else                    // Allows player to equip and unequip while purchasing.
                    {
                        EquipItem(item);
                    }
                    break;

                case WindowModes.Repair:
                    // Check that item can be repaired, is damaged & transfer if so.
                    if (item.IsEnchanted && !DaggerfallUnity.Settings.AllowMagicRepairs)
                    {
                        DaggerfallUI.MessageBox(magicItemsCannotBeRepairedTextId);
                    }
                    else if ((item.currentCondition < item.maxCondition) && item.TemplateIndex != (int)Weapons.Arrow)
                    {
                        TransferItem(item, localItems, remoteItems);
                        // UpdateRepairTimes(false);
                    }
                    else
                    {
                        DaggerfallUI.MessageBox(doesNotNeedToBeRepairedTextId);
                    }
                    break;

                case WindowModes.Identify:
                    // Check if item is unidentified & transfer
                    if (!item.IsIdentified)
                    {
                        TransferItem(item, localItems, remoteItems);
                    }
                    else
                    {
                        DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "doesntNeedIdentify"));
                    }
                    break;
                }
            }
            else if (selectedActionMode == ActionModes.Info)
            {
                ShowInfoPopup(item);
            }
        }
Пример #27
0
        protected void Food_OnItemPicked(int index, string foodOrDrinkName)
        {
            int tavernQuality = playerEnterExit.Interior.BuildingData.Quality;

            DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
            CloseWindow();
            string menu = regionMenu();
            int    price;

            if (tavernQuality < 5)
            {
                if (menu == "s")
                {
                    price = sLowPrices[index];
                }
                else if (menu == "se")
                {
                    price = seLowPrices[index];
                }
                else if (menu == "ne")
                {
                    price = neLowPrices[index];
                }
                else if (menu == "b")
                {
                    price = neLowPrices[index];
                }
                else if (menu == "o")
                {
                    price = neLowPrices[index];
                }
                else
                {
                    price = nLowPrices[index];
                }
            }
            else if (tavernQuality < 13)
            {
                if (menu == "s")
                {
                    price = sMidPrices[index];
                }
                else if (menu == "se")
                {
                    price = seMidPrices[index];
                }
                else if (menu == "ne")
                {
                    price = neMidPrices[index];
                }
                else if (menu == "b")
                {
                    price = neMidPrices[index];
                }
                else if (menu == "o")
                {
                    price = woMidPrices[index];
                }
                else
                {
                    price = nMidPrices[index];
                }
            }
            else
            {
                if (menu == "s")
                {
                    price = sHighPrices[index];
                }
                else if (menu == "se")
                {
                    price = seHighPrices[index];
                }
                else if (menu == "ne")
                {
                    price = neHighPrices[index];
                }
                else if (menu == "b")
                {
                    price = balHighPrices[index];
                }
                else if (menu == "o")
                {
                    price = neHighPrices[index];
                }
                else
                {
                    price = nHighPrices[index];
                }
            }


            uint gameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
            uint cal;

            cal = (uint)Mathf.Min(calories[index] * 10, 240);

            if (playerEntity.GetGoldAmount() < price)
            {
                DaggerfallUI.MessageBox("You do not have enough gold.");
            }
            else
            {
                playerEntity.DeductGoldAmount(price);
                TavernFood(cal);
            }
        }
Пример #28
0
        private void ConfirmTrade_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            bool receivedLetterOfCredit = false;

            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                // Proceed with trade.
                int tradePrice = GetTradePrice();
                switch (windowMode)
                {
                case WindowModes.Sell:
                case WindowModes.SellMagic:
                    float goldWeight = tradePrice * DaggerfallBankManager.goldUnitWeightInKg;
                    if (PlayerEntity.CarriedWeight + goldWeight <= PlayerEntity.MaxEncumbrance)
                    {
                        PlayerEntity.GoldPieces += tradePrice;
                    }
                    else
                    {
                        DaggerfallUnityItem loc = ItemBuilder.CreateItem(ItemGroups.MiscItems, (int)MiscItems.Letter_of_credit);
                        loc.value = tradePrice;
                        GameManager.Instance.PlayerEntity.Items.AddItem(loc, Items.ItemCollection.AddPosition.Front);
                        receivedLetterOfCredit = true;
                    }
                    RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice);
                    remoteItems.Clear();
                    break;

                case WindowModes.Buy:
                    PlayerEntity.DeductGoldAmount(tradePrice);
                    RaiseOnTradeHandler(basketItems.GetNumItems(), tradePrice);
                    PlayerEntity.Items.TransferAll(basketItems);
                    break;

                case WindowModes.Repair:
                    PlayerEntity.DeductGoldAmount(tradePrice);
                    if (DaggerfallUnity.Settings.InstantRepairs)
                    {
                        foreach (DaggerfallUnityItem item in remoteItemsFiltered)
                        {
                            item.currentCondition = item.maxCondition;
                        }
                    }
                    else
                    {
                        UpdateRepairTimes(true);
                    }
                    RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice);
                    break;

                case WindowModes.Identify:
                    PlayerEntity.DeductGoldAmount(tradePrice);
                    for (int i = 0; i < remoteItems.Count; i++)
                    {
                        DaggerfallUnityItem item = remoteItems.GetItem(i);
                        item.IdentifyItem();
                    }
                    RaiseOnTradeHandler(remoteItems.GetNumItems(), tradePrice);
                    break;
                }
                if (receivedLetterOfCredit)
                {
                    DaggerfallUI.Instance.PlayOneShot(SoundClips.ParchmentScratching);
                }
                else
                {
                    DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces);
                }
                PlayerEntity.TallySkill(DFCareer.Skills.Mercantile, 1);
                Refresh();
            }
            CloseWindow();
            if (receivedLetterOfCredit)
            {
                DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "letterOfCredit"));
            }
        }
Пример #29
0
        /// <summary>
        /// Check if player is allowed to rest at this location.
        /// </summary>
        bool CanRest(bool alreadyWarned = false)
        {
            remainingHoursRented = -1;
            allocatedBed         = Vector3.zero;
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;
            PlayerGPS       playerGPS       = GameManager.Instance.PlayerGPS;

            if (playerGPS.IsPlayerInTown(true, true))
            {
                if (!alreadyWarned)
                {
                    CloseWindow();
                    DaggerfallUI.MessageBox(cityCampingIllegal);
                }

                // Register crime and start spawning guards
                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy;
                playerEntity.SpawnCityGuards(true);

                return(alreadyWarned);
            }
            else if (playerGPS.IsPlayerInTown() && playerEnterExit.IsPlayerInsideBuilding)
            {
                // Check owned locations
                string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey);
                if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName))
                {
                    // Can rest if it's an player owned ship/house.
                    int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey;
                    if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey))
                    {
                        return(true);
                    }

                    // Find room rental record and get remaining time..
                    int           mapId = playerGPS.CurrentLocation.MapTableData.MapId;
                    RoomRental_v1 room  = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey);
                    remainingHoursRented = PlayerEntity.GetRemainingHours(room);

                    // Get allocated bed marker - default to 0 if out of range
                    // We relink marker position by index as building positions are not stable, they can move from terrain mods or floating Y
                    Vector3[] restMarkers = playerEnterExit.Interior.FindMarkers(DaggerfallInterior.InteriorMarkerTypes.Rest);
                    int       bedIndex    = (room.allocatedBedIndex >= 0 && room.allocatedBedIndex < restMarkers.Length) ? room.allocatedBedIndex : 0;
                    allocatedBed = restMarkers[bedIndex];
                    if (remainingHoursRented > 0)
                    {
                        return(true);
                    }
                }
                // Check for guild hall rest privileges (exclude taverns since they are all marked as fighters guilds in data)
                if (playerEnterExit.BuildingDiscoveryData.buildingType != DFLocation.BuildingTypes.Tavern &&
                    GameManager.Instance.GuildManager.GetGuild(playerEnterExit.BuildingDiscoveryData.factionID).CanRest())
                {
                    playerEnterExit.Interior.FindMarker(out allocatedBed, DaggerfallInterior.InteriorMarkerTypes.Rest);
                    return(true);
                }
                CloseWindow();
                DaggerfallUI.MessageBox(TextManager.Instance.GetLocalizedText("haveNotRentedRoom"));
                return(false);
            }
            return(true);
        }
Пример #30
0
        protected void DoDrinks()
        {
            CloseWindow();

            if (drunk > (playerEntity.Stats.LiveEndurance + playerEntity.Stats.LiveWillpower + playerEntity.Stats.LivePersonality) / 2)
            {
                DaggerfallUI.MessageBox("I think you've had enough.");
            }
            else
            {
                int  tavernQuality = playerEnterExit.Interior.BuildingData.Quality;
                uint gameMinutes   = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

                DaggerfallListPickerWindow foodAndDrinkPicker = new DaggerfallListPickerWindow(uiManager, this);
                foodAndDrinkPicker.OnItemPicked += Drinks_OnItemPicked;

                string   menu = regionMenu();
                string[] tavernMenu;
                if (tavernQuality < 5)
                {
                    if (menu == "s")
                    {
                        tavernMenu = sLowDrinks;
                    }
                    else if (menu == "se")
                    {
                        tavernMenu = sLowDrinks;
                    }
                    else if (menu == "ne")
                    {
                        tavernMenu = neLowDrinks;
                    }
                    else if (menu == "b")
                    {
                        tavernMenu = neLowDrinks;
                    }
                    else if (menu == "o")
                    {
                        tavernMenu = woLowDrinks;
                    }
                    else
                    {
                        tavernMenu = nLowDrinks;
                    }
                }
                else if (tavernQuality < 13)
                {
                    if (menu == "s")
                    {
                        tavernMenu = sMidDrinks;
                    }
                    else if (menu == "se")
                    {
                        tavernMenu = sMidDrinks;
                    }
                    else if (menu == "ne")
                    {
                        tavernMenu = neMidDrinks;
                    }
                    else if (menu == "b")
                    {
                        tavernMenu = neMidDrinks;
                    }
                    else if (menu == "o")
                    {
                        tavernMenu = woMidDrinks;
                    }
                    else
                    {
                        tavernMenu = nMidDrinks;
                    }
                }
                else
                {
                    if (menu == "s")
                    {
                        tavernMenu = sHighDrinks;
                    }
                    else if (menu == "se")
                    {
                        tavernMenu = sHighDrinks;
                    }
                    else if (menu == "ne")
                    {
                        tavernMenu = neHighDrinks;
                    }
                    else if (menu == "b")
                    {
                        tavernMenu = neHighDrinks;
                    }
                    else if (menu == "o")
                    {
                        tavernMenu = neHighDrinks;
                    }
                    else
                    {
                        tavernMenu = nHighDrinks;
                    }
                }

                foreach (string menuItem in tavernMenu)
                {
                    foodAndDrinkPicker.ListBox.AddItem(menuItem);
                }

                uiManager.PushWindow(foodAndDrinkPicker);
            }
        }