Exemplo n.º 1
0
 public void AddRange(CSBetterList <T> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         Add(list[i]);
     }
 }
Exemplo n.º 2
0
 public void CallBack(T obj)
 {
     for (int i = onLoadedList.Count - 1; i >= 0; i--)//防止回调里面做了-=的操作
     {
         if (onLoadedList[i] != null)
         {
             onLoadedList[i](obj);
         }
     }
 }
Exemplo n.º 3
0
 public void RefreshNames(CSBetterList <string> list, bool isReset = false)
 {
     if (list != null && list.Count > 0)
     {
         if (isReset)
         {
             ResetToBeginning();
         }
         mCurrentNames = list;
     }
 }
Exemplo n.º 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]);
         }
     }
 }
Exemplo n.º 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]);
         }
     }
 }
Exemplo n.º 6
0
 public void Insert(int index, CSBetterList <T> list)
 {
     if (list == null)
     {
         return;
     }
     for (int i = list.Count - 1; i >= 0; i--)
     {
         Insert(index, list[i]);
     }
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 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);
    }
Exemplo n.º 10
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));
    }
Exemplo n.º 11
0
 public void GetRange(int startIndex, int count, CSBetterList <Value> list)
 {
     Values.GetRange(startIndex, count, list);
 }
Exemplo n.º 12
0
 public Value Find(CSBetterList <Value> .CompareFunc_2 match, object obj)
 {
     return(Values.Find(match, obj));
 }
Exemplo n.º 13
0
 public void FindAll(CSBetterList <Value> .CompareFunc_2 match, object obj, CSBetterList <Value> list)
 {
     Values.FindAll(match, obj, list);
 }
Exemplo n.º 14
0
 public void FindAll(Predicate <Value> match, CSBetterList <Value> list)
 {
     Values.FindAll(match, list);
 }