public void Init(MineralRoot root) { if (root == null) { return; } m_Root = root; GamingMapArea gamingArea = root.m_GamingMapArea; if (gamingArea != null) { Area[] areas = FindObjectsOfType <Area>(); if (areas != null && areas.Length > 0) { for (int iArea = 0; iArea < areas.Length; iArea++) { Area area = areas[iArea]; if (area.Uid == gamingArea.m_AreaId) { m_Marks = area.GetMineralSemaphoreMarks(); m_RootMark = area.m_MineralRoot; } } } } }
public IEnumerator DoUpdate_Co(Map map, int indexInMap, bool isExporting, AreaSpawner areaSpawner = null) { m_Leap = GetComponentInChildren <MapLeap>(); m_TreasureRoot = GetComponentInChildren <TreasureRootMark>(); if (m_TreasureRoot != null) { IEnumerator treasureEnumerator = m_TreasureRoot.DoUpdate(); if (treasureEnumerator != null) { while (treasureEnumerator.MoveNext()) { yield return(null); } } } yield return(null); map.LoadExtenInfo(this); m_MineralRoot = GetComponentInChildren <MineralRootMark>(); if (m_MineralRoot != null) { IEnumerator mineralEnumerator = m_MineralRoot.DoUpdate(); if (mineralEnumerator != null) { while (mineralEnumerator.MoveNext()) { yield return(null); } } } yield return(null); if (m_Leap != null) { m_Leap.DoUpdate(areaSpawner.m_AreaUid); } m_OwnerMap = map; m_OwnerAreaSpawner = areaSpawner; transform.localScale = Vector3.one; // 美术说Area不会有缩放 if (m_OwnerAreaSpawner != null) { gameObject.name = m_OwnerAreaSpawner.GetAreaSpawnObjName(); } Bounds areaAABB = new Bounds(); MapEditorUtility.CaculateAABB(transform, ref areaAABB, isExporting); m_AABB = areaAABB; m_Diameter = MathUtility.CaculateDiagonal(m_AABB); if (VoxelGrid != null) { VoxelGrid.DoUpdate(m_AABB); } _Debug.DoUpdate(this); }
/// <summary> /// 同步信息 /// </summary> public void SyncInfo() { if (m_MineralCache == null || m_MineralCache.Count <= 0) { return; } if (m_GamingMapArea != null) { MineralRootMark treasureRoot = null; Area[] areas = FindObjectsOfType <Area>(); if (areas != null && areas.Length > 0) { for (int iArea = 0; iArea < areas.Length; iArea++) { Area area = areas[iArea]; if (area.Uid == m_GamingMapArea.m_AreaId) { treasureRoot = area.m_MineralRoot; } } } if (treasureRoot == null) { EditorUtility.DisplayDialog("提示", string.Format("同步失败!未找到{0}", m_GamingMapArea.m_AreaId), "OK"); return; } List <SemaphoreMark> semaphores = treasureRoot.m_SemaphorMarkCache; if (m_MineralCache != null && m_MineralCache.Count > 0) { List <Mineral> needRelease = new List <Mineral>(); for (int iMineral = m_MineralCache.Count - 1; iMineral >= 0; iMineral--) { Mineral mineral = m_MineralCache[iMineral]; bool hasAlive = false; for (int iSem = 0; iSem < semaphores.Count; iSem++) { SemaphoreMark mark = semaphores[iSem]; if (mineral.name == mark.name && mineral.m_MineralNpcId == mark.m_NpcId && mineral.m_MineralGroupId == mark.m_GroupId) { mineral.Sync(mark); hasAlive = true; break; } } if (!hasAlive) { needRelease.Add(mineral); } } if (needRelease != null && needRelease.Count > 0) { for (int iNeed = 0; iNeed < needRelease.Count; iNeed++) { needRelease[iNeed].Release(true); } needRelease.Clear(); } } } }