예제 #1
0
 private void OnEnable()
 {
     if (Application.isPlaying)
     {
         return;
     }
     m_CreatureRoot = GetComponentInChildren <CreatureRoot>();
     m_LocationRoot = GetComponentInChildren <LocationRoot>();
     m_TeleportRoot = GetComponentInChildren <TeleportRoot>();
     m_LeapRoot     = GetComponentInChildren <LeapRoot>();
     m_TriggerRoot  = GetComponentInChildren <TriggerRoot>();
     m_TreasureRoot = GetComponentInChildren <TreasureRoot>();
     m_MineralRoot  = GetComponentInChildren <MineralRoot>();
     if (m_LeapRoot == null)
     {
         CreateLeapRoot();
     }
     if (m_TriggerRoot == null)
     {
         CreateTriggerRoot();
     }
     if (m_TreasureRoot == null)
     {
         CreateTreasureRoot();
     }
     if (m_MineralRoot == null)
     {
         CreateMineralRoot();
     }
 }
예제 #2
0
        private void OnEnable()
        {
            m_Target = target as LeapRoot;
            List <Leap> leapList = m_Target.GetLeap();

            m_Target.m_MainLeapCache.Clear();
            if (leapList != null && leapList.Count > 0)
            {
                for (int iLeap = 0; iLeap < leapList.Count; iLeap++)
                {
                    Leap leap = leapList[iLeap];
                    if (leap.m_LeapType == LeapType.Main && leap.m_LeapId != m_Target.m_LeapId)
                    {
                        m_Target.m_MainLeapCache.Add(leap);
                    }
                }
            }

            if (m_Target.m_MainLeapCache != null && m_Target.m_MainLeapCache.Count > 0)
            {
                m_MainIdDisplayArray = new string[m_Target.m_MainLeapCache.Count];
                m_MainIdArray        = new ulong[m_Target.m_MainLeapCache.Count];
                for (int iMain = 0; iMain < m_Target.m_MainLeapCache.Count; iMain++)
                {
                    Leap leap = m_Target.m_MainLeapCache[iMain];
                    m_MainIdDisplayArray[iMain] = string.Format("{0}_{1}", leap.m_LeapId, leap.m_LeapName);
                    m_MainIdArray[iMain]        = leap.m_LeapId;
                    if (m_Target.m_MainLeapId == leap.m_LeapId)
                    {
                        m_SelectMainIdIndex = iMain;
                    }
                }
            }
        }
예제 #3
0
        public IEnumerator OnUpdate(LeapOverview leapOverview, GamingMapArea area, GamingMapArea showArea)
        {
            m_LeapOverview = leapOverview;
            m_MeshRender   = GetComponent <MeshRenderer>();
            gameObject.SetActive(m_IsExportToJson);
            if (m_MeshRender != null)
            {
                if (showArea == null)
                {
                    m_MeshRender.enabled = false;
                }
                else
                {
                    LeapRoot root = showArea.m_LeapRoot;
                    bool     show = false;
                    if (root != null && root.m_VisibleLeapList.Length > 0)
                    {
                        for (int iVisible = 0; iVisible < root.m_VisibleLeapList.Length; iVisible++)
                        {
                            if (m_LeapId == root.m_VisibleLeapList[iVisible])
                            {
                                show = true;
                                break;
                            }
                        }
                    }
                    m_MeshRender.enabled = show;
                }
            }
            yield return(null);

            if (area != null && area.m_LeapRoot != null)
            {
                LeapRoot leapRoot = area.m_LeapRoot;
                m_LeapName           = leapRoot.m_LeapName;
                m_LeapType           = leapRoot.m_LeapType;
                m_MainLeapId         = leapRoot.m_MainLeapId;
                transform.position   = leapRoot.transform.position;
                gameObject.name      = string.Format("{0}_{1}", m_LeapId, m_LeapName);
                transform.localScale = Vector3.one * leapRoot.m_Range;
            }
        }
