少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-19 77561bb15f0a5d45146fdf454726393e3987cc23
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
using UnityEngine;
using UnityEngine.UI;
 
using System.Collections.Generic;
 
namespace Snxxz.UI
{
    public class ModelShowPerfab : MonoBehaviour
    {
        [SerializeField] public Text titleText;
        [SerializeField] public RawImage modelImg;
        [SerializeField] public Text fightPowerText;
        [SerializeField] public Image fightImg;
 
        ModelShowType showType;
        FashionDressModel fashionDressModel { get { return ModelCenter.Instance.GetModel<FashionDressModel>(); } }
        ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
        PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
 
        MagicianModel godWeaponModel
        {
            get { return ModelCenter.Instance.GetModel<MagicianModel>(); }
        }
 
        public void OnDisable()
        {
            switch (showType)
            {
                case ModelShowType.treasure:
                    UI3DTreasureExhibition.Instance.StopShow();
                    break;
                case ModelShowType.mount:
                    break;
                case ModelShowType.pet:
                    break;
            }
        }
 
        public void SetModelShow(int id, ModelShowType showType, string title, int fightValue = 0)
        {
            titleText.text = title;
            this.showType = showType;
            var job = PlayerDatas.Instance.baseData.Job;
           
            switch (showType)
            {
                case ModelShowType.treasure:
                    fightImg.SetSprite("FightingLv_Normal");
                    UI3DTreasureExhibition.Instance.BeginShowTreasure(id, modelImg);
                    break;
                case ModelShowType.mount:
                    fightImg.SetSprite("FightingLv_Max");
                    UI3DModelExhibition.Instance.ShowHourse(id, modelImg);
                    break;
                case ModelShowType.pet:
                    fightImg.SetSprite("FightingLv_Max");
                    var npcConfig = NPCConfig.Get(id);
                    UI3DModelExhibition.Instance.ShowNPC(id, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, modelImg);
                    break;
                case ModelShowType.FashionDress:
                    fightImg.SetSprite("FightingLv_Normal");
                    var itemConfig = ItemConfig.Get(id);
                    if(itemConfig != null)
                    {
                        int fashionType = 0;
                        int fashionId = 0;
                        bool isFashion = tipsModel.TryGetItemFashionData(itemConfig.ID, out fashionType, out fashionId);
                        if(isFashion)
                        {
                            List<int> fashionIds = null;
                            fashionDressModel.TryGetFashionIds(fashionType, out fashionIds);
                            if(fashionIds != null && fashionIds.Count > 0)
                            {
                                UI3DModelExhibition.Instance.ShowOtherPlayer(modelImg, SetFashionDressData(fashionIds));
                            }
                        }
                      
                    }
                    break;
                case ModelShowType.Magic:
                    SetMagicFightImg(id);
                    UI3DModelExhibition.Instance.ShowOtherPlayer(modelImg, SetMagicData(id));
                    break;
            }
 
            if (fightValue == 0)
            {
                fightImg.gameObject.SetActive(false);
                fightPowerText.gameObject.SetActive(false);
            }
            else
            {
                fightImg.gameObject.SetActive(true);
                fightPowerText.gameObject.SetActive(true);
                fightPowerText.text = fightValue.ToString();
                fightImg.SetNativeSize();
            }
        }
 
        public UI3DPlayerExhibitionData SetFashionDressData(List<int> fashionIds)
        {
            var job = PlayerDatas.Instance.baseData.Job;
 
            //var playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>();
 
            //var clothes = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retClothes);
            //var clothesId = clothes == null ? 0 : (int)clothes.itemInfo.ItemID;
 
            //var weapon = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWeapon);
            //var weaponId = weapon == null ? 0 : (int)weapon.itemInfo.ItemID;
 
            //var wings = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWing);
            //var wingsId = wings == null ? 0 : (int)wings.itemInfo.ItemID;
 
            //var secondary = playerPack.GetItemModelByIndex(PackType.rptEquip, (int)RoleEquipType.retWeapon2);
            //var secondaryId = secondary == null ? 0 : (int)secondary.itemInfo.ItemID;
            var fashionClothesId = 0;
            var fashionWeaponId = 0;
            var fashionSecondaryId = 0;
            foreach(var fashionId in fashionIds)
            {
                FashionDress fashionDress = null;
                bool isFashion = fashionDressModel.TryGetFashionDress(fashionId, out fashionDress);
                if (isFashion)
                {
                    int itemId = fashionDress.requireLevelUpItem;
                    var itemConfig = ItemConfig.Get(itemId);
                    switch (fashionDress.fashionDressType)
                    {
                        case 1:
                            fashionClothesId = fashionDress.GetEquipItemId();
                            break;
                        case 2:
                            fashionWeaponId = fashionDress.GetEquipItemId();
                            break;
                        case 3:
                            fashionSecondaryId = fashionDress.GetEquipItemId();
                            break;
                    }
                }
 
            }
 
            //int _suitLevel = 0;
            //ItemUseDataKey
            //if (clothes != null)
            //{
            //    if (clothes.itemInfo.IsSuite == 1)
            //    {
            //        if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
            //        {
            //            _suitLevel = clothes.GetUseDataModel(30)[0];
            //        }
            //    }
            //}
 
            //Dictionary<int, int> dict = null;
            //EquipShowSwitch.IsGodWeaponEffectOn(PlayerDatas.Instance.baseData.equipShowSwitch, out dict);
 
            UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData()
            {
                job = job,
                //clothesId = clothesId,
                //suitLevel = _suitLevel,
                //weaponId = weaponId,
                //wingsId = wingsId,
                //secondaryId = secondaryId,
                fashionClothesId = fashionClothesId,
                fashionWeaponId = fashionWeaponId,
                fashionSecondaryId = fashionSecondaryId,
                isDialogue = false,
                //godWeapons = dict
            };
            return data;
        }
 
