少年修仙传客户端代码仓库
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
186
187
188
189
190
191
192
193
194
195
196
197
using LitJson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class HumanTreasureTaskCell : CellView
    {
        [SerializeField] UIEffect m_EffectAppear;
        [SerializeField] UIEffect m_EffectGoto;
        [SerializeField] UIAlphaTween m_AlphaTween;
        [SerializeField] Text m_ClueName;
        [SerializeField] Transform m_ContainerCollected;
        [SerializeField] Transform m_ContainerCollecting;
        [SerializeField] Button m_Goto;
        [SerializeField] Transform m_ContainerCutline;
        [SerializeField] VerticalLayoutGroup m_ContainerTasks;
        [SerializeField] List<Text> m_TaskNames;
        [SerializeField] Transform awardObj;
        [SerializeField] List<ItemCell> itemCells;
        [SerializeField] Button getAward;
        [SerializeField] ImageEx getAwardImg;
        public Text taskName {
            get { return m_TaskNames[0]; }
        }
 
 
        public VerticalLayoutGroup taskLayout {
            get { return m_ContainerTasks; }
        }
 
        public static int lastClue = 0;
 
        TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
        RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
 
        private void Awake()
        {
            m_Goto.AddListener(Goto);
        }
 
        private void OnDisable()
        {
            StopAllCoroutines();
        }
 
        public void Display(int clue, bool animationStep, float displayTime)
        {
            var config = TreasureConfig.Get(model.selectedTreasure);
            Dictionary<int, List<int>> clues;
            if (!model.TryGetTreasureClues(model.selectedTreasure, out clues)
                || !clues.ContainsKey(clue))
            {
                return;
            }
            var tasks = clues[clue];
            var taskConfig = TaskListConfig.Get(tasks[0]);
            this.gameObject.name = StringUtility.Contact("HumanTreasureTaskCell_", taskConfig.TaskID);
            m_ClueName.text = taskConfig.clueName;
 
            var clueState = model.GetClueState(model.selectedTreasure, clue);
 
            m_ContainerCollected.SetActive(clueState == 2);
            m_ContainerCollecting.SetActive(clueState == 1);
            m_ContainerTasks.SetActive(clueState == 1 && tasks.Count > 0);
            if (clueState == 1 && tasks.Count > 0)
            {
                CreateTaskNames(tasks.Count);
                var taskId = taskModel.GetLatestMainTaskId();
                for (int i = 0; i < m_TaskNames.Count; i++)
                {
                    m_TaskNames[i].SetActive(i < tasks.Count);
                    if (i < tasks.Count)
                    {
                        taskConfig = TaskListConfig.Get(tasks[i]);
                        var taskInfoConfig = TASKINFOConfig.Get(taskConfig.TaskName);
                        if (taskInfoConfig != null)
                        {
                            m_TaskNames[i].text = taskInfoConfig.show_writing;
                            m_TaskNames[i].color = tasks[i] >= taskId ? UIHelper.s_Gray : UIHelper.s_LightYellow;
                        }
                        else
                        {
                            DebugEx.LogError("TASKINFOConfig 表格没有Key:" + taskConfig.TaskName);
                        }
                    }
                }
            }
 
            m_ClueName.color = clueState == 0 ? UIHelper.s_Gray : UIHelper.s_LightYellow;
 
            m_ContainerCutline.SetActive(lastClue != clue);
 
            if (!animationStep || !gameObject.activeInHierarchy)
            {
                m_AlphaTween.SetEndState();
                m_EffectGoto.SetActive(true);
            }
            else
            {
                m_AlphaTween.SetStartState();
                StartCoroutine(Co_Display(displayTime));
                m_EffectGoto.SetActive(false);
            }
 
            TaskListConfig awardTaskConfig = null;
            for (int i = 0; i < tasks.Count; i++)
            {
                var task = tasks[i];
                var taskConfig1 = TaskListConfig.Get(task);
                if (taskConfig1.AwardID != 0)
                {
                    awardTaskConfig = taskConfig1;
                    break;
                }
            }
            if (awardTaskConfig != null && awardTaskConfig.AwardID != 0)
            { 
                awardObj.SetActive(true);
                var awardConfig = CustomAwardConfig.Get(awardTaskConfig.AwardID);
                var awardJson = JsonMapper.ToObject<int[][]>(awardConfig.AwardItemList);
                for (int i = 0; i < itemCells.Count; i++)
                {
                    if (i < awardJson.Length)
                    {
                        itemCells[i].SetActive(true);
                        int itemID = awardJson[i][0];
                        itemCells[i].Init(new ItemCellModel(itemID, false, (ulong)awardJson[i][1]));
                        itemCells[i].button.SetListener(() =>
                        {
                            ItemTipUtility.Show(itemID);
                        });
                    }
                    else
                    {
                        itemCells[i].SetActive(false);
                    }
                }
                var state = roleModel.GetCustomAwardState(awardTaskConfig.AwardID);
 
                getAwardImg.SetActive(state == 2);
                getAward.SetActive(state != 2);
                getAward.SetColorful(getAward.GetComponentInChildren<Text>(), state == 1, 2);
                getAward.interactable = state == 1;
                getAward.SetListener(() => { 
                    roleModel.GetCustomAward(awardTaskConfig.AwardID);
                });
            }
            else
            {
                awardObj.SetActive(false);
            }
        }
 
        IEnumerator Co_Display(float time)
        {
            yield return WaitingForSecondConst.GetWaitForSeconds(time);
            m_EffectAppear.Play();
            m_AlphaTween.Play(OnComplete);
        }
 
        private void OnComplete()
        {
            m_EffectGoto.SetActive(true);
        }
 
        private void Goto()
        {
            WindowJumpMgr.Instance.ClearJumpData();
            WindowCenter.Instance.Close<TreasureBaseWin>();
            WindowCenter.Instance.Open<MainInterfaceWin>();
            var taskId = taskModel.GetLatestMainTaskId();
            taskModel.TaskMove(taskId);
        }
 
        void CreateTaskNames(int count)
        {
            if (m_TaskNames.Count < count)
            {
                var delta = count - m_TaskNames.Count;
                for (int i = 0; i < delta; i++)
                {
                    var go = GameObject.Instantiate(m_TaskNames[0].gameObject);
                    var instance = go.GetComponent<Text>();
                    go.transform.SetParentEx(m_ContainerTasks.transform, Vector3.zero, Quaternion.identity, Vector3.one);
                    m_TaskNames.Add(instance);
                }
            }
        }
    }
}