10 public Sprite GemSlotLockedSprite;
15 int _isShownAnimParam = Animator.StringToHash(
"IsShown");
16 Animator _upgradePointAnimator;
17 int _bounceAnimParam = Animator.StringToHash(
"Bounce");
20 Image[] _upgradePoints =
new Image[10];
30 int _currentSelectionIndex;
31 int _currentSubSelectionIndex;
36 Text _itemDescription;
42 _animator = GetComponent<Animator>();
44 _vendorName = transform.FindChild(
"vendor_name").GetComponent<Text>();
45 _itemName = transform.FindChild(
"item_name").GetComponent<Text>();
46 _itemPrice = transform.FindChild(
"item_price").GetComponent<Text>();
47 _itemDescription = transform.FindChild(
"item_description").GetComponent<Text>();
48 _currencyIcon = transform.FindChild(
"currency_icon").GetComponent<Image>();
50 _upgradePointAnimator = transform.FindChild(
"upgrade_point_container").GetComponent<Animator>();
55 Transform grid = transform.FindChild(
"grid");
57 _mainTiles[0] = transform.FindChild(
"upgrade_tile").GetComponent<
InventoryTile>();
59 for (
int i = 0; i < 3; i++)
60 _mainTiles[i+1] = transform.FindChild(
"gem_slot_tile_" + i.ToString()).GetComponent<InventoryTile>();
62 for (
int i = 0; i < _gemTiles.Length; i++)
65 newTile.name =
"gem_tile";
66 newTile.transform.SetParent(grid,
false);
67 _gemTiles[i] = newTile;
70 for (
int i = 0; i < _upgradePoints.Length; i++)
72 _upgradePoints[i] = transform.FindChild(
"upgrade_point_container/points/point_" + i.ToString()).GetComponent<Image>();
81 _instance._animator.SetBool(_instance._isShownAnimParam,
true);
82 _instance._vendorName.text = vendorName;
86 _instance._guardianStyle = Game.LocalPlayerProfile.Styles[
"guardian"];
88 if (_instance._guardianStyle.HasChild(
"upgrade_level"))
89 upgradeLevel = _instance._guardianStyle[
"upgrade_level"].IntValue;
91 _instance._upgradeInfos = upgradeInfos;
92 _instance.UpdateUpgradeTile(upgradeLevel);
94 _instance._gemSlotInfos = gemSlotInfos;
95 _instance.UpdateGemSlots();
97 for (
int i = 0; i < gemInfos.Length; i++)
107 tile.ItemPrice = gemInfos[i].Price;
113 for (
int i = gemInfos.Length; i < _instance._gemTiles.Length; i++)
116 tile.gameObject.SetActive(
false);
123 void UpdateUpgradeTile (
int upgradeLevel)
125 for (
int i = 0; i < _upgradePoints.Length; i++)
126 _upgradePoints[i].enabled = (upgradeLevel > i);
129 int currentDamage = WiskinConstants.GUARDIAN_BASE_DAMAGE + WiskinConstants.GUARDIAN_DAMAGE_PER_LEVEL * upgradeLevel;
131 if (upgradeLevel >= WiskinConstants.MAX_GUARDIAN_UPGRADE)
134 upgradeTile.ItemDescription =
string.Format(
Localizer.
GetString(
"wiskin.max_upgrade.desc"),currentDamage); ;
139 upgradeTile.ItemDescription =
string.Format(
Localizer.
GetString(
"wiskin.upgrade.desc"),currentDamage, currentDamage + WiskinConstants.GUARDIAN_DAMAGE_PER_LEVEL); ;
140 upgradeTile.ItemPrice = _upgradeInfos[upgradeLevel].Price;
147 void UpdateGemSlots ()
149 for (
int i = 0; i < _gemSlotInfos.Length; i++)
155 gemSlotTile.ItemPrice = _gemSlotInfos[i].Price;
158 if (!_guardianStyle.HasChild(_gemSlotInfos[i].ItemID))
159 gemSlotTile.PrimaryIcon = _instance.GemSlotLockedSprite;
161 else if (
string.IsNullOrEmpty(_guardianStyle[_gemSlotInfos[i].ItemID].Value))
162 gemSlotTile.PrimaryIcon = null;
167 gemSlotTile.PrimaryIcon = equippedGem.GUISprite;
178 _instance._mainTiles[_instance._currentSelectionIndex].
SetSelected(
false);
179 _instance._mainTiles[newSelectionIndex].
SetSelected(
true);
180 _instance._currentSelectionIndex = newSelectionIndex;
182 if (_instance._currentSelectionIndex == 0)
183 _instance.UpdateUpgradeTile(upgradeLevel);
185 _instance.UpdateGemSlots();
187 _instance._itemName.text = _instance._mainTiles[newSelectionIndex].ItemName;
188 _instance._itemDescription.text = _instance._mainTiles[newSelectionIndex].ItemDescription;
192 _instance._itemPrice.text = _instance._mainTiles[newSelectionIndex].ItemPrice.ToString(
"N0");
193 _instance._currencyIcon.enabled =
true;
197 _instance._itemPrice.text =
"";
198 _instance._currencyIcon.enabled =
false;
202 public static void EnterSubSelection ()
204 _instance._mainTiles[_instance._currentSelectionIndex].
SetSelected(
false);
205 _instance._mainTiles[_instance._currentSelectionIndex].
SetSpecial(
true);
208 public static void ExitSubSelection ()
210 _instance._gemTiles[_instance._currentSubSelectionIndex].
SetSelected(
false);
211 _instance._mainTiles[_instance._currentSelectionIndex].
SetSpecial(
false);
219 if (newSubSelectionIndex == -1)
221 _instance._gemTiles[_instance._currentSubSelectionIndex].
SetSelected(
false);
225 _instance._gemTiles[_instance._currentSubSelectionIndex].
SetSelected(
false);
226 _instance._gemTiles[newSubSelectionIndex].
SetSelected(
true);
227 _instance._currentSubSelectionIndex = newSubSelectionIndex;
229 _instance._itemName.text = _instance._gemTiles[newSubSelectionIndex].ItemName;
230 _instance._itemDescription.text = _instance._gemTiles[newSubSelectionIndex].ItemDescription;
234 _instance._itemPrice.text = _instance._gemTiles[newSubSelectionIndex].ItemPrice.ToString(
"N0");
235 _instance._currencyIcon.enabled =
true;
239 _instance._itemPrice.text =
"";
240 _instance._currencyIcon.enabled =
false;
244 public static void BounceSelectedIcon ()
246 if (_instance._currentSelectionIndex < _instance._mainTiles.Length)
247 _instance._mainTiles[_instance._currentSelectionIndex].
Bounce();
249 _instance._gemTiles[_instance._currentSelectionIndex].
Bounce();
252 public static void BounceUpgradeBar ()
254 _instance._upgradePointAnimator.SetTrigger(_instance._bounceAnimParam);
262 _instance._animator.SetBool(_instance._isShownAnimParam,
false);
264 for (
int i = 0; i < _instance._mainTiles.Length; i++)
270 for (
int i = 0; i < _instance._gemTiles.Length; i++)
static string GetString(string key, SystemLanguage language=SystemLanguage.Unknown)
Gets the localized string for the given string key.
string DisplayNameID
The Localization ID of the Item's actual name as it will appear in inventory/shops.
static void Hide()
Hide the Upgrade shop GUI.
static void UpdateSelectionIndex(int newSelectionIndex, bool isPurchasable, int upgradeLevel)
Update the selection index, in the context of this GUI, this is either the upgrade button or one of t...
Class to manage the visual representation of the Wiskin Upgrade Shop.
void SetSpecial(bool state)
Makes a tile specially-selected (in the case of gem slot sub menu navigation)
Derived class for storing Wiskin Defense gems.
A Class for storing items. Can be used as is or be derived from. See GemItem or GuardianWeapon for ex...
void SetSelected(bool state)
Makes a tile appear selected (glowing orange selection box, slightly scaled).
virtual string Type
Derived classes should override this property with a relevant string used for comparisons related to ...
Sprite GUISprite
The Sprite used to represent this item in the GUI.
A visual representation of an Inventory item. Used by the StoreUIManager class to display items the v...
static void Show(VendorItemInfo[] upgradeInfos, VendorItemInfo[] gemSlotInfos, VendorItemInfo[] gemInfos, string vendorName)
Show the Wiskin Defence Upgrade GUI and set up all of its necessary tiles.
void Bounce()
Plays a bounce animation on the tile to indicate an action was done on it (purchase/equip, etc).
A class that loads all Item Serializeable Objects from the Resources folder and provides the ability ...
void ResetRotationAndScale()
Resets the rotation and scale of the primary icon to its default values.
static void UpdateSubSelectionIndex(int newSubSelectionIndex, bool isOwned)
Update the sub selection index, in the context of this GUI, this is lower container that holds the ge...
string DescriptionID
The Localization ID of the Item's description/flavour text.
static GameObject SpawnLocal(string prefabId, Vector3 position, UJeli details=null)
Spawn an object locally without propagating onto the network.
Unity version of Jeli markup class.
This class server two main functions: 1) As a MonoBehaviour, it allows for network synchronization of...