Esempio n. 1
0
        public void Awake()
        {
            _instance = this;
            var storeGui = transform.parent.GetComponent <StoreGui>();

            gameObject.name = nameof(MerchantPanel);

            _audioSource = gameObject.GetComponent <AudioSource>();
            if (_audioSource == null)
            {
                _audioSource = gameObject.AddComponent <AudioSource>();
            }

            if (GambleSuccessDialog == null)
            {
                GambleSuccessDialog = CraftSuccessDialog.Create(transform);
                GambleSuccessDialog.Frame.anchoredPosition = new Vector2(-700, -300);
            }

            if (AbandonBountyDialog == null)
            {
                AbandonBountyDialog = transform.Find("AbandonBountyDialog").gameObject.AddComponent <AbandonBountyDialog>();
                AbandonBountyDialog.gameObject.SetActive(false);
            }

            var existingBackground = storeGui.m_rootPanel.transform.Find("border (1)");

            if (existingBackground != null)
            {
                var image = existingBackground.GetComponent <Image>();
                GetComponent <Image>().material = image.material;
            }

            var scrollbars = GetComponentsInChildren <ScrollRect>(true);

            foreach (var scrollRect in scrollbars)
            {
                scrollRect.verticalScrollbar.size = 0.4f;
                scrollRect.onValueChanged.AddListener((_) => scrollRect.verticalScrollbar.size = 0.4f);
                scrollRect.normalizedPosition = new Vector2(0, 1);
            }

            var storeBuyButtonTooltip = storeGui.m_buyButton.GetComponent <UITooltip>().m_tooltipPrefab;
            var storeItemTooltip      = storeGui.m_listElement.GetComponent <UITooltip>().m_tooltipPrefab;
            var tooltips = GetComponentsInChildren <UITooltip>(true);

            foreach (var tooltip in tooltips)
            {
                if (tooltip.name == "Sundial" || tooltip.name == "ItemElement")
                {
                    tooltip.m_tooltipPrefab = storeItemTooltip;
                }
                else
                {
                    tooltip.m_tooltipPrefab = storeBuyButtonTooltip;
                }
            }

            InputBlocker = transform.Find("InputBlocker").gameObject;
            InputBlocker.SetActive(false);

            var secretStashRefreshTooltip = GetRefreshTimeTooltip(AdventureDataManager.SecretStash.RefreshInterval);
            var gambleRefreshTooltip      = GetRefreshTimeTooltip(AdventureDataManager.Gamble.RefreshInterval);
            var treasureMapRefreshTooltip = GetRefreshTimeTooltip(AdventureDataManager.TreasureMaps.RefreshInterval);
            var bountiesRefreshTooltip    = GetRefreshTimeTooltip(AdventureDataManager.Bounties.RefreshInterval);

            transform.Find("Sundial").GetComponent <UITooltip>().m_text =
                $"$mod_epicloot_merchant_secretstash: {secretStashRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_gamble: {gambleRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_treasuremaps: {treasureMapRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_bounties: {bountiesRefreshTooltip}\n\n" +
                $"<color=silver>$mod_epicloot_merchant_rollovertime</color>";

            var buyListPrefab = transform.Find("SecretStash/Panel/ItemElement").gameObject.AddComponent <BuyListElement>();

            buyListPrefab.gameObject.SetActive(false);
            var treasureMapElementPrefab = transform.Find("TreasureMap/Panel/ItemElement").gameObject.AddComponent <TreasureMapListElement>();

            treasureMapElementPrefab.gameObject.SetActive(false);
            var bountyElementPrefab = transform.Find("Bounties/AvailableBountiesPanel/ItemElement").gameObject.AddComponent <BountyListElement>();

            bountyElementPrefab.gameObject.SetActive(false);

            Panels.Add(new SecretStashListPanel(this, buyListPrefab));
            Panels.Add(new GambleListPanel(this, buyListPrefab));
            Panels.Add(new TreasureMapListPanel(this, treasureMapElementPrefab));
            Panels.Add(new AvailableBountiesListPanel(this, bountyElementPrefab));
            Panels.Add(new ClaimableBountiesListPanel(this, bountyElementPrefab));

            CoinsCount            = transform.Find("Currencies/CoinsCount").GetComponent <Text>();
            ForestTokensCount     = transform.Find("Currencies/ForestTokensCount").GetComponent <Text>();
            IronBountyTokensCount = transform.Find("Currencies/BountyTokensIronCount").GetComponent <Text>();
            GoldBountyTokensCount = transform.Find("Currencies/BountyTokensGoldCount").GetComponent <Text>();
        }
