少年修仙传客户端代码仓库
client_Hale
2018-10-13 241d15b925ee77a2ec0800191aaffd27a8fc79a0
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
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)
        {
            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,
    }
 
    public enum E_TriggerType
    {
        Mission,
        Area,
    }
}