少年修仙传客户端代码仓库
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
using UnityEngine;
using System.IO;
using System.Collections.Generic;
 
namespace H2Engine
{
    [System.Serializable]
    public class MapData
    {
        public const string MapEditorData_Suffix = "MapData_";
 
        public int id;
        public MapTrigger[] triggers;
        public Dictionary<int, Evt> eventDict = new Dictionary<int, Evt>();
        public MapTrasfer[] transfers;
 
        public static MapData LoadFormFile(int mapID)
        {
            string _path = null;
            if (AssetSource.refdataFromEditor)
            {
#if UNITY_EDITOR
                _path = StringUtility.Contact(ResourcesPath.CONFIG_FODLER,
                                              "/",
                                              MapEditorData_Suffix,
                                              mapID,
                                              ".txt");
#endif
            }
            else
            {
                _path = AssetVersionUtility.GetAssetFilePath(StringUtility.Contact("config/", MapEditorData_Suffix, mapID, ".txt"));
            }
            MapData _mapData = null;
            if (File.Exists(_path))
            {
                using (var _fileStream = File.OpenRead(_path))
                {
                    using (var _br = new BinaryReader(_fileStream))
                    {
                        _mapData = new MapData();
                        _mapData.Load(_br);
                    }
                }
            }
            return _mapData;
        }
 
        public void Load(BinaryReader br)
        {
            id = br.ReadInt32();
            int _count = br.ReadInt32();
            triggers = new MapTrigger[_count];
            for (int i = 0; i < _count; ++i)
            {
                triggers[i] = new MapTrigger();
                triggers[i].Load(br);
            }
            _count = br.ReadInt32();
            for (int i = 0; i < _count; ++i)
            {
                var _type = (Evt.E_EventType)br.ReadByte();
                Evt _event = null;
                if (_type == Evt.E_EventType.Enemy)
                {
                    _event = new Evt_RefreshMonster();
                }
                else if (_type == Evt.E_EventType.SceneObject)
                {
                    _event = new Evt_RefreshSceneObject();
                }
                if (_event != null)
                {
                    _event.type = _type;
                    _event.Load(br);
                    eventDict[_event.id] = _event;
                }
            }
            _count = br.ReadInt32();
            transfers = new MapTrasfer[_count];
            for (int i = 0; i < _count; ++i)
            {
                transfers[i] = new MapTrasfer();
                transfers[i].Load(br);
            }
        }
    }
}