Пример #1
0
        private void Awake()
        {
            shopUiStorage = FindObjectOfType <ShopUiStorage>()
                            ?? throw new Exception(nameof(ShopUiStorage));
            productClickHandlerScript = FindObjectOfType <ProductClickHandlerScript>()
                                        ?? throw new Exception(nameof(ProductClickHandlerScript));

            // skinItemSpawner = new SkinItemSpawner();
            // warshipItemSpawner = new WarshipItemSpawner();
            // lootboxItemsSpawner = new LootboxItemsSpawner();
            // dailyPresentItemSpawner = new DailyPresentItemSpawner();
            softCurrencyItemSpawner       = new SoftCurrencyItemSpawner();
            hardCurrencyItemSpawner       = new HardCurrencyItemSpawner();
            warshipPowerPointsItemSpawner = new WarshipPowerPointsItemSpawner();
        }
Пример #2
0
        public void Spawn(PurchaseModel purchaseModel, GameObject sectionGameObject,
                          ProductClickHandlerScript productClickHandlerScript)
        {
            var costModel = ZeroFormatterSerializer.Deserialize <RealCurrencyCostModel>(purchaseModel.productModel.CostModel.SerializedCostModel);
            HardCurrencyProductModel hardCurrencyProductModel = purchaseModel.productModel;
            //Создать объект на сцене
            GameObject premiumCurrencyItemPrefab = Resources
                                                   .Load <GameObject>("Prefabs/LobbyShop/Image_PremiumCurrencyItem");
            GameObject premiumCurrencyItemGameObject = Object.Instantiate(premiumCurrencyItemPrefab, sectionGameObject.transform, false);

            //Заполнить картинку
            Image itemPreview = premiumCurrencyItemGameObject.transform.Find("Image_ItemPreview")
                                .GetComponentInChildren <Image>();

            itemPreview.sprite = Resources.Load <Sprite>(purchaseModel.productModel.PreviewImagePath);

            //Заполнить цену
            Text itemCost = premiumCurrencyItemGameObject.transform.Find("Image_Cost/Text_Amount").GetComponent <Text>();

            if (costModel.CostString != null)
            {
                itemCost.text = costModel.CostString.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                itemCost.text = "undefined";
            }

            //Заполнить название
            Text itemName = premiumCurrencyItemGameObject.transform.Find("Image_ItemPreview/Text_ItemName").GetComponent <Text>();

            itemName.text = hardCurrencyProductModel.Amount.ToString();

            //Установить обработчик нажатия
            Button itemButton = premiumCurrencyItemGameObject.GetComponent <Button>();

            itemButton.onClick.RemoveAllListeners();
            itemButton.onClick.AddListener(() =>
            {
                productClickHandlerScript.Product_OnClick(purchaseModel);
            });
        }
Пример #3
0
        public void Spawn(PurchaseModel purchaseModel, GameObject sectionGameObject,
                          ProductClickHandlerScript productClickHandlerScript)
        {
            WarshipPowerPointsProductModel model = purchaseModel.productModel;
            int increment = model.Increment;
            InGameCurrencyCostModel costModel =
                ZeroFormatterSerializer.Deserialize <InGameCurrencyCostModel>(purchaseModel.productModel.CostModel
                                                                              .SerializedCostModel);
            //Создать объект на сцене
            GameObject wppPrefab = Resources.Load <GameObject>("Prefabs/LobbyShop/Image_WarshipPowerPointsItem");
            GameObject wppGo     = Object.Instantiate(wppPrefab, sectionGameObject.transform, false);

            //Установить название обьекта
            wppGo.name += " " + increment;

            //Заполнить картинку
            Image itemPreview = wppGo.transform.Find("Image_WarshipPreview")
                                .GetComponentInChildren <Image>();

            itemPreview.sprite = Resources.Load <Sprite>("SkinPreview/" + purchaseModel.productModel.PreviewImagePath);

            //Заполнить текущий показатель силы
            Text currentPowerValue = wppGo.transform.Find("Empty_PowerValueRoot/Text").GetComponent <Text>();

            currentPowerValue.text = $"{model.SupportClientModel.StartValue}/{model.SupportClientModel.MaxValueForLevel}";

            //Установить значение слайдера
            Slider slider = wppGo.transform.Find("Empty_PowerValueRoot/Slider").GetComponent <Slider>();

            slider.value = 1f * model.SupportClientModel.StartValue / model.SupportClientModel.MaxValueForLevel;

            //Заполнить прибавку к очкам силы
            Text incrementText = wppGo.transform.Find("Text").GetComponent <Text>();

            // log.Debug($"increment = "+increment);
            incrementText.text = $"+{increment}";

            //Заполнить цену
            Text itemCost = wppGo.transform.Find("Image_Cost/Text_Amount").GetComponent <Text>();

            itemCost.text = costModel.Cost.ToString(CultureInfo.InvariantCulture);

            var darkLayer = wppGo.transform.Find("Image_Disabled").gameObject;

            darkLayer.SetActive(purchaseModel.productModel.IsDisabled);
            var boughtText = wppGo.transform.Find("Image_Cost/Text_Bought").gameObject;

            boughtText.SetActive(purchaseModel.productModel.IsDisabled);
            var costText = wppGo.transform.Find("Image_Cost/Text_Amount").gameObject;

            costText.SetActive(!purchaseModel.productModel.IsDisabled);

            if (dictionary.ContainsKey(purchaseModel.productModel.Id))
            {
                dictionary.Remove(purchaseModel.productModel.Id);
            }
            dictionary.Add(purchaseModel.productModel.Id, new StubWppUi()
            {
                boughtText = boughtText,
                costText   = costText,
                darkLayer  = darkLayer
            });

            //Установить обработчик нажатия
            Button itemButton = wppGo.GetComponent <Button>();

            itemButton.onClick.RemoveAllListeners();

            itemButton.onClick.AddListener(() =>
            {
                productClickHandlerScript.Product_OnClick(purchaseModel);
            });
        }