public void TrainDeparted(Trein _t) { // Delete oude trein this.worldObjects.Remove(_t.CarriedRek); this.worldObjects.Remove(_t); //Maak nieuwe trein this.SpawnTrein(-60, 0, -5); }
private Trein SpawnTrein(double x, double y, double z) { Trein t = new Trein(x, y, z, 0, 0, 0, this); t.Rotate(0, 89.55, 0); t.speed = 0.6; worldObjects.Add(t); //CreateRek(15,0,-30); return(t); }
public void TrainArrived(Trein _t, Rek cargo) { //Word aangeroepen wanneer een trein (_t) bij het loading dock is cargo.readyforpickup = true; //Loop door robots en laat een idle robot de cargo ophalen foreach (Robot r in this.robots) { if (r.idle) { CommandPickup(cargo, true, r); r.idle = false; break; } } //Loop door robots een laat een idle robot een rek uit de storage naar de trein brengen foreach (Robot r in this.robots) { foreach (Storage s in this.StorageSpots) { for (int i = 0; i < s.Stored.Count; i++) { Rek rek = s.Stored[i]; if (r.idle) { s.Stored.Remove(rek); rek.readyforpickup = true; r.trainToLoad = _t; CommandPickup(rek, false, r); r.idle = false; } } } } }
/// <summary> /// Main loop /// </summary> public void Main() { // If idle, dont do anything if (idle) { return; } if (route != null && route.Count > position) { this.MoveTo(route[position]); // Check if the robot has reached a node if (this.x == route[position].x && this.y == route[position].y && this.z == route[position].z) { //Check if the robot is at it's destination if (this.x == TargetNode.x && this.y == TargetNode.y && this.z == TargetNode.z) { if (carriedRek != null) { if (this.trainToLoad != null) { this.trainToLoad.Load(carriedRek); this.carriedRek = null; this.trainToLoad = null; } else { DropOffRek(TargetNode); } } else { PickupRek(rekToCarry); } } // Else,check if this is the last stop else if (route[route.Count - 1] == route[position]) { if (carriedRek != null) { if (this.trainToLoad != null) { this.trainToLoad.Load(carriedRek); this.carriedRek = null; this.trainToLoad = null; idle = true; } else { DropOffRek(route[position]); } } idle = true; return; } position++; this.isMoving = false; } } }