少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, November 02, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using LitJson;
 
namespace Snxxz.UI
{
 
    public class BossIntroduceBehaviour : MonoBehaviour
    {
        [SerializeField] protected FindPreciousType m_FindPreciousType = FindPreciousType.WorldBoss;
        [SerializeField] Transform m_ContainerReward;
        [SerializeField] Transform m_ContainerBossInfo;
 
        [SerializeField] Button m_ViewBossInfo;
        [SerializeField] Button m_ViewReward;
 
        [SerializeField] Text m_BossName;
        [SerializeField] Text m_BossLevel;
        [SerializeField] RawImage m_BossPortrait;
        [SerializeField] BossAbilityBehaviour m_BossAbility;
        [SerializeField] FindPreciousRewardPreviewGroup m_UndoubtedlyRewardGroup;
        [SerializeField] FindPreciousRewardPreviewGroup m_UnusualRewardGroup;
 
        ViewType m_ViewType = ViewType.Reward;
 
        float confirmDelay = 0.3f;
        float confirmTimer = 0f;
        int tempBossId = 0;
        protected int bossId = 0;
 
        public void Display(int _bossId, bool _immediately)
        {
            if (_immediately)
            {
                tempBossId = bossId = _bossId;
                Draw();
            }
            else
            {
                tempBossId = _bossId;
                confirmTimer = 0f;
            }
        }
 
        public void Dispose()
        {
            UI3DModelExhibition.Instance.StopShow();
        }
 
        private void LateUpdate()
        {
            if (tempBossId != bossId)
            {
                confirmTimer += Time.deltaTime;
                if (confirmTimer > confirmDelay)
                {
                    bossId = tempBossId;
                    Draw();
                }
            }
        }
 
        private void Draw()
        {
            switch (m_ViewType)
            {
                case ViewType.BossInfo:
                    DrawBossInfo();
                    break;
                case ViewType.Reward:
                    DrawReward();
                    break;
            }
        }
 
        private void DrawBossInfo()
        {
            m_ViewType = ViewType.BossInfo;
            m_ContainerReward.gameObject.SetActive(false);
            m_ContainerBossInfo.gameObject.SetActive(true);
 
            var config = NPCConfig.Get(bossId);
            m_BossName.text = config.charName;
            m_BossLevel.text = Language.Get("Z1024", config.NPCLV);
            UI3DModelExhibition.Instance.ShowNPC(bossId, config.UIModeLOffset, config.UIModelRotation, m_BossPortrait);
            m_BossAbility.Display(bossId);
        }
 
        protected virtual void DrawReward()
        {
            UI3DModelExhibition.Instance.StopShow();
            m_ViewType = ViewType.Reward;
            m_ContainerReward.gameObject.SetActive(true);
            m_ContainerBossInfo.gameObject.SetActive(false);
 
            int[] undoubtedlyRewards = null;
            int[] unusualRewards = null;
            int undoubtedlyNewDropId = 0;
            int unusualNewDropId = 0;
 
            switch (m_FindPreciousType)
            {
                case FindPreciousType.WorldBoss:
                    undoubtedlyRewards = WorldBossConfig.Get(bossId).RareItemID;
                    undoubtedlyNewDropId = WorldBossConfig.Get(bossId).NewItemId;
                    break;
                case FindPreciousType.BossHome:
                    undoubtedlyRewards = BossHomeConfig.Get(bossId).RareItemID;
                    undoubtedlyNewDropId = BossHomeConfig.Get(bossId).NewItemId;
                    break;
                case FindPreciousType.ElderGodArea:
                    undoubtedlyRewards = ElderGodAreaConfig.Get(bossId).RareItemID;
                    undoubtedlyNewDropId = ElderGodAreaConfig.Get(bossId).NewItemId;
                    break;
                case FindPreciousType.PersonalBoss:
                    var personalBossConfig = PersonalBossConfig.Get(bossId);
                    undoubtedlyRewards = personalBossConfig.MustItemID;
                    unusualRewards = personalBossConfig.RareItemID;
                    unusualNewDropId = personalBossConfig.NewItemId;
                    break;
                case FindPreciousType.DemonJar:
                    var demonJarConfig = DemonJarConfig.Get(bossId);
 
                    var json = JsonMapper.ToObject(demonJarConfig.MustItemID);
                    var jobJsonData = json[PlayerDatas.Instance.baseData.Job.ToString()];
                    undoubtedlyRewards = new int[jobJsonData.Count];
                    for (int i = 0; i < undoubtedlyRewards.Length; i++)
                    {
                        undoubtedlyRewards[i] = (int)jobJsonData[i];
                    }
                    unusualRewards = demonJarConfig.RareItemID;
                    unusualNewDropId = demonJarConfig.NewItemId;
                    break;
                case FindPreciousType.CrossServerBoss:
                    undoubtedlyRewards = CrossServerBossConfig.Get(bossId).RareItemID;
                    undoubtedlyNewDropId = CrossServerBossConfig.Get(bossId).NewItemId;
                    break;
            }
 
            if (m_UndoubtedlyRewardGroup != null)
            {
                if (undoubtedlyRewards != null && undoubtedlyRewards.Length > 0)
                {
                    m_UndoubtedlyRewardGroup.gameObject.SetActive(true);
                    m_UndoubtedlyRewardGroup.Display(undoubtedlyNewDropId, undoubtedlyRewards);
                }
                else
                {
                    m_UndoubtedlyRewardGroup.gameObject.SetActive(false);
                }
            }
 
            if (m_UnusualRewardGroup != null)
            {
                if (unusualRewards != null && unusualRewards.Length > 0)
                {
                    m_UnusualRewardGroup.gameObject.SetActive(true);
                    m_UnusualRewardGroup.Display(unusualNewDropId, unusualRewards);
                }
                else
                {
                    m_UnusualRewardGroup.gameObject.SetActive(false);
                }
            }
 
        }
 
        private void Awake()
        {
            m_ViewBossInfo.AddListener(DrawBossInfo);
            m_ViewReward.AddListener(DrawReward);
        }
 
        public enum ViewType
        {
            BossInfo,
            Reward,
        }
 
    }
 
}