Пример #1
0
        /// <summary>
        /// 初始化人形地图id列表
        /// </summary>
        public void LoadHumanSpaceIds()
        {
            if (m_Type == GamingMapType.mapMainCity || m_Type == GamingMapType.mapSpaceStation)
            {
                m_SpaceGamingMapId = 0;
                return;
            }

            if (m_HumanSpaceIds != null && m_HumanSpaceIds.Count > 0)
            {
                return;
            }

            m_HumanSpaceIds    = new List <uint>();
            m_HumanSpaceIdStrs = new List <string>();
            List <EditorGamingMap> gamingMapList = EditorGamingMapData.LoadAllGamingMapJson();

            if (gamingMapList != null && gamingMapList.Count > 0)
            {
                for (int iGaming = 0; iGaming < gamingMapList.Count; iGaming++)
                {
                    EditorGamingMap gamingMap = gamingMapList[iGaming];
                    if (gamingMap.gamingType == (int)GamingMapType.mapSpaceStation || gamingMap.gamingType == (int)GamingMapType.mapMainCity)
                    {
                        m_HumanSpaceIds.Add(gamingMap.gamingmapId);
                        m_HumanSpaceIdStrs.Add(string.Format("{0}_{1}", gamingMap.gamingmapId, gamingMap.gamingmapName));
                    }
                }
            }
        }
Пример #2
0
 public void ExportStarMap()
 {
     if (m_StarMapVoList != null && m_StarMapVoList.Count > 0)
     {
         EditorStarMap            starMapData = new EditorStarMap();
         List <EditorFixedStar>   fixedStars  = new List <EditorFixedStar>();
         List <EditorPlanet>      planets     = new List <EditorPlanet>();
         List <EditorStarMapArea> planetAreas = new List <EditorStarMapArea>();
         FixedStarElement         element     = null;
         for (int iStar = 0; iStar < m_StarMapVoList.Count; iStar++)
         {
             StarMapVO       starMapVo = m_StarMapVoList[iStar];
             EditorFixedStar fixedStar = new EditorFixedStar();
             fixedStars.Add(fixedStar);
             fixedStar.fixedStarId   = starMapVo.FixedStarid;
             fixedStar.fixedStarName = starMapVo.Name;
             fixedStar.fixedStarRes  = starMapVo.AssetName;
             fixedStar.relations     = starMapVo.Relation_Id;
             element = m_StarMapMainPanel.GetElement(starMapVo.FixedStarid);
             if (element != null)
             {
                 fixedStar.position = new EditorPosition2D(element.GetPosition());
             }
             planets.Clear();
             SavePlanet(planets, starMapVo.FixedStarid, planetAreas, fixedStar);
             fixedStar.planetList = planets.ToArray();
         }
         starMapData.fixedStars = fixedStars.ToArray();
         EditorGamingMapData.SaveStarMapToJson(starMapData);
     }
 }
