Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 右键响应
        /// </summary>
        /// <param name="instanceID"></param>
        /// <param name="selectionRect"></param>
        private void OnHierarchyGUI(int instanceID, Rect selectionRect)
        {
            if (Event.current != null && selectionRect.Contains(Event.current.mousePosition) &&
                Event.current.button == 1 && Event.current.type <= EventType.MouseUp)
            {
                GameObject selectedGameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
                if (selectedGameObject)
                {
                    StarMapEditorRoot starMapRoot = selectedGameObject.GetComponent <StarMapEditorRoot>();
                    if (starMapRoot != null)
                    {
                        RefreshStarMapRootUI(starMapRoot);
                    }

                    FixedStarElement starElement = selectedGameObject.GetComponent <FixedStarElement>();
                    if (starElement != null)
                    {
                        RefreshFixedStarElementUI(starElement);
                    }

                    StarMapMainPanel starMapMainPanel = selectedGameObject.GetComponent <StarMapMainPanel>();
                    if (starMapMainPanel != null)
                    {
                        RefreshStarMapMainPanel(starMapMainPanel);
                    }

                    PlanetElement planetElement = selectedGameObject.GetComponent <PlanetElement>();
                    if (planetElement != null)
                    {
                        RefreshPalnetElement(planetElement);
                    }

                    FixedStarPanel fixedStarPanel = selectedGameObject.GetComponent <FixedStarPanel>();
                    if (fixedStarPanel != null)
                    {
                        RefreshFixedStarPanel(fixedStarPanel);
                    }

                    PlanetPanel planetPanel = selectedGameObject.GetComponent <PlanetPanel>();
                    if (planetPanel != null)
                    {
                        RefreshPlanetPanel(planetPanel);
                    }

                    PlanetContainer planetContainer = selectedGameObject.GetComponent <PlanetContainer>();
                    if (planetContainer != null)
                    {
                        RefreshPlanetContainer(planetContainer);
                    }

                    PlanetAreaContainer planetAreaContainer = selectedGameObject.GetComponent <PlanetAreaContainer>();
                    if (planetAreaContainer != null)
                    {
                        RefreshPlanetAreaContainer(planetAreaContainer);
                    }
                }
            }
        }
Esempio n. 3
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();
                    }
                }
            }
        }
Esempio n. 4
0
 private void OpenPlanet(PlanetElement element)
 {
     CloseAllPanel();
     if (element == null)
     {
         m_PlanetPanel.gameObject.SetActive(true);
     }
     if (m_PlanetPanel != null)
     {
         m_PlanetPanel.gameObject.SetActive(true);
         if (element != null && element.m_StarData != null)
         {
             m_PlanetPanel.ShowContainer(element.m_StarData.gamingmapId);
         }
     }
 }
Esempio n. 5
0
        private void RefreshPalnetElement(PlanetElement planetElement)
        {
            m_ContentCache.Clear();
            m_ContentCache.Add(new GUIContent("刷新行星区域"));
            Vector2    mousePosition = Event.current.mousePosition;
            GameObject userData      = Selection.activeGameObject;
            int        selected      = -1;

            EditorUtility.DisplayCustomMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), m_ContentCache.ToArray(), selected,
                                            delegate(object data, string[] opt, int select)
            {
                switch (select)
                {
                case 0:
                    OpenPlanet(planetElement);
                    break;
                }
            }, userData);
            Event.current.Use();
        }
Esempio n. 6
0
        public IEnumerator DoEditorUpdate(FixedStarPanel panel)
        {
            m_FixedStarPanel = panel;
            //Vector3 position = transform.localPosition;
            //transform.localPosition = new Vector3(position.x,panel.m_ContainerY,position.z);
            transform.localPosition = Vector3.zero;
            yield return(null);

            m_PlanetElements.Clear();
            PlanetElement[] elements = GetComponentsInChildren <PlanetElement>(true);
            if (elements != null && elements.Length > 0)
            {
                for (int iElement = 0; iElement < elements.Length; iElement++)
                {
                    m_PlanetElements.Add(elements[iElement]);
                }
            }
            yield return(null);

            if (m_PlanetElements != null && m_PlanetElements.Count > 0)
            {
                for (int iPlanet = 0; iPlanet < m_PlanetElements.Count; iPlanet++)
                {
                    PlanetElement element = m_PlanetElements[iPlanet];
                    if (element == null || element.gameObject == null)
                    {
                        continue;
                    }
                    IEnumerator elementEnumera = element.DoEditorUpdate(this, panel.m_ContainerY);
                    while (elementEnumera.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
        }
Esempio n. 7
0
        private void HierarchyItemCB(int instanceid, Rect selectionrect)
        {
            GameObject obj = EditorUtility.InstanceIDToObject(instanceid) as GameObject;

            if (obj == null)
            {
                return;
            }
            bool              isActive = obj.activeSelf;
            Transform         trans    = obj.transform;
            StarMapEditorRoot root     = obj.GetComponent <StarMapEditorRoot>();

            if (root != null)
            {
                DrawUI(trans, selectionrect, "编辑", Color.red);
            }

            StarMapMainPanel starMapMainPanel = obj.GetComponent <StarMapMainPanel>();

            if (starMapMainPanel != null)
            {
                DrawUI(trans, selectionrect, "编辑星图", isActive ? Color.yellow : Color.red);
            }

            FixedStarPanel fixedStarPanel = obj.GetComponent <FixedStarPanel>();

            if (fixedStarPanel != null)
            {
                DrawUI(trans, selectionrect, "编辑恒星", isActive ? Color.yellow : Color.red);
            }

            PlanetPanel planetPanel = obj.GetComponent <PlanetPanel>();

            if (planetPanel != null)
            {
                DrawUI(trans, selectionrect, "编辑行星", isActive ? Color.yellow : Color.red);
            }

            FixedStarElement fixedStarElement = obj.GetComponent <FixedStarElement>();

            if (fixedStarElement != null)
            {
                DrawUI(trans, selectionrect, "恒星", Color.red);
            }

            PlanetContainer planetContainer = obj.GetComponent <PlanetContainer>();

            if (planetContainer != null)
            {
                DrawUI(trans, selectionrect, "行星组", isActive ? Color.yellow : Color.red);
            }

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

            if (planetElement != null)
            {
                DrawUI(trans, selectionrect, "行星", Color.red);
            }

            PlanetAreaContainer planetAreaContainer = obj.GetComponent <PlanetAreaContainer>();

            if (planetAreaContainer != null)
            {
                DrawUI(trans, selectionrect, "区域组", isActive ? Color.yellow : Color.red);
            }

            PlanetAreaElement planetAreaElement = obj.GetComponent <PlanetAreaElement>();

            if (planetAreaElement != null)
            {
                DrawUI(trans, selectionrect, "区域", Color.blue);
            }
        }
 private void OnEnable()
 {
     m_Target   = target as PlanetElement;
     m_StarData = m_Target.m_StarData;
 }
Esempio n. 9
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);
                            }
                        }
                    }
                }
            }
        }