/// <summary> /// Deliver the shelf /// </summary> /// <param name="robot">Robot</param> public void StartTask(ShelfTransporters robot) { if (Math.Round(robot.x, 1) == 16 && Math.Round(robot.z, 1) == -2.4) { shelf.Move(shelf.x, 1000, shelf.z); } else { shelf.Move(shelf.x, 0, shelf.z); } robot.RemoveShelf(); }
/// <summary> /// methode die de wereld opzet /// </summary> public World() { WorldManager.AddNodes(); Robot r0 = CreateRobot(0, 0, 0); Robot r1 = CreateRobot(0, 0, 0); Robot r2 = CreateRobot(0, 0, 0); Robot r3 = CreateRobot(0, 0, 0); Vrachtwagen = CreateLorry(0, 0, 0); r0.Move(2, 2, 1); r1.Move(2, 2, 2); r2.Move(2, 2, 3); r3.Move(2, 2, 4); Vrachtwagen.Move(0, 0, -2); foreach (var punt in WorldManager.Points()) { if (punt.Id.Length == 1) { Shelf s = CreateShelf(0, 0, 0); punt.Shelf = s; WorldManager.AddShelf(punt); s.Move(punt.X, 0, punt.Z); punt.ShelfStatus = true; } if (punt.Id.Length == 4) { punt.ShelfStatus = false; } } }
/// <summary> /// Restock the shelves /// </summary> /// <param name="train">Train that brings the shelves</param> private void ShelfRestock(Train train) { ShelfTransporters forklift = forklifts.Find(x => x.Status() == false); Shelf shelf = shelfs.First(x => x.Status() == false && Math.Round(x.x, 1) == 16 && Math.Round(x.z, 1) == -2.4 && Math.Round(x.y, 1) == 1000); Node node = g.GetNodes().First(x => x.name.Contains("Res") && x.shelf == null); if (forklift != null && shelf != null && node != null) { forklift.Move(18, 0, 31); shelf.Move(18, 0, 31); forklift.AddShelf(shelf); forklift.AddTask(new ForkliftPickUp(shelf)); forklift.AddTask(new ForkliftMove(g.Shortest_Path("Forklift", node.name))); forklift.AddTask(new ForkliftDeliver(node, shelf)); forklift.AddTask(new ForkliftMove(g.Shortest_Path(node.name, "Forklift"))); forklift.AddTask(new ForkliftReset()); forklift.UpdateStatus(); train.itemRemove(); node.shelf = shelf; ShelfReplace.Add(node); } }
/// <summary> /// Starts the delivery task /// </summary> /// <param name="forklift">The forklift that needs to deliver the shelf</param> public void StartTask(ShelfTransporters forklift) { node.shelf = shelf; shelf.Move(shelf.x, 0, shelf.z); forklift.RemoveShelf(); }
public override bool Update(int tick, int tickCount) { if (tasks.Count == 0 && !moving) { status = "idle"; } else if (tasks.Count > 0 && !moving) { if (tasks[0] is MoveTask) { MoveTask Task = tasks[0] as MoveTask; MoveTo(Task.getinfo()); CurrentPos = Task.getinfo(); if (Task.getinfo() == 'α') { status = "Omw to dock"; } else { status = "Omw to " + Task.getinfo(); } moving = true; } else if (tasks[0] is DropShelf) { DropShelf Task = tasks[0] as DropShelf; shelf.Move(Task.getinfo()[0], 0, Task.getinfo()[1]); shelf = null; tasks.RemoveAt(0); } else if (tasks[0] is PickupShelf) { PickupShelf Task = tasks[0] as PickupShelf; shelf = Task.getinfo(); shelf.Move(_x, 0.3, _z); tasks.RemoveAt(0); } } if (PathToDestNodes.Count > 0 && moving) { if (_x < PathToDestNodes[0].x) { //move right _rY = Math.PI / 2; _x += 0.125; } else if (_x > PathToDestNodes[0].x) { //move left _rY = -Math.PI / 2; _x -= 0.125; } else if (_z < PathToDestNodes[0].z) { //move up _rY = 0; _z += 0.125; } else if (_z > PathToDestNodes[0].z) { //move down _rY = Math.PI; _z -= 0.125; } if (shelf != null) { shelf.Move(_x, 0.3, _z); } if (x == PathToDestNodes[0].x && z == PathToDestNodes[0].z) { PathToDestNodes.RemoveAt(0); if (PathToDestNodes.Count == 0) { tasks.RemoveAt(0); moving = false; } } } return(true); }
private void MoveShelf(Robot r, Shelf s, double x, double y, double z) { s.Move(r.x, s.y, r.z); s.needsUpdate = true; }
/// <summary> /// Move the ShelfTransporter over his path /// </summary> /// <param name="path">Path that the ShelfTransporter should take</param> public void MoveOverPath(List <Node> path) { double deltaX; double deltaZ; if (path.Count() != 0) { if (path.First().x == Math.Round(this.x, 1) && path.First().z == Math.Round(this.z, 1)) { path.RemoveAt(0); } deltaX = path.First().x - this.x; //waar hij naar toe moet - waar hij is deltaZ = path.First().z - this.z; //waar hij naar toe moet - waar hij is if (path.First().x > Math.Round(this.x)) { this.Rotate(this.rotationX, this.rotationY - this.rotationY + (Math.PI / 2), this.rotationZ); if (shelf != null) { shelf.Rotate(rotationX, rotationY - rotationY + (Math.PI / 2), rotationZ); } } else if (path.First().x < Math.Round(this.x)) { this.Rotate(this.rotationX, this.rotationY - this.rotationY - (Math.PI / 2), this.rotationZ); if (shelf != null) { shelf.Rotate(rotationX, rotationY - rotationY - (Math.PI / 2), rotationZ); } } else if (path.First().z > Math.Round(this.z)) { this.Rotate(this.rotationX, this.rotationY - this.rotationY, this.rotationZ); if (shelf != null) { shelf.Rotate(rotationX, rotationY - rotationY, rotationZ); } } else if (path.First().z < Math.Round(this.z)) { this.Rotate(this.rotationX, this.rotationY - this.rotationY + Math.PI, this.rotationZ); if (shelf != null) { shelf.Rotate(rotationX, rotationY - rotationY + Math.PI, rotationZ); } } if (Math.Round(deltaX, 1) > 0) // als deltaX positief is gaat hij vooruit { this.Move(this.x + 0.20, this.y, this.z); if (shelf != null) { shelf.Move(this.x, shelf.y, this.z); } deltaX -= 0.20; //deltaX -= speed * tick/1000 } else if (Math.Round(deltaX, 1) < 0) // als deltaX negatief is gaat hij actheruit { this.Move(this.x - 0.20, this.y, this.z); if (shelf != null) { shelf.Move(this.x, shelf.y, this.z); } deltaX += 0.20; } if (Math.Round(deltaZ, 1) > 0) // als deltaY positief is dan gaat hij vooruit { this.Move(this.x, this.y, this.z + 0.20); if (shelf != null) { shelf.Move(this.x, shelf.y, this.z); } deltaZ -= 0.20; } else if (Math.Round(deltaZ, 1) < 0) // als deltaY negatief is dan gaat hij achteruit { this.Move(this.x, this.y, this.z - 0.20); if (shelf != null) { shelf.Move(this.x, shelf.y, this.z); } deltaZ += 0.20; } } }
/// <summary> /// Pick up the shelf /// </summary> /// <param name="robot">Robot</param> public void StartTask(ShelfTransporters robot) { node.shelf = null; shelf.Move(shelf.x, shelf.y + 0.3, shelf.z); robot.AddShelf(shelf); }
/// <summary> /// Forklift pick up the shelf /// </summary> /// <param name="forklift">Forklift</param> public void StartTask(ShelfTransporters forklift) { shelf.Move(shelf.x, shelf.y + 0.3, shelf.z); forklift.AddShelf(shelf); }