Exemplo n.º 1
0
 private Truck CreateTruck(double x, double y, double z, string name)
 {
     Truck truck = new Truck(x, y, z, 0, Math.PI, 0, name);
     worldObjects.Add(truck);
     return truck;
 }
Exemplo n.º 2
0
 public void RemoveRack(Truck truck)
 {
     truck.AddRack(this.rack);
     this._rack = null;
 }
Exemplo n.º 3
0
 private Robot CreateRobot(double x, double y, double z, char name, Truck t) {
     Robot r = new Robot(x, y, z, 0, 0, 0, name, t);
     worldObjects.Add(r);
     return r;
 }
Exemplo n.º 4
0
        /// <summary>
        /// constructor voor de world
        /// </summary>
        public World() {
            //vul de lijst met alle nodes
            Pathfinding.FillList();

            LoadingBay bay = CreateLoadingBay(20, 20, 20);

            //Maak objecten aan
            Pathfinding.listOfNodes[5].SetRack(CreatePalletRack(15, 1.4, 10));
            Pathfinding.listOfNodes[6].SetRack(CreatePalletRack(15, 1.4, 11.5));
            Pathfinding.listOfNodes[7].SetRack(CreatePalletRack(15, 1.4, 13));
            Pathfinding.listOfNodes[8].SetRack(CreatePalletRack(15, 1.4, 14.5));

            Pathfinding.listOfNodes[9].SetRack(CreatePalletRack(10, 1.4, 10));
            Pathfinding.listOfNodes[10].SetRack(CreatePalletRack(10, 1.4, 11.5));
            Pathfinding.listOfNodes[11].SetRack(CreatePalletRack(10, 1.4, 13));
            Pathfinding.listOfNodes[12].SetRack(CreatePalletRack(10, 1.4, 14.5));

            Pathfinding.listOfNodes[13].SetRack(CreatePalletRack(5, 1.4, 10));
            Pathfinding.listOfNodes[14].SetRack(CreatePalletRack(5, 1.4, 11.5));
            Pathfinding.listOfNodes[15].SetRack(CreatePalletRack(5, 1.4, 13));
            Pathfinding.listOfNodes[16].SetRack(CreatePalletRack(5, 1.4, 14.5));


            Truck t1 = CreateTruck(33, 0.23, 60, "1");
            Truck t2 = CreateTruck(35, 0.23, 60, "2");
            Truck t3 = CreateTruck(37, 0.23, 60, "3");

            Robot r1 = CreateRobot(28, 0.15, 13.5, 'C', t1);
            Robot r2 = CreateRobot(28, 0.15, 13.5, 'D', t2);
            Robot r3 = CreateRobot(28, 0.15, 13.5, 'E', t3);


            //Pad voor de Truck
            Pathfinding.PathTruck = Pathfinding.Listnodes("X1", "Y1", Pathfinding.listOfNodes, Pathfinding.PathTruck);

            t1.AddTask(new TruckMove(Pathfinding.StartTruck1));
            t1.AddTask(new TruckMove(Pathfinding.PathTruck));
            Pathfinding.PathTruck = new List<Node>();


            Pathfinding.PathTruck = Pathfinding.Listnodes("X2", "Y2", Pathfinding.listOfNodes, Pathfinding.PathTruck);

            t2.AddTask(new TruckMove(Pathfinding.StartTruck2));
            t2.AddTask(new TruckMove(Pathfinding.PathTruck));
            Pathfinding.PathTruck = new List<Node>();


            Pathfinding.PathTruck = Pathfinding.Listnodes("X3", "Y3", Pathfinding.listOfNodes, Pathfinding.PathTruck);

            t3.AddTask(new TruckMove(Pathfinding.StartTruck3));
            t3.AddTask(new TruckMove(Pathfinding.PathTruck));


            //Pad voor de robot
            Pathfinding.PathRobot = Pathfinding.Listnodes("A", "C4", Pathfinding.listOfNodes, Pathfinding.PathRobot);

            r1.AddTask(new RobotMove(Pathfinding.StartRobot));
            r1.AddTask(new RobotMove(Pathfinding.PathRobot));
            Pathfinding.PathRobot = new List<Node>();


            Pathfinding.PathRobot = Pathfinding.Listnodes("A", "D4", Pathfinding.listOfNodes, Pathfinding.PathRobot);

            r2.AddTask(new RobotMove(Pathfinding.StartRobot));
            r2.AddTask(new RobotMove(Pathfinding.PathRobot));
            Pathfinding.PathRobot = new List<Node>();

            Pathfinding.PathRobot = Pathfinding.Listnodes("A", "E4", Pathfinding.listOfNodes, Pathfinding.PathRobot);

            r3.AddTask(new RobotMove(Pathfinding.StartRobot));
            r3.AddTask(new RobotMove(Pathfinding.PathRobot));
        }
