少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, January 06, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class NewGuideWin : Window
    {
        public SquareHollowImage holdImage;
        public RectTransform container;
 
        public RectTransform rtSelectFrame;
        public FakeButton2 btnFake;
 
        public RectTransform rtContent;
        public Text txtContent;
 
        public RectTransform rtArrow;
 
        private Transform m_PreParent;
        private Transform m_HighLight;
 
        private UnityEngine.Events.UnityAction onClose;
        private byte m_Direction;
        private bool m_PressClose;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
        }
 
        protected override void OnPreOpen()
        {
            btnFake.RemoveAllListeners();
            btnFake.AddListener(OnClick);
            NewGuideModel _model = ModelCenter.Instance.GetModel<NewGuideModel>();
            m_HighLight = WindowCenter.Instance.uiRoot.transform.Find(_model.componentPath);
 
            holdImage.cell = _model.size;
            rtSelectFrame.sizeDelta = _model.size + new Vector2(15, 15);
            if (string.IsNullOrEmpty(_model.content))
            {
                rtContent.SetActive(false);
            }
            else
            {
                rtContent.SetActive(true);
            }
            txtContent.text = _model.content;
            m_PressClose = _model.pressedClose;
            rtArrow.localScale = Vector3.one * _model.arrowScale;
            container.SetActive(_model.showMask);
 
            if (_model.onClose != null)
            {
                onClose = _model.onClose;
            }
 
            m_Direction = _model.direction;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            if (onClose != null)
            {
                onClose();
                onClose = null;
            }
        }
 
        protected override void OnAfterClose()
        {
            btnFake.RemoveAllListeners();
        }
        #endregion
 
        protected override void LateUpdate()
        {
            base.LateUpdate();
 
            if (m_PressClose)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    var sp = Input.mousePosition;
                    if (RectTransformUtility.RectangleContainsScreenPoint(rtSelectFrame.transform as RectTransform, sp, CameraManager.uiCamera))
                    {
                        OnClick();
                        return;
                    }
                }
            }
 
            if (m_HighLight == null)
            {
                return;
            }
 
            if (m_HighLight.position != rtSelectFrame.transform.position)
            {
                rtSelectFrame.transform.position = m_HighLight.position;
                holdImage.center = holdImage.transform.InverseTransformPoint(m_HighLight.position);
 
                Vector2 _arrowPosition = Vector3.zero;
                Vector2 _contentPosition = Vector3.zero;
                Vector3 _rotation = Vector3.zero;
 
                if (m_Direction == 0)// 上
                {
                    _arrowPosition = rtSelectFrame.anchoredPosition + new Vector2(0, rtSelectFrame.sizeDelta.y * .5f + 20f);
                    _contentPosition = _arrowPosition + new Vector2(0, rtArrow.sizeDelta.y * .5f + rtContent.sizeDelta.y * .5f + 5);
                    _rotation = new Vector3(0, 0, 90);
                }
                else if (m_Direction == 1)// 下
                {
                    _arrowPosition = rtSelectFrame.anchoredPosition + new Vector2(0, -rtSelectFrame.sizeDelta.y * .5f - 20f);
                    _contentPosition = _arrowPosition + new Vector2(0, -rtArrow.sizeDelta.y * .5f - rtContent.sizeDelta.y * .5f - 5);
                    _rotation = new Vector3(0, 0, 270);
                }
                else if (m_Direction == 2)// 左
                {
                    _arrowPosition = rtSelectFrame.anchoredPosition + new Vector2(-rtSelectFrame.sizeDelta.x * .5f - 20f, 0);
                    _contentPosition = _arrowPosition + new Vector2(-rtArrow.sizeDelta.x * .5f - rtContent.sizeDelta.x * .5f - 5, 0);
                    _rotation = new Vector3(0, 0, 180);
                }
                else if (m_Direction == 3)// 右
                {
                    _arrowPosition = rtSelectFrame.anchoredPosition + new Vector2(rtSelectFrame.sizeDelta.x * .5f + 20f, 0);
                    _contentPosition = _arrowPosition + new Vector2(rtArrow.sizeDelta.x * .5f + rtContent.sizeDelta.x * .5f + 5, 0);
                    _rotation = Vector3.zero;
                }
 
                rtArrow.anchoredPosition = _arrowPosition;
                rtArrow.eulerAngles = _rotation;
                rtContent.anchoredPosition = _contentPosition;
            }
 
        }
 
        private void OnClick()
        {
 
            NewGuideModel _model = ModelCenter.Instance.GetModel<NewGuideModel>();
            if (_model.clickClosed)
            {
                WindowCenter.Instance.Close<NewGuideWin>();
            }
        }
    }
 
}