Beispiel #1
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);
            }
        }
    }
 /// <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]);
         }
     }
 }
 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]);
         }
     }
 }
 public void BeginLoad()
 {
     PreBeginLoad();
     mObjectList.Clear();
     mObjectFinishStateList.Clear();
     for (int i = 0; i < mStructures.Length; i++)
     {
         mStructures[i] = 0;
     }
     //onFinishAll = callBack;
 }
Beispiel #5
0
 public void Reset()
 {
     for (int i = 0; i < nodes.Count; i++)
     {
         Node node = nodes[i];
         if (node != null)
         {
             node.isInOpenList   = false;
             node.isInClonseList = false;
         }
     }
     nodes.Clear();
 }
 public override void OnDestroy()
 {
     base.OnDestroy();
     Dictionary <string, CSObjectPoolBase> .Enumerator cur = mDic.GetEnumerator();
     while (cur.MoveNext())
     {
         cur.Current.Value.CSOnDestroy(false);
     }
     mList.Clear();
     mList = null;
     mDic.Clear();
     mDic = null;
 }
    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]);
        }
    }
 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);
 }
Beispiel #9
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);
    }
 public virtual void Clear()
 {
     mList.Clear();
     refCount = 0;
 }
 public void Clear()
 {
     onLoadedList.Clear();
 }
Beispiel #12
0
    public static CSBetterList <Node> FindPathInGrassScene(Node start, Node goal, bool isAssist = false, bool isMainPlayer = false, CSBetterList <Node> assistList = null)
    {
        //SFMisc.Dot2 startCoord = new SFMisc.Dot2(41, 67);
        //SFMisc.Dot2 targetCoord = new SFMisc.Dot2(45, 65);

        //start = CSScene.Sington.Mesh.getNode(startCoord);
        //goal = CSScene.Sington.Mesh.getNode(targetCoord);
        bool isCanCrossScene = SFOut.IGame.isCanCrossScene;
        //isCanCrossScene = false;
        CSBetterList <Node> list = isAssist ? assistList : normalList;

        if (assistList != null)
        {
            list = assistList;
        }
        bool isIgnoreResistance = false;

        if (goal == null || start == null || goal.bObstacle ||
            start.bObstacle || goal.coord.Equal(start.coord))
        {
#if UNITY_EDITOR
            UnityEngine.Debug.LogError("开始或目的点有阻挡点");
#endif
            if (list != null)
            {
                list.Clear();
            }
            return(list);
        }
        if (start.cell == null)
        {
            start.cell = SFOut.IScene.getiMesh.getCellByISfCell(start.coord.x, start.coord.y);
        }
        if (goal.cell == null)
        {
            goal.cell = SFOut.IScene.getiMesh.getCellByISfCell(goal.coord.x, goal.coord.y);
        }
        if (start != null && goal != null)
        {
            if (goal.cell.isAttributesByISFCell((int)SFCellType.Separate) && start.cell.isAttributesByISFCell((int)SFCellType.Normal))
            {
                if (list != null)
                {
                    list.Clear();
                }
                return(list);
            }
            if (goal.cell.isAttributesByISFCell((int)SFCellType.Normal) && start.cell.isAttributesByISFCell((int)SFCellType.Separate))
            {
                if (list != null)
                {
                    list.Clear();
                }
                return(list);
            }
        }


        //Debug.Log("start.position=" + start.coord.x + " " + start.coord.y+" goal.position = " + goal.coord.x + " " + goal.coord.y);
        start.parent = null;
        openList.Push(start);

        start.nodeTotalCost = 0.0f;
        start.estimatedCost = HeuristicEstimateCost(start, goal);
        Node node = null;
        CSBetterList <Node> neighbours = new CSBetterList <Node>();
        while (openList.Length != 0)
        {
            node = openList.First();
            node.isInOpenList = false;
            if (node.coord.Equal(goal.coord))
            {
                Reset();
                return(CalculatePath(node));
            }
            neighbours.Clear();
            SFOut.IScene.getiMesh.GetNeighbours(node, neighbours);
            for (int i = 0; i < neighbours.Count; i++)
            {
                Node neighbourNode = (Node)neighbours[i];
                if (isMainPlayer && isAssist)
                {
                    if (!neighbourNode.coord.Equal(goal.coord))
                    {
                        if (/*isAssist && */ !neighbourNode.isCanCrossNpc)
                        {
                            continue;
                        }
                        //if (neighbourNode.avatarNum >= 2) continue;
                        if (!isCanCrossScene && !neighbourNode.isProtect && neighbourNode.avatarNum > 0 && SFOut.IGame.IsLanuchMainPlayer && SFOut.IScene.getMainPlayer.getMoveStateBySF != EMoveState.YeManChongZhuang)
                        {
                            continue;
                        }
                    }
                }
                if (SFOut.IGame.IsNotCrossToAnthor(node.coord, neighbourNode.coord))
                {
                    continue;
                }

                if (!neighbourNode.isInClonseList && !neighbourNode.bObstacle && SFOut.IGame.IsCanMoveFromSafeArea(node, neighbourNode))
                {
                    float cost                 = HeuristicCloselyCost(node, neighbourNode);
                    float totalCost            = node.nodeTotalCost + cost;
                    float neighbourNodeEstCost = HeuristicEstimateCost(neighbourNode, goal);

                    if (!neighbourNode.isInOpenList || totalCost < neighbourNode.nodeTotalCost)
                    {
                        neighbourNode.nodeTotalCost = totalCost;
                        neighbourNode.parent        = node;
                        neighbourNode.estimatedCost = totalCost + neighbourNodeEstCost;
                    }
                    if (!neighbourNode.isInOpenList)
                    {
                        neighbourNode.isInOpenList = true;
                        openList.Push(neighbourNode);
                    }
                }
            }
            node.isInClonseList = true;
            closedList.Push(node, false);
            //node.isInOpenList = false;
            //openList.Remove(node);
        }
        Reset();
        if (node.position != goal.position)
        {
            // Debug.LogError("Goal Not Found = " + start.coord.x + "," + start.coord.y + "|" + goal.coord.x + "," + goal.coord.y);
            if (list != null)
            {
                list.Clear();
            }
            return(list);
        }
        return(CalculatePath(node, isAssist));
    }
Beispiel #13
0
 public virtual void Clear()
 {
     mCurrentNames.Clear();
 }
Beispiel #14
0
 public void Clear()
 {
     mCurrentNames.Clear();
 }