Esempio n. 2
0
        public void Awake()
        {
            _instance = this;
            var storeGui = transform.parent.GetComponent <StoreGui>();

            gameObject.name = nameof(MerchantPanel);

            _audioSource = gameObject.GetComponent <AudioSource>();
            if (_audioSource == null)
            {
                _audioSource = gameObject.AddComponent <AudioSource>();
            }

            if (GambleSuccessDialog == null)
            {
                if (EpicLoot.HasAuga)
                {
                    var resultsPanel = Auga.API.Workbench_CreateNewResultsPanel();
                    resultsPanel.SetActive(false);
                    resultsPanel.transform.SetParent(transform);
                    GambleSuccessDialog          = resultsPanel.gameObject.AddComponent <CraftSuccessDialog>();
                    GambleSuccessDialog.NameText = GambleSuccessDialog.transform.Find("Topic").GetComponent <Text>();
                    GambleSuccessDialog.Frame    = (RectTransform)GambleSuccessDialog.transform;
                    GambleSuccessDialog.Frame.anchoredPosition = new Vector2(0, 0);
                }
                else
                {
                    GambleSuccessDialog = CraftSuccessDialog.Create(transform);
                    GambleSuccessDialog.Frame.anchoredPosition = new Vector2(-700, -300);
                }
            }

            if (AbandonBountyDialog == null)
            {
                if (EpicLoot.HasAuga)
                {
                    AugaReplaceButton(transform.Find("AbandonBountyDialog/YesButton").GetComponent <Button>());
                    AugaReplaceButton(transform.Find("AbandonBountyDialog/NoButton").GetComponent <Button>());
                }

                AbandonBountyDialog = transform.Find("AbandonBountyDialog").gameObject.AddComponent <AbandonBountyDialog>();
                AbandonBountyDialog.gameObject.SetActive(false);
            }

            var existingBackground = storeGui.m_rootPanel.transform.Find("border (1)");

            if (existingBackground != null)
            {
                var image = existingBackground.GetComponent <Image>();
                GetComponent <Image>().material = image.material;
            }

            var scrollbars = GetComponentsInChildren <ScrollRect>(true);

            foreach (var scrollRect in scrollbars)
            {
                scrollRect.verticalScrollbar.size = 0.4f;
                scrollRect.onValueChanged.AddListener((_) => scrollRect.verticalScrollbar.size = 0.4f);
                scrollRect.normalizedPosition = new Vector2(0, 1);
            }

            var storeBuyButtonTooltip = storeGui.m_buyButton.GetComponent <UITooltip>().m_tooltipPrefab;
            var storeItemTooltip      = storeGui.m_listElement.GetComponent <UITooltip>().m_tooltipPrefab;
            var tooltips = GetComponentsInChildren <UITooltip>(true);

            foreach (var tooltip in tooltips)
            {
                if (tooltip.name == "Sundial" || tooltip.name == "ItemElement")
                {
                    tooltip.m_tooltipPrefab = storeItemTooltip;
                }
                else
                {
                    tooltip.m_tooltipPrefab = storeBuyButtonTooltip;
                }
            }

            InputBlocker = transform.Find("InputBlocker").gameObject;
            InputBlocker.SetActive(false);

            var secretStashRefreshTooltip = GetRefreshTimeTooltip(AdventureDataManager.SecretStash.RefreshInterval);
            var gambleRefreshTooltip      = GetRefreshTimeTooltip(AdventureDataManager.Gamble.RefreshInterval);
            var treasureMapRefreshTooltip = GetRefreshTimeTooltip(AdventureDataManager.TreasureMaps.RefreshInterval);
            var bountiesRefreshTooltip    = GetRefreshTimeTooltip(AdventureDataManager.Bounties.RefreshInterval);

            var sundialTooltip = transform.Find("Sundial").GetComponent <UITooltip>();

            if (EpicLoot.HasAuga)
            {
                Auga.API.Tooltip_MakeSimpleTooltip(sundialTooltip.gameObject);
                var rt = (RectTransform)sundialTooltip.transform;
                rt.anchoredPosition = new Vector2(20, -20);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 40);
                rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 40);
            }

            sundialTooltip.m_text =
                $"$mod_epicloot_merchant_secretstash: {secretStashRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_gamble: {gambleRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_treasuremaps: {treasureMapRefreshTooltip}\n" +
                $"$mod_epicloot_merchant_bounties: {bountiesRefreshTooltip}\n\n" +
                $"<color=silver>$mod_epicloot_merchant_rollovertime</color>";

            var buyListPrefab = transform.Find("SecretStash/Panel/ItemElement").gameObject.AddComponent <BuyListElement>();

            buyListPrefab.gameObject.SetActive(false);
            var treasureMapElementPrefab = transform.Find("TreasureMap/Panel/ItemElement").gameObject.AddComponent <TreasureMapListElement>();

            treasureMapElementPrefab.gameObject.SetActive(false);
            var bountyElementPrefab = transform.Find("Bounties/AvailableBountiesPanel/ItemElement").gameObject.AddComponent <BountyListElement>();

            bountyElementPrefab.gameObject.SetActive(false);
            var activeBountyElementPrefab = transform.Find("Bounties/ClaimableBountiesPanel/ItemElement").gameObject.AddComponent <BountyListElement>();

            bountyElementPrefab.gameObject.SetActive(false);

            if (EpicLoot.HasAuga)
            {
                AugaReplaceButton(transform.Find("SecretStash/SecretStashBuyButton").GetComponent <Button>());
                AugaReplaceButton(transform.Find("Gamble/GambleBuyButton").GetComponent <Button>());
                AugaReplaceButton(transform.Find("TreasureMap/TreasureMapBuyButton").GetComponent <Button>());
                AugaReplaceButton(transform.Find("Bounties/AcceptBountyButton").GetComponent <Button>());
                AugaReplaceButton(transform.Find("Bounties/ClaimBountyButton").GetComponent <Button>());
                AugaReplaceButton(transform.Find("Bounties/AbandonBountyButton").GetComponent <Button>(), true);
            }

            Panels.Add(new SecretStashListPanel(this, buyListPrefab));
            Panels.Add(new GambleListPanel(this, buyListPrefab));
            Panels.Add(new TreasureMapListPanel(this, treasureMapElementPrefab));
            Panels.Add(new AvailableBountiesListPanel(this, bountyElementPrefab));
            Panels.Add(new ClaimableBountiesListPanel(this, activeBountyElementPrefab));

            CoinsCount            = transform.Find("Currencies/CoinsCount").GetComponent <Text>();
            ForestTokensCount     = transform.Find("Currencies/ForestTokensCount").GetComponent <Text>();
            IronBountyTokensCount = transform.Find("Currencies/BountyTokensIronCount").GetComponent <Text>();
            GoldBountyTokensCount = transform.Find("Currencies/BountyTokensGoldCount").GetComponent <Text>();

            if (EpicLoot.HasAuga)
            {
                AugaReplaceBackground(gameObject, true);
                AugaReplaceBackground(AbandonBountyDialog.gameObject, false);

                AugaFixItemBG(buyListPrefab.gameObject);
                AugaFixItemBG(treasureMapElementPrefab.gameObject);
                AugaFixItemBG(bountyElementPrefab.gameObject);
                AugaFixItemBG(activeBountyElementPrefab.gameObject);
                AugaFixItemBG(AbandonBountyDialog.BountyDisplay.gameObject);

                AugaFixListElementColors(buyListPrefab.gameObject);
                AugaFixListElementColors(treasureMapElementPrefab.gameObject);
                AugaFixListElementColors(bountyElementPrefab.gameObject);
                AugaFixListElementColors(activeBountyElementPrefab.gameObject);
                AugaFixListElementColors(AbandonBountyDialog.BountyDisplay.gameObject);

                AugaFixFonts(gameObject);

                AugaMakeSimpleTooltip(treasureMapElementPrefab.gameObject);
                AugaMakeSimpleTooltip(bountyElementPrefab.gameObject);
                AugaMakeSimpleTooltip(activeBountyElementPrefab.gameObject);
            }
        }