public override void OnInspectorGUI() { LevelMonsterGroup pElem = target as LevelMonsterGroup; int pId = EditorGUILayout.IntField("Id", pElem.Id); if (pElem.Id != pId) { pElem.Id = pId; pElem.SetName(); } int pMonsterID = EditorGUILayout.IntField("创建怪物ID", pElem.MonsterID); if (pMonsterID != pElem.MonsterID) { pElem.MonsterID = pMonsterID; } float pRebornCD = EditorGUILayout.FloatField("创建怪物重生时间", pElem.RebornCD); if (pRebornCD != pElem.RebornCD) { pElem.RebornCD = pRebornCD; } bool TriggerResult = EditorGUILayout.Toggle("是否触发结算", pElem.TriggerResult); if (TriggerResult != pElem.TriggerResult) { pElem.TriggerResult = TriggerResult; } int pMaxCount = EditorGUILayout.IntField("创建怪物最大数量", pElem.MaxCount); if (pMaxCount != pElem.MaxCount) { pElem.MaxCount = pMaxCount; } EditorGUILayout.Space(); LevelRegion pRegion = (LevelRegion)EditorGUILayout.ObjectField("传送门触发器", pElem.Region, typeof(LevelRegion), true); if (pRegion != pElem.Region) { pElem.Region = pRegion; } EditorGUILayout.LabelField("使用触发器ID", pElem.RegionID.ToString()); EditorGUILayout.Space(); LevelBarrier pBarrier = (LevelBarrier)EditorGUILayout.ObjectField("解锁障碍物", pElem.Barrier, typeof(LevelBarrier), true); if (pBarrier != pElem.Barrier) { pElem.Barrier = pBarrier; } EditorGUILayout.LabelField("解锁障碍物ID", pElem.BarrierID.ToString()); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); LevelBarrier pElem = target as LevelBarrier; float pWidth = EditorGUILayout.FloatField("宽度", pElem.Width); if (pWidth != pElem.Width) { pElem.Width = pWidth; pElem.Build(); } }
private void InitLevelObject() { //触发区域 for (int i = 0; i < Config.Regions.Count; i++) { MapRegion data = Config.Regions[i]; if (data.StartActive) { LevelElement pHolder = GetHolder(MapHolderType.Region); GameObject go = pHolder.gameObject.AddChild(); LevelRegion pRegion = go.AddComponent <LevelRegion>(); pRegion.Import(data, false); pRegion.Init(); } } //障碍物 for (int i = 0; i < Config.Barriers.Count; i++) { MapBarrier data = Config.Barriers[i]; LevelElement pHolder = GetHolder(MapHolderType.Barrier); GameObject go = pHolder.gameObject.AddChild(); LevelBarrier pBarrier = go.AddComponent <LevelBarrier>(); pBarrier.Import(data, false); pBarrier.Init(); } //传送门 for (int i = 0; i < Config.Portals.Count; i++) { MapPortal data = Config.Portals[i]; LevelElement pHolder = GetHolder(MapHolderType.Portal); GameObject go = pHolder.gameObject.AddChild(); LevelPortal pPortal = go.AddComponent <LevelPortal>(); pPortal.Import(data, false); pPortal.Init(); } }
private void Import() { LevelComponent levelCom = target as LevelComponent; levelCom.transform.DestroyChildren(); levelCom.InitHolder(); string fsPath = AssetUtility.GetLevelConfigAsset(levelCom.LevelID.ToString()); MapConfig data = new MapConfig(); data.EditorLoad(fsPath); levelCom.MapName = data.MapName; for (int i = 0; i < data.Regions.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Region); GameObject go = pHolder.gameObject.AddChild(); LevelRegion pRegion = go.AddComponent <LevelRegion>(); pRegion.Import(data.Regions[i], true); } for (int i = 0; i < data.Barriers.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Barrier); GameObject go = pHolder.gameObject.AddChild(); LevelBarrier pBarrier = go.AddComponent <LevelBarrier>(); pBarrier.Import(data.Barriers[i], true); } for (int i = 0; i < data.WaveSets.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.WaveSet); GameObject go = pHolder.gameObject.AddChild(); LevelWaveSet pWaveSet = go.AddComponent <LevelWaveSet>(); pWaveSet.Import(data.WaveSets[i], true); } for (int i = 0; i < data.MonsterGroups.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.MonsterGroup); GameObject go = pHolder.gameObject.AddChild(); LevelMonsterGroup pGroup = go.AddComponent <LevelMonsterGroup>(); pGroup.Import(data.MonsterGroups[i], true); } for (int i = 0; i < data.MineGroups.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.MineGroup); GameObject go = pHolder.gameObject.AddChild(); LevelMineGroup pGroup = go.AddComponent <LevelMineGroup>(); pGroup.Import(data.MineGroups[i], true); } for (int i = 0; i < data.Portals.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Portal); GameObject go = pHolder.gameObject.AddChild(); LevelPortal pPortal = go.AddComponent <LevelPortal>(); pPortal.Import(data.Portals[i], true); } for (int i = 0; i < data.Npcs.Count; i++) { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Npc); GameObject go = pHolder.gameObject.AddChild(); LevelNpc pNpc = go.AddComponent <LevelNpc>(); pNpc.Import(data.Npcs[i], true); } { LevelElement pHolder = levelCom.GetHolder(MapHolderType.Born); if (data.Ally != null) { GameObject gA = pHolder.gameObject.AddChild(); LevelBorn pBornA = gA.AddComponent <LevelBorn>(); pBornA.Import(data.Ally, true); } if (data.Enemy != null) { GameObject gB = pHolder.gameObject.AddChild(); LevelBorn pBornB = gB.AddComponent <LevelBorn>(); pBornB.Import(data.Enemy, true); } if (data.Neutral != null) { GameObject gC = pHolder.gameObject.AddChild(); LevelBorn pBornC = gC.AddComponent <LevelBorn>(); pBornC.Import(data.Neutral, true); } } Debug.Log("导入关卡数据:" + fsPath); }