public void CreateMapEvent <T, S>(MapEvent pData, LevelRegion pRegion, LevelContainerBase <T> pHolder, List <S> pElemDataList) where T : LevelElement where S : MapElement { T tElement = null; if (pData.Active) { for (int i = 0; i < pElemDataList.Count; i++) { if (pElemDataList[i].Id == pData.Id) { tElement = pHolder.AddElement(); tElement.Import(pElemDataList[i], false); if (tElement is LevelWaveSet) { LevelWaveSet waveset = tElement as LevelWaveSet; waveset.Region = pRegion; } tElement.Init(); } } } else { tElement = pHolder.FindElement(pData.Id); if (tElement != null) { DestroyImmediate(tElement.gameObject); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); LevelRegion pElem = target as LevelRegion; Color pColor = EditorGUILayout.ColorField("颜色", pElem.color); if (pColor != pElem.color) { pElem.color = pColor; pElem.Build(); } Vector3 pSize = EditorGUILayout.Vector3Field("大小", pElem.Size); if (pSize != pElem.Size) { pElem.Size = pSize; pElem.Build(); } bool pStartActive = EditorGUILayout.Toggle("默认是否开启", pElem.StartActive); if (pStartActive != pElem.StartActive) { pElem.StartActive = pStartActive; } if (GUILayout.Button("添加事件")) { pElem.AddElement(); } }
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 void StartMapEvent(MapEvent pData, LevelRegion pRegion) { switch (pData.Type) { case MapTriggerType.Barrier: { HolderBarrier pHolder = GetHolder(MapHolderType.Barrier) as HolderBarrier; CreateMapEvent <LevelBarrier, MapBarrier>(pData, pRegion, pHolder, Config.Barriers); } break; case MapTriggerType.Region: { HolderRegion pHolder = GetHolder(MapHolderType.Region) as HolderRegion; CreateMapEvent <LevelRegion, MapRegion>(pData, pRegion, pHolder, Config.Regions); } break; case MapTriggerType.Portal: { HolderPortal pHolder = GetHolder(MapHolderType.Portal) as HolderPortal; CreateMapEvent <LevelPortal, MapPortal>(pData, pRegion, pHolder, Config.Portals); } break; case MapTriggerType.Waveset: { HolderWaveSet pHolder = GetHolder(MapHolderType.WaveSet) as HolderWaveSet; CreateMapEvent <LevelWaveSet, MapWaveSet>(pData, pRegion, pHolder, Config.WaveSets); } break; case MapTriggerType.Result: { OnLevelEnd(); } break; case MapTriggerType.Monstegroup: { HolderMonsterGroup pHolder = GetHolder(MapHolderType.MonsterGroup) as HolderMonsterGroup; CreateMapEvent <LevelMonsterGroup, MapMonsterGroup>(pData, pRegion, pHolder, Config.MonsterGroups); } break; case MapTriggerType.Minegroup: { HolderMineGroup pHolder = GetHolder(MapHolderType.MineGroup) as HolderMineGroup; CreateMapEvent <LevelMineGroup, MapMineGroup>(pData, pRegion, pHolder, Config.MineGroups); } break; } }
public override void OnInspectorGUI() { LevelMineGroup pElem = target as LevelMineGroup; int pId = EditorGUILayout.IntField("Id", pElem.Id); if (pElem.Id != pId) { pElem.Id = pId; pElem.SetName(); } int pMineID = EditorGUILayout.IntField("创建矿物ID", pElem.MineID); if (pMineID != pElem.MineID) { pElem.MineID = pMineID; for (int i = 0; i < pElem.Elements.Count; i++) { LevelMine mine = pElem.Elements[i]; mine.Id = pMineID; mine.SetName(); mine.Build(); } } float pRebornCD = EditorGUILayout.FloatField("矿物重生时间", pElem.RebornCD); if (pRebornCD != pElem.RebornCD) { pElem.RebornCD = pRebornCD; } if (GUILayout.Button("添加矿物")) { LevelMine pMine = pElem.AddElement(); pMine.Id = pMineID; pMine.SetName(); pMine.Build(); } 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()); }
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); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); LevelPortal pElem = target as LevelPortal; int pDestID = EditorGUILayout.IntField("目标区域ID", pElem.DestMapID); if (pDestID != pElem.DestMapID) { pElem.DestMapID = pDestID; pElem.Build(); } bool pIsDisplayText = EditorGUILayout.Toggle("显示文字", pElem.DisplayText); if (pIsDisplayText != pElem.DisplayText) { pElem.DisplayText = pIsDisplayText; pElem.Build(); } string pPortalName = EditorGUILayout.TextField("传送门名字",pElem.PortalName); if (pPortalName != pElem.PortalName) { pElem.PortalName = pPortalName; pElem.Build(); } EditorGUILayout.Space(); EditorGUILayout.IntField("特效ID", pElem.SerialId); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("传送所需条件之间的关系,当一个条件值为-1时不参与"); ConditionRelationType pRelation = (ConditionRelationType)EditorGUILayout.EnumPopup(string.Empty, pElem.Relation); if (pRelation != pElem.Relation) { pElem.Relation = pRelation; } EditorGUILayout.EndVertical(); int pOpenLevel = EditorGUILayout.IntField("传送所需等级", pElem.OpenLevel); if (pOpenLevel != pElem.OpenLevel) { pElem.OpenLevel = pOpenLevel; } int pOpenItemID = EditorGUILayout.IntField("传送所需所需物品ID", pElem.OpenItemID); if (pOpenItemID != pElem.OpenItemID) { pElem.OpenItemID = pOpenItemID; } int pOpenVIP = EditorGUILayout.IntField("传送所需VIP等级", pElem.OpenVIP); if (pOpenVIP != pElem.OpenVIP) { pElem.OpenVIP = pOpenVIP; } 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()); }