| | |
| | | { |
| | | type = (Evt.E_EventType)(byte)json["type"]; |
| | | id = (int)json["id"]; |
| | | float _pX = (float)json["px"]; |
| | | float _pY = (float)json["py"]; |
| | | float _pZ = (float)json["pz"]; |
| | | float _pX = Bhv_MapData.GetJsonFloat(json["px"]); |
| | | float _pY = Bhv_MapData.GetJsonFloat(json["py"]); |
| | | float _pZ = Bhv_MapData.GetJsonFloat(json["pz"]); |
| | | transform.position = new Vector3(_pX, _pY, _pZ); |
| | | overCondition = (Evt_RefreshMonster.E_OverCondition)(byte)json["overCondition"]; |
| | | refreshType = (Evt_RefreshMonster.E_RefreshType)(byte)json["refreshType"]; |
| | |
| | | monsterList[i].npcID = (uint)EditorGUILayout.IntField((int)monsterList[i].npcID, guiSkin.textField, GUILayout.Height(20), GUILayout.Width(70)); |
| | | EditorGUILayout.LabelField("模型名", guiSkin.customStyles[0], GUILayout.Height(20), GUILayout.Width(50)); |
| | | monsterList[i].resName = EditorGUILayout.TextField(monsterList[i].resName, guiSkin.textField, GUILayout.Height(20), GUILayout.Width(70)); |
| | | EditorGUILayout.LabelField("朝向", guiSkin.customStyles[0], GUILayout.Height(22), GUILayout.Width(50)); |
| | | monsterList[i].faceDir = EditorGUILayout.IntField(monsterList[i].faceDir, 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; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static float GetJsonFloat(LitJson.JsonData jsonData) |
| | | { |
| | | if (jsonData.IsDouble) |
| | | { |
| | | return (float)(double)jsonData; |
| | | } |
| | | else if (jsonData.IsInt) |
| | | { |
| | | return (float)(int)jsonData; |
| | | } |
| | | else |
| | | { |
| | | return 0f; |
| | | } |
| | | } |
| | | #endif |
| | | } |
| | | } |
| | |
| | | type = (Evt.E_EventType)(byte)json["type"]; |
| | | prevID = (int)json["prevID"]; |
| | | nextID = (int)json["nextID"]; |
| | | float _pX = (float)json["px"]; |
| | | float _pY = (float)json["py"]; |
| | | float _pZ = (float)json["pz"]; |
| | | float _x = (float)json["sx"]; |
| | | float _z = (float)json["sz"]; |
| | | float _eY = (float)json["ey"]; |
| | | float _pX = Bhv_MapData.GetJsonFloat(json["px"]); |
| | | float _pY = Bhv_MapData.GetJsonFloat(json["py"]); |
| | | float _pZ = Bhv_MapData.GetJsonFloat(json["pz"]); |
| | | float _x = Bhv_MapData.GetJsonFloat(json["sx"]); |
| | | float _z = Bhv_MapData.GetJsonFloat(json["sz"]); |
| | | float _eY = Bhv_MapData.GetJsonFloat(json["ey"]); |
| | | transform.position = new Vector3(_pX, _pY, _pZ); |
| | | boxCollider.size = new Vector3(_x, 1, _z); |
| | | transform.eulerAngles = new Vector3(0, _eY, 0); |
| | |
| | | public string resName; |
| | | [HideInInspector] |
| | | public byte ai; |
| | | [HideInInspector] |
| | | public int faceDir; |
| | | |
| | | #if UNITY_EDITOR |
| | | |
| | |
| | | stringBuilder.Append("\"resName\":\"").Append(resName).Append("\","); |
| | | stringBuilder.Append("\"npcID\":").Append(npcID).Append(","); |
| | | stringBuilder.Append("\"ai\":").Append(npcID).Append(","); |
| | | stringBuilder.Append("\"faceDir\":").Append(faceDir).Append(","); |
| | | stringBuilder.Append("\"px\":").Append((float)System.Math.Round(transform.position.x, 2)).Append(","); |
| | | stringBuilder.Append("\"py\":").Append((float)System.Math.Round(transform.position.y, 2)).Append(","); |
| | | stringBuilder.Append("\"pz\":").Append((float)System.Math.Round(transform.position.z, 2)); |
| | |
| | | resName = jsonData["resName"].ToString(); |
| | | npcID = (uint)(int)jsonData["npcID"]; |
| | | ai = (byte)jsonData["ai"]; |
| | | float _pX = (float)jsonData["px"]; |
| | | float _pY = (float)jsonData["py"]; |
| | | float _pZ = (float)jsonData["pz"]; |
| | | faceDir = (int)jsonData["faceDir"]; |
| | | float _pX = Bhv_MapData.GetJsonFloat(jsonData["px"]); |
| | | float _pY = Bhv_MapData.GetJsonFloat(jsonData["py"]); |
| | | float _pZ = Bhv_MapData.GetJsonFloat(jsonData["pz"]); |
| | | transform.position = new Vector3(_pX, _pY, _pZ); |
| | | name = "RefreshMonster_" + npcID; |
| | | } |
| | |
| | | { |
| | | bw.Write(npcID); |
| | | bw.Write(ai); |
| | | bw.Write(faceDir); |
| | | 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)); |
| | |
| | | flyTimeFront = (int)json["flyTimeFront"]; |
| | | stateNameBack = json["stateNameBack"].ToString(); |
| | | flyTimeBack = (int)json["flyTimeBack"]; |
| | | float _pX = (float)json["px"]; |
| | | float _pY = (float)json["py"]; |
| | | float _pZ = (float)json["pz"]; |
| | | float _pX = Bhv_MapData.GetJsonFloat(json["px"]); |
| | | float _pY = Bhv_MapData.GetJsonFloat(json["py"]); |
| | | float _pZ = Bhv_MapData.GetJsonFloat(json["pz"]); |
| | | transform.position = new Vector3(_pX, _pY, _pZ); |
| | | float _r = (float)json["r"]; |
| | | float _r = Bhv_MapData.GetJsonFloat(json["r"]); |
| | | capsuleCollider.radius = _r; |
| | | if (EffectConfig.Has(effectID)) |
| | | { |
| | |
| | | { |
| | | SaveJson(); |
| | | } |
| | | if (GUILayout.Button("加载1", gUISkin.button, GUILayout.Width(60), GUILayout.Height(22))) |
| | | { |
| | | LoadJson(); |
| | | } |
| | | EditorGUILayout.EndHorizontal(); |
| | | |
| | | /// -------------------------------------------------------------------------------- |
| | |
| | | { |
| | | return; |
| | | } |
| | | EditorPrefs.SetString(LS_KEY_SAVEPATH, Path.GetDirectoryName(_path)); |
| | | File.WriteAllText(_path, _mapData.SaveJson()); |
| | | } |
| | | |
| | | private void LoadJson() |
| | | { |
| | | var _mapData = target as Bhv_MapData; |
| | | |
| | | var _defaultPath = EditorPrefs.GetString(LS_KEY_SAVEPATH); |
| | | if (string.IsNullOrEmpty(_defaultPath)) |
| | | { |
| | | _defaultPath = System.Environment.CurrentDirectory; |
| | | } |
| | | var _loadPath = EditorUtility.OpenFilePanel("读取Json数据", _defaultPath, "json"); |
| | | if (string.IsNullOrEmpty(_loadPath)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var _mapData = target as Bhv_MapData; |
| | | _mapData.Clear(); |
| | | |
| | | var _strJson = File.ReadAllText(_loadPath); |
| | | var _jsonData = LitJson.JsonMapper.ToObject(_strJson); |
| | | |
| | | _mapData.LoadJson(_jsonData); |
| | | } |
| | | |
| | | private void Export() |