少年修仙传客户端代码仓库
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace vnxbqy.UI
{
    
    
    public class FashionDecomposeModel : Singleton<FashionDecomposeModel>
    {
        FashionDressModel model {
            get { return ModelCenter.Instance.GetModel<FashionDressModel>(); }
        }
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        public Dictionary<string, DecomposeItem> decomposeItemDict = new Dictionary<string, DecomposeItem>();
        public List<string> decomposeItemGuids { get; private set; }
        public event Action UpdateDecomposeExpEvent;
        List<int> fashionMatIds = new List<int>();
 
        public void GetDecomposeItem()
        {
            decomposeItemGuids = null;
            decomposeItemDict.Clear();
            SinglePack singlePack = playerPack.GetSinglePack(PackType.Item);
            if (singlePack == null) return;
 
            fashionMatIds.Clear();
            model.TryGetSatisfyResolves(ref fashionMatIds);
            foreach (var matId in fashionMatIds)
            {
                var itemModels = singlePack.GetItemsById(matId);
                if (itemModels != null)
                {
                    foreach (var model in itemModels)
                    {
                        var decomposeItem = new DecomposeItem();
                        decomposeItem.SetModel(model);
                        decomposeItemDict.Add(decomposeItem.guid, decomposeItem);
                    }
                }
            }
            decomposeItemGuids = decomposeItemDict.Keys.ToList();
        }
 
        public void UpdateDecomposeItem(string guid, bool _isSelect)
        {
            DecomposeItem decomposeItem = null;
            bool isItem = TryGetDecomposeItem(guid, out decomposeItem);
            if (isItem)
            {
                decomposeItem.SetIsSelect(_isSelect);
                if (UpdateDecomposeExpEvent != null)
                {
                    UpdateDecomposeExpEvent();
                }
            }
        }
 
        public bool TryGetDecomposeItem(string guid, out DecomposeItem decomposeItem)
        {
            return decomposeItemDict.TryGetValue(guid, out decomposeItem);
        }
 
        public int GetSumDecomposeExp()
        {
            int sumExp = 0;
            foreach (var guid in decomposeItemDict.Keys)
            {
                var decomposeItem = decomposeItemDict[guid];
                if (decomposeItem.isSelect)
                {
                    sumExp += decomposeItem.decomposeExp;
                }
            }
            return sumExp;
        }
 
        public void GetSelectItemlist(out List<ushort> indexs, out List<uint> ids)
        {
            indexs = new List<ushort>();
            ids = new List<uint>();
            foreach (var item in decomposeItemDict.Values)
            {
                if (item.isSelect)
                {
                    indexs.Add((ushort)item.itemModel.gridIndex);
                    ids.Add((uint)item.itemModel.itemId);
                }
            }
        }
 
        public void SendDecomposeFashion()
        {
            List<ushort> indexs = null;
            List<uint> ids = null;
            GetSelectItemlist(out indexs, out ids);
            CA520_tagCMCoatDecompose coatDecompose = new CA520_tagCMCoatDecompose();
            coatDecompose.Count = (byte)indexs.Count;
            coatDecompose.IndexList = indexs.ToArray();
            coatDecompose.ItemIDList = ids.ToArray();
            GameNetSystem.Instance.SendInfo(coatDecompose);
        }
 
        public class DecomposeItem
        {
            public string guid { get; private set; }
            public bool isSelect { get; private set; }
            public ItemModel itemModel { get; private set; }
            public int decomposeExp { get; private set; }
 
            public void SetModel(ItemModel _model)
            {
                guid = _model.guid;
                isSelect = true;
                itemModel = _model;
                if (itemModel.config.Effect1 == 243)
                {
                    decomposeExp = itemModel.config.EffectValueB1 * itemModel.count;
                }
                else
                {
                    decomposeExp = 0;
                }
            }
 
            public void SetIsSelect(bool _isSelect)
            {
                isSelect = _isSelect;
            }
        }
    }
}