Beispiel #1
0
        private List <PathStatistics> GetNewPaths(PathStatistics sequence, TeleportNode endNode)
        {
            TeleportNode lastNode = sequence.path.Last();

            if (lastNode.ID != endNode.ID)
            {
                List <PathStatistics> sequenses = new List <PathStatistics>();

                foreach (ushort nextNodeID in lastNode.Costs.Keys)
                {
                    TeleportNode         nextNode = database.Points[nextNodeID];
                    TeleportNodeComparer comparer = new TeleportNodeComparer();

                    if (!sequence.path.Contains(nextNode, comparer))
                    {
                        //flag = true;
                        PathStatistics newSequence = (PathStatistics)sequence.Clone();
                        newSequence.path.Add(nextNode);

                        newSequence.cost += lastNode.GetCost(nextNodeID);
                        sequenses.Add(newSequence);
                    }
                }

                return(sequenses);
            }
            else
            {
                return(null);
            }
        }
 public object Clone()
 {
     PathStatistics clone = new PathStatistics();
     clone.cost = this.cost;
     clone.efficiency = this.efficiency;
     clone.flyTime = this.flyTime;
     clone.path = new List<TeleportNode>(this.path);
     clone.rideTime = this.rideTime;
     clone.teleportTime = this.teleportTime;
     clone.walkTime = this.walkTime;
     return clone;
 }
        public object Clone()
        {
            PathStatistics clone = new PathStatistics();

            clone.cost         = this.cost;
            clone.efficiency   = this.efficiency;
            clone.flyTime      = this.flyTime;
            clone.path         = new List <TeleportNode>(this.path);
            clone.rideTime     = this.rideTime;
            clone.teleportTime = this.teleportTime;
            clone.walkTime     = this.walkTime;
            return(clone);
        }
Beispiel #4
0
        internal List <PathStatistics> GetPaths(float absX1, float absY1, float absX2, float absY2)
        {
            List <PathStatistics> statistics = new List <PathStatistics>();
            float dummy;
            List <TeleportNodeDistance> points = GetClosestPoint(absX1, absY1, out dummy, out dummy, out dummy);

            List <TeleportNodeDistance> possibleStartNodes = new List <TeleportNodeDistance>(points.GetRange(0, Settings.Default.ClosestTeleportNodesCount));
            TeleportNode endNode = GetClosestPoint(absX2, absY2, out dummy, out dummy, out dummy)[0].point;

            TeleportNode          closestStartPoint           = possibleStartNodes[0].point;
            PathStatistics        closestStartPointStatistics = new PathStatistics(closestStartPoint);
            List <PathStatistics> sequences = new List <PathStatistics>();

            sequences.Add(closestStartPointStatistics);

            List <PathStatistics> newSequences = new List <PathStatistics>();

            while (flag)
            {
                foreach (PathStatistics sequence in sequences)
                {
                    List <PathStatistics> tmp = GetNewPaths(sequence, endNode);
                    if (tmp != null)
                    {
                        newSequences.AddRange(tmp);
                    }
                    else
                    {
                        flag = false;
                        newSequences.Add(sequence);
                    }
                }

                sequences = new List <PathStatistics>(newSequences);
                newSequences.Clear();
            }

            flag = true;

            foreach (PathStatistics sequence in sequences)
            {
                if (sequence.path.Last().ID == endNode.ID)
                {
                    newSequences.Add(sequence);
                }
            }

            return(newSequences);
        }