예제 #4
0
        private void CreateLeapRoot()
        {
            string leapTempletePath = GamingMapEditorUtility.GetLeapTempletePath();

            if (string.IsNullOrEmpty(leapTempletePath))
            {
                return;
            }
            GameObject leapTemplete = AssetDatabase.LoadAssetAtPath <GameObject>(leapTempletePath);

            if (leapTemplete != null)
            {
                GameObject leapRootObj = GameObject.Instantiate(leapTemplete);
                leapRootObj.name = "LeapRoot";
                leapRootObj.transform.SetParent(transform);
                leapRootObj.transform.localPosition = Vector3.zero;
                leapRootObj.transform.localRotation = Quaternion.identity;
                m_LeapRoot = leapRootObj.AddComponent <LeapRoot>();
            }
        }
예제 #5
0
        /// <summary>
        /// 创建跃迁点
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        private Leap CreateLeap(LeapRoot root)
        {
            Leap   leap             = null;
            string leapTempletePath = GamingMapEditorUtility.GetLeapTempletePath();

            if (string.IsNullOrEmpty(leapTempletePath))
            {
                return(leap);
            }

            GameObject leapTemplete = AssetDatabase.LoadAssetAtPath <GameObject>(leapTempletePath);

            if (leapTemplete != null)
            {
                GameObject leapRootObj = GameObject.Instantiate(leapTemplete);
                leapRootObj.name = root.m_LeapName;
                leapRootObj.transform.SetParent(transform);
                leapRootObj.transform.localPosition = Vector3.zero;
                leapRootObj.transform.localRotation = Quaternion.identity;
                leap          = leapRootObj.AddComponent <Leap>();
                leap.m_LeapId = root.m_LeapId;
            }
            return(leap);
        }
예제 #6
0
        public IEnumerator OnUpdate(GamingMap gamingMap)
        {
            m_GamingMap = gamingMap;
            if (m_LeapList == null)
            {
                m_LeapList = new List <Leap>();
            }
            m_LeapList.Clear();
            Leap[] leaps = GetComponentsInChildren <Leap>(true);
            if (leaps != null && leaps.Length > 0)
            {
                for (int iLeap = 0; iLeap < leaps.Length; iLeap++)
                {
                    m_LeapList.Add(leaps[iLeap]);
                }
            }
            yield return(null);

            //为了确定有没有遗漏没有的跃迁点
            if (m_GamingMap != null)
            {
                List <GamingMapArea> areaList = m_GamingMap.m_GamingAreaList;
                if (areaList != null && areaList.Count > 0)
                {
                    for (int iArea = 0; iArea < areaList.Count; iArea++)
                    {
                        GamingMapArea area = areaList[iArea];
                        if (area != null)
                        {
                            LeapRoot leapRoot = area.m_LeapRoot;
                            if (leapRoot != null)
                            {
                                Leap leap = GetLeap(leapRoot.m_LeapId);
                                if (leap == null)
                                {
                                    leap = CreateLeap(leapRoot);
                                    m_LeapList.Add(leap);
                                }
                            }
                        }
                    }
                }
            }
            yield return(null);

            //因为只能由一个区域在线
            GamingMapArea showArea = null;

            if (m_GamingMap.m_GamingAreaList != null && m_GamingMap.m_GamingAreaList.Count > 0)
            {
                showArea = m_GamingMap.m_GamingAreaList[0];
            }
            //刷新Leap
            if (m_LeapList != null && m_LeapList.Count > 0)
            {
                for (int iLeap = 0; iLeap < m_LeapList.Count; iLeap++)
                {
                    Leap leap = m_LeapList[iLeap];

                    IEnumerator leapUpdateEnum = leap.OnUpdate(this, GetArea(leap.m_LeapId), showArea);
                    while (leapUpdateEnum != null && leapUpdateEnum.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            yield return(null);
        }