public static DownloadCounterNode Create(int downloadedLength)
                {
                    DownloadCounterNode downloadCounterNode = ReferencePool.Acquire <DownloadCounterNode>();

                    downloadCounterNode.m_DownloadedLength = downloadedLength;
                    return(downloadCounterNode);
                }
            public void RecordDownloadedLength(int downloadedLength)
            {
                if (downloadedLength <= 0)
                {
                    return;
                }

                m_DownloadCounterNodes.Enqueue(DownloadCounterNode.Create(downloadedLength));
            }
            public void RecordDownloadedLength(int downloadedLength)
            {
                if (downloadedLength <= 0)
                {
                    return;
                }

                DownloadCounterNode downloadCounterNode = ReferencePool.Acquire <DownloadCounterNode>();

                downloadCounterNode.Initialize(downloadedLength);
                m_DownloadCounterNodes.Enqueue(downloadCounterNode);
            }
Ejemplo n.º 4
0
        public void RecordDownloadedLength(int downloadedLength)
        {
            if (downloadedLength <= 0)
            {
                return;
            }

            DownloadCounterNode downloadCounterNode = GameEntry.Pool.SpawnClassObject <DownloadCounterNode>();

            downloadCounterNode.Clear();
            downloadCounterNode.DownloadedLength = downloadedLength;
            m_DownloadCounterNodes.Enqueue(downloadCounterNode);
        }
            public void Update(float elapseSeconds, float realElapseSeconds)
            {
                if (m_DownloadCounterNodes.Count <= 0)
                {
                    return;
                }

                m_Accumulator += realElapseSeconds;
                if (m_Accumulator > m_RecordInterval)
                {
                    m_Accumulator = m_RecordInterval;
                }

                m_TimeLeft -= realElapseSeconds;
                foreach (DownloadCounterNode downloadCounterNode in m_DownloadCounterNodes)
                {
                    downloadCounterNode.Update(elapseSeconds, realElapseSeconds);
                }

                while (m_DownloadCounterNodes.Count > 0)
                {
                    DownloadCounterNode downloadCounterNode = m_DownloadCounterNodes.First.Value;
                    if (downloadCounterNode.ElapseSeconds < m_RecordInterval)
                    {
                        break;
                    }

                    ReferencePool.Release(downloadCounterNode);
                    m_DownloadCounterNodes.RemoveFirst();
                }

                if (m_DownloadCounterNodes.Count <= 0)
                {
                    Reset();
                    return;
                }

                if (m_TimeLeft <= 0f)
                {
                    long totalDeltaLength = 0L;
                    foreach (DownloadCounterNode downloadCounterNode in m_DownloadCounterNodes)
                    {
                        totalDeltaLength += downloadCounterNode.DeltaLength;
                    }

                    m_CurrentSpeed = m_Accumulator > 0f ? totalDeltaLength / m_Accumulator : 0f;
                    m_TimeLeft    += m_UpdateInterval;
                }
            }
            public void RecordDownloadedLength(int downloadedLength)
            {
                if (downloadedLength <= 0)
                {
                    return;
                }

                if (m_DownloadCounterNodes.Count > 0)
                {
                    DownloadCounterNode downloadCounterNode = m_DownloadCounterNodes.Last.Value;
                    if (downloadCounterNode.ElapseSeconds < m_UpdateInterval)
                    {
                        downloadCounterNode.AddDownloadedLength(downloadedLength);
                        return;
                    }
                }

                m_DownloadCounterNodes.AddLast(DownloadCounterNode.Create(downloadedLength));
            }
            public void RecordDeltaLength(int deltaLength)
            {
                if (deltaLength <= 0)
                {
                    return;
                }

                DownloadCounterNode downloadCounterNode = null;

                if (m_DownloadCounterNodes.Count > 0)
                {
                    downloadCounterNode = m_DownloadCounterNodes.Last.Value;
                    if (downloadCounterNode.ElapseSeconds < m_UpdateInterval)
                    {
                        downloadCounterNode.AddDeltaLength(deltaLength);
                        return;
                    }
                }

                downloadCounterNode = DownloadCounterNode.Create();
                downloadCounterNode.AddDeltaLength(deltaLength);
                m_DownloadCounterNodes.AddLast(downloadCounterNode);
            }