コード例 #1
0
ファイル: GamingMap.cs プロジェクト: mengtest/RewriteFrame
        /// <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);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: GamingMap.cs プロジェクト: mengtest/RewriteFrame
        /// <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));
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 判断excel表中是否有新增或者删除 有的话刷新对应的
        /// </summary>
        private void Check()
        {
            List <EditorGamingMap> allGamingMaps = m_Root.m_AllGamingMaps;

            if (allGamingMaps == null || allGamingMaps.Count <= 0)
            {
                for (int iStar = m_PlanetAreaContainers.Count - 1; iStar >= 0; iStar--)
                {
                    PlanetAreaContainer element = m_PlanetAreaContainers[iStar];
                    if (element == null || element.gameObject == null)
                    {
                        continue;
                    }
                    GameObject.DestroyImmediate(element.gameObject);
                    m_PlanetAreaContainers.Remove(element);
                    Debug.LogError("PlanetPanel 删除了:" + element.m_GamingMapId);
                }
                return;
            }

            ///判断是否有新增的 有的话添加
            for (int iStar = 0; iStar < allGamingMaps.Count; iStar++)
            {
                EditorGamingMap starMapVo = allGamingMaps[iStar];
                if (starMapVo == null)
                {
                    continue;
                }
                PlanetAreaContainer container = ExistElement(starMapVo.gamingmapId);
                if (container == null)
                {
                    CreatePlanetArea(starMapVo);
                    Debug.LogError("PlanetPanel 新增了:" + starMapVo.gamingmapId);
                }
                else
                {
                    container.UpdateElements(starMapVo.areaList);
                }
            }
            //判断是否有删除的 有的话删除
            if (m_PlanetAreaContainers != null && m_PlanetAreaContainers.Count > 0)
            {
                for (int iStar = m_PlanetAreaContainers.Count - 1; iStar >= 0; iStar--)
                {
                    PlanetAreaContainer element = m_PlanetAreaContainers[iStar];
                    if (element == null || element.gameObject == null)
                    {
                        continue;
                    }
                    uint            fixedStarId = element.m_GamingMapId;
                    EditorGamingMap vo          = GetMapData(fixedStarId);
                    if (vo == null)
                    {
                        GameObject.DestroyImmediate(element.gameObject);
                        m_PlanetAreaContainers.Remove(element);
                        Debug.LogError("PlanetPanel 删除了:" + element.m_GamingMapId);
                    }
                }
            }
        }
コード例 #4
0
        public void Init(StarMapEditorRoot root, bool needReset = false)
        {
            m_Root = root;
            if (!needReset)
            {
                Check();
                return;
            }
            int childCount = transform.childCount;

            if (childCount > 0)
            {
                for (int iChild = childCount - 1; iChild >= 0; iChild--)
                {
                    GameObject.DestroyImmediate(transform.GetChild(iChild).gameObject);
                }
            }

            m_PlanetAreaContainers.Clear();

            List <EditorGamingMap> allGamingMaps = m_Root.m_AllGamingMaps;

            if (allGamingMaps != null && allGamingMaps.Count > 0)
            {
                for (int iAllGaming = 0; iAllGaming < allGamingMaps.Count; iAllGaming++)
                {
                    EditorGamingMap editorData = allGamingMaps[iAllGaming];
                    if (editorData == null)
                    {
                        continue;
                    }
                    CreatePlanetArea(editorData);
                }
            }
        }
コード例 #5
0
        private void CreateElement(EditorGamingMap editorData)
        {
            GameObject planetObj = Instantiate(m_FixedStarPanel.m_PlanetElementPrefab);

            planetObj.SetActive(true);
            planetObj.transform.SetParent(transform);

            PlanetElement planetElement = planetObj.GetComponent <PlanetElement>();

            if (planetElement != null)
            {
                EditorPlanet planet = m_FixedStarPanel.m_Root.GetPreviewPlanet(editorData.gamingmapId);
                if (planet != null)
                {
                    planetElement.Init(editorData, planet);
                    //planetObj.transform.localPosition = Vector3.zero;
                }
                else
                {
                    planetElement.Init(editorData, null);
                    //planetObj.transform.localPosition = Vector3.zero;
                    Debug.LogError("PlanetContainer " + m_StarMapId + "新增了:" + editorData.gamingmapId);
                }
                m_PlanetElements.Add(planetElement);
            }
        }
コード例 #6
0
 private void InitGamingMapDatas()
 {
     //if(m_AllGamingMaps == null)
     //{
     //    return;
     //}
     m_GamingMapDatas.Clear();
     if (m_StarMapVoList != null && m_StarMapVoList.Count > 0)
     {
         for (int iStar = 0; iStar < m_StarMapVoList.Count; iStar++)
         {
             StarMapVO starVo = m_StarMapVoList[iStar];
             if (starVo == null)
             {
                 continue;
             }
             List <EditorGamingMap> editorGamings = new List <EditorGamingMap>();
             for (int iAll = 0; iAll < m_AllGamingMaps.Count; iAll++)
             {
                 EditorGamingMap editorGaming = m_AllGamingMaps[iAll];
                 if (editorGaming.belongFixedStar == starVo.FixedStarid)
                 {
                     editorGamings.Add(editorGaming);
                 }
             }
             m_GamingMapDatas.Add(starVo.FixedStarid, editorGamings);
         }
     }
 }
