示例#1
0
        /// <summary>
        /// Scan if a merge point is ahead of the car, and if so, handle merging.
        /// </summary>
        private void HandleMerging()
        {
            double totalDist = Util.Distance(x, y, CurrentCityPath.e.x, CurrentCityPath.e.y);

            foreach (CityPath p in path)
            {
                if (p != CurrentCityPath)
                {
                    totalDist += Util.Distance(p.s.x, p.s.y, p.e.x, p.e.y);
                }

                if (p.e is MergeNode)
                {
                    if (2 * Util.StopDistance(speed, DEACCELERATION) + 25 >= totalDist)
                    {
                        MergeNode m = p.e as MergeNode;
                        if (!m.intersection.Contains(this))
                        {
                            m.intersection.VehicleApproach(this);
                        }
                        MergePoint point = m.intersection as MergePoint;
                        if (point.inside.Contains(this))
                        {
                            limits.RemoveAll(l => l.name == "merge");
                            return;
                        }
                        else if (Util.StopDistance(speed, DEACCELERATION) + 25 >= totalDist)
                        {
                            limits.RemoveAll(l => l.name == "merge");
                            limits.Add(new SpeedLimiter(0, "merge"));
                        }
                    }
                }
            }
        }
示例#2
0
        private void AddMenus()
        {
            var insertBeforeWindowSeparator = new MergePoint(MergeOperation.InsertBefore, "WindowSeparator");

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Output"], insertBeforeWindowSeparator, MergePoint.Append))
            };
            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#3
0
        public int FindMergeNode_ForTwoLists_ReturnsDataFromFirstSharedNode(
            int[] firstIndices,
            int[] secondIndices,
            int[] sharedIndices
            )
        {
            TestSinglyLinkedList onlyFirst  = SinglyLinkedListHelper.CreateLinkedList(firstIndices);
            TestSinglyLinkedList onlySecond = SinglyLinkedListHelper.CreateLinkedList(secondIndices);
            TestSinglyLinkedList onlyShared = SinglyLinkedListHelper.CreateLinkedList(sharedIndices);

            SinglyLinkedListNode firstHead  = ConcatLists(onlyFirst, onlyShared);
            SinglyLinkedListNode secondHead = ConcatLists(onlySecond, onlyShared);

            return(MergePoint.FindMergeNode(firstHead, secondHead));
        }
示例#4
0
        private void AddMenus()
        {
            var insertBeforeSearchSeparator = new MergePoint(MergeOperation.InsertBefore, "SearchSeparator");

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("EditGroup", "_Edit"),
                                                 new MergeableNode <ICommandItem>(new CommandGroup("FindGroup", "_Find and replace"), insertBeforeSearchSeparator, MergePoint.Append,
                                                                                  new MergeableNode <ICommandItem>(CommandItems["Find"]),
                                                                                  new MergeableNode <ICommandItem>(CommandItems["FindAndReplace"]),
                                                                                  new MergeableNode <ICommandItem>(CommandItems["FindNext"]),
                                                                                  new MergeableNode <ICommandItem>(CommandItems["FindPrevious"]))),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#5
0
        private void AddMenus()
        {
            var insertBeforeWindowSeparator = new MergePoint(MergeOperation.InsertBefore, "WindowSeparator");

            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                    new MergeableNode<ICommandItem>(CommandItems["Output"], insertBeforeWindowSeparator, MergePoint.Append))
            };
            Editor.MenuNodeCollections.Add(_menuNodes);
        }
        public override void Build(City c)
        {
            MergePoint m1  = new MergePoint();
            CityNode   nw1 = wTop = new MergeNode(x - 40, y - 80, m1, "nw1");
            CityNode   ne1 = eTop = new CityNode(x + 40, y - 80, "ne1");
            CityPath   p1  = ne1.Connect(nw1, CityPathType.privates);

            m1.priority = p1;

            MergePoint m2  = new MergePoint();
            CityNode   nw2 = wLeft = new MergeNode(x - 80, y + 40, m2, "nw2");
            CityNode   ne2 = eLeft = new CityNode(x - 80, y - 40, "ne2");
            CityPath   p2  = ne2.Connect(nw2, CityPathType.privates);

            m2.priority = p2;

            MergePoint m3  = new MergePoint();
            CityNode   nw3 = wBottom = new MergeNode(x + 40, y + 80, m3, "nw3");
            CityNode   ne3 = eBottom = new CityNode(x - 40, y + 80, "ne3");
            CityPath   p3  = ne3.Connect(nw3, CityPathType.privates);

            m3.priority = p3;

            MergePoint m4  = new MergePoint();
            CityNode   nw4 = wRight = new MergeNode(x + 80, y - 40, m4, "nw4");
            CityNode   ne4 = eRight = new CityNode(x + 80, y + 40, "ne4");
            CityPath   p4  = ne4.Connect(nw4, CityPathType.privates);

            m4.priority = p4;

            nw1.Connect(ne2, CityPathType.privates, 40);
            nw2.Connect(ne3, CityPathType.privates, 40);
            nw3.Connect(ne4, CityPathType.privates, 40);
            nw4.Connect(ne1, CityPathType.privates, 40);

            pTopLeft     = new CityNode(x - 100, y - 100);
            pTopRight    = new CityNode(x + 100, y - 100);
            pBottomLeft  = new CityNode(x - 100, y + 100);
            pBottomRight = new CityNode(x + 100, y + 100);

            pTopLeft.Connect(pTopRight, CityPathType.pedestrians);
            pTopLeft.Connect(pBottomLeft, CityPathType.pedestrians);

            pTopRight.Connect(pTopLeft, CityPathType.pedestrians);
            pTopRight.Connect(pBottomRight, CityPathType.pedestrians);

            pBottomLeft.Connect(pBottomRight, CityPathType.pedestrians);
            pBottomLeft.Connect(pTopLeft, CityPathType.pedestrians);

            pBottomRight.Connect(pBottomLeft, CityPathType.pedestrians);
            pBottomRight.Connect(pTopRight, CityPathType.pedestrians);

            c.nodes.Add(pTopLeft);
            c.nodes.Add(pTopRight);
            c.nodes.Add(pBottomLeft);
            c.nodes.Add(pBottomRight);

            c.nodes.Add(nw1);
            c.nodes.Add(ne1);

            c.nodes.Add(nw2);
            c.nodes.Add(ne2);

            c.nodes.Add(nw3);
            c.nodes.Add(ne3);

            c.nodes.Add(nw4);
            c.nodes.Add(ne4);
        }
示例#7
0
        private void AddMenus()
        {
            var insertBeforeSearchSeparator = new MergePoint(MergeOperation.InsertBefore, "SearchSeparator");
            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("EditGroup", "_Edit"),
                    new MergeableNode<ICommandItem>(new CommandGroup("FindGroup", "_Find and replace"), insertBeforeSearchSeparator, MergePoint.Append,
                        new MergeableNode<ICommandItem>(CommandItems["Find"]),
                        new MergeableNode<ICommandItem>(CommandItems["FindAndReplace"]),
                        new MergeableNode<ICommandItem>(CommandItems["FindNext"]),
                        new MergeableNode<ICommandItem>(CommandItems["FindPrevious"]))),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#8
0
 public MergeNode(int x, int y, MergePoint intersection, string name) : base(x, y, intersection, name)
 {
 }
示例#9
0
 public MergeNode(int x, int y, MergePoint intersection) : base(x, y, intersection)
 {
 }