69 lines
1.3 KiB
C#
69 lines
1.3 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using TMPro;
|
|||
|
|
|||
|
public class UserTipTool : MonoBehaviour
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
public Text txtInfo;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|||
|
public float moveSpeed;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
|
|||
|
public float hideSpeed;
|
|||
|
//λ<><CEBB>
|
|||
|
public RectTransform rec;
|
|||
|
//<><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public CanvasGroup can;
|
|||
|
//<2F><>¼ʱ<C2BC><CAB1>
|
|||
|
private float addTime;
|
|||
|
//<2F><>ʼ<EFBFBD><CABC>
|
|||
|
private Vector2 startPos;
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
can.alpha = 1;
|
|||
|
startPos = rec.localPosition;
|
|||
|
}
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
if (GameMgr.Instance.isUserNumAndGas)
|
|||
|
{
|
|||
|
ResetData();
|
|||
|
return;
|
|||
|
}
|
|||
|
addTime += Time.deltaTime;
|
|||
|
startPos.y += Time.deltaTime * moveSpeed;
|
|||
|
if (startPos.y >= 300f)
|
|||
|
{
|
|||
|
startPos.y = 300f;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
rec.localPosition = startPos;
|
|||
|
}
|
|||
|
if (addTime >= 1.5f)
|
|||
|
{
|
|||
|
can.alpha -=Time.deltaTime * hideSpeed;
|
|||
|
if (can.alpha<=0)
|
|||
|
{
|
|||
|
ResetData();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateTxtInfo(string str)
|
|||
|
{
|
|||
|
txtInfo.text=str;
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public void ResetData()
|
|||
|
{
|
|||
|
can.alpha = 0;
|
|||
|
addTime = 0;
|
|||
|
rec.position = Vector3.zero;
|
|||
|
PoolMgr.Instance.PushObj(this.gameObject);
|
|||
|
}
|
|||
|
}
|