少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using UnityEngine;
using System.Collections.Generic;
 
public class SoMap : ScriptableObject
{
    public int mapID;
 
    public List<MissionTrigger> missionTriggerList = new List<MissionTrigger>();
    public List<AreaTrigger> areaTriggerList = new List<AreaTrigger>();
 
    [System.Serializable]
    public class MissionTrigger
    {
        public int id;
        public int state;
        public List<RefreshNPC> refreshNPCList = new List<RefreshNPC>();
        public List<CreateImpasse> createImpasseList = new List<CreateImpasse>();
    }
 
    [System.Serializable]
    public class AreaTrigger
    {
        public int id;
 
        public Vector3 position;
        public Vector3 eulerAngle;
        public Vector3 localScale;
 
        public List<RefreshNPC> refreshNPCList = new List<RefreshNPC>();
        public List<CreateImpasse> createImpasseList = new List<CreateImpasse>();
    }
 
    [System.Serializable]
    public class RefreshNPC : MapEvent
    {
        public int NpcID;
        public E_ClientNpcType npcType;
        public Vector3 position;
        public bool randomPostion;
        public float randomDist;
        public Vector3 eulerAngles;
        public int count = 1;
        public float refreshInterval;
        public int waveCount = 1;
        public float waveInterval;
 
        public RefreshNPC()
        {
            eventType = E_EventType.RefreshNpc;
        }
    }
 
    [System.Serializable]
    public class CreateImpasse : MapEvent
    {
        public int id;
        public Vector3 position;
        public Vector3 eulerAngles;
        public Vector3 localScale;
        public int effectID = -1;
 
        public CreateImpasse()
        {
            eventType = E_EventType.CreateImpasse;
        }
 
        public void Carve()
        {
            General(position, eulerAngles, localScale);
        }
 
        public static UnityEngine.AI.NavMeshObstacle General(Vector3 position, Vector3 eulerAngles, Vector3 scale)
        {
            GameObject _impasse = new GameObject();
 
            position.y = 0;
            _impasse.transform.position = position;
            _impasse.transform.eulerAngles = eulerAngles;
            _impasse.transform.localScale = scale;
 
            UnityEngine.AI.NavMeshObstacle _obstacle = _impasse.AddComponent<UnityEngine.AI.NavMeshObstacle>();
            _obstacle.carving = true;
 
            return _obstacle;
        }
 
        public static UnityEngine.AI.NavMeshObstacle GeneralCircle(Vector3 position, float radius)
        {
            GameObject _impasse = new GameObject();
 
            position.y = 0;
            _impasse.transform.position = position;
            _impasse.transform.localScale = new Vector3(1, 5, 1);
 
            UnityEngine.AI.NavMeshObstacle _obstacle = _impasse.AddComponent<UnityEngine.AI.NavMeshObstacle>();
            _obstacle.shape = UnityEngine.AI.NavMeshObstacleShape.Capsule;
            _obstacle.carving = true;
            _obstacle.radius = radius;
 
            return _obstacle;
        }
 
        public static UnityEngine.AI.NavMeshObstacle General(Vector3 start, Vector3 end, float angle)
        {
            GameObject _impasse = new GameObject();
 
            // 计算长度
            float _length = Vector3.Distance(end * .5f, start * .5f);
            float _width = 1.5f;
 
            float _centerX;
            float _centerZ;
 
            if (end.x > start.x)
            {
                _centerX = (end.x * .5f - start.x * .5f) * .5f + start.x * .5f;
            }
            else
            {
                _centerX = (end.x * .5f - start.x * .5f) * .5f + end.x * .5f;
            }
 
            if (end.z > start.z)
            {
                _centerZ = (end.z * .5f - start.z * .5f) * .5f + start.z * .5f;
            }
            else
            {
                _centerZ = (start.z * .5f - end.z * .5f) * .5f + end.z * .5f;
            }
 
 
#if UNITY_EDITOR
            _impasse.name = "Obstacle_" + _length + "_" + _width;
#endif
            _impasse.transform.position = new Vector3(_centerX, 0, _centerZ);
            _impasse.transform.localScale = new Vector3(_length, 10, _width);
 
            UnityEngine.AI.NavMeshObstacle _obstacle = _impasse.AddComponent<UnityEngine.AI.NavMeshObstacle>();
            _obstacle.transform.eulerAngles = new Vector3(0, angle, 0);
            _obstacle.carving = true;
            return _obstacle;
        }
 
        public static UnityEngine.AI.NavMeshObstacle General(Vector3 start, Vector3 end)
        {
            GameObject _impasse = new GameObject();
 
            // 判断是横向还是纵向的阻挡
            bool _isHorizontal = start.z == end.z;
 
            float _centerX = 0, _centerZ = 0, _width = 0, _height = 0;
 
            if (_isHorizontal)
            {
                _width = start.x > end.x ? (start.x - end.x) * .5f : (end.x - start.x) * .5f;
                _height = 2;
                _centerX = start.x > end.x ? end.x * .5f + _width * .5f : start.x * .5f + _width * .5f;
                _centerZ = start.z * .5f;
            }
            else
            {
                _width = 2;
                _height = start.z > end.z ? (start.z - end.z) * .5f : (end.z - start.z) * .5f;
                _centerZ = start.z > end.z ? end.z * .5f + _height * .5f : start.z * .5f + _height * .5f;
                _centerX = start.x * .5f;
            }
#if UNITY_EDITOR
            _impasse.name = "Obstacle_" + _width + "_" + _height;
#endif
            _impasse.transform.position = new Vector3(_centerX, 0, _centerZ);
            _impasse.transform.localScale = new Vector3(_width, 10, _height);
 
            UnityEngine.AI.NavMeshObstacle _obstacle = _impasse.AddComponent<UnityEngine.AI.NavMeshObstacle>();
            _obstacle.carving = true;
            return _obstacle;
        }
    }
 
    [System.Serializable]
    public class MapEvent
    {
        public E_EventType eventType;
    }
 
    public enum E_EventType
    {
        RefreshNpc,
        CreateImpasse,
        ShowDialog,
        ShowTip,
        ShowIconTip,
        ShowGuide,
        PlayEffect,
        //后续IL开发添加预设
        default1,
        default2,
        default3,
        default4,
        default5,
        default6,
        default7,
        default8,
        default9,
        default10,
    }
 
    public enum E_TriggerType
    {
        Mission,
        Area,
        //后续IL开发添加预设
        default1,
        default2,
        default3,
        default4,
        default5,
        default6,
        default7,
        default8,
        default9,
        default10,
    }
}