public void AddCart() { if (addInTurn == 0) { int[] numbers = new int[3] { 0, 20, 31 }; Random rd = new Random(); int randomIndex = rd.Next(0, 3); int randomNumber = numbers[randomIndex]; Track track = TrackContainer.SearchIndex(randomNumber); // Index zetten, zodat we adhv lijst Cartren weten waar Cart staat Cart Cart = new Cart { Index = randomNumber }; Carts.Add(Cart); track.Cart = Cart; addInTurn = 1; } else { addInTurn--; } }
public void CheckDocks() { // Controleer of een van de Docks geen Ship heeft Track Track1 = TrackContainer.SearchIndex(19); Dock Dock1 = (Dock)Track1; Track Track2 = TrackContainer.SearchIndex(44); Dock Dock2 = (Dock)Track2; CheckDock(Dock1); CheckDock(Dock2); }
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); } }
public void printTrack(TrackContainer t) { Console.Write(" "); for (int i = 0; i <= t.TrackAmount; i++) { Track tr = t.SearchIndex(i); switch (i) { case 4: Console.Write(" "); break; case 9: Console.WriteLine(""); Console.Write(" "); break; case 12: Console.Write(" "); break; case 20: Console.WriteLine(""); Console.Write(" "); break; case 24: Console.Write(" "); break; case 26: Console.Write(" "); break; case 28: Console.WriteLine(""); Console.Write(" "); break; case 31: Console.WriteLine(""); Console.Write(" "); break; case 32: Console.Write(" "); break; case 38: Console.Write(" "); break; default: break; } if (tr.GetType().Name == "Dock") { Dock dock = (Dock)tr; if (Dock.hasShip()) { Console.Write(tr.Display + " (schip " + dock.Ship.Content + "/" + dock.Ship.MaxContent + ")"); } else { Console.Write(tr.Display); } } else { Console.Write(tr.Display); } } Console.WriteLine(""); }