Beispiel #1
0
        private Track SearchRouteA(int key)
        {
            Track       current = StartA;
            TrackSwitch w       = null;

            while (current.Index != key)
            {
                if (current.GetType().Name == "TrackSwitch")
                {
                    w = (TrackSwitch)current;
                    if (w.TrackType == TrackType.TwoInOneOut)
                    {
                        current = w.Next;
                    }
                    else
                    {
                        current = w.Up;
                    }
                }
                else
                {
                    if (current.Next == null)
                    {
                        return(null);
                    }
                    else
                    {
                        current = current.Next;
                    }
                }
            }
            return(current);
        }
Beispiel #2
0
        public void Switch()
        {
            int inputkey;
            int index = 0;

            while (!Game.IsOver)
            {
                // Vraag om user input
                inputkey = this.getInput();

                switch (inputkey)
                {
                case 1:
                    index = 9;
                    break;

                case 2:
                    index = 11;
                    break;

                case 3:
                    index = 28;
                    break;

                case 4:
                    index = 30;
                    break;

                default:
                    index = 12;
                    break;
                }
                TrackSwitch trackSwitch = (TrackSwitch)Game.TrackContainer.SearchIndex(index);
                trackSwitch.Switch();
                MakeGUI();
            }
        }
Beispiel #3
0
        public void MoveCarts()
        {
            TrackSwitch w      = null;
            Dock        k      = null;
            List <Cart> delete = new List <Cart>();
            Track       next   = null;

            foreach (Cart Cart in Carts)
            {
                // TrackContainervak zoeken
                Track track = TrackContainer.SearchIndex(Cart.Index);

                // Kijken of VOLGEND TrackContainervaak een wissel is
                if (track.Next != null && track.Next.GetType().Name == "TrackSwitch")
                {
                    w = (TrackSwitch)track.Next;

                    if (w.TrackType == TrackType.TwoInOneOut)
                    {
                        // Wanneer stand van wissel op Boven staat
                        if (w.Position == Position.Up)
                        {
                            // Wanneer inkomend TrackContainervak gelijk is aan Boven
                            if (track == w.Up)
                            {
                                next = w;
                            }
                        }
                        else if (w.Position == Position.Down)
                        {
                            if (track == w.Down)
                            {
                                next = w;
                            }
                        }
                    }
                    else
                    {
                        next = track.Next;
                    }
                }
                // Kijken of HUIDIG TrackContainervak wissel is
                else if (track.GetType().Name == "TrackSwitch")
                {
                    w = (TrackSwitch)track;

                    if (w.TrackType == TrackType.OneInTwoOut)
                    {
                        if (w.Position == Position.Up)
                        {
                            next = w.Up;
                        }
                        else
                        {
                            next = w.Down;
                        }
                    }
                    else
                    {
                        next = track.Next;
                    }
                }
                // Als volgende normaal TrackContainervak is
                else if (track.GetType().Name == "Track" || track.GetType().Name == "Start")
                {
                    next = track.Next;
                }
                else if (track.GetType().Name == "Dock")
                {
                    k = (Dock)track;

                    if (k.hasShip())
                    {
                        Points += k.fillShip();
                    }

                    track.Cart = null;
                    delete.Add(Cart);
                }
                //TODO
                try
                {
                    moveCart(track, next);
                }
                catch (Exception_CantMoveCart e)
                {
                    controller.Stop();
                    Console.WriteLine(e.ToString());
                    Console.ReadLine();
                    //throw new Exception_KanCartNietVerplaatsen();
                }

                next = null;
            }

            // Remove Cartren from Cartren outside foreach loop
            foreach (Cart Cart in delete)
            {
                Carts.Remove(Cart);
            }
        }
