Exemplo n.º 1
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);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void Open(PlanetContainer container)
 {
     if (m_PlanetContains != null && m_PlanetContains.Count > 0)
     {
         for (int iPlanet = 0; iPlanet < m_PlanetContains.Count; iPlanet++)
         {
             m_PlanetContains[iPlanet].gameObject.SetActive(m_PlanetContains[iPlanet] == container);
         }
     }
 }
Exemplo 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();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void OpenPlanetContainer(PlanetContainer planetContainer)
        {
            if (planetContainer == null)
            {
                return;
            }
            CloseAllPanel();
            FixedStarPanel fixedStarPanel = planetContainer.m_FixedStarPanel;

            if (fixedStarPanel != null)
            {
                fixedStarPanel.gameObject.SetActive(true);
                fixedStarPanel.Open(planetContainer);
            }
        }
Exemplo n.º 5
0
        private void CreateFixedStarElement(StarMapVO starVo)
        {
            GameObject container = new GameObject(starVo.Name);

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

            m_PlanetContains.Add(planetContainer);
            List <EditorGamingMap> gamingMaps = new List <EditorGamingMap>();

            GetGamingMap(starVo.FixedStarid, gamingMaps);
            planetContainer.Init(starVo.FixedStarid, this, gamingMaps);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 判断excel表中是否有新增或者删除 有的话刷新对应的
        /// </summary>
        private void Check()
        {
            if (m_StarMapVoList == null || m_StarMapVoList.Count <= 0)
            {
                return;
            }
            ///判断是否有新增的 有的话添加
            for (int iStar = 0; iStar < m_StarMapVoList.Count; iStar++)
            {
                StarMapVO starMapVo = m_StarMapVoList[iStar];
                if (starMapVo == null)
                {
                    continue;
                }
                PlanetContainer container = ExistElement(starMapVo.FixedStarid);
                if (container == null)
                {
                    CreateFixedStarElement(starMapVo);
                }
                else
                {
                    List <EditorGamingMap> gamingMaps = new List <EditorGamingMap>();
                    GetGamingMap(starMapVo.FixedStarid, gamingMaps);
                    container.UpdateElements(gamingMaps);
                }
            }
            //判断是否有删除的 有的话删除
            if (m_PlanetContains != null && m_PlanetContains.Count > 0)
            {
                for (int iStar = m_PlanetContains.Count - 1; iStar >= 0; iStar--)
                {
                    PlanetContainer element = m_PlanetContains[iStar];
                    if (element == null || element.gameObject == null)
                    {
                        continue;
                    }
                    int       fixedStarId = element.m_StarMapId;
                    StarMapVO vo          = ConfigVO <StarMapVO> .Instance.GetData(fixedStarId);

                    if (vo == null)
                    {
                        GameObject.DestroyImmediate(element.gameObject);
                        m_PlanetContains.Remove(element);
                    }
                }
            }
        }
Exemplo n.º 7
0
 private PlanetContainer ExistElement(int starId)
 {
     if (m_PlanetContains != null && m_PlanetContains.Count > 0)
     {
         for (int iFixed = 0; iFixed < m_PlanetContains.Count; iFixed++)
         {
             PlanetContainer element = m_PlanetContains[iFixed];
             if (element == null || element.gameObject == null)
             {
                 continue;
             }
             if (element.m_StarMapId == starId)
             {
                 return(element);
             }
         }
     }
     return(null);
 }
Exemplo n.º 8
0
 public void ShowContainer(int starMapId)
 {
     if (m_PlanetContains != null && m_PlanetContains.Count > 0)
     {
         for (int iContain = 0; iContain < m_PlanetContains.Count; iContain++)
         {
             PlanetContainer container = m_PlanetContains[iContain];
             if (container.m_StarMapId == starMapId)
             {
                 container.gameObject.SetActive(true);
                 Selection.activeGameObject = container.gameObject;
             }
             else
             {
                 container.gameObject.SetActive(false);
             }
             //container.gameObject.SetActive(container.m_StarMapId == starMapId);
         }
     }
 }
Exemplo n.º 9
0
        public IEnumerator DoEditorUpdate(StarMapEditorRoot root)
        {
            m_Root = root;
            if (m_RectTrans == null)
            {
                m_RectTrans = GetComponent <RectTransform>();
            }
            if (m_RectTrans != null)
            {
                m_RectTrans.anchoredPosition = Vector2.zero;
            }
            yield return(null);

            m_PlanetContains.Clear();
            PlanetContainer[] containers = GetComponentsInChildren <PlanetContainer>(true);
            if (containers != null && containers.Length > 0)
            {
                for (int iContainer = 0; iContainer < containers.Length; iContainer++)
                {
                    m_PlanetContains.Add(containers[iContainer]);
                }
            }
            yield return(null);

            if (m_PlanetContains != null && m_PlanetContains.Count > 0)
            {
                for (int iPlanet = 0; iPlanet < m_PlanetContains.Count; iPlanet++)
                {
                    PlanetContainer container = m_PlanetContains[iPlanet];
                    if (container == null || container.gameObject == null)
                    {
                        continue;
                    }
                    IEnumerator containerEnumer = container.DoEditorUpdate(this);
                    while (container != null && container.gameObject != null && containerEnumer.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void RefreshPlanetContainer(PlanetContainer planetContainer)
        {
            if (planetContainer == null)
            {
                return;
            }
            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:
                    OpenPlanetContainer(planetContainer);
                    break;
                }
            }, userData);
            Event.current.Use();
        }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
0
 public IEnumerator DoEditorUpdate(PlanetContainer container, float offestY)
 {
     m_Container = container;
     if (m_RectTrans == null)
     {
         m_RectTrans = GetComponent <RectTransform>();
     }
     if (m_RectTrans != null)
     {
         Vector2 anchorPos = m_RectTrans.anchoredPosition;
         m_RectTrans.anchoredPosition3D = new Vector3(anchorPos.x, offestY, 0);
         m_RectTrans.sizeDelta          = m_ResScale;
     }
     else
     {
         Vector3 position = transform.localPosition;
         if (position.y != 0)
         {
             transform.localPosition = new Vector3(position.x, offestY, position.z);
         }
     }
     if (m_ResObj != null)
     {
         m_Res = m_ResObj.name;
     }
     else
     {
         m_Res = "";
     }
     //int childCount = transform.childCount;
     //if(m_ResObj != null)
     //{
     //    m_Res = m_ResObj.name;
     //    Transform trans = null;
     //    if(childCount>0)
     //    {
     //        trans = transform.GetChild(0);
     //        if(trans.name != m_Res)
     //        {
     //            GameObject.DestroyImmediate(trans.gameObject);
     //            childCount = transform.childCount;
     //        }
     //    }
     //    if(childCount <=0)
     //    {
     //        trans = GameObject.Instantiate(m_ResObj,transform).transform;
     //        trans.gameObject.name = m_Res;
     //    }
     //    trans.localPosition = Vector3.zero;
     //    trans.localScale = m_ResScale;
     //}
     //else
     //{
     //    m_Res = "";
     //    if (childCount > 0)
     //    {
     //        for(int iChild = childCount-1; iChild>=0;iChild--)
     //        {
     //            GameObject.DestroyImmediate(transform.GetChild(iChild).gameObject);
     //        }
     //    }
     //}
     //transform.localScale = Vector3.one;
     yield return(null);
 }