Exemplo n.º 5
0
        // Hier worden de graph, de truck, de robots en de rekjes neergezet
        public World()
        {
            Point a = new Point(-20, 0, 0);
            Point b = new Point(-10, 0, 0);
            Point c = new Point(-10, 0, 10);
            Point d = new Point(0, 0, 10);
            Point e = new Point(10, 0, 10);
            Point f = new Point(10, 0, 0);
            Point g = new Point(10, 0, -10);
            Point h = new Point(0, 0, -10);
            Point i = new Point(-10, 0, -10);
            Point j = new Point(0, 0, 0);

            Point tA = new Point(-20, 0, -50);
            Point tB = new Point(-20, 0, 0);
            Point tC = new Point(-20, 0, 50);

            a.AddNode(b);
            b.AddNode(new List <Point>()
            {
                c, i
            });
            c.AddNode(d);
            d.AddNode(new List <Point>()
            {
                e, j
            });
            e.AddNode(f);
            f.AddNode(g);
            h.AddNode(new List <Point>()
            {
                i, j, g
            });

            tB.AddNode(new List <Point>()
            {
                tA, tB
            });

            List <Point> pointList = new List <Point>()
            {
                a, b, c, d, e, f, g, h, i, j
            };

            pointGraph = new Graph((pointList));

            truckGraph = new Graph(new List <Point>()
            {
                tA, tB, tC
            });

            Robot robot1 = CreateRobot(a);
            Robot robot2 = CreateRobot(a);
            Robot robot3 = CreateRobot(a);

            Rack rack1 = CreateRack(e);
            Rack rack2 = CreateRack(i);
            Rack rack3 = CreateRack(j);
            Rack rack4 = CreateRack(g);
            Rack rack5 = CreateRack(b);
            Rack rack6 = CreateRack(c);

            Truck t = CreateTruck(tA);

            robot1.AddTask(new RobotMove(pointGraph, rack1.point));
            robot2.AddTask(new RobotMove(pointGraph, rack2.point));
            robot3.AddTask(new RobotMove(pointGraph, rack3.point));

            int counter = 3;

            foreach (Model3D r in worldObjects)
            {
                if (r is Robot)
                {
                    ((Robot)r).AddTask(new RobotPickUp());
                    ((Robot)r).AddTask(new RobotMove(pointGraph, a));
                    ((Robot)r).AddTask(new RobotDropOff(t));
                    ((Robot)r).AddTask(new RobotPickUp());
                    ((Robot)r).AddTask(new RobotMove(pointGraph, pointList[counter]));
                    ((Robot)r).AddTask(new RobotDropOff(pointList[counter]));
                    counter++;
                    ((Robot)r).AddTask(new RobotMove(pointGraph, a));
                }
            }
            t.AddTask(new TruckMove(tB));
            t.AddTask(new TruckLoad());
            t.AddTask(new TruckMove(tC));
            t.AddTask(new TruckTeleport(tA));
            t.AddTask(new TruckMove(tB));
            t.AddTask(new TruckDump(a));
            t.AddTask(new TruckMove(tC));
        }
Exemplo n.º 6
0
        public override bool Tick()
        {
            switch (_state)
            {
            case TaskState.Init:
                _truck = _targetEntity.CreateTruck(Constants.TruckSpawn.X, Constants.TruckSpawn.Y, Constants.TruckSpawn.Z, 0f, 0f, 0f, 0);
                _truck.SetTarget(Constants.TruckStop);

                this._state = TaskState.WaitTruckArrival;
                break;

            case TaskState.WaitTruckArrival:
                if (!_truck.IsAtTarget)
                {
                    break;
                }
                var occupied = _targetEntity.ObjectsOfType <StoragePlot>().SelectMany(plot => plot.OccupiedCargoSlots).ToList();
                _slotsToUnload = new Queue <CargoSlot>(occupied.Take(Math.Min(Math.Min(occupied.Count(), _truck.FreeCargoSlots.Count), amount)));
                _robotTasks    = new List <RobotLoadTruckTask>();
                this._state    = TaskState.WaitTruckLoaded;
                break;

            case TaskState.WaitTruckLoaded:
                _truck.setDoorOpen(true);
                List <Robot>     idleRobots            = _targetEntity.ObjectsOfType <Robot>().Where((r) => r.IsStandBy).ToList();
                List <CargoSlot> availableStorageSlots = _truck.FreeCargoSlots;
                availableStorageSlots.Reverse();
                if (idleRobots.Count == 0 || availableStorageSlots.Count == 0)
                {
                    break;
                }

                if (_slotsToUnload.Count != 0)
                {
                    RobotLoadTruckTask rt = new RobotLoadTruckTask(idleRobots[0], _truck, _slotsToUnload.Dequeue().ReleaseCargo(), availableStorageSlots[0]);
                    idleRobots[0].AssignTask(rt);
                    _robotTasks.Add(rt);
                }

                if (_slotsToUnload.Count == 0)
                {
                    _state = TaskState.WaitCargoTasksFinished;
                }
                break;

            case TaskState.WaitCargoTasksFinished:
                if (!_robotTasks.All((task) => task.IsFinished))
                {
                    break;
                }
                _truck.SetTarget(Constants.TruckDespawn);
                _state = TaskState.WaitTruckExit;
                _truck.setDoorOpen(false);
                break;

            case TaskState.WaitTruckExit:
                if (!_truck.IsAtTarget)
                {
                    break;
                }
                _truck.Destroy();
                _state = TaskState.Finished;
                break;

            case TaskState.Finished:
                this._isFinished = true;
                break;
            }
            return(base.Tick());
        }
