public override void OnInspectorGUI()
        {
            LevelBorn      pElem = target as LevelBorn;
            BattleCampType pCamp = (BattleCampType)EditorGUILayout.EnumPopup("阵营类型", pElem.Camp);

            if (pCamp != pElem.Camp)
            {
                pElem.Camp = pCamp;
                pElem.Build();
                pElem.SetName();
            }
        }
Exemple #2
0
        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);
        }