chenxin
2020-11-26 b3597e5148e64a08abe5730396c4018ccfa76e22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
        
    }
}