From e83bd6acf4401fb0e7e358bca2c0db0e23e4d18f Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期五, 01 三月 2019 18:14:54 +0800
Subject: [PATCH] 6317 【前端】【2.0】场景化单机战斗 编辑器相关内容

---
 Core/MapEditor/Behavior/Bhv_MapTrigger.cs             |   22 ++++++
 Core/MapEditor/Editor/MapEditor.cs                    |    1 
 Core/MapEditor/Behavior/Bhv_MonsterData.cs            |   10 +++
 Core/MapEditor/Behavior/Bhv_Evt_RefreshSceneObject.cs |    2 
 Core/MapEditor/Behavior/Bhv_Evt_RefreshMonster.cs     |   91 ++++++++++++++++++++++++-----
 Core/MapEditor/Data/Event/Evt_RefreshMonster.cs       |    5 +
 Fight/Stage/Dungeon/DungeonStage.cs                   |   17 +++++
 Core/MapEditor/Data/MapTrigger.cs                     |    3 
 8 files changed, 127 insertions(+), 24 deletions(-)

diff --git a/Core/MapEditor/Behavior/Bhv_Evt_RefreshMonster.cs b/Core/MapEditor/Behavior/Bhv_Evt_RefreshMonster.cs
index 25b5cef..0eee7dd 100644
--- a/Core/MapEditor/Behavior/Bhv_Evt_RefreshMonster.cs
+++ b/Core/MapEditor/Behavior/Bhv_Evt_RefreshMonster.cs
@@ -11,7 +11,7 @@
     public class Bhv_Evt_RefreshMonster : Bhv_Evt
     {
         [HideInInspector]
-        public Evt_RefreshMonster.E_OverCondition overCondition = Evt_RefreshMonster.E_OverCondition.None;
+        public Evt_RefreshMonster.E_OverCondition overCondition = Evt_RefreshMonster.E_OverCondition.DeadCount;
         [HideInInspector]
         public Evt_RefreshMonster.E_RefreshType refreshType = Evt_RefreshMonster.E_RefreshType.All;
         [HideInInspector]
@@ -20,11 +20,15 @@
         public int conditionParam;
         [HideInInspector]
         public int overParam;
+        [HideInInspector]
+        public int nextEventID = -1;
 
 #if UNITY_EDITOR
 
         [HideInInspector]
         private bool showMonsterList = false;
+        private int npcID = -1;
+        private string resName;
 
         public override void Save(BinaryWriter bw)
         {
@@ -33,6 +37,7 @@
             bw.Write((byte)refreshType);
             bw.Write(conditionParam);
             bw.Write(overParam);
+            bw.Write(nextEventID);
             bw.Write(monsterList.Count);
             foreach (var _monster in monsterList)
             {
@@ -47,6 +52,7 @@
             bw.Write((byte)refreshType);
             bw.Write(conditionParam);
             bw.Write(overParam);
+            bw.Write(nextEventID);
             bw.Write(monsterList.Count);
             foreach (var _monster in monsterList)
             {
@@ -61,6 +67,7 @@
             refreshType = (Evt_RefreshMonster.E_RefreshType)br.ReadByte();
             conditionParam = br.ReadInt32();
             overParam = br.ReadInt32();
+            nextEventID = br.ReadInt32();
             int _count = br.ReadInt32();
             for (int i = 0; i < _count; ++i)
             {
@@ -130,21 +137,33 @@
                 }
                 EditorGUILayout.EndHorizontal();
 
+                EditorGUILayout.BeginHorizontal(guiSkin.customStyles[1], GUILayout.Height(22));
+                EditorGUILayout.LabelField("涓嬩竴浜嬩欢", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(60));
+                nextEventID = EditorGUILayout.IntField(nextEventID, guiSkin.textField, GUILayout.Height(22));
+                EditorGUILayout.EndHorizontal();
+
                 EditorGUILayout.BeginVertical(guiSkin.customStyles[1]);
+
                 EditorGUILayout.BeginHorizontal(GUILayout.Height(22));
                 showMonsterList = EditorGUILayout.Foldout(showMonsterList, "  鍒锋�垪琛�", true, guiSkin.customStyles[3]);
+                EditorGUILayout.LabelField("NPCID", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(50));
+                npcID = EditorGUILayout.IntField(npcID, guiSkin.textField, GUILayout.Height(22), GUILayout.Width(70));
+                EditorGUILayout.LabelField("妯″瀷鍚�", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(50));
+                resName = EditorGUILayout.TextField(resName, guiSkin.textField, GUILayout.Height(22), GUILayout.Width(70));
                 if (GUILayout.Button("娣诲姞", guiSkin.button, GUILayout.Width(60), GUILayout.Height(22)))
                 {
-                    var _go = new GameObject("RefreshMonster");
-                    _go.transform.SetParent(transform);
-                    _go.transform.localPosition = Vector3.zero;
-                    _go.transform.eulerAngles = Vector3.zero;
-                    _go.transform.localScale = Vector3.one;
+                    var _monsterData = CreateNPC(npcID, resName);
+                    if (_monsterData)
+                    {
+                        monsterList.Add(_monsterData);
+                        showMonsterList = true;
 
-                    var _monsterData = _go.AddComponent<Bhv_MonsterData>();
-                    monsterList.Add(_monsterData);
-
-                    showMonsterList = true;
+                        Selection.activeGameObject = _monsterData.gameObject;
+                        if (Selection.activeGameObject)
+                        {
+                            SceneView.lastActiveSceneView.LookAt(Selection.activeGameObject.transform.position);
+                        }
+                    }
                 }
                 EditorGUILayout.EndHorizontal();
                 if (showMonsterList)
@@ -152,13 +171,10 @@
                     for (int i = monsterList.Count - 1; i >= 0; --i)
                     {
                         EditorGUILayout.BeginHorizontal(GUILayout.Height(22));
-                        EditorGUILayout.LabelField("NPCID", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(60));
-                        var _npcID = monsterList[i].npcID;
-                        monsterList[i].npcID = EditorGUILayout.IntField(monsterList[i].npcID, guiSkin.textField, GUILayout.Height(20));
-                        if (_npcID != monsterList[i].npcID)
-                        {
-                            monsterList[i].name = monsterList[i].npcID + "_RefreshNPC";
-                        }
+                        EditorGUILayout.LabelField("NPCID", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(50));
+                        EditorGUILayout.LabelField(monsterList[i].npcID.ToString(), guiSkin.textField, GUILayout.Height(20));
+                        EditorGUILayout.LabelField("妯″瀷鍚�", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(50));
+                        EditorGUILayout.LabelField(monsterList[i].resName, guiSkin.textField, GUILayout.Height(22), GUILayout.Width(70));
                         if (GUILayout.Button("瀹氶珮", guiSkin.button, GUILayout.Width(60), GUILayout.Height(20)))
                         {
                             Vector3 _pos = monsterList[i].transform.position;
@@ -194,6 +210,47 @@
             EditorGUILayout.EndVertical();
             return _result;
         }
+
+        private Bhv_MonsterData CreateNPC(int id, string name)
+        {
+            if (id <= 0)
+            {
+                Debug.Log("NPCID闈炴硶");
+                return null;
+            }
+
+            if (string.IsNullOrEmpty(name.Trim()))
+            {
+                Debug.Log("妯″瀷鍚嶄笉搴旇涓虹┖");
+                return null;
+            }
+
+            string _path = "Assets/ResourcesOut/Mob/Prefab_Race_" + name + ".prefab";
+            var _obj = AssetDatabase.LoadAssetAtPath<GameObject>(_path);
+            if (!_obj)
+            {
+                Debug.LogError("鎵�瑕佸垱寤虹殑璧勬簮涓嶅瓨鍦�: " + _path);
+                return null;
+            }
+
+            _obj = Instantiate(_obj);
+
+            RaycastHit _hit;
+            Ray _ray = SceneView.lastActiveSceneView.camera.ViewportPointToRay(new Vector3(.5f, .5f, 0));
+            if (Physics.Raycast(_ray, out _hit, 1000f, LayerUtility.WalkbleMask))
+            {
+                _obj.transform.position = _hit.point;
+            }
+            _obj.transform.SetParent(transform);
+            _obj.transform.eulerAngles = Vector3.zero;
+            _obj.transform.localScale = Vector3.one;
+
+            var _monsterData = _obj.AddComponent<Bhv_MonsterData>();
+            _monsterData.npcID = id;
+            _monsterData.resName = name;
+
+            return _monsterData;
+        }
 #endif
     }
 }
\ No newline at end of file
diff --git a/Core/MapEditor/Behavior/Bhv_Evt_RefreshSceneObject.cs b/Core/MapEditor/Behavior/Bhv_Evt_RefreshSceneObject.cs
index d7f2718..db0cd89 100644
--- a/Core/MapEditor/Behavior/Bhv_Evt_RefreshSceneObject.cs
+++ b/Core/MapEditor/Behavior/Bhv_Evt_RefreshSceneObject.cs
@@ -164,7 +164,7 @@
                 _sceneObjData.resName = sceneName;
                 RaycastHit _hit;
                 Ray _ray = SceneView.lastActiveSceneView.camera.ViewportPointToRay(new Vector3(.5f, .5f, 0));
-                if (Physics.Raycast(_ray, out _hit, 1000f, LayerUtility.WalkbleMask))
+                if (Physics.Raycast(_ray, out _hit, 10000f, LayerUtility.WalkbleMask))
                 {
                     _sceneObjData.transform.position = _hit.point;
                 }
diff --git a/Core/MapEditor/Behavior/Bhv_MapTrigger.cs b/Core/MapEditor/Behavior/Bhv_MapTrigger.cs
index 7081694..28d9196 100644
--- a/Core/MapEditor/Behavior/Bhv_MapTrigger.cs
+++ b/Core/MapEditor/Behavior/Bhv_MapTrigger.cs
@@ -19,6 +19,8 @@
         [HideInInspector]
         public int prevID = -1;
         [HideInInspector]
+        public int nextID = -1;
+        [HideInInspector]
         public List<int> eventIDList = new List<int>();
 
 #if UNITY_EDITOR
@@ -35,6 +37,7 @@
             bw.Write((byte)triggerType);
             bw.Write((byte)type);
             bw.Write(prevID);
+            bw.Write(nextID);
             bw.Write((float)System.Math.Round(transform.position.x, 2));
             bw.Write((float)System.Math.Round(transform.position.y, 2));
             bw.Write((float)System.Math.Round(transform.position.z, 2));
@@ -59,6 +62,7 @@
             triggerType = (MapTrigger.E_TriggerType)br.ReadByte();
             type = (Evt.E_EventType)br.ReadByte();
             prevID = br.ReadInt32();
+            nextID = br.ReadInt32();
             float _pX = br.ReadSingle();
             float _pY = br.ReadSingle();
             float _pZ = br.ReadSingle();
@@ -98,10 +102,24 @@
             if (showDetail)
             {
                 EditorGUILayout.BeginHorizontal(GUILayout.Height(22));
-                EditorGUILayout.LabelField("鍓嶇疆瑙﹀彂鍣�", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(80));
-                prevID = EditorGUILayout.IntField(prevID, guiSkin.textField, GUILayout.Height(20));
                 EditorGUILayout.LabelField("瑙﹀彂鍣ㄧ被鍨�", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(80));
                 triggerType = (MapTrigger.E_TriggerType)EditorGUILayout.EnumPopup(triggerType, guiSkin.customStyles[1], GUILayout.Height(20), GUILayout.Width(100));
+                if (triggerType != MapTrigger.E_TriggerType.EnterStage)
+                {
+                    var _descript = string.Empty;
+                    if (triggerType == MapTrigger.E_TriggerType.Trigger)
+                    {
+                        _descript = "鍓嶇疆ID";
+                    }
+                    else if (triggerType == MapTrigger.E_TriggerType.Mission)
+                    {
+                        _descript = "浠诲姟ID";
+                    }
+                    EditorGUILayout.LabelField(_descript, guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(55));
+                    prevID = EditorGUILayout.IntField(prevID, guiSkin.textField, GUILayout.Height(20));
+                }
+                EditorGUILayout.LabelField("缁撴潫瑙﹀彂", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(55));
+                nextID = EditorGUILayout.IntField(nextID, guiSkin.textField, GUILayout.Height(20));
                 EditorGUILayout.EndHorizontal();
 
                 EditorGUILayout.BeginVertical(guiSkin.customStyles[1]);
diff --git a/Core/MapEditor/Behavior/Bhv_MonsterData.cs b/Core/MapEditor/Behavior/Bhv_MonsterData.cs
index c6d856f..cc61d9a 100644
--- a/Core/MapEditor/Behavior/Bhv_MonsterData.cs
+++ b/Core/MapEditor/Behavior/Bhv_MonsterData.cs
@@ -8,6 +8,8 @@
         [HideInInspector]
         public int npcID;
         [HideInInspector]
+        public string resName;
+        [HideInInspector]
         public byte ai;
 
 #if UNITY_EDITOR
@@ -15,6 +17,7 @@
         public void Save(BinaryWriter bw)
         {
             bw.Write(npcID);
+            bw.Write(resName);
             bw.Write(ai);
             bw.Write((float)System.Math.Round(transform.position.x, 2));
             bw.Write((float)System.Math.Round(transform.position.y, 2));
@@ -24,6 +27,7 @@
         public void Load(BinaryReader br)
         {
             npcID = br.ReadInt32();
+            resName = br.ReadString();
             ai = br.ReadByte();
             float _x = br.ReadSingle();
             float _y = br.ReadSingle();
@@ -34,7 +38,11 @@
 
         public void Export(BinaryWriter bw)
         {
-            Save(bw);
+            bw.Write(npcID);
+            bw.Write(ai);
+            bw.Write((float)System.Math.Round(transform.position.x, 2));
+            bw.Write((float)System.Math.Round(transform.position.y, 2));
+            bw.Write((float)System.Math.Round(transform.position.z, 2));
         }
 
 #endif
diff --git a/Core/MapEditor/Data/Event/Evt_RefreshMonster.cs b/Core/MapEditor/Data/Event/Evt_RefreshMonster.cs
index 3113d63..8223a44 100644
--- a/Core/MapEditor/Data/Event/Evt_RefreshMonster.cs
+++ b/Core/MapEditor/Data/Event/Evt_RefreshMonster.cs
@@ -8,7 +8,6 @@
     {
         public enum E_OverCondition
         {
-            None,
             DeadCount,
             Time,
         }
@@ -21,7 +20,7 @@
         }
 
         public MonsterData[] monsters;
-        public E_OverCondition overCondition = E_OverCondition.None;
+        public E_OverCondition overCondition = E_OverCondition.DeadCount;
         public E_RefreshType refreshType = E_RefreshType.All;
         /// <summary>
         /// 鍙傛暟
@@ -34,6 +33,7 @@
         /// <para>鍒锋柊绫诲瀷: OneByOneTime, 浣滀负鏃堕棿(姣)</para>
         /// </summary>
         public int refreshParam;
+        public int nextEventID = -1;
 
         public override void Load(BinaryReader br)
         {
@@ -42,6 +42,7 @@
             refreshType = (Evt_RefreshMonster.E_RefreshType)br.ReadByte();
             refreshParam = br.ReadInt32();
             conditionParam = br.ReadInt32();
+            nextEventID = br.ReadInt32();
             int _count = br.ReadInt32();
             monsters = new MonsterData[_count];
             for (int i = 0; i < _count; ++i)
diff --git a/Core/MapEditor/Data/MapTrigger.cs b/Core/MapEditor/Data/MapTrigger.cs
index 9184af1..8c34b43 100644
--- a/Core/MapEditor/Data/MapTrigger.cs
+++ b/Core/MapEditor/Data/MapTrigger.cs
@@ -9,7 +9,8 @@
         public enum E_TriggerType
         {
             Trigger,
-            EnterStage
+            EnterStage,
+            Mission,
         }
 
         public Evt.E_EventType type;
diff --git a/Core/MapEditor/Editor/MapEditor.cs b/Core/MapEditor/Editor/MapEditor.cs
index 838cb1d..8eaf9ef 100644
--- a/Core/MapEditor/Editor/MapEditor.cs
+++ b/Core/MapEditor/Editor/MapEditor.cs
@@ -52,6 +52,7 @@
                         _root.AddComponent<MeshCollider>();
                         _root.transform.position = _go.transform.position;
                         _root.transform.rotation = _go.transform.rotation;
+                        _root.layer = LayerUtility.Walkble;
                         break;
                     }
                 }
diff --git a/Fight/Stage/Dungeon/DungeonStage.cs b/Fight/Stage/Dungeon/DungeonStage.cs
index 69e8afc..01b3bd1 100644
--- a/Fight/Stage/Dungeon/DungeonStage.cs
+++ b/Fight/Stage/Dungeon/DungeonStage.cs
@@ -477,6 +477,23 @@
         }
     }
 
+    public Vector3 GetCloseTransPoint(Vector3 pos)
+    {
+        // 閬嶅巻鎵惧埌绂荤粰瀹氱偣鏈�杩戝苟涓斿彲瀵昏矾鑷崇殑浼犻�佺偣 P
+        // 鎵惧埌 P鐐圭殑 鍙︿竴绔� P1
+        // 鍒ゆ柇褰撳墠浼犲叆鐨勭偣鏄惁鍙互瀵昏矾鑷� P1
+        // 涓嶈鐨勮瘽閲嶆柊瀵绘壘 鍙互鐨勮瘽杩斿洖 P1 鐨勫潗鏍�
+        float _compareDis;
+        float _dis;
+
+        foreach (var _p in m_TransferGroupList)
+        {
+
+        }
+
+        return Vector3.zero;
+    }
+
     private void SceneResourceReplace10010()
     {
         for (var i = 100101; i <= 100109; i++)

--
Gitblit v1.8.0