少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
55
56
57
58
59
60
61
62
63
64
65
66
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, March 28, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
 
namespace vnxbqy.UI
{
 
    public class MainWinRightBottomGrid : MonoBehaviour
    {
        [SerializeField] int m_Index;
        public int index { get { return m_Index; } }
 
        [SerializeField] int m_FunctionId;
        [SerializeField] RectTransform m_Content;
        [SerializeField] CanvasGroup m_CanvasGroup;
 
        public RectTransform rectTransform { get { return this.transform as RectTransform; } }
 
        float targetX = 0f;
        float targetAlpha = 0f;
 
        public void Switch(bool active, float offset, float delay)
        {
            targetX = active ? 0 : (120f + SafeAreaUI.SafeWidth + offset);
            targetAlpha = active ? 1f : 0f;
 
            if (active)
            {
                m_Content.DOLocalMoveX(targetX, 0.3f).SetDelay(delay).SetEase(Ease.OutSine);
            }
            else
            {
                m_Content.DOLocalMoveX(targetX, 0.3f).SetDelay(delay).SetEase(Ease.InSine);
            }
 
            m_CanvasGroup.DOFade(targetAlpha, 0.3f).SetDelay(delay).SetEase(active ? Ease.OutSine : Ease.InSine);
            m_CanvasGroup.blocksRaycasts = active;
        }
 
        public void SwitchImmediately(bool active, float offset)
        {
            targetX = active ? 0 : 120f + SafeAreaUI.SafeWidth + offset;
            targetAlpha = active ? 1f : 0f;
            m_Content.anchoredPosition = m_Content.anchoredPosition.SetX(targetX);
            m_CanvasGroup.alpha = targetAlpha;
            m_CanvasGroup.blocksRaycasts = active;
        }
 
        public bool IsOpen()
        {
            if (m_FunctionId > 0)
            {
                return FuncOpen.Instance.IsFuncOpen(m_FunctionId);
            }
 
            return true;
        }
 
    }
 
}