コード例 #7
0
        private void CreatePlanetArea(EditorGamingMap editorData)
        {
            GameObject planetContainer = new GameObject(editorData.gamingmapName);

            planetContainer.SetActive(false);
            planetContainer.transform.SetParent(transform);
            planetContainer.transform.localPosition = Vector3.zero;
            planetContainer.transform.localScale    = Vector3.one;
            PlanetAreaContainer planetAreaConatiner = planetContainer.AddComponent <PlanetAreaContainer>();

            m_PlanetAreaContainers.Add(planetAreaConatiner);
            EditorArea[] areas = editorData.areaList;
            planetAreaConatiner.Init(this, areas, editorData.gamingmapId);
        }
コード例 #8
0
        /// <summary>
        /// 保存行星
        /// </summary>
        /// <param name="planets"></param>
        private void SavePlanet(List <EditorPlanet> planets, int fixedStarId, List <EditorStarMapArea> areaList, EditorFixedStar fixedStar)
        {
            List <EditorGamingMap> gamingDatas = null;

            if (m_GamingMapDatas.TryGetValue(fixedStarId, out gamingDatas))
            {
                PlanetContainer panelContainer = m_FixedStarPanel.GetElement(fixedStarId);
                if (gamingDatas != null)
                {
                    for (int iGaming = 0; iGaming < gamingDatas.Count; iGaming++)
                    {
                        EditorGamingMap gamingData = gamingDatas[iGaming];
                        PlanetElement   element    = null; //= GetElement(gamingData.gamingmap_id);
                        if (panelContainer != null)
                        {
                            element = panelContainer.GetElement(gamingData.gamingmapId);
                        }
                        EditorPlanet editorPlanet = new EditorPlanet();
                        planets.Add(editorPlanet);
                        editorPlanet.gamingmapId   = gamingData.gamingmapId;
                        editorPlanet.gamingmapName = gamingData.gamingmapName;
                        PlanetAreaContainer areaContainer = m_PlanetPanel.ExistElement(gamingData.gamingmapId);
                        if (areaContainer != null)
                        {
                            editorPlanet.minimapSize = areaContainer.m_MiniMapSize;
                            editorPlanet.bgmapRes    = areaContainer.GetStarRes();
                            editorPlanet.bgmapScale  = new EditorPosition2D(areaContainer.m_FixedStarScale);
                            editorPlanet.bgmapPos    = new EditorPosition2D(areaContainer.m_FixedStarPos);
                        }

                        if (element != null)
                        {
                            editorPlanet.gamingmapRes = element.m_Res;
                            editorPlanet.position     = new EditorPosition2D(element.GetPosition());
                            editorPlanet.scale        = new EditorPosition2D(element.GetScale());
                        }
                        areaList.Clear();
                        ulong areaId = 0;
                        SaveArea(gamingData, areaList, ref areaId);
                        if (areaId > 0)
                        {
                            fixedStar.ttGamingMapId  = gamingData.gamingmapId;
                            fixedStar.ttGamingAreaId = areaId;
                        }
                        editorPlanet.arealist = areaList.ToArray();
                    }
                }
            }
        }
コード例 #9
0
ファイル: GamingMap.cs プロジェクト: mengtest/RewriteFrame
        /// <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);
        }
コード例 #10
0
 public void Init(int starMapId, FixedStarPanel panel, List <EditorGamingMap> gamingMaps)
 {
     m_StarMapId      = starMapId;
     m_FixedStarPanel = panel;
     if (gamingMaps != null && gamingMaps.Count > 0)
     {
         for (int iGaming = 0; iGaming < gamingMaps.Count; iGaming++)
         {
             EditorGamingMap editorData = gamingMaps[iGaming];
             if (editorData == null)
             {
                 continue;
             }
             CreateElement(editorData);
         }
     }
 }
