예제 #1
0
    /// <summary>
    /// 添加一个模型的加载数据
    /// 在结束解析的时候,开始加载
    /// </summary>
    /// <param name="model"></param>
    /// <param name="structure"></param>
    /// <param name="motion"></param>
    /// <param name="direction"></param>
    /// <param name="resourceType"></param>
    /// <param name="resourceAssistType"></param>
    protected void Load(uint model, EModelStructure structure, CSMotion motion, CSDirection direction, EResourceType resourceType, EResourceAssistType resourceAssistType)
    {
        //加载的模型不存在
        if (model == 0)
        {
            //如果要加载身体模型不存在,那么要注意清理其他的组件
            if (structure == EModelStructure.Body)
            {
            }
            return;
        }

        long key = GetKey((int)model, (int)motion, (int)direction, (int)structure);
        ModelComponentLoadData data = null;

        if (!ModelComponentLoadedCacheDic.TryGetValue(key, out data))
        {
            data = new T();
            ModelComponentLoadedCacheDic[key] = data;
        }
        data.Model              = model;
        data.Key                = key;
        data.Structure          = structure;
        data.ResourceType       = resourceType;
        data.ResourceAssistType = resourceAssistType;

        WaitLoadComponentKey.Add(data);
    }
예제 #2
0
    public CSProtoMessageData(string content)
    {
        this.content = content;

        string          pattern = "message ([^{^ ])+";
        MatchCollection matchs  = null;

        matchs = Regex.Matches(content, pattern);

        if (matchs != null && matchs.Count > 0)
        {
            messageName = matchs[0].Groups[1].Value;
        }

        pattern = "(required|optional|repeated) (\\S+) ([\\S^=]+)[ ]*=[ ]*([0-9]+)[^;]*;//(\\S+)";
        matchs  = Regex.Matches(content, pattern);

        fieldList.Clear();
        if (matchs != null && matchs.Count > 0)
        {
            for (int i = 0; i < matchs.Count; i++)
            {
                GroupCollection         group = matchs[i].Groups;
                CSProtoMessageFieldData data  = new CSProtoMessageFieldData(group[1].Value, group[2].Value, group[3].Value, uint.Parse(group[4].Value), group[5].Value);
                fieldList.Add(data);
            }
        }
    }
