예제 #1
0
 private void OnEnable()
 {
     m_Target             = target as GamingMap;
     m_SelectTypeIndex    = (int)m_Target.m_Type;
     m_NeedDeleteMissions = new List <int>();
     RefreshHumanSpaceIds();
     RefreshFixedStarIds();
     RefreshMissionIds();
 }
예제 #2
0
        private IEnumerator ExportToJson(GamingMap gamingMap, Map map)
        {
            List <AreaSpawner> areaSpawnerList = map.GetAreaSpawnerList();

            if (areaSpawnerList != null && areaSpawnerList.Count > 0)
            {
                for (int iArea = 0; iArea < areaSpawnerList.Count; iArea++)
                {
                    AreaSpawner areaSpawner = areaSpawnerList[iArea];
                    if (areaSpawner != null)
                    {
                        LoadGamingMapArea(areaSpawner, false);
                        yield return(null);
                    }
                }
            }
            yield return(null);

            InitGamingArea();
            yield return(null);

            BeginExport();
            yield return(null);

            IEnumerator updateAreaEnum = UpdataGamingAreas(true);

            if (updateAreaEnum != null)
            {
                while (updateAreaEnum.MoveNext())
                {
                    yield return(null);
                }
            }
            yield return(null);

            //刷新LeapOverview
            if (m_LeapOverview != null)
            {
                IEnumerator leapOverviewUpdate = m_LeapOverview.OnUpdate(this);
                if (leapOverviewUpdate != null)
                {
                    while (leapOverviewUpdate != null && leapOverviewUpdate.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            yield return(null);

            EditorGamingMapData.SaveGamingMapToJson(gamingMap);
            yield return(null);

            gamingMap.EndExport();
            yield return(null);

            m_ExporterGamingMapHandle.IsDone = true;
        }
예제 #3
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="areaId"></param>
 public void Init(AreaSpawner areaSpawner, GamingMap map)
 {
     m_GamingMap = map;
     m_AreaId    = areaSpawner.GetAreaId();
     //gameObject.name = string.Format("Area_{0}", m_AreaId);
     //gameObject.name = string.Format("Area_{0}", m_AreaName);
     gameObject.name = string.Format("{0}_{1}", m_AreaName, m_AreaId);
     AdjustTransform(areaSpawner);
     RefreshAreaInfo();
 }
예제 #4
0
        public void Init(EditorTeleport[] teleports, GamingMapArea area)
        {
            m_GamingMapArea = area;
            m_EditorTeleport = teleports;
            GetTeleportList();
            GetTeleportShowNames();

            //m_SelectLocation = new Dictionary<int, int>();
            m_SelectLocation = new List<TeleportInfo>();

            if (m_EditorTeleport != null && m_EditorTeleport.Length > 0)
            {
                for (int iTeleport = 0;  m_EditorTeleport != null && iTeleport < m_EditorTeleport.Length; iTeleport++)
                {
                    EditorChanel[] chanelList = m_EditorTeleport[iTeleport].chanelList;
                    if (chanelList != null && chanelList.Length > 0)
                    {
                        for (int iChanel = 0; iChanel < chanelList.Length; iChanel++)
                        {
                            EditorChanel chanel = chanelList[iChanel];
                            TeleportChanelVO chanelVO = ConfigVO<TeleportChanelVO>.Instance.GetData(chanel.chanelId);
                            if (chanelVO != null)
                            {
                                EditorLocation[] locations = GamingMap.GetEditorLocations(chanelVO.EndGamingMap, chanelVO.EndGamingMapArea);
                                if (locations != null && locations.Length > 0)
                                {

                                    List<EditorLocation> locationList = new List<EditorLocation>();
                                    for (int iLocation = 0; iLocation < locations.Length; iLocation++)
                                    {
                                        EditorLocation location = locations[iLocation];
                                        if (location.locationType == (int)LocationType.TeleportIn)
                                        {
                                            locationList.Add(location);
                                        }
                                    }

                                    for (int iLocation = 0; iLocation < locationList.Count; iLocation++)
                                    {
                                        if (locationList[iLocation].locationId == chanel.eLocation)
                                        {
                                            m_SelectLocation.Add(new TeleportInfo(chanel.chanelId, iLocation));
                                            break;
                                        }
                                    }
                                }

                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 显示模型
        /// </summary>
        public void ShowModel()
        {
            if (string.IsNullOrEmpty(m_ModelPath))
            {
                if (transform.childCount > 0)
                {
                    for (int iChild = transform.childCount - 1; iChild >= 0; iChild--)
                    {
                        DestroyImmediate(transform.GetChild(iChild).gameObject);
                    }
                }
            }

            if (transform.childCount > 0)
            {
                for (int iChild = 0; iChild < transform.childCount; iChild++)
                {
                    transform.GetChild(iChild).gameObject.SetActive(true);
                }
                return;
            }

            string    modelPath = GetModelPath();
            GamingMap map       = m_Root.GetGamingMap();

            if (!string.IsNullOrEmpty(modelPath))
            {
                GameObject teleportTemplete = AssetDatabase.LoadAssetAtPath <GameObject>(modelPath);
                if (teleportTemplete != null)
                {
                    GameObject locationObj = GameObject.Instantiate(teleportTemplete);
                    Collider[] colliders   = locationObj.GetComponents <Collider>();
                    if ((colliders == null || colliders.Length <= 0) && m_Root.GetGamingMapType() != GamingMapType.mapMainCity)
                    {
                        CapsuleCollider collider = EditorGamingMapData.CalculateCapsuleCollider(locationObj);
                        if (collider != null)
                        {
                            GamingMapArea area = m_Root.m_GamingMapArea;
                            if (area != null)
                            {
                                area.SetMaxWarShipHeight(collider.height);
                            }
                        }
                    }
                    locationObj.transform.SetParent(transform);
                    locationObj.transform.localPosition = Vector3.zero;
                    locationObj.transform.localRotation = Quaternion.identity;
                    locationObj.transform.localScale    = Vector3.one;
                }
            }
        }
예제 #6
0
 public override ExporterHandle BeginExport(params object[] exportPara)
 {
     if (exportPara == null || exportPara.Length < 2)
     {
         Debug.LogError("ExportGamingMapData 参数异常");
         return(null);
     }
     m_Map       = exportPara[0] as Map;
     m_GamingMap = exportPara[1] as GamingMap;
     if (exportPara.Length >= 3)
     {
         m_ExportAreaIds = exportPara[2] as List <ulong>;
     }
     return(base.BeginExport(exportPara));
 }
예제 #7
0
        public IEnumerator OnUpdate(GamingMapArea mapArea)
        {
            MapLeap[] mapLeaps = FindObjectsOfType <MapLeap>();
            if (mapLeaps != null && mapLeaps.Length > 0)
            {
                for (int iMap = 0; iMap < mapLeaps.Length; iMap++)
                {
                    if (mapLeaps[iMap].m_AreaId == mapArea.m_AreaId)
                    {
                        transform.position = mapLeaps[iMap].GetPosition();
                        break;
                    }
                }
            }
            yield return(null);

            m_Collider = GetComponent <SphereCollider>();
            if (m_Collider == null)
            {
                m_Collider = gameObject.AddComponent <SphereCollider>();
            }

            m_Collider.radius = 0.5f + m_Offest + mapArea.GetMaxWarShipHeight() / 2;
            m_GamingMapArea   = mapArea;
            m_LeapId          = mapArea.m_AreaId;
            GamingMap gamingMap = m_GamingMapArea.m_GamingMap;

            m_LeapOverView = gamingMap.m_LeapOverview;
            yield return(null);

            RefreshColliderState();
            yield return(null);

            transform.localScale = Vector3.one * m_Range;

            //可见跃迁点每帧去算 是因为以防所有GamingMapArea加载进来后,策划手动去改了其他区域的跃迁点信息
            List <ulong> cacheList = gamingMap.m_LeapIdCache;

            cacheList.Clear();
            CalcuateVisibleList(ref cacheList);
            m_VisibleLeapList = cacheList.ToArray();
            yield return(null);
        }
예제 #8
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="area"></param>
        /// <param name="map"></param>
        public void Init(EditorArea area, GamingMap map)
        {
            m_GamingMap      = map;
            m_AreaId         = area.areaId;
            m_EditorArea     = area;
            m_AreaName       = area.areaName;
            m_AreaType       = (AreaType)area.areaType;
            m_FatherArea     = area.fatherArea;
            m_RelieveCreatue = area.relieveCreature;
            if (area.childrenAreaList != null && area.childrenAreaList.Length > 0)
            {
                m_ChildAreas = new List <ulong>();
                for (int iChild = 0; iChild < area.childrenAreaList.Length; iChild++)
                {
                    m_ChildAreas.Add(area.childrenAreaList[iChild]);
                }
            }
            else
            {
                m_ChildAreas = null;
            }
            //gameObject.name = string.Format("Area_{0}", m_AreaName);
            gameObject.name = string.Format("{0}_{1}", m_AreaName, m_AreaId);
            AreaSpawner areaSpawner = map.GetAreaSpawner(m_AreaId);

            AdjustTransform(areaSpawner);

            if (m_EditorArea != null)
            {
                CreateRoots(m_EditorArea);
                m_EditorArea = null;
            }

            if (area.sceneMissionReleaseId != null && area.sceneMissionReleaseId.Length > 0)
            {
                m_MissionList = new List <int>(area.sceneMissionReleaseId);
            }
        }
예제 #9
0
 /// <summary>
 /// 获取当前打开的Scene
 /// </summary>
 private void InitOwnerScene()
 {
     for (int iScene = 0; iScene < SceneManager.sceneCount; iScene++)
     {
         Scene scene = SceneManager.GetSceneAt(iScene);
         if (!scene.isLoaded)
         {
             continue;
         }
         GameObject[] rootObjs = scene.GetRootGameObjects();
         if (rootObjs != null && rootObjs.Length > 0)
         {
             for (int iRoot = 0; iRoot < rootObjs.Length; iRoot++)
             {
                 GamingMap map = rootObjs[iRoot].GetComponent <GamingMap>();
                 if (map != null && map == this)
                 {
                     m_OwnerScene = scene;
                     break;
                 }
             }
         }
     }
 }
예제 #10
0
 /// <summary>
 /// 开始导出collider
 /// </summary>
 public ExporterHandle BeginExportGamingMap(GamingMap gamingMap, Map map)
 {
     m_ExporterGamingMapHandle.IsDone = false;
     m_OnExportEnumerator             = ExportToJson(gamingMap, map);
     return(m_ExporterGamingMapHandle);
 }
예제 #11
0
        /// <summary>
        /// 刷新GamingMap ui
        /// </summary>
        /// <param name="map"></param>
        private void RefreshMapUI(GamingMap gamingMap)
        {
            if (gamingMap == null)
            {
                return;
            }

            m_ContentCache.Clear();
            m_ContentCache.Add(new GUIContent("导出数据到json"));
            m_ContentCache.Add(new GUIContent("保存"));
            Scene scene = gamingMap.GetMapScene();

            if (!scene.isLoaded)
            {
                gamingMap.OpenMapScene();
            }

            Map map = null;

            GameObject[] rootObjs = scene.GetRootGameObjects();
            if (rootObjs != null && rootObjs.Length > 0)
            {
                for (int iRoot = 0; iRoot < rootObjs.Length; iRoot++)
                {
                    GameObject obj = rootObjs[iRoot];
                    map = obj.GetComponent <Map>();
                    if (map != null)
                    {
                        break;
                    }
                }
            }
            if (map != null)
            {
                List <AreaSpawner> areaSpawnerList = map.GetAreaSpawnerList();
                if (areaSpawnerList != null && areaSpawnerList.Count > 0)
                {
                    for (int iArea = 0; iArea < areaSpawnerList.Count; iArea++)
                    {
                        AreaSpawner areaSpawner = areaSpawnerList[iArea];
                        GUIContent  content     = new GUIContent(string.Format("区域/GamingArea_{0}", areaSpawner.GetAreaId()));
                        m_ContentCache.Add(content);
                    }
                }
            }

            Vector2    mousePosition = Event.current.mousePosition;
            GameObject userData      = Selection.activeGameObject;
            int        selected      = -1;

            EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), m_ContentCache.ToArray(), selected,
                                            delegate(object data, string[] opt, int select)
            {
                switch (select)
                {
                case 0:
                    //BeginExportGamingMap(gamingMap,map);
                    List <ulong> areaIds = new List <ulong>();
                    List <Leap> allLeaps = m_LeapOverview.m_LeapList;
                    if (allLeaps != null && allLeaps.Count > 0)
                    {
                        for (int iLeap = 0; iLeap < allLeaps.Count; iLeap++)
                        {
                            if (allLeaps[iLeap].m_IsExportToJson)
                            {
                                areaIds.Add(allLeaps[iLeap].m_LeapId);
                            }
                        }
                    }
                    new ExportGamingMapData().BeginExport(map, gamingMap, areaIds);
                    break;

                case 1:                                //保存
                    gamingMap.SaveScene();
                    break;

                default:
                    gamingMap.OnClickArea(select, map);
                    break;
                }
            }, userData);
            Event.current.Use();
        }
예제 #12
0
        /// <summary>
        /// 右键响应
        /// </summary>
        /// <param name="instanceID"></param>
        /// <param name="selectionRect"></param>
        private void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            if (Event.current != null && selectionRect.Contains(Event.current.mousePosition) &&
                Event.current.button == 1 && Event.current.type <= EventType.MouseUp)
            {
                GameObject selectedGameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
                if (selectedGameObject)
                {
                    CreatureRoot creatureRoot = selectedGameObject.GetComponent <CreatureRoot>();
                    if (creatureRoot != null)
                    {
                        RefreshCreatureRootUI(creatureRoot);
                    }

                    Creature creature = selectedGameObject.GetComponent <Creature>();
                    if (creature != null)
                    {
                        RefreshCreatureUI(creature);
                    }

                    LocationRoot locationRoot = selectedGameObject.GetComponent <LocationRoot>();
                    if (locationRoot != null)
                    {
                        RefreashLocationRootUI(locationRoot);
                    }

                    Location location = selectedGameObject.GetComponent <Location>();
                    if (location != null)
                    {
                        RefreshLocationUI(location);
                    }

                    TriggerRoot triggerRoot = selectedGameObject.GetComponent <TriggerRoot>();
                    if (triggerRoot != null)
                    {
                        RefreshTriggerRootUI(triggerRoot);
                    }
                    Trigger trigger = selectedGameObject.GetComponent <Trigger>();
                    if (trigger != null)
                    {
                        RefreshTriggerUI(trigger);
                    }

                    TeleportRoot teleportRoot = selectedGameObject.GetComponent <TeleportRoot>();
                    if (teleportRoot != null)
                    {
                        RefreashTeleportRootUI(teleportRoot);
                    }

                    GamingMapArea mapArea = selectedGameObject.GetComponent <GamingMapArea>();
                    if (mapArea != null)
                    {
                        RefreshMapAreaUI(mapArea);
                    }

                    GamingMap map = selectedGameObject.GetComponent <GamingMap>();
                    if (map != null)
                    {
                        RefreshMapUI(map);
                    }

                    Leap leap = selectedGameObject.GetComponent <Leap>();
                    if (leap != null)
                    {
                        RefreshLeapUI(leap);
                    }
                }
            }
        }
예제 #13
0
 protected override void DoEnd()
 {
     base.DoEnd();
     m_Map       = null;
     m_GamingMap = null;
 }
        protected override IEnumerator DoExport()
        {
            if (m_GamingMapPaths != null && m_GamingMapPaths.Count > 0)
            {
                for (int iMap = 0; iMap < m_GamingMapPaths.Count; iMap++)
                {
                    string mapPath   = m_GamingMapPaths[iMap];
                    Scene  iterScene = EditorSceneManager.OpenScene(mapPath, OpenSceneMode.Single);

                    GameObject[] rootGameObjects = iterScene.GetRootGameObjects();
                    for (int iRootGameObject = 0; iRootGameObject < rootGameObjects.Length; iRootGameObject++)
                    {
                        GameObject iterGameObject = rootGameObjects[iRootGameObject];
                        GamingMap  iterMap        = iterGameObject.GetComponent <GamingMap>();
                        if (iterMap)
                        {
                            Scene scene = iterMap.GetMapScene();
                            if (!scene.isLoaded)
                            {
                                iterMap.OpenMapScene();
                                scene = iterMap.GetMapScene();
                            }
                            while (!scene.isLoaded)
                            {
                                yield return(null);
                            }
                            Map          map      = null;
                            GameObject[] rootObjs = scene.GetRootGameObjects();
                            if (rootObjs != null && rootObjs.Length > 0)
                            {
                                for (int iRoot = 0; iRoot < rootObjs.Length; iRoot++)
                                {
                                    GameObject obj = rootObjs[iRoot];
                                    map = obj.GetComponent <Map>();
                                    if (map != null)
                                    {
                                        break;
                                    }
                                }
                            }
                            while (map == null)
                            {
                                yield return(null);
                            }
                            LeapOverview leapOverView = iterMap.GetComponentInChildren <LeapOverview>();
                            List <ulong> areaIds      = null;
                            if (leapOverView != null)
                            {
                                areaIds = new List <ulong>();
                                List <Leap> allLeaps = leapOverView.m_LeapList;
                                if (allLeaps != null && allLeaps.Count > 0)
                                {
                                    for (int iLeap = 0; iLeap < allLeaps.Count; iLeap++)
                                    {
                                        if (allLeaps[iLeap].m_IsExportToJson)
                                        {
                                            areaIds.Add(allLeaps[iLeap].m_LeapId);
                                        }
                                    }
                                }
                            }
                            ExporterHandle handle = new ExportGamingMapData().BeginExport(map, iterMap, areaIds);
                            //ExporterHandle handle = iterMap.BeginExportGamingMap(iterMap, map);
                            while (!handle.IsDone)
                            {
                                yield return(null);
                            }
                        }
                    }
                }
            }
        }
예제 #15
0
        public override void OnInspectorGUI()
        {
            EditorGUI.indentLevel = 0;
            GUILayout.BeginVertical("box");
            if (m_Teleports != null && m_Teleports.Count > 0)
            {
                for (int iTeleport = 0; iTeleport < m_Teleports.Count; iTeleport++)
                {
                    m_ShowTeleportPoup[iTeleport] = EditorGUILayout.Foldout(m_ShowTeleportPoup[iTeleport], m_ShowTeleportNames[iTeleport]);
                    if (m_ShowTeleportPoup[iTeleport])
                    {
                        EditorGUI.indentLevel = 1;
                        int[] chanelList = m_Teleports[iTeleport].ChanelList;
                        if (chanelList != null && chanelList.Length > 0)
                        {
                            GUILayout.BeginVertical("box");
                            if (m_Target.m_SelectLocation == null)
                            {
                                m_Target.m_SelectLocation = new List <TeleportRoot.TeleportInfo>();
                            }
                            for (int iChanel = 0; iChanel < chanelList.Length; iChanel++)
                            {
                                GUILayout.BeginVertical("box");
                                TeleportChanelVO chanelVO = ConfigVO <TeleportChanelVO> .Instance.GetData(chanelList[iChanel]);

                                if (chanelVO != null)
                                {
                                    TeleportRoot.TeleportInfo info = m_Target.GetTeleportInfo(chanelVO.ID);
                                    if (info == null)
                                    {
                                        info = new TeleportRoot.TeleportInfo(chanelVO.ID, -1);
                                        m_Target.m_SelectLocation.Add(info);
                                    }
                                    EditorGUILayout.LabelField("通道ID", chanelList[iChanel].ToString());
                                    EditorGamingMap gamingMap = EditorGamingMapData.LoadGamingMapFromJson(chanelVO.EndGamingMap);
                                    if (gamingMap != null)
                                    {
                                        EditorGUILayout.LabelField("终点地图", gamingMap.gamingmapName);
                                        EditorArea area = gamingMap.GetAreaByAreaId(chanelVO.EndGamingMapArea);
                                        if (area != null)
                                        {
                                            EditorGUILayout.LabelField("终点区域", area.areaName);
                                        }
                                    }

                                    EditorLocation[] locations = GamingMap.GetEditorLocations(chanelVO.EndGamingMap, chanelVO.EndGamingMapArea);
                                    if (locations != null && locations.Length > 0)
                                    {
                                        string[]      m_LocationIdArray = null;
                                        List <string> locationIds       = new List <string>();
                                        for (int iLocation = 0; iLocation < locations.Length; iLocation++)
                                        {
                                            EditorLocation location = locations[iLocation];
                                            if (location.locationType == (int)LocationType.TeleportIn)
                                            {
                                                string locationStr = string.Format("{0}_{1}", locations[iLocation].locationName, locations[iLocation].locationId);
                                                locationIds.Add(locationStr);
                                            }
                                        }
                                        m_LocationIdArray  = locationIds.ToArray();
                                        info.m_SelectIndex = EditorGUILayout.Popup("Location ID", info.m_SelectIndex, m_LocationIdArray);
                                    }
                                }
                                GUILayout.EndVertical();
                            }
                            GUILayout.EndVertical();
                        }
                    }
                }
            }
            GUILayout.EndVertical();
        }
예제 #16
0
        public IEnumerator OnUpdate(GamingMap gamingMap)
        {
            m_GamingMap = gamingMap;
            if (m_LeapList == null)
            {
                m_LeapList = new List <Leap>();
            }
            m_LeapList.Clear();
            Leap[] leaps = GetComponentsInChildren <Leap>(true);
            if (leaps != null && leaps.Length > 0)
            {
                for (int iLeap = 0; iLeap < leaps.Length; iLeap++)
                {
                    m_LeapList.Add(leaps[iLeap]);
                }
            }
            yield return(null);

            //为了确定有没有遗漏没有的跃迁点
            if (m_GamingMap != null)
            {
                List <GamingMapArea> areaList = m_GamingMap.m_GamingAreaList;
                if (areaList != null && areaList.Count > 0)
                {
                    for (int iArea = 0; iArea < areaList.Count; iArea++)
                    {
                        GamingMapArea area = areaList[iArea];
                        if (area != null)
                        {
                            LeapRoot leapRoot = area.m_LeapRoot;
                            if (leapRoot != null)
                            {
                                Leap leap = GetLeap(leapRoot.m_LeapId);
                                if (leap == null)
                                {
                                    leap = CreateLeap(leapRoot);
                                    m_LeapList.Add(leap);
                                }
                            }
                        }
                    }
                }
            }
            yield return(null);

            //因为只能由一个区域在线
            GamingMapArea showArea = null;

            if (m_GamingMap.m_GamingAreaList != null && m_GamingMap.m_GamingAreaList.Count > 0)
            {
                showArea = m_GamingMap.m_GamingAreaList[0];
            }
            //刷新Leap
            if (m_LeapList != null && m_LeapList.Count > 0)
            {
                for (int iLeap = 0; iLeap < m_LeapList.Count; iLeap++)
                {
                    Leap leap = m_LeapList[iLeap];

                    IEnumerator leapUpdateEnum = leap.OnUpdate(this, GetArea(leap.m_LeapId), showArea);
                    while (leapUpdateEnum != null && leapUpdateEnum.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            yield return(null);
        }
예제 #17
0
        public IEnumerator OnUpdate(GamingMap map, bool isExport = false)
        {
            m_GamingMap     = map;
            m_AreaScenePath = string.Format("{0}/GamingMapArea_{1}_{2}.unity", m_GamingMap.GetOwnerAreaPath(), m_GamingMap.m_Uid, m_AreaId);
            gameObject.name = string.Format("{0}_{1}", m_AreaName, m_AreaId);
            if (m_CreatureRoot == null && m_LocationRoot == null && m_TriggerRoot == null && m_TreasureRoot == null && m_MineralRoot == null)
            {
                yield return(null);
            }
            else
            {
                if (m_CreatureRoot != null)
                {
                    IEnumerator creatureRootEnumerot = m_CreatureRoot.OnUpdate(this);
                    if (creatureRootEnumerot != null)
                    {
                        while (m_CreatureRoot != null && creatureRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }
                if (m_LocationRoot != null)
                {
                    IEnumerator locationRootEnumerot = m_LocationRoot.OnUpdate(this);
                    if (locationRootEnumerot != null)
                    {
                        while (m_LocationRoot != null && m_LocationRoot.gameObject != null && locationRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                if (m_TeleportRoot != null)
                {
                    IEnumerator teleportRootEnumerot = m_TeleportRoot.OnUpdate(this);
                    if (teleportRootEnumerot != null)
                    {
                        while (m_TeleportRoot != null && teleportRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                if (m_LeapRoot != null)
                {
                    IEnumerator leapRootEnumerot = m_LeapRoot.OnUpdate(this);
                    if (leapRootEnumerot != null)
                    {
                        while (m_LeapRoot != null && leapRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                if (m_TriggerRoot != null)
                {
                    IEnumerator triggerRootEnumerot = m_TriggerRoot.OnUpdate(this);
                    if (triggerRootEnumerot != null)
                    {
                        while (m_TriggerRoot != null && m_TriggerRoot.gameObject != null && triggerRootEnumerot != null && triggerRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                if (m_TreasureRoot != null && m_TreasureRoot.gameObject != null)
                {
                    IEnumerator treasureRootEnumerot = m_TreasureRoot.OnUpdate(this);
                    if (treasureRootEnumerot != null)
                    {
                        while (m_TreasureRoot != null && m_TreasureRoot.gameObject != null &&
                               treasureRootEnumerot != null && treasureRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                if (m_MineralRoot != null && m_MineralRoot.gameObject != null)
                {
                    IEnumerator mineralRootEnumerot = m_MineralRoot.OnUpdate(this);
                    if (mineralRootEnumerot != null)
                    {
                        while (m_MineralRoot != null && m_MineralRoot.gameObject != null &&
                               mineralRootEnumerot != null && mineralRootEnumerot.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }
            }
            if (isExport)
            {
                RefreshAreaInfo();
            }
        }
예제 #18
0
        private void OnGUI()
        {
            GUILayout.BeginHorizontal("box");
            EditorGUILayout.LabelField("关联地图Scene:", m_RelationScene);
            if (m_HasSelect)
            {
                if (GUILayout.Button("收起", GUILayout.Width(100)))
                {
                    m_HasSelect = false;
                }
                GUILayout.EndHorizontal();
                m_VerticalPos = GUILayout.BeginScrollView(m_VerticalPos);
                GUILayout.BeginVertical("box");
                if (m_RelationSceneList != null && m_RelationSceneList.Count > 0)
                {
                    for (int iRelation = 0; iRelation < m_RelationSceneList.Count; iRelation++)
                    {
                        string[] splitPath = m_RelationSceneList[iRelation].Split('/');
                        if (splitPath != null && splitPath.Length > 0)
                        {
                            string showPath = splitPath[splitPath.Length - 1];
                            if (!string.IsNullOrEmpty(showPath))
                            {
                                showPath = showPath.Replace(".unity", "");
                                if (GUILayout.Button(showPath))
                                {
                                    m_RelationScene = m_RelationSceneList[iRelation];
                                    m_HasSelect     = false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    GUILayout.Label("未找到关联的Scene");
                }
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            }
            else
            {
                if (GUILayout.Button("选择", GUILayout.Width(100)))
                {
                    m_HasSelect = true;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginVertical("box");
            m_GamingMapId   = EditorGUILayout.TextField("GamingMap Id:", m_GamingMapId);
            m_GamingMapName = EditorGUILayout.TextField("名称:", m_GamingMapName);
            //m_GamingMapType = (GamingMapType)EditorGUILayout.EnumPopup("类型:", m_GamingMapType);
            m_SelectTypeIndex = EditorGUILayout.Popup(new GUIContent("类型:"), m_SelectTypeIndex, EditorGamingMapData.GAMINGMAPTYPE_NAME);
            m_GamingMapType   = (GamingMapType)m_SelectTypeIndex;
            if (GUILayout.Button("创建"))
            {
                if (m_RelationScene == null)
                {
                    EditorUtility.DisplayDialog("提示", "请选择关联地图Scene", "确定");
                    return;
                }

                uint mapId;
                if (!uint.TryParse(m_GamingMapId, out mapId))
                {
                    EditorUtility.DisplayDialog("提示", "GamingMap id格式错误", "确定");
                    return;
                }
                if (string.IsNullOrEmpty(m_GamingMapName))
                {
                    EditorUtility.DisplayDialog("提示", "名称不能为空", "确定");
                    return;
                }
                string mapPath = "";
                GamingMapEditorSetting gamingSetting = GamingMapEditorUtility.GetGamingMapEditorSetting();
                if (gamingSetting != null)
                {
                    mapPath = string.Format("{0}/GamingMap_{1}.unity", MapEditorUtility.GetFullPath(gamingSetting.m_GamingMapPath), mapId);
                }
                if (File.Exists(mapPath))
                {
                    EditorUtility.DisplayDialog("提示", "该GamingMap已存在", "确定");
                    return;
                }
                List <Scene> openScenes = new List <Scene>();
                for (int iScene = 0; iScene < EditorSceneManager.sceneCount; iScene++)
                {
                    Scene sceneTmp = EditorSceneManager.GetSceneAt(iScene);
                    openScenes.Add(sceneTmp);
                }

                SaveOpenScene();
                //打开对应的map 找到mapid 创建Gamingmap 初始化GamingMap和Area
                Scene        scene = EditorSceneManager.OpenScene(m_RelationScene, OpenSceneMode.Additive);
                Map          map   = null;
                GameObject[] objs  = scene.GetRootGameObjects();
                if (objs != null && objs.Length > 0)
                {
                    for (int iObj = 0; iObj < objs.Length; iObj++)
                    {
                        map = objs[iObj].GetComponent <Map>();
                        if (map != null)
                        {
                            break;
                        }
                    }
                }

                //string gamingPath = PlayerPrefsUtility.GetString(Constants.GAMINGMAP_TEMPLETE_PATH);
                string gamingPath = "";
                if (gamingSetting != null)
                {
                    gamingPath  = MapEditorUtility.GetFullPath(gamingSetting.m_GamingMapTemplete);
                    gamingPath += "/";
                }
                FileUtil.CopyFileOrDirectory(gamingPath, mapPath);
                AssetDatabase.ImportAsset(mapPath);
                Scene        exportScene = EditorSceneManager.OpenScene(mapPath, OpenSceneMode.Additive);
                GameObject[] exportObjs  = exportScene.GetRootGameObjects();
                if (exportObjs != null && exportObjs.Length > 0)
                {
                    for (int iExport = 0; iExport < exportObjs.Length; iExport++)
                    {
                        GamingMap gamingMap = exportObjs[iExport].GetComponent <GamingMap>();
                        if (gamingMap != null)
                        {
                            gamingMap.Init(mapId, map.Uid, m_GamingMapName, m_GamingMapType, map.GetAreaSpawnerList());
                            break;
                        }
                    }
                }
                SceneManager.SetActiveScene(exportScene);
                EditorSceneManager.SaveScene(exportScene);
                EditorSceneManager.CloseScene(scene, true);

                if (openScenes != null && openScenes.Count > 0)
                {
                    for (int iOpen = 0; iOpen < openScenes.Count; iOpen++)
                    {
                        Scene openScene = openScenes[iOpen];
                        EditorSceneManager.SaveScene(openScene);
                        EditorSceneManager.CloseScene(openScene, true);
                    }
                }
            }
            GUILayout.EndVertical();
        }