Exemplo n.º 7
0
        /// <summary>
        /// constructor van een robot
        /// </summary>
        /// <param name="x">xPos</param>
        /// <param name="y">yPos</param>
        /// <param name="z">zPos</param>
        /// <param name="rotationX">xRot</param>
        /// <param name="rotationY">yRot</param>
        /// <param name="rotationZ">zRot</param>
        /// <param name="name">naam van het object</param>
        /// <param name="truck">welke truck is gekoppeld aan deze robot</param>
        public Robot(double x, double y, double z, double rotationX, double rotationY, double rotationZ, char name, Truck truck)
        {
            type = "robot";
            guid = Guid.NewGuid();

            _x = x;
            _y = y;
            _z = z;

            _rX = rotationX;
            _rY = rotationY;
            _rZ = rotationZ;

            _name  = name;
            _truck = truck;
        }
Exemplo n.º 8
0
        public void Update()
        {
            Truck truck  = (Truck)world.worldObjects[4];
            Robot robot1 = (Robot)world.worldObjects[0];
            Robot robot2 = (Robot)world.worldObjects[1];
            Robot robot3 = (Robot)world.worldObjects[2];
            Robot robot4 = (Robot)world.worldObjects[3];


            if (truck.truckHere == true)
            {
                robot1.ChangeTruckHere(true);
                robot2.ChangeTruckHere(true);
                robot3.ChangeTruckHere(true);
                robot4.ChangeTruckHere(true);
            }

            if (robot1.robotReady == true)
            {
                Package package1 = (Package)world.worldObjects[28 + cycles];
                MovePackage(robot1, package1, robot1.x, robot1.y, robot1.z);
                robot1.ChangePackage(package1);
                robot1.ChangeRobotReady(false);
                robot1.ChangeRobotLoaded(true);
                ReadySetGo++;
            }

            if (robot2.robotReady == true)
            {
                Package package2 = (Package)world.worldObjects[29 + cycles];
                MovePackage(robot2, package2, robot2.x, robot2.y, robot2.z);
                robot2.ChangePackage(package2);
                robot2.ChangeRobotReady(false);
                robot2.ChangeRobotLoaded(true);
                ReadySetGo++;
            }

            if (robot3.robotReady == true)
            {
                Package package3 = (Package)world.worldObjects[30 + cycles];
                MovePackage(robot3, package3, robot3.x, robot3.y, robot3.z);
                robot3.ChangePackage(package3);
                robot3.ChangeRobotReady(false);
                robot3.ChangeRobotLoaded(true);
                ReadySetGo++;
            }

            if (robot4.robotReady == true)
            {
                Package package4 = (Package)world.worldObjects[31 + cycles];
                MovePackage(robot4, package4, robot4.x, robot4.y, robot4.z);
                robot4.ChangePackage(package4);
                robot4.ChangeRobotReady(false);
                robot4.ChangeRobotLoaded(true);
                ReadySetGo++;
            }

            if (robot1.robotDropped)
            {
                world.RobotGoesBack(robot1, robot1.target, "A");
            }

            if (robot2.robotDropped)
            {
                world.RobotGoesBack(robot2, robot2.target, "null1");
            }

            if (robot3.robotDropped)
            {
                world.RobotGoesBack(robot3, robot3.target, "null2");
            }

            if (robot4.robotDropped)
            {
                world.RobotGoesBack(robot4, robot4.target, "null3");
            }

            if (ReadySetGo == 4)
            {
                truck.ChangeTruckEmpty(true);
                robot1.ChangeRobotDone(false);
                robot2.ChangeRobotDone(false);
                robot3.ChangeRobotDone(false);
                robot4.ChangeRobotDone(false);
                ReadySetGo++;
                world.TruckHere();
            }

            if (robot1.robotReset && robot2.robotReset && robot3.robotReset &&
                robot4.robotReset)
            {
                ReadySetGo = 0;
                cycles    += 4;
                robot1.RESET();
                robot2.RESET();
                robot3.RESET();
                robot4.RESET();
                truck.RESET();
            }
        }
 /// <summary>
 /// sets the truck
 /// </summary>
 /// <param name="truck">Truck</param>
 public void SetTruck(Truck truck)
 {
     this.truck = truck;
 }