예제 #3
0
 /// <summary>
 /// 设置放入对象池的时间
 /// </summary>
 /// <param name="mPoolItem"></param>
 /// <param name="time">秒</param>
 public void SetPoolRemoveTime(CSObjectPoolItem mPoolItem, float time, EPoolItemRemoveMethod removeMethod = EPoolItemRemoveMethod.OnDisEnable)
 {
     if (mPoolItem == null)
     {
         return;
     }
     mPoolItem.RemoveTime = Time.time + time;
     WaitRemoveList.Add(mPoolItem);
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="match"></param>
 /// <param name="obj">值类型装换成object有装箱操作,有一定的性能消耗,防止大量的装箱的出现</param>
 /// <param name="list"></param>
 public void FindAll(CompareFunc_2 match, object obj, CSBetterList <T> list)
 {
     list.Clear();
     for (int i = 0; i < size; i++)
     {
         if (match(buffer[i], obj))
         {
             list.Add(buffer[i]);
         }
     }
 }
예제 #5
0
 public void FindAll(Predicate <T> match, CSBetterList <T> list)
 {
     list.Clear();
     for (int i = 0; i < size; i++)
     {
         if (match(buffer[i]))
         {
             list.Add(buffer[i]);
         }
     }
 }
예제 #6
0
 private void AddLoadingQueue(CSResource res)
 {
     if (!loadingQueue.ContainsKey(res.Path))
     {
         loadingQueue.Add(res.Path, res);
     }
     if (!loadingQueueList.Contains(res))
     {
         loadingQueueList.Add(res);
     }
 }
예제 #7
0
 public Value this[Key i]
 {
     get { return(mDic[i]); }
     set
     {
         if (mIsHasValues)
         {
             mValues.Remove(mDic[i]);
             mValues.Add(value);
         }
         mDic[i] = value;
     }
 }
    public void RefushFolder()
    {
        DirectoryInfo directory = new DirectoryInfo(OrigionFolder);

        if (!directory.Exists)
        {
            return;
        }
        FileList.Clear();

        FileInfo[] files = directory.GetFiles("*.proto");
        for (int i = 0; i < files.Length; i++)
        {
            FileList.Add(files[i]);
        }
    }
예제 #9
0
 public CSBetterList <T> GetRange(int startIndex, int count, CSBetterList <T> list)
 {
     list.Clear();
     for (int i = startIndex; i < startIndex + count; i++)
     {
         if (i < 0)
         {
             continue;
         }
         if (i < size)
         {
             list.Add(buffer[i]);
         }
     }
     return(list);
 }
예제 #10
0
    private static CSBetterList <Node> CalculatePath(Node node, bool isAssist = false)
    {
        CSBetterList <Node> data = isAssist ? assistList : normalList;

        data.Clear();
        while (node != null)
        {
            data.Add(node);
            node = node.parent;

            if (data.Count > 1000)
            {
                return(null);
            }
        }
        data.Reverse();
        return(data);
    }
예제 #11
0
    /// <summary>
    /// 从缓存池里面获得GameObject,并且从缓存池里面去除,返回的Gameobject.active = false
    /// </summary>resPath 资源路径,也是缓存池名称
    /// <param name="poolName">资源路径</param>
    CSObjectPoolItem GetPoolItem(string resName, string resPath, EPoolType poolType, int poolNum = 0, bool isForever = false)
    {
        CSObjectPoolBase pool     = null;
        string           poolName = resPath;

        if (mDic.ContainsKey(poolName))
        {
            pool = mDic[poolName];
        }
        else
        {
            if (poolNum == 0)
            {
                return(null);
            }
            CSStringBuilder.Clear();

            GameObject poolGO = new GameObject();
            Transform  trans  = poolGO.transform;
            trans.parent = transform;
            if (poolType == EPoolType.Normal)
            {
                pool = poolGO.AddComponent <CSObjectPoolNormal>();
                CSStringBuilder.Append("Normal Pool->", resName);
                poolGO.name = CSStringBuilder.ToString();
            }
            else if (poolType == EPoolType.Resource)
            {
                pool = poolGO.AddComponent <CSObjectPoolAtlas>();
                CSStringBuilder.Append("Atlas Pool->", resName);
                poolGO.name = CSStringBuilder.ToString();
            }
            pool.resName = resName;
            //pool.resType = resType;
            pool.Init(this);
            mDic.Add(poolName, pool);
            mList.Add(pool);
        }
        pool.poolNum   = poolNum;
        pool.poolName  = poolName;
        pool.isForever = isForever;
        return(pool.GetGOFromPool());
    }
예제 #12
0
    /// <summary>
    /// 从缓存池里面获得GameObject,并且从缓存池里面去除,返回的Gameobject.active = false
    /// </summary>resPath 资源路径,也是缓存池名称
    /// <param name="poolName">资源路径</param>
    private CSObjectPoolItem GetPoolItem(string resName, string resPath, EPoolType poolType, int poolNum = 0, bool isForever = false)
    {
        CSObjectPoolBase pool     = null;
        string           poolName = resPath;

        if (mDic.TryGetValue(poolName, out pool) && pool != null)
        {
            pool = mDic[poolName];
        }
        else
        {
            if (poolNum == 0)
            {
                return(null);
            }

            CSStringBuilder.Clear();

            GameObject poolGO = new GameObject();
            Transform  trans  = poolGO.transform;
            trans.parent = transform;
            if (poolType == EPoolType.Normal)
            {
                pool = poolGO.AddComponent <CSObjectPoolNormal>();
                CSStringBuilder.Append("Normal Pool->", resName);
                poolGO.name = CSStringBuilder.ToString();
            }
            pool.resName = resName;
            //pool.resType = resType;
            pool.Init();
            mDic[poolName]            = pool;
            pool.transform.localScale = Vector3.zero;
            //mDic.Add(poolName, pool);
            mList.Add(pool);
        }
        pool.poolNum   = poolNum;
        pool.poolName  = poolName;
        pool.isForever = isForever;
        return(pool.GetGOFromPool());
    }
예제 #13
0
    public void Load(uint modelID, uint motion, uint direction, uint structure, ResourceType type, ResourceAssistType assistType)
    {
        //Debug.Log(modelID + " " + motion + " " + direction);
        if (SFOut.IResourceManager == null)
        {
            return;
        }
        long key = GetKey((int)modelID, (int)motion, (int)direction);

        //if (avater != null && avater.getAvatarType() == EAvatarType.MainPlayer)
        //{
        //    Debug.Log("motion = " + (CSMotion)motion);
        //}
        if (mLoadedDic.ContainsKey(key))
        {
            ModelLoadData data = mLoadedDic[key];
            if (data != null && data.atlas != null && !data.atlas.HasBeenDestroy)
            {
                mStructures[structure] = key;
                string     path = SFOut.IResourceManager.GetKeyPath(key);
                CSResource res  = SFOut.IResourceManager.GetRes(path);
                if (res != null)
                {
                    BeginLoadModelResCallBack(res);
                }
                return;
            }
        }
        else
        {
            ModelLoadData data = new ModelLoadData();
            mLoadedDic.Add(key, data);
            data.type       = type;
            data.assistType = assistType;
        }
        mStructures[structure] = key;
        mObjectList.Add(key);
        mObjectFinishStateList.Add(false);
    }
예제 #14
0
 public void AddFrontCallBack(OnLoaded onLoaded)
 {
     onLoadedList.Add(onLoaded);
 }