少年修仙传客户端代码仓库
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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, October 30, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using EnhancedUI.EnhancedScroller;
 
namespace vnxbqy.UI
{
 
    public class FeatureNotice2Win : Window,SecondWindowInterface
    {
        [SerializeField] ScrollerController m_ScrollerController;
        [SerializeField] ScaleTween m_ScaleTween;
        FeatureNoticeModel featureNoticeModel { get { return ModelCenter.Instance.GetModel<FeatureNoticeModel>(); } }
        public int Offset = 0;//偏移
        private bool IsJump = false;
 
        public Button close { get; set; }
        #region Built-in
        protected override void BindController()
        {
            if (this is SecondWindowInterface)
            {
                var frame = this.GetComponentInChildren<SecondFrameLoader>();
                frame.Create();
                close = frame.GetComponentInChildren<Button>();
            }
        }
 
        protected override void AddListeners()
        {
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
            close.AddListener(OnClickBtn);
        }
 
        protected override void OnPreOpen()
        {
            UnopenedFirst();
            m_ScaleTween.SetStartState();
            IsJump = WindowJumpMgr.Instance.IsJumpState;
            OnCreateGridLineCell(m_ScrollerController);
        }
 
        protected override void OnAfterOpen()
        {
            if (!IsJump)//是否经历跳转打开
            {
                m_ScaleTween.Play(false, IsOpen);
            }
            else
            {
                m_ScaleTween.SetEndState();
            }
            featureNoticeModel.UpdateAwarfItem += UpdateAwarfItem;
        }
 
        private void UpdateAwarfItem()
        {
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
            featureNoticeModel.UpdateAwarfItem -= UpdateAwarfItem;
        }
        protected override void OnActived()
        {
            var offset = 0f;
            m_ScrollerController.JumpIndex(JumpIndex(), ref offset);
            m_ScrollerController.JumpIndex(Offset + offset, 0, EnhancedScroller.TweenType.immediate);
        }
        private void OnClickBtn()
        {
            if (!WindowJumpMgr.Instance.IsJumpState)//是否经历跳
            {
                m_ScaleTween.Play(true, IsClose);
            }
            else
            {
                Close();
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
        }
        void OnCreateGridLineCell(ScrollerController gridCtrl)
        {
            gridCtrl.Refresh();
            for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
            {
                gridCtrl.AddCell(ScrollerDataType.Header, featureNoticeModel.FunctionList[i].FuncId);
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            int funcId = cell.index;
            Transform Tran = cell.transform;
            GameObject Tran1 = Tran.Find("FeaturesTypeOne").gameObject;
            GameObject Tran2 = Tran.Find("FeaturesTypeTwo").gameObject;
            var configs = FunctionForecastConfig.Get(funcId);
            if (configs.OpenNumber == featureNoticeModel.FunctionForecastIndex)
            {
               
                Tran1.SetActive(false);
                Tran2.SetActive(true);
                FeaturesType3 featuresType3 = Tran2.GetComponent<FeaturesType3>();
                featuresType3.GetTheFeatureID(funcId);
                return;
            }
            else
            {
                Tran1.SetActive(true);
                Tran2.SetActive(false);
                FeaturesType3 featuresType3 = Tran1.GetComponent<FeaturesType3>();
                featuresType3.GetTheFeatureID(funcId);
                return;
            }
 
        }
 
        private void IsOpen()
        {
        }
 
        private void IsClose()
        {
            Close();
            WindowCenter.Instance.Open<MainInterfaceWin>();
        }
        List<FunctionForecastConfig> con_fig = new List<FunctionForecastConfig>();
        private void UnopenedFirst()            ///找到第一个不是打开状态的细胞的的openNumber
        {
            if (con_fig.Count <= 0)
            {
                con_fig = FunctionForecastConfig.GetValues();
            }
           // var configs = FunctionForecastConfig.GetValues();
            foreach (var config in con_fig)
            {
                int openTag = config.FuncId;
                if (!FuncOpen.Instance.IsFuncOpen(openTag))
                {
                    featureNoticeModel.FunctionForecastIndex = config.OpenNumber;
                    return;
                }
            }
        }
 
        private int JumpIndex()//Jump选中
        {
            int Index = 0;
            for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
            {
                int funcID = featureNoticeModel.FunctionList[i].FuncId;
                if (featureNoticeModel.DicRedPoint.ContainsKey(funcID) && featureNoticeModel.DicRedPoint[funcID].state==RedPointState.Simple)
                {
                    Index = i;
                    return Index;
                }
            }
            Index = featureNoticeModel.FunctionList.FindIndex((x) =>
            {
                return x.OpenNumber == featureNoticeModel.FunctionForecastIndex;
            });
            if (Index == -1)
            {
                Index = 0;
            }
            return Index;
        }
        #endregion
 
    }
 
}