87 lines
2.0 KiB
C#
87 lines
2.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ShopPackagePage : MonoBehaviour
|
|
{
|
|
public Text itemName;
|
|
|
|
public Text itemPrice;
|
|
|
|
public Text itemPriceOff;
|
|
|
|
public Text statsLabel;
|
|
|
|
public Text statsValue;
|
|
|
|
public Button buyButton;
|
|
|
|
public Button addToBasketButton;
|
|
|
|
public ShopManager.Categories category;
|
|
|
|
public int itemID;
|
|
|
|
public string sortName = "ALL";
|
|
|
|
public float itemPriceValue;
|
|
|
|
public Color overPriceColor = Color.red;
|
|
|
|
public Transform packageItemsContent;
|
|
|
|
private ShopManager shopManager;
|
|
|
|
public int levelReq;
|
|
|
|
public static event Action OnUIBuyGlobal;
|
|
|
|
public static event Action OnUIAddBasketGlobal;
|
|
|
|
private void Start()
|
|
{
|
|
shopManager = UnityEngine.Object.FindObjectOfType<ShopManager>();
|
|
SetButtonsByLevelAndPrice();
|
|
}
|
|
|
|
public void SetButtonsByLevelAndPrice()
|
|
{
|
|
if ((itemPriceValue > Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerCash || levelReq > Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel) && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox())
|
|
{
|
|
itemPrice.color = overPriceColor;
|
|
buyButton.interactable = false;
|
|
addToBasketButton.interactable = false;
|
|
}
|
|
else
|
|
{
|
|
itemPrice.color = Color.white;
|
|
buyButton.interactable = true;
|
|
addToBasketButton.interactable = true;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
public void AddToBasket()
|
|
{
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerShopBasket.AddToBasket(category, itemID, itemPriceValue, sortName);
|
|
shopManager.UpdatebasketCounter();
|
|
ShopPackagePage.OnUIAddBasketGlobal?.Invoke();
|
|
UnityEngine.Object.FindObjectOfType<MyBasketInfo>().UpdateMyBasket();
|
|
}
|
|
|
|
public void BuyItemOneByButton()
|
|
{
|
|
shopManager.BuyItem(category, itemID, 1, itemPriceValue, sortName);
|
|
ShopPackagePage.OnUIBuyGlobal?.Invoke();
|
|
GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("BUY_ONE_DONE"), shopManager.transform, deleteLast: true);
|
|
}
|
|
|
|
public void Show3DModel()
|
|
{
|
|
shopManager.Show3Dmodel(category, itemID);
|
|
}
|
|
}
|