Esempio n. 1
0
        public void Init(TreasureRoot 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.GetSemaphoreMarks();
                            m_RootMark = area.m_TreasureRoot;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <summary>
        /// 同步信息
        /// </summary>
        public void SyncInfo()
        {
            if (m_TreasureCache == null || m_TreasureCache.Count <= 0)
            {
                return;
            }

            if (m_GamingMapArea != null)
            {
                TreasureRootMark 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_TreasureRoot;
                        }
                    }
                }

                if (treasureRoot == null)
                {
                    EditorUtility.DisplayDialog("提示", string.Format("同步失败!未找到{0}", m_GamingMapArea.m_AreaId), "OK");
                    return;
                }

                List <SemaphoreMark> semaphores = treasureRoot.m_SemaphorMarkCache;
                if (m_TreasureCache != null && m_TreasureCache.Count > 0)
                {
                    List <Treasure> needRelease = new List <Treasure>();
                    for (int iTreasure = m_TreasureCache.Count - 1; iTreasure >= 0; iTreasure--)
                    {
                        Treasure treasure = m_TreasureCache[iTreasure];
                        bool     hasAlive = false;
                        for (int iSem = 0; iSem < semaphores.Count; iSem++)
                        {
                            SemaphoreMark mark = semaphores[iSem];
                            if (treasure.name == mark.name && treasure.m_TreasureNpcId == mark.m_NpcId &&
                                treasure.m_TreasureGroupId == mark.m_GroupId)
                            {
                                treasure.Sync(mark);
                                hasAlive = true;
                                break;
                            }
                        }
                        if (!hasAlive)
                        {
                            needRelease.Add(treasure);
                        }
                    }
                    if (needRelease != null && needRelease.Count > 0)
                    {
                        for (int iNeed = 0; iNeed < needRelease.Count; iNeed++)
                        {
                            needRelease[iNeed].Release(true);
                        }
                        needRelease.Clear();
                    }
                }
            }
        }