Пример #3
0
        /// <summary>
        /// 读取json数据
        /// </summary>
        /// <param name="mapArea"></param>
        private void ReadJsonData(GamingMapArea mapArea)
        {
            if (mapArea == null)
            {
                return;
            }

            EditorGamingMap gamingMap = EditorGamingMapData.LoadGamingMapFromJson(mapArea.GetGamingMapId());

            if (gamingMap != null)
            {
                EditorArea[] areas = gamingMap.areaList;
                if (areas != null && areas.Length > 0)
                {
                    for (int iArea = 0; iArea < areas.Length; iArea++)
                    {
                        EditorArea area = areas[iArea];
                        if (area.areaId == mapArea.m_AreaId)
                        {
                            mapArea.Init(area, this);
                        }
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 初始化恒星id列表
        /// </summary>
        public void LoadFixedStarIds()
        {
            if (m_FixedStarIds != null && m_FixedStarIds.Count > 0)
            {
                return;
            }
            if (m_Type != GamingMapType.mapDeepSpace)
            {
                return;
            }

            m_FixedStarIds    = new List <int>();
            m_FixedStarIdStrs = new List <string>();
            EditorGamingMapData.LoadStarMapVO();
            List <StarMapVO> starVoList = ConfigVO <StarMapVO> .Instance.GetList();

            if (starVoList != null && starVoList.Count > 0)
            {
                for (int iStar = 0; iStar < starVoList.Count; iStar++)
                {
                    StarMapVO starMapVo = starVoList[iStar];
                    if (starMapVo == null)
                    {
                        continue;
                    }
                    m_FixedStarIds.Add(starMapVo.FixedStarid);
                    m_FixedStarIdStrs.Add(string.Format("{0}_{1}", starMapVo.FixedStarid, starMapVo.Name));
                }
            }
        }
Пример #5
0
 /// <summary>
 /// 清理
 /// </summary>
 private void Clear()
 {
     EditorApplication.update -= OnUpdate;
     m_OnUpdateEnumerator      = null;
     EditorApplication.hierarchyWindowItemOnGUI -= OnHierarchyGUI;
     EditorGamingMapData.Clear();
     m_LeapIdCache = null;
 }
Пример #6
0
        protected override IEnumerator DoExport()
        {
            List <AreaSpawner> areaSpawnerList = m_Map.GetAreaSpawnerList();

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

            m_GamingMap.InitGamingArea();
            yield return(null);

            m_GamingMap.BeginExport();
            yield return(null);

            IEnumerator updateAreaEnum = m_GamingMap.UpdataGamingAreas(true);

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

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

            EditorGamingMapData.SaveGamingMapToJson(m_GamingMap, m_ExportAreaIds);
            yield return(null);

            m_GamingMap.EndExport();
            yield return(null);
        }
Пример #7
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;
        }
Пример #8
0
        public void LoadStarMap()
        {
            EditorStarMap starMap = EditorGamingMapData.LoadStarMap();

            if (starMap == null)
            {
                return;
            }
            m_PreviewStarMap = starMap;
            InitPanels(true);
        }
Пример #9
0
        private void InitEditor()
        {
            m_PreviewStarMap = null;
            EditorApplication.hierarchyWindowItemOnGUI += OnHierarchyGUI;
            EditorApplication.update += DoUpdate;
            m_DoUpdateEnumerator      = DoEditorUpdate();
            m_AllGamingMaps           = EditorGamingMapData.LoadAllDeapSpaceMapJson();
            EditorGamingMapData.LoadStarMapVO();
            m_StarMapVoList = ConfigVO <StarMapVO> .Instance.GetList();

            InitPanels();
        }
Пример #10
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;
                }
            }
        }
Пример #11
0
        private void CheckColliderLayer(Collider collider)
        {
            if (collider.isTrigger)
            {
                return;
            }

            string layer = LayerMask.LayerToName(collider.gameObject.layer);

            if (!layer.Equals("SceneOnly"))
            {
                Debug.LogError(string.Format("{0}层不对,需要改成SceneOnly", EditorGamingMapData.GetParentName(collider.gameObject)));
            }
        }
Пример #12
0
        private IEnumerator GenerateResidentDecorate(List <EditorDecorate> editorDecorateList)
        {
            DontDestroyAtExport residentRoot = UnityEngine.Object.FindObjectOfType <DontDestroyAtExport>();

            if (residentRoot != null)
            {
                List <Transform> colliderRoots = MapEditorUtility.FindChilds <Transform>(residentRoot.transform, "Collider");
                if (colliderRoots == null || colliderRoots.Count <= 0)
                {
                    yield break;
                }

                for (int iRoot = 0; iRoot < colliderRoots.Count; iRoot++)
                {
                    Transform colliderRoot = colliderRoots[iRoot];
                    if (colliderRoot != null)
                    {
                        Collider[] colliders = colliderRoot.GetComponentsInChildren <Collider>();
                        if (colliders != null && colliders.Length > 0)
                        {
                            for (int iCollider = 0; iCollider < colliders.Length; iCollider++)
                            {
                                EditorGamingMapData.CorrectCollider(colliders[iCollider]);
                                yield return(null);

                                yield return(null);

                                Quaternion rot = colliders[iCollider].transform.rotation;
                                colliders[iCollider].transform.rotation = Quaternion.identity;
                                yield return(null);

                                EditorDecorate decorate = EditorGamingMapData.SaveColliderData(colliders[iCollider], rot);
                                yield return(null);

                                colliders[iCollider].transform.rotation = rot;
                                if (decorate != null)
                                {
                                    decorate.id = m_AutoId++;
                                    editorDecorateList.Add(decorate);
                                }
                                CheckColliderLayer(colliders[iCollider]);
                            }
                        }
                    }
                }
            }
            yield return(null);
        }
Пример #13
0
    public void Generate()
    {
        int childCount = transform.childCount;

        for (int iChild = childCount - 1; iChild >= 0; iChild--)
        {
            GameObject.DestroyImmediate(transform.GetChild(iChild).gameObject);
        }
        m_ColliderData = EditorGamingMapData.LoadMapCollider(m_MapId);
        if (m_ColliderData == null)
        {
            Debug.LogError("地图碰撞配置错误");
            return;
        }
        m_Spawner = SpawnerCollider();
    }