        private UI3DPlayerExhibitionData SetMagicData(int itemId)
        {
            var job = PlayerDatas.Instance.baseData.Job;
 
            var clothes = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Clothes);
            var clothesId = clothes == null ? 0 : (int)clothes.itemInfo.ItemID;
 
            var weapon = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Weapon);
            var weaponId = weapon == null ? 0 : (int)weapon.itemInfo.ItemID;
 
            var wings = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Wing);
            var wingsId = wings == null ? 0 : (int)wings.itemInfo.ItemID;
 
            var secondary = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.Weapon2);
            var secondaryId = secondary == null ? 0 : (int)secondary.itemInfo.ItemID;
 
            var fashionClothes = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionClothes);
            var fashionClothesId = fashionClothes == null ? 0 : (int)fashionClothes.itemInfo.ItemID;
 
            var fashionWeapon = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon);
            var fashionWeaponId = fashionWeapon == null ? 0 : (int)fashionWeapon.itemInfo.ItemID;
 
            var fashionSecondary = playerPack.GetItemModelByIndex(PackType.Equip, (int)RoleEquipType.FashionWeapon2);
            var fashionSecondaryId = fashionSecondary == null ? 0 : (int)fashionSecondary.itemInfo.ItemID;
 
            int _suitLevel = 0;
 
            if (clothes != null)
            {
                if (clothes.itemInfo.IsSuite == 1)
                {
                    if (clothes.GetUseDataModel(30) != null && clothes.GetUseDataModel(30)[0] != 0)
                    {
                        _suitLevel = clothes.GetUseDataModel(30)[0];
                    }
                }
            }
 
            int magicType = 0;
            bool isMagic = godWeaponModel.TryGetMagicType(itemId, out magicType);
            int magicEffectStage = godWeaponModel.GetGodWeaponStage(magicType) + 1;
            magicEffectStage = magicEffectStage > 3 ? 3 : magicEffectStage;
            Dictionary<int, int> dict = new Dictionary<int, int>();
            if(isMagic)
            {
                dict[magicType] = godWeaponModel.GetGodWeaponStageRequireLevel(magicType, magicEffectStage);
            }
           
            UI3DPlayerExhibitionData data = new UI3DPlayerExhibitionData()
            {
                job = job,
 
                fashionClothesId = fashionClothesId,
                fashionWeaponId = fashionWeaponId,
                fashionSecondaryId = fashionSecondaryId,
                clothesId = clothesId,
                suitLevel = _suitLevel,
                weaponId = weaponId,
                wingsId = wingsId,
                secondaryId = secondaryId,
                isDialogue = false,
                godWeapons = dict
            };
            return data;
        }
 
        private void SetMagicFightImg(int itemId)
        {
            int magicType = 0;
            bool isMagic = godWeaponModel.TryGetMagicType(itemId, out magicType);
            if (!isMagic) return;
 
            int magicEffectStage = godWeaponModel.GetGodWeaponStage(magicType) + 1;
            magicEffectStage = magicEffectStage > 3 ? 3 : magicEffectStage;
            switch(magicEffectStage)
            {
                case 1:
                    fightImg.SetSprite("FightingLv_100");
                    break;
                case 2:
                    fightImg.SetSprite("FightingLv_200");
                    break;
                case 3:
                    fightImg.SetSprite("FightingLv_300");
                    break;
            }
        }
    }
 
    public enum ModelShowType
    {
        treasure, //法宝
        mount, //坐骑
        pet, //灵宠
        FashionDress, //时装
        Magic,//神兵
    }
}