少年修仙传客户端代码仓库
client_Wu Xijin
2018-09-10 34c01f30d2e26aa76a0ee0a5a06664a25ef3fe5a
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.UI
{
    public class TreasurePotentialLines : MonoBehaviour
    {
        [SerializeField] UIEffect[] m_Lines;
        [SerializeField] RectTransform[] m_Targets;
 
        public void Display(int _index, bool _open)
        {
            m_Lines[_index].StopImediatly();
            if (_open)
            {
                StartCoroutine(Co_Display(_index));
            }
        }
 
        IEnumerator Co_Display(int _index)
        {
            yield return null;
            m_Lines[_index].Play();
            var animator = m_Lines[_index].target.GetAnimator();
            var _frompos = transform.InverseTransformPoint(m_Targets[_index].transform.TransformPoint(Vector3.zero));
            var _angle = VectorUtility.VectorAngle(Vector3.zero, _frompos);
            m_Lines[_index].transform.localEulerAngles = Vector3.zero.SetZ(_angle);
            animator.transform.localScale = Vector3.one.SetY(Vector2.Distance(_frompos, Vector3.zero)
                / TreasureAnimation.LINE_NORMAL_LENGTH * TreasureAnimation.LINE_NORMAL_SCALE);
            animator.Play(TreasureAnimation.POTENTIAL_LINE_STATE_2, 0, 0);
        }
 
        public void Dispose()
        {
            for (int i = 0; i < m_Lines.Length; i++)
            {
                m_Lines[i].StopImediatly();
            }
        }
    }
}