/// <summary> /// Called from ActionButton /// </summary> /// <param name="itemClicked"></param> public void ShopLevelClicked(GameObject itemClicked) { var clickedItemLevel = itemClicked.GetComponent <UI_WeaponShop_ItemLevel>(); SetActivePreview(clickedItemLevel.level); // note: we want to include the shop potential sales in the price. int previousItemValue = weaponShop.GetItemValue(weaponShop.equippedWeapon); int newItemCost = weaponShop.GetItemValue(clickedItemLevel.item, clickedItemLevel.level); if (previousItemValue + GameCoordinator.instance.currencyValue < newItemCost) { GameCoordinator.PlayOneShot(GameCoordinator.instance.data.errorSound); } else { GameCoordinator.instance.currencyValue += previousItemValue - newItemCost; level = clickedItemLevel.level; weaponShop.EquipdWeapon(this); GameCoordinator.instance.data.equippedPrimaryWeaponPrefab = primaryWeapon; GameCoordinator.instance.data.primaryWeaponLevel = level; foreach (var itemLevel in itemLevels) { if (itemLevel.level <= clickedItemLevel.level) { itemLevel.SetUIActive(); } else { itemLevel.SetUIDisabled(); } } } }