Ejemplo n.º 1
0
        /// <summary>
        /// 添加一个导航信息
        /// </summary>
        public void AddNavi(GameObject fromObj, GameObject toObj, UINaviNodeRelation relation)
        {
            if (fromObj == null || toObj == null)
            {
                return;
            }

            UINaviNode naviNode = GetActiveNaviNode(fromObj);

            switch (relation)
            {
            case UINaviNodeRelation.Left:
                naviNode.leftObj = toObj;
                break;

            case UINaviNodeRelation.Right:
                naviNode.rightObj = toObj;
                break;

            case UINaviNodeRelation.Up:
                naviNode.upObj = toObj;
                break;

            case UINaviNodeRelation.Down:
                naviNode.downObj = toObj;
                break;
            }
        }
Ejemplo n.º 2
0
        public GameObject GetNavi(GameObject fromObj, UINaviNodeRelation relation)
        {
            GameObject toObj    = null;
            UINaviNode naviNode = GetActiveNaviNode(fromObj);

            switch (relation)
            {
            case UINaviNodeRelation.Left:
                toObj = naviNode.leftObj;
                break;

            case UINaviNodeRelation.Right:
                toObj = naviNode.rightObj;
                break;

            case UINaviNodeRelation.Up:
                toObj = naviNode.upObj;
                break;

            case UINaviNodeRelation.Down:
                toObj = naviNode.downObj;
                break;
            }
            return(toObj);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取一个有效的节点
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="fromObj"></param>
        /// <returns></returns>
        UINaviNode GetActiveNaviNode(GameObject fromObj)
        {
            UINaviNode node;

            if (!m_NaviMap.TryGetValue(fromObj, out node))
            {
                node = new UINaviNode();
                m_NaviMap.Add(fromObj, node);
            }
            return(node);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取监听事件
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="evt"></param>
        /// <returns></returns>
        public Action <GameObject> GetEvent(GameObject obj, UINaviNodeEvent evt)
        {
            Action <GameObject> action   = null;
            UINaviNode          naviNode = GetActiveNaviNode(obj);

            switch (evt)
            {
            case UINaviNodeEvent.Selected:
                action = naviNode.onSelected;
                break;

            case UINaviNodeEvent.UnSelected:
                action = naviNode.onUnSeleced;
                break;
            }
            return(action);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加事件监听
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="action"></param>
        /// <param name="evt"></param>
        public void AddEvent(GameObject obj, Action <GameObject> action, UINaviNodeEvent evt)
        {
            if (obj == null)
            {
                return;
            }

            UINaviNode naviNode = GetActiveNaviNode(obj);

            switch (evt)
            {
            case UINaviNodeEvent.Selected:
                naviNode.onSelected = action;
                break;

            case UINaviNodeEvent.UnSelected:
                naviNode.onUnSeleced = action;
                break;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 移除一个导航
        /// </summary>
        /// <param name="obj"></param>
        public void RemoveNavi(GameObject obj)
        {
            UINaviNode naviNode = GetActiveNaviNode(obj);

            naviNode.Clear();
        }