Beispiel #4
0
        private void Add()
        {
            StartA = new Start {
                Index = 0, Display = "A"
            };
            StartB = new Start {
                Index = 20, Display = "B"
            };
            StartC = new Start {
                Index = 31, Display = "C"
            };

            TrackSwitch TrackSwitchA = new TrackSwitch {
                Index = 9, Display = "\\"
            };
            TrackSwitch TrackSwitchB = new TrackSwitch {
                Index = 11, Display = "/"
            };
            TrackSwitch TrackSwitchC = new TrackSwitch {
                Index = 28, Display = "\\"
            };
            TrackSwitch TrackSwitchD = new TrackSwitch {
                Index = 30, Display = "/"
            };
            TrackSwitch TrackSwitchE = new TrackSwitch {
                Index = 12, Display = "\\"
            };

            Dock DockA = new Dock {
                Index = 19, Display = "K", Ship = new Ship()
            };
            Dock DockB = new Dock {
                Index = 44, Display = "K", Ship = new Ship()
            };

            Track Track0 = new Track {
                Index = 1
            };
            Track Track1 = new Track {
                Index = 2
            };
            Track Track2 = new Track {
                Index = 3
            };
            Track Track4 = new Track {
                Index = 21
            };
            Track Track5 = new Track {
                Index = 22
            };
            Track Track6 = new Track {
                Index = 23
            };
            Track Track7 = new Track {
                Index = 10
            };
            Track Track8 = new Track {
                Index = 4
            };
            Track Track9 = new Track {
                Index = 5
            };
            Track Track10 = new Track {
                Index = 6
            };
            Track Track11 = new Track {
                Index = 7
            };
            Track Track12 = new Track {
                Index = 8
            };
            Track Track13 = new Track {
                Index = 24
            };
            Track Track14 = new Track {
                Index = 25
            };
            Track Track15 = new Track {
                Index = 29
            };
            Track Track16 = new Track {
                Index = 26
            };
            Track Track17 = new Track {
                Index = 27
            };
            Track Track18 = new Track {
                Index = 38
            };
            Track Track19 = new Track {
                Index = 39
            };
            Track Track20 = new Track {
                Index = 40
            };
            Track Track21 = new Track {
                Index = 41
            };
            Track Track22 = new Track {
                Index = 42
            };
            Track Track23 = new Track {
                Index = 43
            };
            Track Track25 = new Track {
                Index = 13
            };
            Track Track26 = new Track {
                Index = 14
            };
            Track Track27 = new Track {
                Index = 15
            };
            Track Track28 = new Track {
                Index = 16
            };
            Track Track29 = new Track {
                Index = 17
            };
            Track Track30 = new Track {
                Index = 18
            };
            Track Track31 = new Track {
                Index = 32
            };
            Track Track32 = new Track {
                Index = 33
            };
            Track Track33 = new Track {
                Index = 34
            };
            Track Track34 = new Track {
                Index = 35
            };
            Track Track35 = new Track {
                Index = 36
            };
            Track Track36 = new Track {
                Index = 37
            };

            // TrackSwitch A
            TrackSwitchA.TrackType = TrackType.TwoInOneOut;
            TrackSwitchA.Up        = Track2;
            TrackSwitchA.Down      = Track6;

            // TrackSwitch B
            TrackSwitchB.TrackType = TrackType.OneInTwoOut;
            TrackSwitchB.Up        = Track8;
            TrackSwitchB.Down      = Track13;

            // TrackSwitch C
            TrackSwitchC.TrackType = TrackType.TwoInOneOut;
            TrackSwitchC.Up        = Track14;
            TrackSwitchC.Down      = Track36;

            // TrackSwitch D
            TrackSwitchD.TrackType = TrackType.OneInTwoOut;
            TrackSwitchD.Up        = Track16;
            TrackSwitchD.Down      = Track18;

            // TrackSwitch E
            TrackSwitchE.TrackType = TrackType.TwoInOneOut;
            TrackSwitchE.Up        = Track12;
            TrackSwitchE.Down      = Track17;

            // Route A
            StartA.Next = Track0;
            Track0.Next = Track1;
            Track1.Next = Track2;
            Track2.Next = TrackSwitchA;

            // Route B
            StartB.Next = Track4;
            Track4.Next = Track5;
            Track5.Next = Track6;
            Track6.Next = TrackSwitchA;

            // Route C
            TrackSwitchA.Next = Track7;
            Track7.Next       = TrackSwitchB;

            // Route D
            Track8.Next  = Track9;
            Track9.Next  = Track10;
            Track10.Next = Track11;
            Track11.Next = Track12;
            Track12.Next = TrackSwitchE;

            // Route E
            Track13.Next = Track14;
            Track14.Next = TrackSwitchC;

            // Route F
            TrackSwitchC.Next = Track15;
            Track15.Next      = TrackSwitchD;

            // Route G
            Track16.Next = Track17;
            Track17.Next = TrackSwitchE;

            // Route H
            Track18.Next = Track19;
            Track19.Next = Track20;
            Track20.Next = Track21;
            Track21.Next = Track22;
            Track22.Next = Track23;
            Track23.Next = DockB;

            // Route I
            TrackSwitchE.Next = Track25;
            Track25.Next      = Track26;
            Track26.Next      = Track27;
            Track27.Next      = Track28;
            Track28.Next      = Track29;
            Track29.Next      = Track30;
            Track30.Next      = DockA;

            // Route J
            StartC.Next  = Track31;
            Track31.Next = Track32;
            Track32.Next = Track33;
            Track33.Next = Track34;
            Track34.Next = Track35;
            Track35.Next = Track36;
            Track36.Next = TrackSwitchC;
        }