37 lines
940 B
C#
37 lines
940 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
|
|
public class GoldPackButton : MonoBehaviour
|
|
{
|
|
public bool autoReadFromText = true;
|
|
public TMP_Text txtAmount;
|
|
public TMP_Text txtPrice;
|
|
public int Amount;
|
|
public int Price;
|
|
void Start()
|
|
{
|
|
GetComponent<Button>().onClick.AddListener(OnClicked);
|
|
}
|
|
|
|
void OnClicked(){
|
|
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {Amount} Gold for {Price} Gems?", Buy,null);
|
|
}
|
|
|
|
void Buy(){
|
|
GameManager.instance.BuyGold(this);
|
|
}
|
|
|
|
void OnValidate() {
|
|
if(!autoReadFromText){return;}
|
|
if(txtAmount!=null){
|
|
Amount = int.Parse(txtAmount.text.Replace(",",""));
|
|
}
|
|
if(txtPrice!=null){
|
|
Price = int.Parse(txtPrice.text.Replace(",",""));
|
|
}
|
|
}
|
|
}
|