Beispiel #1
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.");
            }
        }
Beispiel #2
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);
        }
        protected override void ShowTradePopup()
        {
            const int tradeMessageBaseId = 260;
            const int notEnoughGoldId    = 454;
            int       msgOffset          = 0;
            int       tradePrice         = GetTradePrice();

            int currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey;
            int goldSupply        = 0;
            int shopAttitude      = 0; // For now, 0 = Nice Attitude and 1 = Bad Attitude.

            LimitedGoldShops.ShopData sd;
            if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd))
            {
                goldSupply   = sd.CurrentGoldSupply;
                shopAttitude = sd.ShopAttitude;
            }

            if (WindowMode == WindowModes.Sell && goldSupply <= 0)
            {
                int buildQual           = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.quality;
                TextFile.Token[] tokens = LGSTextTokenHolder.ShopTextTokensNice(4);
                if (buildQual <= 3)        // 01 - 03
                {
                    if (shopAttitude == 0) // Possibly could add the "shop type" to the save-data as well, and use that to determine some other things.
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(5);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(4);
                    }
                }
                else if (buildQual <= 7) // 04 - 07
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(6);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(5);
                    }
                }
                else if (buildQual <= 13) // 08 - 13
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(4);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(6);
                    }
                }
                else if (buildQual <= 17) // 14 - 17
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(7);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(7);
                    }
                }
                else                      // 18 - 20
                {
                    if (shopAttitude == 0)
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensNice(8);
                    }
                    else
                    {
                        tokens = LGSTextTokenHolder.ShopTextTokensMean(8);
                    }
                }

                DaggerfallMessageBox noGoldShop = new DaggerfallMessageBox(DaggerfallUI.UIManager, this);
                noGoldShop.SetTextTokens(tokens, this);
                noGoldShop.ClickAnywhereToClose = true;
                uiManager.PushWindow(noGoldShop);
            }
            else if (WindowMode == WindowModes.Sell && goldSupply < tradePrice)
            {
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.CreateTokens(
                    TextFile.Formatting.JustifyCenter,
                    "I can't afford your offer.",
                    "Would you be willing to settle",
                    "for the " + goldSupply.ToString() + " gold that I have left?");

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmPoorTrade_OnButtonClick;
                uiManager.PushWindow(messageBox);
            }
            else if (WindowMode != WindowModes.Sell && WindowMode != WindowModes.SellMagic && PlayerEntity.GetGoldAmount() < tradePrice)
            {
                DaggerfallUI.MessageBox(notEnoughGoldId);
            }
            else
            {
                if (cost >> 1 <= tradePrice)
                {
                    if (cost - (cost >> 2) <= tradePrice)
                    {
                        msgOffset = 2;
                    }
                    else
                    {
                        msgOffset = 1;
                    }
                }
                if (WindowMode == WindowModes.Sell || WindowMode == WindowModes.SellMagic)
                {
                    msgOffset += 3;
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset);
                messageBox.SetTextTokens(tokens, this);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrade_OnButtonClick;
                uiManager.PushWindow(messageBox);
            }
        }