예제 #1
0
파일: ShopUI.cs 프로젝트: ssshammi/RPG
        private void RefreshUI()
        {
            foreach (Transform child in listRoot)
            {
                Destroy(child.gameObject);
            }

            foreach (ShopItem item in currentShop.GetFilteredItems())
            {
                RowUI row = Instantiate <RowUI>(rowPrefab, listRoot);
                row.Setup(currentShop, item);
            }

            totalField.text            = $"Total: ${currentShop.TransactionTotal():N2}";
            totalField.color           = currentShop.HasSufficientFunds() ? originalTotalTextColor : Color.red;
            confirmButton.interactable = currentShop.CanTransact();
            TextMeshProUGUI switchText  = switchButton.GetComponentInChildren <TextMeshProUGUI>();
            TextMeshProUGUI confirmText = confirmButton.GetComponentInChildren <TextMeshProUGUI>();

            if (currentShop.IsBuyingMode())
            {
                switchText.text  = "Switch To Selling";
                confirmText.text = "Buy";
            }
            else
            {
                switchText.text  = "Switch To Buying";
                confirmText.text = "Sell";
            }

            foreach (FilterButtonUI button in GetComponentsInChildren <FilterButtonUI>())
            {
                button.RefreshUI();
            }
        }
예제 #2
0
        private void RefreshUI()
        {
            foreach (Transform child in listRoot)
            {
                Destroy(child.gameObject);
            }

            foreach (ShopItem item in currentShop.GetFilteredItems())
            {
                RowUI row = Instantiate <RowUI>(rowPrefab, listRoot);
                row.Setup(currentShop, item);
            }

            totalField.text = $"Total: ${currentShop.TransactionTotal():N2}";
        }