| | |
| | | [HideInInspector] |
| | | public Evt.E_EventType type; |
| | | |
| | | public virtual void Import(BinaryReader br) |
| | | { |
| | | type = (Evt.E_EventType)br.ReadByte(); |
| | | id = br.ReadByte(); |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | [HideInInspector] |
| | |
| | | { |
| | | bw.Write((byte)type); |
| | | bw.Write(id); |
| | | bw.Write((float)System.Math.Round(transform.position.x)); |
| | | bw.Write((float)System.Math.Round(transform.position.y)); |
| | | bw.Write((float)System.Math.Round(transform.position.z)); |
| | | 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)); |
| | | } |
| | | |
| | | public virtual void Load(BinaryReader br) |
| | |
| | | [HideInInspector] |
| | | private string newSceneObjResName = ""; |
| | | |
| | | public override void Save(BinaryWriter bw) |
| | | { |
| | | base.Save(bw); |
| | | bw.Write(sceneObjList.Count); |
| | | foreach (var _sceneObject in sceneObjList) |
| | | { |
| | | _sceneObject.Save(bw); |
| | | } |
| | | } |
| | | |
| | | public override void Export(BinaryWriter bw) |
| | | { |
| | | base.Export(bw); |
| | | bw.Write(sceneObjList.Count); |
| | | foreach (var _sceneObject in sceneObjList) |
| | | { |
| | | _sceneObject.Export(bw); |
| | | } |
| | | } |
| | | |
| | | public override void Load(BinaryReader br) |
| | | { |
| | | base.Load(br); |
| | | int _count = br.ReadInt32(); |
| | | for (int i = 0; i < _count; ++i) |
| | | { |
| | | string _resName = br.ReadString(); |
| | | var _sceneData = CreateSceneObject(_resName); |
| | | _sceneData.transform.SetParent(transform); |
| | | _sceneData.Load(br); |
| | | |
| | | sceneObjList.Add(_sceneData); |
| | | } |
| | | } |
| | | |
| | | public override bool DrawUI(GUISkin guiSkin) |
| | | { |
| | | bool _result = false; |
| | |
| | | newSceneObjResName = EditorGUILayout.TextField(newSceneObjResName, guiSkin.textField, GUILayout.Width(100), GUILayout.Height(20)); |
| | | if (GUILayout.Button("添加", guiSkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | | Debug.Log("!!!"); |
| | | var _sceneObject = CreateSceneObject(); |
| | | var _sceneObject = CreateSceneObject(newSceneObjResName); |
| | | if (_sceneObject) |
| | | { |
| | | sceneObjList.Add(_sceneObject); |
| | |
| | | |
| | | if (showSceneObjList) |
| | | { |
| | | for (int i = sceneObjList.Count - 1; i >= 0; --i) |
| | | { |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | EditorGUILayout.LabelField(string.Format("{0}. ResName", (i + 1)), guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(80)); |
| | | var _npcID = sceneObjList[i].resName; |
| | | EditorGUILayout.TextField(sceneObjList[i].resName, guiSkin.textField, GUILayout.Height(20)); |
| | | sceneObjList[i].isObstacle = GUILayout.Toggle(sceneObjList[i].isObstacle, "障碍", guiSkin.button, GUILayout.Width(50), GUILayout.Height(20)); |
| | | if (GUILayout.Button("定高", guiSkin.button, GUILayout.Width(60), GUILayout.Height(20))) |
| | | { |
| | | Vector3 _pos = sceneObjList[i].transform.position; |
| | | _pos.y = 0; |
| | | RaycastHit _hit; |
| | | |
| | | Ray _ray = new Ray(_pos + Vector3.up * 100, Vector3.down); |
| | | if (Physics.Raycast(_ray, out _hit, 200, LayerUtility.WalkbleMask)) |
| | | { |
| | | sceneObjList[i].transform.position = _hit.point; |
| | | } |
| | | } |
| | | if (GUILayout.Button("查找", guiSkin.button, GUILayout.Width(60), GUILayout.Height(20))) |
| | | { |
| | | Selection.activeGameObject = sceneObjList[i].gameObject; |
| | | if (Selection.activeGameObject) |
| | | { |
| | | SceneView.lastActiveSceneView.LookAt(Selection.activeGameObject.transform.position); |
| | | } |
| | | } |
| | | if (GUILayout.Button("删除", guiSkin.button, GUILayout.Width(60), GUILayout.Height(20))) |
| | | { |
| | | DestroyImmediate(sceneObjList[i].gameObject); |
| | | sceneObjList.RemoveAt(i); |
| | | } |
| | | EditorGUILayout.EndHorizontal(); |
| | | } |
| | | } |
| | | EditorGUILayout.EndVertical(); |
| | | } |
| | |
| | | return _result; |
| | | } |
| | | |
| | | private Bhv_SceneObjectData CreateSceneObject() |
| | | private Bhv_SceneObjectData CreateSceneObject(string sceneName = null) |
| | | { |
| | | if (!string.IsNullOrEmpty(newSceneObjResName)) |
| | | if (!string.IsNullOrEmpty(sceneName)) |
| | | { |
| | | string _path = "Assets/ResourcesOut/Mob/Prefab_Race_" + newSceneObjResName + ".prefab"; |
| | | string _path = "Assets/ResourcesOut/Mob/Prefab_Race_" + sceneName + ".prefab"; |
| | | var _obj = AssetDatabase.LoadAssetAtPath<GameObject>(_path); |
| | | if (!_obj) |
| | | { |
| | |
| | | } |
| | | _obj = Instantiate(_obj); |
| | | var _sceneObjData = _obj.AddComponent<Bhv_SceneObjectData>(); |
| | | _sceneObjData.resName = newSceneObjResName; |
| | | _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)) |
| | |
| | | eventList.Add(_eventBhv); |
| | | _eventBhv.Load(br); |
| | | } |
| | | else if (_type == Evt.E_EventType.SceneObject) |
| | | { |
| | | var _eventBhv = _go.AddComponent<Bhv_Evt_RefreshSceneObject>(); |
| | | _eventBhv.type = _type; |
| | | _eventBhv.transform.SetParent(transform.Find(NodeName_EventList)); |
| | | eventList.Add(_eventBhv); |
| | | _eventBhv.Load(br); |
| | | } |
| | | } |
| | | _count = br.ReadInt32(); |
| | | for (int i = 0; i < _count; ++i) |
| | |
| | | { |
| | | public class Bhv_MapTrigger : MonoBehaviour |
| | | { |
| | | public enum E_TriggerType |
| | | { |
| | | Trigger, |
| | | EnterStage |
| | | } |
| | | |
| | | [HideInInspector] |
| | | public int id; |
| | | [HideInInspector] |
| | | public E_TriggerType triggerType = E_TriggerType.Trigger; |
| | | [HideInInspector] |
| | | public Evt.E_EventType type = Evt.E_EventType.Enemy; |
| | | [HideInInspector] |
| | | public int prevID = -1; |
| | | [HideInInspector] |
| | | public BoxCollider boxCollider; |
| | | private bool showDetail = false; |
| | | private bool showEventList = false; |
| | | [HideInInspector] |
| | | public List<int> eventIDList = new List<int>(); |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | [HideInInspector] |
| | | public BoxCollider boxCollider; |
| | | |
| | | private bool showDetail = false; |
| | | private bool showEventList = false; |
| | | |
| | | public void Save(BinaryWriter bw) |
| | | { |
| | | bw.Write(id); |
| | | bw.Write((byte)triggerType); |
| | | bw.Write((byte)type); |
| | | bw.Write(prevID); |
| | | bw.Write((float)System.Math.Round(transform.position.x, 2)); |
| | |
| | | public void Load(BinaryReader br) |
| | | { |
| | | id = br.ReadInt32(); |
| | | triggerType = (E_TriggerType)br.ReadByte(); |
| | | type = (Evt.E_EventType)br.ReadByte(); |
| | | prevID = br.ReadInt32(); |
| | | float _pX = br.ReadSingle(); |
| | |
| | | if (showDetail) |
| | | { |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | EditorGUILayout.LabelField("前置触发器ID", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(80)); |
| | | 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 = (E_TriggerType)EditorGUILayout.EnumPopup(triggerType, guiSkin.customStyles[1], GUILayout.Height(20), GUILayout.Width(100)); |
| | | EditorGUILayout.EndHorizontal(); |
| | | |
| | | EditorGUILayout.BeginVertical(guiSkin.customStyles[1]); |
| | | |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | if (eventIDList.Count > 0) |
| | | { |
| | | showEventList = EditorGUILayout.Foldout(showEventList, " 触发事件列表", true, guiSkin.customStyles[3]); |
| | | } |
| | | else |
| | | { |
| | | EditorGUILayout.LabelField(" 触发事件列表:", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(100)); |
| | | GUILayout.FlexibleSpace(); |
| | | } |
| | | if (GUILayout.Button("添加", guiSkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | | eventIDList.Add(0); |
| | | showEventList = true; |
| | | } |
| | | EditorGUILayout.EndHorizontal(); |
| | | |
| | | if (showEventList) |
| | | { |
| | | for (int i = eventIDList.Count - 1; i >= 0; --i) |
| | |
| | | [HideInInspector] |
| | | public byte ai; |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | public void Save(BinaryWriter bw) |
| | | { |
| | | bw.Write(npcID); |
| | | bw.Write(ai); |
| | | bw.Write(Mathf.Round(transform.position.x)); |
| | | bw.Write(Mathf.Round(transform.position.y)); |
| | | bw.Write(Mathf.Round(transform.position.z)); |
| | | 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)); |
| | | } |
| | | |
| | | public void Load(BinaryReader br) |
| | |
| | | { |
| | | Save(bw); |
| | | } |
| | | |
| | | #endif |
| | | } |
| | | } |
| | |
| | | using System.IO; |
| | | #if UNITY_EDITOR |
| | | using UnityEditor; |
| | | #endif |
| | | using UnityEngine; |
| | | |
| | | public class Bhv_SceneObjectData : MonoBehaviour |
| | | { |
| | | [HideInInspector] |
| | | public string resName; |
| | | public bool isObstacle = false; |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | public void Save(BinaryWriter bw) |
| | | { |
| | | bw.Write(resName); |
| | | bw.Write(isObstacle); |
| | | 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)); |
| | | bw.Write((float)System.Math.Round(transform.eulerAngles.y, 2)); |
| | | } |
| | | |
| | | public void Load(BinaryReader br) |
| | | { |
| | | resName = br.ReadString(); |
| | | name = "RefreshMonster_" + resName; |
| | | // 加载逻辑原因在父节点进行读取 |
| | | // resName = br.ReadString(); |
| | | isObstacle = br.ReadBoolean(); |
| | | float _x = br.ReadSingle(); |
| | | float _y = br.ReadSingle(); |
| | | float _z = br.ReadSingle(); |
| | | float _eurlerAngle = br.ReadSingle(); |
| | | |
| | | name = "RefreshSceneObject_" + resName; |
| | | transform.position = new Vector3(_x, _y, _z); |
| | | transform.eulerAngles = new Vector3(0, _eurlerAngle, 0); |
| | | } |
| | | |
| | | public void Export(BinaryWriter bw) |
| | | { |
| | | Save(bw); |
| | | } |
| | | |
| | | private Bhv_SceneObjectData CreateSceneObject(string sceneName = null) |
| | | { |
| | | if (!string.IsNullOrEmpty(sceneName)) |
| | | { |
| | | string _path = "Assets/ResourcesOut/Mob/Prefab_Race_" + sceneName + ".prefab"; |
| | | var _obj = AssetDatabase.LoadAssetAtPath<GameObject>(_path); |
| | | if (!_obj) |
| | | { |
| | | Debug.LogError("所要创建的资源不存在: " + _path); |
| | | return null; |
| | | } |
| | | _obj = Instantiate(_obj); |
| | | var _sceneObjData = _obj.AddComponent<Bhv_SceneObjectData>(); |
| | | _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)) |
| | | { |
| | | _sceneObjData.transform.position = _hit.point; |
| | | } |
| | | _sceneObjData.transform.SetParent(transform); |
| | | _sceneObjData.transform.eulerAngles = Vector3.zero; |
| | | _sceneObjData.transform.localScale = Vector3.one; |
| | | |
| | | Selection.activeGameObject = _sceneObjData.gameObject; |
| | | if (Selection.activeGameObject) |
| | | { |
| | | SceneView.lastActiveSceneView.LookAt(Selection.activeGameObject.transform.position); |
| | | } |
| | | |
| | | return _sceneObjData; |
| | | } |
| | | return null; |
| | | } |
| | | #endif |
| | | } |
| | |
| | | { |
| | | [HideInInspector] |
| | | public int effectID = -1; |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | [HideInInspector] |
| | | public CapsuleCollider capsuleCollider; |
| | | |
| | | public void Save(BinaryWriter bw) |
| | | { |
| | | bw.Write(effectID); |
| | | bw.Write((float)System.Math.Round(transform.position.x)); |
| | | bw.Write((float)System.Math.Round(transform.position.y)); |
| | | bw.Write((float)System.Math.Round(transform.position.z)); |
| | | bw.Write((float)System.Math.Round(capsuleCollider.radius)); |
| | | 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)); |
| | | bw.Write((float)System.Math.Round(capsuleCollider.radius, 2)); |
| | | } |
| | | |
| | | public void Load(BinaryReader br) |
| | |
| | | { |
| | | Save(bw); |
| | | } |
| | | |
| | | #endif |
| | | } |
| | | } |
| | |
| | | public int param; |
| | | [HideInInspector] |
| | | public List<Bhv_TransferPoint> pointList = new List<Bhv_TransferPoint>(); |
| | | private bool showDetail; |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | | private bool showDetail; |
| | | |
| | | public void Save(BinaryWriter bw) |
| | | { |
| | | bw.Write((byte)transferType); |
| | |
| | | [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(string fileName) |
| | | public static MapData LoadFormFile(int mapID) |
| | | { |
| | | string _path = null; |
| | | if (AssetSource.refdataFromEditor) |
| | | { |
| | | _path = ResourcesPath.ResourcesOutPath + "Refdata/MapData/" + fileName + ".gd"; |
| | | #if UNITY_EDITOR |
| | | _path = ResourcesPath.ResourcesOutPath + "Refdata/ScriptableObject/MapData/" + mapID + ".gd"; |
| | | |
| | | #endif |
| | | } |
| | | else |
| | | { |
| | | _path = AssetVersionUtility.GetAssetFilePath(StringUtility.Contact("mapdata/", fileName, ".gd")); |
| | | _path = AssetVersionUtility.GetAssetFilePath(StringUtility.Contact("mapdata/", mapID, ".gd")); |
| | | } |
| | | MapData _mapData = null; |
| | | if (File.Exists(_path)) |
| | |
| | | m_OnNormal: |
| | | m_Background: {fileID: 11005, guid: 0000000000000000e000000000000000, type: 0} |
| | | m_ScaledBackgrounds: [] |
| | | m_TextColor: {r: 0.9019608, g: 0.9019608, b: 0.9019608, a: 1} |
| | | m_TextColor: {r: 0.07586217, g: 1, b: 0, a: 1} |
| | | m_OnHover: |
| | | m_Background: {fileID: 11004, guid: 0000000000000000e000000000000000, type: 0} |
| | | m_ScaledBackgrounds: [] |
| | | m_TextColor: {r: 1, g: 1, b: 1, a: 1} |
| | | m_TextColor: {r: 0.07450981, g: 1, b: 0, a: 1} |
| | | m_OnActive: |
| | | m_Background: {fileID: 11002, guid: 0000000000000000e000000000000000, type: 0} |
| | | m_ScaledBackgrounds: [] |
| | |
| | | m_Normal: |
| | | m_Background: {fileID: 11018, guid: 0000000000000000e000000000000000, type: 0} |
| | | m_ScaledBackgrounds: [] |
| | | m_TextColor: {r: 0.89112896, g: 0.89112896, b: 0.89112896, a: 1} |
| | | m_TextColor: {r: 1, g: 1, b: 1, a: 1} |
| | | m_Hover: |
| | | m_Background: {fileID: 11014, guid: 0000000000000000e000000000000000, type: 0} |
| | | m_ScaledBackgrounds: [] |
| | |
| | | m_Top: 4 |
| | | m_Bottom: 4 |
| | | m_Padding: |
| | | m_Left: 15 |
| | | m_Left: 3 |
| | | m_Right: 0 |
| | | m_Top: 3 |
| | | m_Bottom: 0 |
| | |
| | | m_ContentOffset: {x: 0, y: 0} |
| | | m_FixedWidth: 0 |
| | | m_FixedHeight: 0 |
| | | m_StretchWidth: 1 |
| | | m_StretchWidth: 0 |
| | | m_StretchHeight: 0 |
| | | m_label: |
| | | m_Name: label |
| | |
| | | m_Font: {fileID: 0} |
| | | m_FontSize: 12 |
| | | m_FontStyle: 0 |
| | | m_Alignment: 4 |
| | | m_Alignment: 3 |
| | | m_WordWrap: 0 |
| | | m_RichText: 1 |
| | | m_TextClipping: 0 |
| | |
| | | EditorGUILayout.BeginVertical(gUISkin.box); |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | EditorGUI.indentLevel += 1; |
| | | if (_mapData.triggerList.Count > 0) |
| | | { |
| | | _mapData.showTriggerList = EditorGUILayout.Foldout(_mapData.showTriggerList, " 触发器列表", true, gUISkin.customStyles[3]); |
| | | } |
| | | else |
| | | { |
| | | EditorGUILayout.LabelField("触发器列表", gUISkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(100)); |
| | | GUILayout.FlexibleSpace(); |
| | | } |
| | | EditorGUI.indentLevel -= 1; |
| | | if (GUILayout.Button("添加", gUISkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | |
| | | EditorGUILayout.BeginVertical(gUISkin.box); |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | EditorGUI.indentLevel += 1; |
| | | if (_mapData.eventList.Count > 0) |
| | | { |
| | | _mapData.showEventList = EditorGUILayout.Foldout(_mapData.showEventList, " 事件列表", true, gUISkin.customStyles[3]); |
| | | } |
| | | else |
| | | { |
| | | EditorGUILayout.LabelField("事件列表", gUISkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(100)); |
| | | GUILayout.FlexibleSpace(); |
| | | } |
| | | EditorGUI.indentLevel -= 1; |
| | | eventType = (Evt.E_EventType)EditorGUILayout.EnumPopup(eventType, gUISkin.box, GUILayout.Height(22), GUILayout.Width(100)); |
| | | eventType = (Evt.E_EventType)EditorGUILayout.EnumPopup(eventType, gUISkin.customStyles[1], GUILayout.Height(22), GUILayout.Width(100)); |
| | | if (GUILayout.Button("添加", gUISkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | | CreateEvent(eventType); |
| | |
| | | EditorGUILayout.BeginVertical(gUISkin.box); |
| | | EditorGUILayout.BeginHorizontal(GUILayout.Height(22)); |
| | | EditorGUI.indentLevel += 1; |
| | | if (_mapData.transferList.Count > 0) |
| | | { |
| | | _mapData.showTransferList = EditorGUILayout.Foldout(_mapData.showTransferList, " 传送组列表", true, gUISkin.customStyles[3]); |
| | | } |
| | | else |
| | | { |
| | | EditorGUILayout.LabelField("传送组列表", gUISkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(100)); |
| | | GUILayout.FlexibleSpace(); |
| | | } |
| | | EditorGUI.indentLevel -= 1; |
| | | if (GUILayout.Button("添加", gUISkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | |
| | | { |
| | | var _mapData = target as Bhv_MapData; |
| | | string _defaultPath = EditorPrefs.GetString(LS_KEY_SAVEPATH, System.Environment.CurrentDirectory); |
| | | string _path = EditorUtility.SaveFilePanel("导出数据", _defaultPath, "map_" + _mapData.id, "gd"); |
| | | string _path = EditorUtility.SaveFilePanel("导出数据", _defaultPath, "map_" + _mapData.id, "bytes"); |
| | | if (string.IsNullOrEmpty(_path)) |
| | | { |
| | | return; |