示例#1
0
        /// <summary>
        /// 生成任务。
        /// </summary>
        /// <typeparam name="T">任务的类型。</typeparam>
        /// <param name="priority">任务的优先级。</param>
        /// <returns>生成的指定类型的任务。</returns>
        public T GenerateTask <T>(int priority) where T : TaskBase, new()
        {
            T task = ReferencePool.Acquire <T>();

            task.Initialize(++m_Serial, priority);
            task.OnGenerate();

            LinkedListNode <TaskBase> current = m_Tasks.First;

            while (current != null)
            {
                if (task.Priority > current.Value.Priority)
                {
                    break;
                }

                current = current.Next;
            }

            if (current != null)
            {
                m_Tasks.AddBefore(current, task);
            }
            else
            {
                m_Tasks.AddLast(task);
            }

            return(task);
        }
示例#2
0
        /// <summary>
        /// 注册游戏框架组件。
        /// </summary>
        /// <param name="gameFrameworkComponent">要注册的游戏框架组件。</param>
        internal static void RegisterComponent(GameFrameworkComponent gameFrameworkComponent)
        {
            if (gameFrameworkComponent == null)
            {
                Log.Error("Game Framework component is invalid.");
                return;
            }

            Type type = gameFrameworkComponent.GetType();

            LinkedListNode <GameFrameworkComponent> current = s_GameFrameworkComponents.First;

            while (current != null)
            {
                if (current.Value.GetType() == type)
                {
                    Log.Error("Game Framework component type '{0}' is already exist.", type.FullName);
                    return;
                }

                current = current.Next;
            }

            s_GameFrameworkComponents.AddLast(gameFrameworkComponent);
        }
示例#3
0
        private void AddData(Data data, Type dataType, int priority)
        {
            if (data == null)
            {
                throw new GameFrameworkException("Can not add null data");
            }

            DataInfo dataInfo = DataInfo.Create(data);

            dataInfo.Priority = priority;

            m_dicDataInfos.Add(dataType, dataInfo);

            LinkedListNode <DataInfo> current = m_linkedListDataInfos.First;

            while (current != null)
            {
                if (dataInfo.Priority > current.Value.Priority)
                {
                    break;
                }

                current = current.Next;
            }

            if (current != null)
            {
                m_linkedListDataInfos.AddBefore(current, dataInfo);
            }
            else
            {
                m_linkedListDataInfos.AddLast(dataInfo);
            }
        }
            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);
            }
 /// <summary>
 /// 往实体组增加实体。
 /// </summary>
 /// <param name="entity">要增加的实体。</param>
 public void AddEntity(IEntity entity)
 {
     m_Entities.AddLast(entity);
 }
 /// <summary>
 /// 往实体组增加实体。
 /// </summary>
 /// <param name="Item">要增加的实体。</param>
 public void AddItem(IItem Item)
 {
     m_Items.AddLast(Item);
 }