Beispiel #1
0
 private void Update()
 {
     m_AllZone = FindObjectsOfType <LevelZone>();
     v_Type    = (enZoneType)0;
     for (int i = 0; i < m_AllZone.Length; i++)
     {
         if (m_AllZone[i].F_IsInRound(this.transform.position))
         {
             v_Type |= m_AllZone[i].v_ZoneType;
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 通过坐标获取当前所属的区域类型
        /// </summary>
        /// <param name="pos">坐标</param>
        /// <returns></returns>
        private enZoneType GetCurrentTypeByPos(Vector3 pos)
        {
            enZoneType type = (enZoneType)0;

            for (int i = 0; i < m_AllZone.Length; i++)
            {
                if (m_AllZone[i].F_IsInRound(pos))
                {
                    type |= m_AllZone[i].v_ZoneType;
                }
            }

            return(type);
        }
Beispiel #3
0
        private void ClearZone(enZoneType zone)
        {
            // 清除不在这个区域的数据与资源
            for (int i = m_StackObj.Count - 1; i >= 0; i--)
            {
                if ((m_StackObj[i].v_ZoneType & zone) == 0)
                {
                    Destroy(m_StackObj[i].v_LevelObj);
                    m_StackObj.Remove(m_StackObj[i]);
                }
            }

            SetLightMap(m_StackObj);
        }
Beispiel #4
0
        /// <summary>
        /// 刷新区域
        /// </summary>
        /// <param name="isForceUpdate"></param>
        private void UpdateLevel(bool isForceUpdate)
        {
            if (PlayerManager.LocalPlayerController() != null)
            {
                enZoneType zoneType = GetCurrentTypeByPos(PlayerManager.LocalPlayerController().transform.position);

                if (m_CurrentZone != zoneType || isForceUpdate)
                {
                    LoadLevelZone(zoneType);
                    m_CurrentZone = zoneType;

                    if (zoneType == (enZoneType)0)
                    {
                        EB.Debug.LogError("+++++++++为什么会存在0的区域情况呢?+++++++++++++");
                    }
                }
            }
        }
Beispiel #5
0
        private void Awake()
        {
            m_AllZone         = this.GetComponentsInChildren <LevelZone>(true);
            m_StackObj        = new List <LevelInfo>();
            m_LightmapDataDic = new Dictionary <enZoneType, LightmapData>();
            m_CurrentZone     = (enZoneType)0;

            m_LightmapStr = new Dictionary <enZoneType, string>();
            m_LightmapStr.Add(enZoneType.Zone_0, "ZC");
            m_LightmapStr.Add(enZoneType.Zone_1, "ZC_1");
            m_LightmapStr.Add(enZoneType.Zone_2, "ZC_2");
            m_LightmapStr.Add(enZoneType.Zone_3, "ZC_3");
            m_LightmapStr.Add(enZoneType.Zone_4, "ZC_4");
            m_LightmapStr.Add(enZoneType.Zone_5, "ZC_a");
            m_LightmapStr.Add(enZoneType.Zone_6, "ZC_b");
            m_LightmapStr.Add(enZoneType.Zone_7, "ZC_c");
            m_LightmapStr.Add(enZoneType.Zone_8, "ZC_d");
            m_LightmapStr.Add(enZoneType.Zone_9, "ZC_e");
            m_LightmapStr.Add(enZoneType.Zone_10, "ZC_f");
            m_LightmapStr.Add(enZoneType.Zone_11, "ZC_g");
            m_LightmapStr.Add(enZoneType.Zone_12, "diaoxiang");
        }
Beispiel #6
0
        /// <summary>
        /// 加载相应的区域
        /// </summary>
        /// <param name="zone">区域类型</param>
        private void LoadLevelZone(enZoneType zone)
        {
            LoadingLogic.AddCustomProgress(10, "LoadLevelZone.Begin");
            for (var i = 0; i < _coroutines.Count; i++)
            {
                if (_coroutines[i] != null)
                {
                    StopCoroutine(_coroutines[i]);
                }
            }
            _coroutines.Clear();

            LevelInfo  levelInfo                 = null;
            enZoneType tempType                  = (enZoneType)0;
            int        lightmapIndex             = 0;
            int        count                     = 0;
            Dictionary <string, enZoneType> dict = new Dictionary <string, enZoneType>();

            for (int i = 0; i <= m_LightmapStr.Count; i++)
            {
                tempType = (enZoneType)(1 << i);

                if ((zone & tempType) > 0)
                {
                    levelInfo = m_StackObj.Find(p => p.v_ZoneType == tempType);

                    if (levelInfo == null)
                    {
                        dict.Add(m_LightmapStr[tempType], tempType);

                        var c1 = EB.Assets.LoadAsync(string.Format("_GameAssets/Res/Environment/s001a/MainLevelZone/Lightmap_{0}", m_LightmapStr[tempType]), typeof(Texture2D), (obj) => {
                            var lightmapData           = new LightmapData();
                            lightmapData.lightmapColor = obj as Texture2D;
                            var key = dict[obj.name.Replace("Lightmap_", "")];

                            if (!m_LightmapDataDic.ContainsKey(key))
                            {
                                m_LightmapDataDic.Add(key, lightmapData);
                            }
                            else
                            {
                                m_LightmapDataDic[key] = lightmapData;
                            }

                            var c2 = EB.Assets.LoadAsync(string.Format("_GameAssets/Res/Environment/s001a/MainLevelZone/{0}", m_LightmapStr[key]), typeof(GameObject), (o) => {
                                var li             = new LevelInfo();
                                li.v_LevelObj      = Instantiate <GameObject>((GameObject)o);
                                li.v_ZoneType      = dict[o.name];
                                li.v_LightmapIndex = lightmapIndex;
                                m_StackObj.Add(li);
                                count++;
                                lightmapIndex++;

                                if (count > m_LightmapStr.Count)
                                {
                                    ClearZone(zone);
                                    dict.Clear();
                                }
                            });
                            _coroutines.Add(c2);
                        });
                        _coroutines.Add(c1);
                    }
                    else
                    {
                        levelInfo.v_LightmapIndex = lightmapIndex;
                        count++;
                        lightmapIndex++;

                        if (count > m_LightmapStr.Count)
                        {
                            ClearZone(zone);
                            dict.Clear();
                        }
                    }
                }
                else
                {
                    count++;

                    if (count > m_LightmapStr.Count)
                    {
                        ClearZone(zone);
                        dict.Clear();
                    }
                }
            }
        }