|
- using System;
- using CIG.Translation;
- using CIGEnums;
- using SUISS.Core;
- using SUISSEngine;
- using UnityEngine;
- using UnityEngine.UI;
-
- public class BuildingShopItem : ShopItem
- {
- public void Init(CIGBuilding building, bool isLocked, Action<CIGBuilding> onClick)
- {
- base.Init(delegate
- {
- onClick(building);
- });
- isLocked |= !building.IsUnlocked;
- this._lockObject.gameObject.SetActive(isLocked);
- this._objectButton.interactable = !isLocked;
- Material asset = SingletonMonobehaviour<MaterialAssetCollection>.Instance.GetAsset((!isLocked) ? MaterialType.UIClip : MaterialType.UIClipGreyscale);
- GridTile tile = building.tile;
- this._frameImage.sprite = SingletonMonobehaviour<SurfaceSpriteAssetCollection>.Instance.GetAsset((SurfaceType)tile.requiredGridType);
- this._frameImage.material = asset;
- this._buildingTopImage.sprite = tile.spriteRenderer.sprite;
- this._buildingTopImage.material = asset;
- if (tile.bottomRenderer != null)
- {
- this._buildingBottomImage.sprite = tile.bottomRenderer.sprite;
- this._buildingBottomImage.gameObject.SetActive(true);
- this._buildingBottomImage.material = asset;
- }
- else
- {
- this._buildingBottomImage.gameObject.SetActive(false);
- }
- this._buildingText.LocalizedString = building.LocalName;
- if (isLocked)
- {
- this._costIcon.sprite = SingletonMonobehaviour<UISpriteAssetCollection>.Instance.GetAsset(UISpriteType.XPSmall);
- this._costText.LocalizedString = Localization.Concat(new ILocalizedString[]
- {
- Localization.Key("level"),
- Localization.LiteralWhiteSpace,
- Localization.Integer(building.NextUnlockLevel)
- });
- this._badgeObject.gameObject.SetActive(false);
- }
- else
- {
- Currencies purchasePrice = building.PurchasePrice;
- bool flag = !purchasePrice.ContainsApproximate("Cash") && !purchasePrice.ContainsApproximate("Gold");
- this._costIcon.gameObject.SetActive(!flag);
- this._badgeObject.gameObject.SetActive(flag);
- if (purchasePrice.ContainsApproximate("Cash"))
- {
- this._costIcon.sprite = SingletonMonobehaviour<UISpriteAssetCollection>.Instance.GetAsset(UISpriteType.CashSmall);
- this._costText.LocalizedString = Localization.Integer(purchasePrice.GetValue("Cash"));
- }
- else if (purchasePrice.ContainsApproximate("Gold"))
- {
- this._costIcon.sprite = SingletonMonobehaviour<UISpriteAssetCollection>.Instance.GetAsset(UISpriteType.GoldSmall);
- this._costText.LocalizedString = Localization.Integer(purchasePrice.GetValue("Gold"));
- }
- else
- {
- this._costText.LocalizedString = Localization.Key("free");
- }
- }
- }
-
- [SerializeField]
- private Image _frameImage;
-
- [SerializeField]
- private Image _buildingTopImage;
-
- [SerializeField]
- private Image _buildingBottomImage;
-
- [SerializeField]
- private LocalizedText _buildingText;
-
- [SerializeField]
- private Image _costIcon;
-
- [SerializeField]
- private LocalizedText _costText;
-
- [SerializeField]
- private GameObject _lockObject;
-
- [SerializeField]
- private GameObject _badgeObject;
-
- [SerializeField]
- private Button _objectButton;
- }
|