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); }
public IEnumerator OnUpdate(LeapOverview leapOverview, GamingMapArea area, GamingMapArea showArea) { m_LeapOverview = leapOverview; m_MeshRender = GetComponent <MeshRenderer>(); gameObject.SetActive(m_IsExportToJson); if (m_MeshRender != null) { if (showArea == null) { m_MeshRender.enabled = false; } else { LeapRoot root = showArea.m_LeapRoot; bool show = false; if (root != null && root.m_VisibleLeapList.Length > 0) { for (int iVisible = 0; iVisible < root.m_VisibleLeapList.Length; iVisible++) { if (m_LeapId == root.m_VisibleLeapList[iVisible]) { show = true; break; } } } m_MeshRender.enabled = show; } } yield return(null); if (area != null && area.m_LeapRoot != null) { LeapRoot leapRoot = area.m_LeapRoot; m_LeapName = leapRoot.m_LeapName; m_LeapType = leapRoot.m_LeapType; m_MainLeapId = leapRoot.m_MainLeapId; transform.position = leapRoot.transform.position; gameObject.name = string.Format("{0}_{1}", m_LeapId, m_LeapName); transform.localScale = Vector3.one * leapRoot.m_Range; } }
private IEnumerator UpdateGamingAreaList() { yield return(null); //不放在OnEnable里初始化是因为 OnEnable时 当前Scene还未加载完毕 Scene scene = GetOwnerScene(); if (scene != null) { string[] paths = scene.path.Split('/'); if (paths != null && paths.Length > 0) { string ownerSceneFloder = scene.path.Substring(0, scene.path.Length - paths[paths.Length - 1].Length); m_OwnerAreaPath = string.Format("{0}{1}", ownerSceneFloder, m_OwnerScene.name); FileUtility.ExistsDirectoryOrCreate(m_OwnerAreaPath); AssetDatabase.Refresh(); } Selection.activeObject = gameObject; } yield return(null); //初始化LeapPreview m_LeapOverview = GetComponentInChildren <LeapOverview>(); if (m_LeapOverview == null) { GameObject leapObj = new GameObject("LeapOverview"); leapObj.transform.SetParent(transform); leapObj.transform.localPosition = Vector3.zero; leapObj.transform.localRotation = Quaternion.identity; m_LeapOverview = leapObj.AddComponent <LeapOverview>(); } yield return(null); //加载对应的MapScene Scene mapScene = GetMapScene(); if (!mapScene.isLoaded) { OpenMapScene(); } yield return(null); IEnumerator initEnumerator = EditorConfigData.Instance.InitExcelData(); if (initEnumerator != null) { while (initEnumerator.MoveNext()) { yield return(null); } } while (true) { InitGamingArea(); yield return(null); IEnumerator updateAreaEnum = UpdataGamingAreas(); if (updateAreaEnum != null) { while (updateAreaEnum.MoveNext()) { yield return(null); } } if (m_LeapOverview != null) { IEnumerator leapUpdateEnum = m_LeapOverview.OnUpdate(this); if (leapUpdateEnum != null) { while (leapUpdateEnum.MoveNext()) { yield return(null); } } } yield return(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); } } } } } }