private void OnEnable()
        {
            m_Target = target as SemaphoreMark;
            allNpcs  = ConfigVO <NpcVO> .Instance.GetList();

            if (allNpcs != null)
            {
                for (int iNpc = 0; iNpc < allNpcs.Count; iNpc++)
                {
                    if (allNpcs[iNpc].ID == m_Target.m_NpcId)
                    {
                        m_Target.m_SelectNpcIndex = iNpc;
                        break;
                    }
                }
            }

            if (m_Target.m_NpcIdArray == null || m_Target.m_NpcIdArray.Length <= 0)
            {
                if (allNpcs != null && allNpcs.Count > 0)
                {
                    m_Target.m_NpcIdArray = new string[allNpcs.Count];
                    for (int iNpc = 0; iNpc < allNpcs.Count; iNpc++)
                    {
                        NpcVO vo = allNpcs[iNpc];
                        m_Target.m_NpcIdArray[iNpc] = string.Format("{0}_{1}", vo.ID, vo.Name);
                    }
                }
            }
            m_LastNpcId   = m_Target.m_NpcId;
            m_LastGroupId = m_Target.m_GroupId;
        }
Ejemplo n.º 2
0
 public bool Exists(SemaphoreMark mark)
 {
     if (mark == null)
     {
         return(false);
     }
     return(Exists(mark.m_GroupId, mark.m_NpcId, mark.name));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 同步位置
 /// </summary>
 /// <param name="mark"></param>
 public void Sync(SemaphoreMark mark)
 {
     if (mark == null)
     {
         return;
     }
     transform.position = mark.transform.position;
 }
Ejemplo n.º 4
0
 public void Add(SemaphoreMark mark)
 {
     RefreshTreasureCache();
     if (Exists(mark))
     {
         return;
     }
     m_TreasureCache.Add(CreateTreasure(mark));
 }
Ejemplo n.º 5
0
 public void Add(SemaphoreMark mark)
 {
     RefreshMineralCache();
     if (Exists(mark))
     {
         return;
     }
     CreateMineral(mark);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建矿节点
        /// </summary>
        /// <param name="mark"></param>
        private void CreateMineral(SemaphoreMark mark)
        {
            GameObject treasureObj = new GameObject();

            treasureObj.transform.SetParent(transform);
            treasureObj.transform.localRotation = Quaternion.identity;
            treasureObj.transform.position      = mark.transform.position;
            treasureObj.name = mark.name;
            Mineral mineral = treasureObj.AddComponent <Mineral>();

            mineral.Init(mark.m_NpcId, mark.m_GroupId);
        }
Ejemplo n.º 7
0
        private Treasure CreateTreasure(SemaphoreMark mark)
        {
            GameObject treasureObj = new GameObject();

            treasureObj.transform.SetParent(transform);
            treasureObj.transform.localRotation = Quaternion.identity;
            treasureObj.transform.position      = mark.transform.position;
            treasureObj.name = mark.name;
            Treasure treasure = treasureObj.AddComponent <Treasure>();

            treasure.Init(mark.m_NpcId, mark.m_GroupId);
            return(treasure);
        }
Ejemplo n.º 8
0
 public void Remove(SemaphoreMark mark)
 {
     RefreshMineralCache();
     if (Exists(mark))
     {
         if (m_MineralCache != null && m_MineralCache.Count > 0)
         {
             for (int iMineral = m_MineralCache.Count - 1; iMineral >= 0; iMineral--)
             {
                 Mineral mineral = m_MineralCache[iMineral];
                 if (mineral.name == mark.name && mineral.m_MineralNpcId == mark.m_NpcId &&
                     mineral.m_MineralGroupId == mark.m_GroupId)
                 {
                     mineral.Release(true);
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
 public void Remove(SemaphoreMark mark)
 {
     RefreshTreasureCache();
     if (Exists(mark))
     {
         if (m_TreasureCache != null && m_TreasureCache.Count > 0)
         {
             for (int iTreasure = m_TreasureCache.Count - 1; iTreasure >= 0; iTreasure--)
             {
                 Treasure treasure = m_TreasureCache[iTreasure];
                 if (treasure.name == mark.name && treasure.m_TreasureNpcId == mark.m_NpcId &&
                     treasure.m_TreasureGroupId == mark.m_GroupId)
                 {
                     treasure.Release(true);
                     m_TreasureCache.Remove(treasure);
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
        public IEnumerator DoUpdate()
        {
            Transform areaTrans = transform.parent;

            while (areaTrans != null && areaTrans.GetComponent <Area>() == null)
            {
                areaTrans = areaTrans.parent;
            }
            Area area = areaTrans.GetComponent <Area>();

            if (area != null)
            {
                m_AreaId = area.Uid;

                m_RelativeAreaPos   = area.transform.InverseTransformPoint(transform.position);
                m_RelativeAreaRot   = Quaternion.Inverse(areaTrans.rotation) * transform.rotation;
                m_RelativeAreaScale = ObjectUtility.CalculateLossyScale(transform, area.transform);
                gameObject.name     = string.Format("{0}_寻宝节点", areaTrans.name);
            }

            m_SemaphorMarkCache.Clear();
            SemaphoreMark[] m_SemaphorMarks = GetComponentsInChildren <SemaphoreMark>();
            if (m_SemaphorMarks != null && m_SemaphorMarks.Length > 0)
            {
                m_SemaphorMarkCache.AddRange(m_SemaphorMarks);
                for (int iSeam = 0; iSeam < m_SemaphorMarkCache.Count; iSeam++)
                {
                    SemaphoreMark mark = m_SemaphorMarks[iSeam];
                    if (mark != null && mark.gameObject != null)
                    {
                        mark.DoUpdate();
                    }
                    yield return(null);
                }
            }
            yield return(null);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 同步信息
        /// </summary>
        public void SyncInfo()
        {
            if (m_TreasureCache == null || m_TreasureCache.Count <= 0)
            {
                return;
            }

            if (m_GamingMapArea != null)
            {
                TreasureRootMark treasureRoot = null;
                Area[]           areas        = FindObjectsOfType <Area>();
                if (areas != null && areas.Length > 0)
                {
                    for (int iArea = 0; iArea < areas.Length; iArea++)
                    {
                        Area area = areas[iArea];
                        if (area.Uid == m_GamingMapArea.m_AreaId)
                        {
                            treasureRoot = area.m_TreasureRoot;
                        }
                    }
                }

                if (treasureRoot == null)
                {
                    EditorUtility.DisplayDialog("提示", string.Format("同步失败!未找到{0}", m_GamingMapArea.m_AreaId), "OK");
                    return;
                }

                List <SemaphoreMark> semaphores = treasureRoot.m_SemaphorMarkCache;
                if (m_TreasureCache != null && m_TreasureCache.Count > 0)
                {
                    List <Treasure> needRelease = new List <Treasure>();
                    for (int iTreasure = m_TreasureCache.Count - 1; iTreasure >= 0; iTreasure--)
                    {
                        Treasure treasure = m_TreasureCache[iTreasure];
                        bool     hasAlive = false;
                        for (int iSem = 0; iSem < semaphores.Count; iSem++)
                        {
                            SemaphoreMark mark = semaphores[iSem];
                            if (treasure.name == mark.name && treasure.m_TreasureNpcId == mark.m_NpcId &&
                                treasure.m_TreasureGroupId == mark.m_GroupId)
                            {
                                treasure.Sync(mark);
                                hasAlive = true;
                                break;
                            }
                        }
                        if (!hasAlive)
                        {
                            needRelease.Add(treasure);
                        }
                    }
                    if (needRelease != null && needRelease.Count > 0)
                    {
                        for (int iNeed = 0; iNeed < needRelease.Count; iNeed++)
                        {
                            needRelease[iNeed].Release(true);
                        }
                        needRelease.Clear();
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void OnGUI()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Name", GUILayout.Width(200)))
            {
            }
            if (GUILayout.Button("GroupId", GUILayout.Width(100)))
            {
            }
            if (GUILayout.Button("NpcId", GUILayout.Width(100)))
            {
            }
            GUILayout.EndHorizontal();
            if (m_Marks != null && m_Marks.Count > 0)
            {
                GUILayout.BeginVertical();
                m_TreasureScrollPos = GUILayout.BeginScrollView(m_TreasureScrollPos);
                int minCount  = (m_CurPage - 1) * PAGE_MAX_COUNT;
                int maxCount  = m_CurPage * PAGE_MAX_COUNT;
                int lastCell  = m_Marks.Count % PAGE_MAX_COUNT;
                int totalPage = m_Marks.Count / PAGE_MAX_COUNT;
                if (lastCell > 0)
                {
                    totalPage++;
                }

                for (int iMark = 0; iMark < m_Marks.Count; iMark++)
                {
                    if (iMark < minCount || iMark > maxCount)
                    {
                        continue;
                    }
                    SemaphoreMark markInfo = m_Marks[iMark];
                    GUILayout.BeginHorizontal("box");
                    GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                    if (GUILayout.Button(markInfo.name, GUILayout.Width(200)))
                    {
                        Selection.activeObject = markInfo.gameObject;
                    }

                    GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                    GUILayout.Space(10);

                    GUILayout.Label(markInfo.m_GroupId.ToString(), GUILayout.MaxWidth(100));
                    GUILayout.Label(markInfo.m_NpcId.ToString(), GUILayout.MaxWidth(100));

                    if (m_Root.Exists(markInfo))
                    {
                        if (GUILayout.Button("移除"))
                        {
                            m_Root.Remove(markInfo);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("添加"))
                        {
                            m_Root.Add(markInfo);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
                GUILayout.BeginHorizontal();
                if (m_CurPage > 1)
                {
                    if (GUILayout.Button("上一页"))
                    {
                        m_CurPage--;
                    }
                }
                GUILayout.Label("当前页:" + m_CurPage);
                if (GUILayout.Button("刷新"))
                {
                    Init(m_Root);
                }
                if (m_CurPage < totalPage)
                {
                    if (GUILayout.Button("下一页"))
                    {
                        m_CurPage++;
                    }
                }
                GUILayout.EndHorizontal();
            }
        }