Пример #14
0
        /// <summary>
        /// 获取某个地图某个区域的Locations
        /// </summary>
        /// <param name="mapId"></param>
        /// <param name="areaId"></param>
        /// <returns></returns>
        public static EditorLocation[] GetEditorLocations(uint mapId, ulong areaId)
        {
            EditorGamingMap map = EditorGamingMapData.LoadGamingMapFromJson(mapId);

            if (map != null && map.areaList != null && map.areaList.Length > 0)
            {
                for (int iArea = 0; iArea < map.areaList.Length; iArea++)
                {
                    EditorArea area = map.areaList[iArea];
                    if (area.areaId == areaId)
                    {
                        return(area.locationList);
                    }
                }
            }
            return(null);
        }
Пример #15
0
        protected override IEnumerator DoExport()
        {
            DontDestroyAtExport[] exports = UnityEngine.Object.FindObjectsOfType <DontDestroyAtExport>();
            if (exports != null && exports.Length > 0)
            {
                for (int iExport = 0; iExport < exports.Length; iExport++)
                {
                    DontDestroyAtExport export = exports[iExport];
                    export.gameObject.SetActive(false);
                }
            }
            yield return(null);

            List <AreaSpawner> areaSpawners = m_Map.GetAreaSpawnerList();

            if (areaSpawners != null && areaSpawners.Count > 0)
            {
                for (int iArea = 0; iArea < areaSpawners.Count; iArea++)
                {
                    AreaSpawner areaSpawner    = areaSpawners[iArea];
                    IEnumerator areaUpdateEnum = areaSpawner.DoUpdate(m_Map, false);
                    while (areaUpdateEnum.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }

            IEnumerator loadAllAreaEnumerator = m_Map.LoadAllArea(true);

            while (loadAllAreaEnumerator.MoveNext())
            {
                yield return(null);
            }


            IEnumerator export3DNavMeshEnum = EditorGamingMapData.Export3DNavMesh(m_SceneCutSize, m_Map);

            while (export3DNavMeshEnum.MoveNext())
            {
                yield return(null);
            }
        }
Пример #16
0
        private IEnumerator ExportUpdate()
        {
            ConfigVO <ModelVO> .Instance.GetList();

            yield return(null);

            ConfigVO <ModShipDecorateVO> .Instance.GetList();

            ConfigVO <ModShipDecorateVO> .Instance.ResetData();

            yield return(null);

            List <ModelVO> shipModelList = new List <ModelVO>();
            List <ModelVO> modelList     = ConfigVO <ModelVO> .Instance.GetList();

            if (modelList != null && modelList.Count > 0)
            {
                for (int iModel = 0; iModel < modelList.Count; iModel++)
                {
                    ModelVO modelVo = modelList[iModel];
                    if (modelVo.type == (int)EditorGamingMapData.ModelType.WarShip)
                    {
                        shipModelList.Add(modelVo);
                    }
                }
            }
            yield return(null);

            if (shipModelList != null && shipModelList.Count > 0)
            {
                for (int iShip = 0; iShip < shipModelList.Count; iShip++)
                {
                    ModelVO modelVo   = shipModelList[iShip];
                    string  assetName = modelVo.assetName;
                    if (!string.IsNullOrEmpty(assetName))
                    {
                        string[] resAssets = AssetDatabase.FindAssets(string.Format("{0} t:Prefab", assetName));
                        if (resAssets != null && resAssets.Length > 0)
                        {
                            for (int iRes = 0; iRes < resAssets.Length; iRes++)
                            {
                                assetName = AssetDatabase.GUIDToAssetPath(resAssets[iRes]);
                                string[] assetSplit = assetName.Split('/');
                                if (assetSplit != null && assetSplit.Length > 0)
                                {
                                    if (assetSplit[assetSplit.Length - 1].Equals(string.Format("{0}.prefab", modelVo.assetName)))
                                    {
                                        break;
                                    }
                                }
                            }
                            GameObject assetObj = AssetDatabase.LoadAssetAtPath <GameObject>(assetName);
                            if (assetObj != null)
                            {
                                GameObject shipObj = GameObject.Instantiate(assetObj);
                                JudegeShipCollider(shipObj);
                                shipObj.transform.SetParent(transform);
                                shipObj.transform.localPosition = Vector3.zero;
                                CapsuleCollider shipCollider = EditorGamingMapData.CalculateCapsuleCollider(shipObj);
                                EditorGamingMapData.CorrectCollider(shipCollider);
                                yield return(null);

                                yield return(null);

                                Quaternion shipRot = shipCollider.transform.rotation;
                                shipCollider.transform.rotation = Quaternion.identity;
                                yield return(null);

                                EditorDecorate decorate = EditorGamingMapData.SaveColliderData(shipCollider, shipRot);
                                yield return(null);

                                shipCollider.transform.rotation = shipRot;
                                ModShipDecorateVO shipDecorateVo = ConfigVO <ModShipDecorateVO> .Instance.GetData(modelVo.ID);

                                if (shipDecorateVo != null)
                                {
                                    shipDecorateVo.colliderMax = decorate.dirMax;
                                    shipDecorateVo.colliderMin = decorate.dirMin;
                                    // shipDecorateVo.colliderMax = new float[3] { CalcuateRound(decorate.dirmax.x, 3), CalcuateRound(decorate.dirmax.y, 3), CalcuateRound(decorate.dirmax.z, 3) };
                                    // shipDecorateVo.colliderMin = new float[3] { CalcuateRound(decorate.dirmin.x, 3), CalcuateRound(decorate.dirmin.y, 3), CalcuateRound(decorate.dirmin.z, 3) };
                                }
                                else
                                {
                                    ModShipDecorateVO decorateVo = new ModShipDecorateVO();
                                    decorateVo.ID     = modelVo.ID;
                                    decorateVo.unitId = modelVo.ID;
                                    decorateVo.type   = (int)EditorGamingMapData.COLLIDER_TYPE.PX_CAPSULE;
                                    //decorateVo.colliderMax = new float[3] { CalcuateRound(decorate.dirmax.x, 3), CalcuateRound(decorate.dirmax.y, 3), CalcuateRound(decorate.dirmax.z, 3) };
                                    //decorateVo.colliderMin = new float[3] { CalcuateRound(decorate.dirmin.x, 3), CalcuateRound(decorate.dirmin.y, 3), CalcuateRound(decorate.dirmin.z, 3) };
                                    decorateVo.colliderMax = decorate.dirMax;
                                    decorateVo.colliderMin = decorate.dirMin;
                                    ConfigVO <ModShipDecorateVO> .Instance.AddData(decorateVo);
                                }
                                yield return(null);

                                if (shipObj != null)
                                {
                                    GameObject.DestroyImmediate(shipObj);
                                }
                                yield return(null);
                            }
                        }
                    }
                }
            }
            yield return(null);

            ConfigVO <ModShipDecorateVO> .Instance.SaveCSV();

            bool isConfirm = EditorUtility.DisplayDialog("提示", "战舰碰撞信息导出成功", "确定");

            if (isConfirm)
            {
                GameObject.DestroyImmediate(gameObject);
            }
        }
Пример #17
0
 private void RefreshColliderState()
 {
     if (m_Collider == null || m_LeapType <= 0)
     {
         return;
     }
     m_Collider.enabled = false;
     Collider[] colliders = Physics.OverlapSphere(m_Collider.center, m_Collider.radius);
     if (colliders != null && colliders.Length > 0)
     {
         for (int iCollider = 0; iCollider < colliders.Length; iCollider++)
         {
             Collider colliderTmp = colliders[iCollider];
             //Debug.LogError("ActiveScene:"+SceneManager.GetActiveScene().name+"  gameObject scene:"+colliderTmp.gameObject.scene.name);
             if (m_GamingMapArea != null && m_GamingMapArea.m_GamingMap != null &&
                 colliderTmp.gameObject.scene == m_GamingMapArea.m_GamingMap.GetOwnerScene())
             {
                 continue;
             }
             Debug.LogError(string.Format("跃迁点位置错误:{0}与{1}相交", gameObject.name, EditorGamingMapData.GetParentName(colliders[iCollider].gameObject)));
         }
     }
 }
Пример #18
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();
        }
Пример #19
0
        protected override IEnumerator DoExport()
        {
            List <AreaSpawner> areaSpawners = m_Map.GetAreaSpawnerList();

            if (areaSpawners != null && areaSpawners.Count > 0)
            {
                for (int iArea = 0; iArea < areaSpawners.Count; iArea++)
                {
                    AreaSpawner areaSpawner    = areaSpawners[iArea];
                    IEnumerator areaUpdateEnum = areaSpawner.DoUpdate(m_Map, false);
                    while (areaUpdateEnum.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            IEnumerator loadAreaEnumerator = m_Map.LoadAllArea();

            while (loadAreaEnumerator.MoveNext())
            {
                yield return(null);
            }
            EditorCollider        outData            = new EditorCollider();
            List <EditorDecorate> editorDecorateList = new List <EditorDecorate>();

            m_AutoId = 1;
            IEnumerator residentColliderEnumerator = GenerateAreaDecorate(outData, editorDecorateList);

            while (residentColliderEnumerator.MoveNext())
            {
                yield return(null);
            }

            //常驻collider导出
            editorDecorateList.Clear();

            IEnumerator areaColliderEnumerator = GenerateResidentDecorate(editorDecorateList);

            while (areaColliderEnumerator.MoveNext())
            {
                yield return(null);
            }

            outData.mapID = m_Map.Uid;
            outData.commondecorateList = editorDecorateList.ToArray();
            EditorGamingMapData.SaveColliderToJson(outData);

            yield return(null);

            Area[] areaArray = UnityEngine.Object.FindObjectsOfType <Area>();
            if (areaArray != null && areaArray.Length > 0)
            {
                for (int iArea = areaArray.Length - 1; iArea >= 0; iArea--)
                {
                    GameObject.DestroyImmediate(areaArray[iArea].gameObject);
                    if (iArea % 10 == 0)
                    {
                        yield return(null);
                    }
                }
            }
        }
Пример #20
0
        public IEnumerator GenerateAreaDecorate(EditorCollider outData, List <EditorDecorate> editorDecorateList)
        {
            if (m_Map.m_AreaSpawnerCache != null && m_Map.m_AreaSpawnerCache.Count > 0)
            {
                EditorColliderArea[] areaList = new EditorColliderArea[m_Map.m_AreaSpawnerCache.Count];
                outData.areaList = areaList;
                List <GameObject> prefabList = new List <GameObject>();
                for (int iArea = 0; iArea < m_Map.m_AreaSpawnerCache.Count; iArea++)
                {
                    editorDecorateList.Clear();
                    EditorColliderArea editorArea = new EditorColliderArea();
                    areaList[iArea] = editorArea;
                    AreaSpawner areaSpawner = m_Map.m_AreaSpawnerCache[iArea];
                    Area        area        = areaSpawner.GetArea();

                    string areaName = areaSpawner.GetAreaScenePath();
                    while (!string.IsNullOrEmpty(areaName) && area == null)
                    {
                        area = areaSpawner.GetArea();
                        yield return(null);
                    }

                    editorArea.areaId = areaSpawner.GetAreaId();
                    if (area != null)
                    {
                        EditorGamingMapData.CorrectAreaColliderCenter(area);
                        yield return(null);

                        yield return(null);

                        prefabList.Clear();
                        MapEditorUtility.GetAllPrefab(area.transform, prefabList);
                        if (prefabList != null && prefabList.Count > 0)
                        {
                            for (int iUnit = 0; iUnit < prefabList.Count; iUnit++)
                            {
                                GameObject       unit          = prefabList[iUnit];
                                List <Transform> colliderRoots = MapEditorUtility.FindChilds <Transform>(unit.transform, "Collider");
                                if (colliderRoots == null || colliderRoots.Count <= 0)
                                {
                                    continue;
                                }
                                for (int iRoot = 0; iRoot < colliderRoots.Count; iRoot++)
                                {
                                    Transform colliderRoot = colliderRoots[iRoot];
                                    if (colliderRoot != null)
                                    {
                                        Collider[] colliders = colliderRoot.GetComponentsInChildren <Collider>();
                                        if (colliders != null && colliders.Length > 0)
                                        {
                                            for (int iCollider = 0; iCollider < colliders.Length; iCollider++)
                                            {
                                                EditorUtility.DisplayProgressBar("GenerateAreaDecorate", string.Format("{0} {1}", area.name, colliders[iCollider].gameObject.name), (iArea + 1) * 1.0f / m_Map.m_AreaSpawnerCache.Count);
                                                Quaternion rot = colliders[iCollider].transform.rotation;
                                                colliders[iCollider].transform.rotation = Quaternion.identity;
                                                yield return(null);

                                                EditorDecorate decorate = EditorGamingMapData.SaveColliderData(colliders[iCollider], rot, true);
                                                yield return(null);

                                                colliders[iCollider].transform.rotation = rot;
                                                if (decorate != null)
                                                {
                                                    decorate.id = m_AutoId++;
                                                    editorDecorateList.Add(decorate);
                                                }
                                                CheckColliderLayer(colliders[iCollider]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        editorArea.decorateList = editorDecorateList.ToArray();
                    }
                    else
                    {
                        Debug.LogError(string.Format("Area {0} 未加载进来", areaSpawner.GetAreaId()));
                    }
                    yield return(null);

                    EditorUtility.ClearProgressBar();
                }
            }
        }