46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TextBox : MonoBehaviour
|
|
{
|
|
public Text numText;
|
|
public Transform ParentHouse;
|
|
public Transform Parent;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
transform.SetParent(Parent);//¸Ä±ä¸¸½Úµã£¬ÏÔʾ³öÀ´
|
|
numText = transform.Find("Text").GetComponent<Text>();
|
|
SetText(0);
|
|
}
|
|
|
|
public void SetText(float add)
|
|
{
|
|
float start = ParentHouse.GetComponent<HouseInfo>().Money;
|
|
ParentHouse.GetComponent<HouseInfo>().Money = add;
|
|
|
|
StartCoroutine(Tools.AnimateText(start, ParentHouse.GetComponent<HouseInfo>().Money, 0.5f, numText));
|
|
}
|
|
|
|
public void AddText(float add)
|
|
{
|
|
float start = ParentHouse.GetComponent<HouseInfo>().Money;
|
|
ParentHouse.GetComponent<HouseInfo>().Money += add;
|
|
|
|
StartCoroutine(Tools.AnimateText(start, ParentHouse.GetComponent<HouseInfo>().Money,0.5f,numText));
|
|
}
|
|
|
|
|
|
public float ReturnText()
|
|
{
|
|
return ParentHouse.GetComponent<HouseInfo>().Money;
|
|
}
|
|
|
|
public void PlayAni()
|
|
{
|
|
ParentHouse.GetComponent<MoneyAnimation>().PlayCoinAnimation();
|
|
}
|
|
}
|