| | |
| | | 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] |
| | |
| | | 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) |
| | | { |
| | |
| | | bw.Write((byte)refreshType); |
| | | bw.Write(conditionParam); |
| | | bw.Write(overParam); |
| | | bw.Write(nextEventID); |
| | | bw.Write(monsterList.Count); |
| | | foreach (var _monster in monsterList) |
| | | { |
| | |
| | | bw.Write((byte)refreshType); |
| | | bw.Write(conditionParam); |
| | | bw.Write(overParam); |
| | | bw.Write(nextEventID); |
| | | bw.Write(monsterList.Count); |
| | | foreach (var _monster in monsterList) |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | } |
| | | 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) |
| | |
| | | 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; |
| | |
| | | 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 |
| | | } |
| | | } |