Exemplo n.º 1
0
        public void OnEndDrag(PointerEventData eventData)
        {
            if (views.Count == 0)
            {
                return;
            }

            DragHandler(eventData);

            // 拖动距离 或 拖动速度 已经达到切换至下一个界面的限定值
            float speed  = (m_curPosVal - m_startPosVal) / (TimeUtil.GetTimeSec() - m_startTime);
            bool  isFlip = Mathf.Abs(m_curScale) > 0.4f || speed > 500;

            // other view is next?
            if (m_isVertical)
            {
                m_otherIsNext = m_curPosVal > m_startPosVal;
            }
            else
            {
                m_otherIsNext = m_curPosVal < m_startPosVal;
            }

            // 翻页
            if (isFlip && m_otherView != null)
            {
                m_otherView         = m_currentView;
                m_otherViewIndex    = m_currentViewIndex;
                m_currentViewIndex += m_otherIsNext ? 1 : -1;
                m_currentView       = GetView(m_currentViewIndex);
                m_curScale          = m_otherIsNext ? m_curScale + 1 : m_curScale - 1;
                m_otherIsNext       = !m_otherIsNext;
            }
            StartScroll();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 开始向指定主机发送 ping,获取 ping 值
 /// </summary>
 /// <param name="address">目标主机地址</param>
 /// <param name="count">ping 多少次,0 表示无限次</param>
 /// <param name="interval">ping 间隔(秒),也是超时时间</param>
 public static void StartPing(string address, int count = 0, float interval = 1)
 {
     s_pinging      = true;
     s_pingAddress  = address;
     s_pingCount    = count;
     s_pingInterval = interval;
     s_pingLastTime = TimeUtil.GetTimeSec() - interval;
     s_pingTimes    = 0;
 }
Exemplo n.º 3
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (views.Count == 0)
            {
                return;
            }

            m_scrolling   = false;
            m_curScale    = 0;
            m_startTime   = TimeUtil.GetTimeSec();
            m_startPosVal = (m_isVertical ? eventData.position.y : eventData.position.x) * Common.GetFixedScreenScale();
            m_sizeVal     = m_isVertical ? m_viewSize.y : m_viewSize.x;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 检查缓存是否已过期,并清除它
        /// </summary>
        /// <param name="timer">Timer.</param>
        private static void ClearCache(Timer timer)
        {
            float         time       = TimeUtil.GetTimeSec();
            List <string> unloadList = new List <string>();

            foreach (var item in s_infoMap)
            {
                AudioInfo info = item.Value;
                if (!IsPlaying(info.path) && time - info.lastTime > CacheTime)
                {
                    unloadList.Add(info.path);
                    ResManager.Unload(info.path);
                    Object.Destroy(info.src);
                    //Debug.Log("[Unload Audio] " + info.path);
                }
            }

            foreach (string path in unloadList)
            {
                s_infoMap.Remove(path);
            }

            Timer.Once(1000 * 60, ClearCache);
        }