コード例 #11
0
        private void SaveArea(EditorGamingMap gamingData, List <EditorStarMapArea> areaList, ref ulong areaId)
        {
            if (gamingData == null || gamingData.areaList == null || gamingData.areaList.Length <= 0)
            {
                return;
            }
            EditorArea[] editorAreas = gamingData.areaList;
            for (int iArea = 0; iArea < editorAreas.Length; iArea++)
            {
                EditorArea editorArea = editorAreas[iArea];
                if (editorArea == null)
                {
                    continue;
                }

                EditorStarMapArea starMapArea = new EditorStarMapArea();
                areaList.Add(starMapArea);
                starMapArea.areaId   = editorArea.areaId;
                starMapArea.areaType = editorArea.areaType;
                starMapArea.areaName = editorArea.areaName;
                PlanetAreaElement areaElement = m_PlanetPanel.GetElement(gamingData.gamingmapId, editorArea.areaId);
                if (areaElement != null)
                {
                    starMapArea.area_res         = areaElement.m_Res;
                    starMapArea.childrenAreaList = editorArea.childrenAreaList;
                    if (editorArea.leapList != null && editorArea.leapList.Length > 0)
                    {
                        starMapArea.area_leap_type = editorArea.leapList[0].leapType;
                    }
                    starMapArea.position = new EditorPosition2D(areaElement.GetPosition());
                }
                if (editorArea.areaType == (int)AreaType.Titan)
                {
                    if (areaId > 0)
                    {
                        Debug.LogError(gamingData.gamingmapName + "存在多个泰坦区域:" + editorArea.areaId);
                    }
                    else
                    {
                        areaId = editorArea.areaId;
                    }
                }
            }
        }
コード例 #12
0
        private void GetGamingMap(int starId, List <EditorGamingMap> gamingMapList)
        {
            gamingMapList.Clear();
            List <EditorGamingMap> m_AllGamingMaps = m_Root.m_AllGamingMaps;

            if (m_AllGamingMaps != null && m_AllGamingMaps.Count > 0)
            {
                for (int iAllGaming = 0; iAllGaming < m_AllGamingMaps.Count; iAllGaming++)
                {
                    EditorGamingMap editorData = m_AllGamingMaps[iAllGaming];
                    if (editorData == null)
                    {
                        continue;
                    }
                    if (editorData.belongFixedStar == starId)
                    {
                        gamingMapList.Add(editorData);
                    }
                }
            }
        }
コード例 #13
0
 public void Init(EditorGamingMap gamingData, EditorPlanet planet)
 {
     if (gamingData == null)
     {
         return;
     }
     m_StarData      = gamingData;
     gameObject.name = gamingData.gamingmapName;
     if (m_RectTrans == null)
     {
         m_RectTrans = GetComponent <RectTransform>();
     }
     if (planet != null)
     {
         m_Res = planet.gamingmapRes;
         m_RectTrans.anchoredPosition = planet.position.ToVector2();
         m_ResScale            = planet.scale.ToVector2();
         m_RectTrans.sizeDelta = m_ResScale;
         m_ResObj = StarMapEditorRoot.FindResAsset(m_Res);
     }
 }
コード例 #14
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();
        }
コード例 #15
0
 private void OnEnable()
 {
     m_Target   = target as PlanetElement;
     m_StarData = m_Target.m_StarData;
 }
コード例 #16
0
        public void UpdateElements(List <EditorGamingMap> gamingMaps)
        {
            if (gamingMaps == null || gamingMaps.Count <= 0)
            {
                for (int iElement = m_PlanetElements.Count - 1; iElement >= 0; iElement--)
                {
                    PlanetElement planetElement = m_PlanetElements[iElement];
                    if (planetElement != null)
                    {
                        GameObject.DestroyImmediate(planetElement.gameObject);
                        EditorGamingMap gamingMap = planetElement.m_StarData;
                        if (gamingMap != null)
                        {
                            Debug.LogError("PlanetContainer " + m_StarMapId + " 删除了" + gamingMap.gamingmapId);
                        }
                    }
                }
                return;
            }

            for (int iGaming = 0; iGaming < gamingMaps.Count; iGaming++)
            {
                EditorGamingMap editorData = gamingMaps[iGaming];
                if (editorData == null)
                {
                    continue;
                }
                PlanetElement element = GetElement(editorData.gamingmapId);
                if (element == null)
                {
                    CreateElement(editorData);
                    if (editorData != null)
                    {
                        Debug.LogError("PlanetContainer " + m_StarMapId + "新增了" + editorData.gamingmapId);
                    }
                }
                else
                {
                    element.Init(editorData, null);
                }
            }

            if (m_PlanetElements != null && m_PlanetElements.Count > 0)
            {
                for (int iElement = m_PlanetElements.Count - 1; iElement >= 0; iElement--)
                {
                    PlanetElement planetElement = m_PlanetElements[iElement];
                    if (planetElement == null)
                    {
                        continue;
                    }
                    EditorGamingMap editorGamingMap = planetElement.m_StarData;
                    if (editorGamingMap != null)
                    {
                        bool exist = ExistsGamingMap(gamingMaps, editorGamingMap.gamingmapId);
                        if (!exist)
                        {
                            m_PlanetElements.Remove(planetElement);
                            GameObject.DestroyImmediate(planetElement.gameObject);
                            EditorGamingMap gamingMap = planetElement.m_StarData;
                            if (gamingMap != null)
                            {
                                Debug.LogError("PlanetContainer " + m_StarMapId + "删除了" + gamingMap.gamingmapId);
                            }
                        }
                    }
                }
            }
        }