diff --git a/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml b/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml new file mode 100644 index 0000000..2f5824e --- /dev/null +++ b/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml.meta b/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml.meta new file mode 100644 index 0000000..919b470 --- /dev/null +++ b/Assets/GameAssets/Maps/1000/XML/MonstersConfig.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 521040d6d88094b428ebf8c1a0dbac02 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index df89d11..7fb95bc 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -3037,6 +3037,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 687449961} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &154101546 GameObject: @@ -6623,6 +6635,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 1286502938} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &350730894 GameObject: @@ -10201,7 +10225,11 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 1287609758} + - {fileID: 687449962} + - {fileID: 1286502939} + - {fileID: 655392906} m_Father: {fileID: 841691708} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &523688423 @@ -12788,6 +12816,37 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 654655632} m_CullTransparentMesh: 1 +--- !u!1 &655392905 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 655392906} + m_Layer: 9 + m_Name: ReliveArea + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &655392906 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 655392905} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 519310460} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &673641485 GameObject: m_ObjectHideFlags: 0 @@ -13013,6 +13072,37 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 676414811} m_CullTransparentMesh: 1 +--- !u!1 &687449961 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 687449962} + m_Layer: 9 + m_Name: NpcArea + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &687449962 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 687449961} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 519310460} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &694870550 GameObject: m_ObjectHideFlags: 0 @@ -16559,12 +16649,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b7cce2a4c6c6cc14f876c47961979fb5, type: 3} m_Name: m_EditorClassIdentifier: + isDragging: 0 + downPos: {x: 0, y: 0, z: 0} + currentComponent: {fileID: 0} mapWidth: 0 mapHeight: 0 _curOpenMapId: 0 mapRegionParent: {fileID: 782149589} mapGridParent: {fileID: 504155531} mapAreaParent: {fileID: 519310460} + mapMonsterArea: {fileID: 1287609758} + mapNPCArea: {fileID: 687449962} + mapTeleportArea: {fileID: 1286502939} + mapReliveArea: {fileID: 655392906} _curMapRegions: regionRowNum: 0 regionColNum: 0 @@ -23935,6 +24032,68 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1283425210} m_CullTransparentMesh: 1 +--- !u!1 &1286502938 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1286502939} + m_Layer: 9 + m_Name: TeleportArea + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &1286502939 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1286502938} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 519310460} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1287609757 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1287609758} + m_Layer: 9 + m_Name: MonsterArea + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &1287609758 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1287609757} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 519310460} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1290605789 GameObject: m_ObjectHideFlags: 0 @@ -24984,7 +25143,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1325607736 RectTransform: m_ObjectHideFlags: 0 @@ -30459,6 +30618,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 1287609757} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &1615225086 GameObject: @@ -34973,6 +35144,18 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 655392905} + m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine + m_MethodName: SetActive + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_IsOn: 0 --- !u!1 &1825064713 GameObject: @@ -38941,10 +39124,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 16fab2e09ef3ffa4582b982dc9775080, type: 3} m_Name: m_EditorClassIdentifier: - curActiveInput: {fileID: 0} - curActiveList: [] - itemParent: {fileID: 1454471842} - btnAdd: {fileID: 1644398427} --- !u!1 &2007759514 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Map/MapManager.Cell.cs b/Assets/Scripts/Map/MapManager.Cell.cs index 75b8826..ad32a4f 100644 --- a/Assets/Scripts/Map/MapManager.Cell.cs +++ b/Assets/Scripts/Map/MapManager.Cell.cs @@ -418,7 +418,7 @@ public partial class MapManager : MonoBehaviour public void RemoveSpecialPoint(EditCellType cellType, int idx = 0) { - + Transform parentArea = mapAreaParent; string cellName = string.Empty; switch (cellType) { @@ -436,6 +436,7 @@ public partial class MapManager : MonoBehaviour break; case EditCellType.ReliveCell: cellName = $"¸´»îµã{_curReliveCenterPoint.areaIdx}"; + parentArea = mapReliveArea; break; case EditCellType.AudioTrigger: cellName = $"ÒôЧ´¥·¢{_curAudioTriggerCenterPoint.areaIdx}"; @@ -448,6 +449,7 @@ public partial class MapManager : MonoBehaviour break; case EditCellType.MonsterArea: cellName = $"¹ÖÎïÇø{_curMonsterPoint.areaIdx}"; + parentArea = mapMonsterArea; break; case EditCellType.FuBenArea: cellName = $"¸±±¾Ë¢¹Ö{_curFuBenPoint.areaIdx}"; @@ -465,9 +467,9 @@ public partial class MapManager : MonoBehaviour return; } - if (mapAreaParent.Find(cellName)) + if (parentArea.Find(cellName)) { - DestroyImmediate(mapAreaParent.Find(cellName).gameObject); + DestroyImmediate(parentArea.Find(cellName).gameObject); } } public void CreateSpecialPoint(int x, int y, EditCellType cellType) @@ -475,6 +477,7 @@ public partial class MapManager : MonoBehaviour if (_curOpenMapId <= 0) return; UnityEngine.Object obj = null; + Transform parentArea = mapAreaParent; if (cellType < EditCellType.AudioTrigger) obj = null; else if (cellType == EditCellType.AudioTrigger) @@ -482,14 +485,19 @@ public partial class MapManager : MonoBehaviour else if (cellType == EditCellType.TriggerCell) obj = Resources.Load("Prefabs/triggerCenterPoint"); else if (cellType == EditCellType.ReliveCell) + { obj = Resources.Load("Prefabs/reliveCenterPoint"); + parentArea = mapReliveArea; + } else if (cellType == EditCellType.MonsterArea) + { obj = Resources.Load("Prefabs/monsterPoint"); + parentArea = mapMonsterArea; + } else if (cellType == EditCellType.FuBenArea) obj = Resources.Load("Prefabs/fubenPoint"); else if (cellType == EditCellType.JuBaoArea) obj = Resources.Load("Prefabs/jubaoPoint"); - if (obj == null) { UIWindow.Instance.ShowMessage("¼ÓÔØcell.prefabʧ°Ü"); @@ -530,6 +538,7 @@ public partial class MapManager : MonoBehaviour case EditCellType.MonsterArea: cellName = $"¹ÖÎïÇø{_curMonsterPoint.areaIdx}"; Idx = _curMonsterPoint.areaIdx; + if (Idx < 0) return; break; case EditCellType.FuBenArea: cellName = $"¸±±¾Ë¢¹Ö{_curFuBenPoint.areaIdx}"; @@ -550,14 +559,14 @@ public partial class MapManager : MonoBehaviour } GameObject go = null; - if (mapAreaParent.Find(cellName)) + if (parentArea.Find(cellName)) { - go = mapAreaParent.Find(cellName).gameObject; + go = parentArea.Find(cellName).gameObject; } else { go = Instantiate(obj) as GameObject; - go.transform.SetParent(mapAreaParent, false); + go.transform.SetParent(parentArea, false); } var sceneArea = go.GetComponent(); sceneArea.SetSceneAreaData(cellType, Idx); diff --git a/Assets/Scripts/Map/MapManager.Region.cs b/Assets/Scripts/Map/MapManager.Region.cs index a190702..110496a 100644 --- a/Assets/Scripts/Map/MapManager.Region.cs +++ b/Assets/Scripts/Map/MapManager.Region.cs @@ -26,6 +26,10 @@ public partial class MapManager : MonoBehaviour public Transform mapGridParent; public Transform mapAreaParent; + public Transform mapMonsterArea; + public Transform mapNPCArea; + public Transform mapTeleportArea; + public Transform mapReliveArea; public Dictionary allMaps = new Dictionary(); /// diff --git a/Assets/Scripts/Map/MapManager.cs b/Assets/Scripts/Map/MapManager.cs index 07ff25e..f6be5ca 100644 --- a/Assets/Scripts/Map/MapManager.cs +++ b/Assets/Scripts/Map/MapManager.cs @@ -10,6 +10,7 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.UI; +using UnityEngine.UIElements; public partial class MapManager : MonoBehaviour { @@ -132,6 +133,23 @@ public partial class MapManager : MonoBehaviour { if (_curOpenMapId <= 0) return; + //ÇåÀíËùÓг¡¾°µÄ¶«Î÷ + foreach (Transform child in mapMonsterArea) + { + Destroy(child.gameObject); + } + foreach (Transform child in mapNPCArea) + { + Destroy(child.gameObject); + } + foreach (Transform child in mapTeleportArea) + { + Destroy(child.gameObject); + } + foreach (Transform child in mapReliveArea) + { + Destroy(child.gameObject); + } UIWindow.Instance.uiCellInfo.CloseMap(); UIWindow.Instance.uiMonstersPanel.RemoveAll(); ClearMapRegions(); diff --git a/Assets/Scripts/Map/SceneArea.cs b/Assets/Scripts/Map/SceneArea.cs index 18e806e..0b96ce9 100644 --- a/Assets/Scripts/Map/SceneArea.cs +++ b/Assets/Scripts/Map/SceneArea.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; using static MapManager; +using static UnityEditor.PlayerSettings; public class SceneArea : MonoBehaviour { @@ -18,12 +19,24 @@ public class SceneArea : MonoBehaviour public void OnPointerClick() { Debug.Log($"Ñ¡ÖÐÎÒÁË..."); + switch (editCellType) + { + case EditCellType.MonsterArea: + UIWindow.Instance.uiMonstersPanel.SelectMonsterPos(Idx); + break; + } } public void OnPointerDrag(Vector3 mousePosition) { Vector2Int pos = MapManager.Instance.map.selector.GetMouseByCell(); SetAreaPos(pos); + switch (editCellType) + { + case EditCellType.MonsterArea: + UIWindow.Instance.uiMonstersPanel.UpdateMonsterPos(Idx,pos); + break; + } } public void OnPointerUp() diff --git a/Assets/Scripts/UI/UIMonsterItem.cs b/Assets/Scripts/UI/UIMonsterItem.cs index eb4712f..eed4700 100644 --- a/Assets/Scripts/UI/UIMonsterItem.cs +++ b/Assets/Scripts/UI/UIMonsterItem.cs @@ -78,7 +78,11 @@ public class UIMonsterItem : MonoBehaviour MapManager.Instance.CreateSpecialPoint(monster.pos.x, monster.pos.y, MapManager.EditCellType.MonsterArea); MapManager.Instance.SetCurMonsterPathIdx(pathIdx); } - + public void RefreshPos(Vector2Int newPos) + { + monster.pos = newPos; + txtPos.text = newPos.ToString() ; + } public void RefreshItem() { txtMonsterID.text = monster.id.ToString(); diff --git a/Assets/Scripts/UI/UIMonsterPanel.cs b/Assets/Scripts/UI/UIMonsterPanel.cs index 686b3b7..c408e00 100644 --- a/Assets/Scripts/UI/UIMonsterPanel.cs +++ b/Assets/Scripts/UI/UIMonsterPanel.cs @@ -2,6 +2,7 @@ using HxGame.Data; using System; using System.Collections; using System.Collections.Generic; +using System.Threading; using UnityEngine; using UnityEngine.UI; using static System.Net.Mime.MediaTypeNames; @@ -42,13 +43,12 @@ public class UIMonsterPanel : MonoBehaviour private UIMonsterItem _curMonsterItem; //private Dictionary> _dicGroupItem; - private Dictionary _dicGroupItem; //·Ö×é¹éÊôµÄitem + private Dictionary _dicGroupItem = new(); //·Ö×é¹éÊôµÄitem + private Dictionary _dicAllItem = new(); //ËùÓÐÒ»¼¶item private void Awake() { itemIdx = 0; - //_dicGroupItem = new Dictionary>(); - _dicGroupItem = new Dictionary(); btnClose.onClick.AddListener(OnClickClose); btnAddGroup.onClick.AddListener(OnAddGroup); btnDeleteGroup.onClick.AddListener(OnDeleteGroup); @@ -145,8 +145,6 @@ public class UIMonsterPanel : MonoBehaviour item.OnClick = OnClickItem; item.OnCopyItem = OnCopyItem; item.btnClickSelf.Select(); - - AddGroupMap(_curMonsterItem.monster.itemIdx, _curMonsterItem); } @@ -184,7 +182,7 @@ public class UIMonsterPanel : MonoBehaviour _curMonsterItem.transform.parent.GetComponent().sizeDelta -= Vector2Int.up * 30; DestroyImmediate(_curMonsterItem.gameObject); - + MapManager.Instance.RemoveMonsterPoint(_curMonsterItem.monster.itemIdx); _curMonsterItem = null; } @@ -197,7 +195,6 @@ public class UIMonsterPanel : MonoBehaviour UIWindow.Instance.ShowMessage("monsterItem.prefabʧ°Ü"); return; } - GameObject go = Instantiate(obj) as GameObject; ; go.transform.SetParent(itemParent, false); UIMonsterItem item = go.transform.Find("monsterSubItem").GetComponent(); @@ -213,6 +210,7 @@ public class UIMonsterPanel : MonoBehaviour item.OnCopyItem = OnCopyItem; _curMonsterItem = item; item.btnClickSelf.Select(); + _dicAllItem.Add(monster.itemIdx, item); } public void LoadMonsterConfig(int mapId) @@ -254,6 +252,7 @@ public class UIMonsterPanel : MonoBehaviour item.OnClick = OnClickItem; item.OnCopyItem = OnCopyItem; _curMonsterItem = item; + _dicAllItem.Add(monster.itemIdx, item); } private void SaveItem() @@ -440,8 +439,23 @@ public class UIMonsterPanel : MonoBehaviour { DestroyImmediate(itemParent.GetChild(0).gameObject); } - _dicGroupItem?.Clear(); + _dicAllItem?.Clear(); itemIdx = 0; } + public void SelectMonsterPos(int Idx) + { + if (_dicAllItem.TryGetValue(Idx, out var monsterItem)) + { + monsterItem.btnClickSelf.Select(); + } + } + public void UpdateMonsterPos(int Idx, Vector2Int newPos) + { + if (_dicAllItem.TryGetValue(Idx, out var monsterItem)) + { + monsterItem.RefreshPos(newPos); + monsterItem.btnClickSelf.Select(); + } + } }