Ejemplo n.º 1
0
        /// <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;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// update alle 3d modellen in de wereld
        /// ook hier wordt de route voor vrachtwagen bepaald
        /// als laatste wordt gekeken of het magazijn moet worden bijgevuld
        /// </summary>
        /// <param name="tick">aantal beeld updates per minuut</param>
        /// <returns>bool</returns>
        public bool Update(int tick)
        {
            for (int i = 0; i < worldObjects.Count; i++)
            {
                _3DModel u = worldObjects[i];

                if (Vrachtwagen.GetRoute().Count == 0 && Vrachtwagen.x < 16)
                {
                    Vrachtwagen.VrachtwagenRoute(WorldManager.ReturnNodes().Shortest_path("VA", "VB"));
                }
                if (Math.Round(Vrachtwagen.x, 1) == 20)
                {
                    if (WorldManager.AvailableRobots() == 4)
                    {
                        if (WorldManager.Shelfs().Count() == 12)
                        {
                            WorldManager.AssignRobot();
                        }
                        else if (WorldManager.Shelfs().Count() == 8)
                        {
                            StorageEmpty = true;
                            WorldManager.SetFillStorage(true);
                            WorldManager.FillStorage();
                        }
                    }
                    else if (WorldManager.DockNodes().Count() == 4 && WorldManager.GetFillStorage() == false)
                    {
                        Vrachtwagen.VrachtwagenRoute(WorldManager.ReturnNodes().Shortest_path("VB", "VC"));
                        foreach (Node n in WorldManager.Points())
                        {
                            if (n.Id.Length == 4)
                            {
                                n.Shelf.Move(0, 1000, 0);

                                n.ShelfStatus = false;
                            }
                        }
                    }
                }
                if (Vrachtwagen.x > 39)
                {
                    StorageEmpty = false;
                    Vrachtwagen.Move(0, 0, -2);
                }

                if (u is IUpdatable)
                {
                    bool needsCommand = ((IUpdatable)u).Update(tick);

                    if (needsCommand)
                    {
                        SendCommandToObservers(new UpdateModel3DCommand(u));
                    }
                }
            }

            return(true);
        }