73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CustomizeBuyScreen : MonoBehaviour
|
|
{
|
|
public static CustomizeBuyScreen instance;
|
|
string nameResourceToBuy;
|
|
int coinsValue;
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
public Text txtCoins_01, txtCoins_02;
|
|
public Outline outline;
|
|
public Text backTxt;
|
|
public void SetInfo(string group, string nameItem, string resource, int value)
|
|
{
|
|
Text txtconfirm = transform.Find("txtConfirm").GetComponent<Text>();
|
|
txtconfirm.text = "Do you want to buy the <b>" + group + "</b> item: <color=#C02C89>" +
|
|
nameItem + "</color> ?";
|
|
|
|
nameResourceToBuy = group + "_" + resource; Debug.Log(nameResourceToBuy);
|
|
coinsValue = value;
|
|
|
|
txtCoins_01.text = coinsValue.ToString();
|
|
txtCoins_02.text = coinsValue.ToString();
|
|
|
|
CustomizeZoe_Screen custom = CustomizeZoe_Screen.instance;
|
|
if (coinsValue > custom.coins)
|
|
{
|
|
transform.Find("BtnConfirm").GetComponent<Button>().interactable = false;
|
|
|
|
outline.effectColor = Color.red;
|
|
backTxt.color = Color.red;
|
|
}
|
|
else
|
|
{
|
|
transform.Find("BtnConfirm").GetComponent<Button>().interactable = true;
|
|
|
|
outline.effectColor = new Color(.22f, .22f, .22f, 1);
|
|
backTxt.color = new Color(.22f, .22f, .22f, 1);
|
|
}
|
|
}
|
|
|
|
public void Buy()
|
|
{
|
|
CustomizeZoe_Screen custom = CustomizeZoe_Screen.instance;
|
|
if (coinsValue <= custom.coins)
|
|
{
|
|
APICustomize.instance.BuyItem(nameResourceToBuy, coinsValue);
|
|
}
|
|
}
|
|
|
|
public void BoughtItemReady()
|
|
{
|
|
CustomizeZoe_Screen.instance.LiberarItemComprado(nameResourceToBuy);
|
|
CustomizeZoe_Screen.instance.coins -= coinsValue;
|
|
|
|
CustomizeZoe_Screen.instance.UpdateCoins();
|
|
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void NotBuy()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|