예제 #1
0
        /// <summary>
        /// In this method the object door is created.
        /// </summary>
        /// <param name="x">x-position of the door</param>
        /// <param name="y">y-position of the door</param>
        /// <param name="z">z-position of the door</param>
        /// <returns>The object door</returns>
        private Doors CreateDoors(double x, double y, double z)
        {
            Doors door = new Doors(this, "door", x, y, z, 0, 0, 0);

            worldObjects.Add(door);
            return(door);
        }
예제 #2
0
        public bool Update(int tick)
        {
            for (int i = 0; i < worldObjects.Count; i++)
            {
                Model3D u = worldObjects[i];

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

                    if (needsCommand)
                    {
                        if (u is Robots)
                        {
                            Robots robot = (Robots)u;
                            robot.Update(tick);
                        }
                        else if (u is Spaceships)
                        {
                            Spaceships spaceship = (Spaceships)u;
                            spaceship.needsUpdate = true;

                            // Check if the spaceship is above the building and shipments is not empty
                            if (Inventory.shipments.Count() > 0 && (spaceship.z <= 8 && spaceship.z >= -8))
                            {
                                ReceiveShipment(spaceship);
                            }

                            // Check if the warehouse needs to be restocked after the spaceship passed the building
                            if (spaceship.z < -8)
                            {
                                Inventory.CheckStock();
                            }

                            // Check if the warehouse has orders
                            if (Inventory.orders.Count() > 0)
                            {
                                checkCoordinateShip = ReceiveCargo(spaceship);
                            }

                            // Move the spaceship if the spaceship has any type of orders or has already begun moving
                            if ((Inventory.orders.Count() > 0 || Inventory.shipments.Count() > 0) || (spaceship.z > -140 ^ spaceship.z == 125))
                            {
                                spaceship.moveSpaceship();
                            }

                            // If the spaceship has almost reached his destination, you receive your delivery
                            if (spaceship.z == -139 && spaceship.cargo.Count() > 0)
                            {
                                spaceship.cargo.ForEach(x =>
                                                        Console.WriteLine("{0} of {1} was delivered to you", x.stock, x.name));

                                spaceship.cargo.Clear();
                            }
                        }
                        else if (u is Racks)
                        {
                            Racks rack = (Racks)u;
                            rack.moveRack();

                            if (rack.attr == "deleted")
                            {
                                worldObjects.Remove(rack);
                                Inventory.RemoveRack(rack);
                            }
                        }

                        else if (u is Doors)
                        {
                            Doors door = (Doors)u;
                            door.Update(tick);
                        }

                        else if (u is Model3D)
                        {
                            Model3D model = (Model3D)u;
                            //If model type is light then call the methode move of light.
                            if (model.type == "light")
                            {
                                model.Move(model.x, model.y, model.z);
                            }

                            //Calls the methode moveEarth and gives model along with it.
                            moveEarth(model);
                        }

                        SendCommandToObservers(new UpdateModel3DCommand(u));
                    }
                }
            }
            return(true);
        }