少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
using System;
using LitJson;
 
namespace vnxbqy.UI
{
    
    
    public class CrossServerModel : Model, IPlayerLoginOk
    {
        
        public override void Init()
        {
            ParseConfig();
        }
 
        public override void UnInit()
        {
        }
 
        public void OnPlayerLoginOk()
        {
        }
 
        private void ParseConfig()
        {
            var config = FuncConfigConfig.Get("CrossBattlefieldCrystal");
            var json = JsonMapper.ToObject(config.Numerical1);
            foreach (var key in json.Keys)
            {
                crystalIDList.Add(int.Parse(key));
            }
            crystalIDList.Sort();
            npcModelReplaceIDs = JsonMapper.ToObject<int[][]>(config.Numerical5);  //根据阵营替换模型的NPCID
        }
 
 
        //GeneralDefine.CrossBattleFieldMapID 32060
        Dictionary<int, int> warCrystalDict = new Dictionary<int, int>();   //水晶npcid对应阵营
        public int[][] npcModelReplaceIDs;
        List<int> crystalIDList = new List<int>();    //灰色水晶
        public event Action CrystalBelongChangeEvent;
        public void UpdateFBHelp(string _mission)
        {
            var _jsonData = JsonMapper.ToObject(_mission);
            foreach (var _key in _jsonData.Keys)
            {
                if (_key == "worldInfo")
                { 
                    var json = _jsonData[_key];
                    foreach (var key in json.Keys)
                    {
                        //"crystalFactionInfo": {"30908101": 1, "30908103": 2},     资源水晶NPCID对应所属阵营  {"npcID":所属阵营}
                        if (key == "crystalFactionInfo")
                        {
                            warCrystalDict.Clear();
                            var factionDict = JsonMapper.ToObject(json[key].ToJson());
 
                            foreach (var key1 in factionDict.Keys)
                            {
                                warCrystalDict[int.Parse(key1)] = int.Parse(factionDict[key1].ToJson());
                            }
 
                            CrystalBelongChangeEvent?.Invoke();
                            break;
                        }
                    }
                    break;
                }
            }
        }
 
        //获得水晶当前阵营
        public int GetCrystalFaction(int npcID)
        {
            if (!warCrystalDict.ContainsKey(npcID))
            {
                return 0;
            }
 
            return warCrystalDict[npcID];
        }
 
        public int GetNewCrystalID(int npcID, int faction)
        {
            if (faction == 0) return npcID;
            return npcModelReplaceIDs[faction - 1][crystalIDList.IndexOf(npcID)];
        }
    }
 
}