using UnityEngine.UI;
|
using UnityEngine;
|
|
public class DropCoinImage : MonoBehaviour
|
{
|
Button tmpBtn;
|
FlyImage flyImage;
|
/// <summary>
|
/// Awake is called when the script instance is being loaded.
|
/// </summary>
|
void Awake()
|
{
|
tmpBtn = transform.GetComponent<Button>();
|
flyImage = transform.GetComponent<FlyImage>();
|
tmpBtn.onClick.AddListener(OnClick);
|
}
|
|
private void OnClick()
|
{
|
StartFly();
|
}
|
bool countdown;
|
float timer;
|
|
public void Init()
|
{
|
timer = 0;
|
countdown = true;
|
tmpBtn.interactable = true;
|
}
|
|
|
// Update is called once per frame
|
void Update()
|
{
|
if (countdown)
|
{
|
timer += Time.deltaTime;
|
if (timer >= 3)
|
{
|
countdown = false;
|
StartFly();
|
}
|
}
|
}
|
|
private void StartFly()
|
{
|
tmpBtn.interactable = false;
|
RectTransform end = GameObject.Find("UICamera/MainUI/FlyEndPos").GetComponent<RectTransform>();
|
flyImage.SetDestination(null, transform.position, end.position, true);
|
|
}
|
}
|