Ejemplo n.º 1
0
 /// <summary>
 /// Moves the earth
 /// </summary>
 /// <param name="model">Receives the object model</param>
 private void moveEarth(Model3D model)
 {
     if (model.type == "earth")
     {
         model.Rotate(-0.15, 0, -0.15);
         model.Rotate(model.rotationX, radius, model.rotationZ);
         model.Move(model.x, model.y, model.z);
         radius = radius + 0.0025;
         radius = (radius >= 360) ? 0 : radius;
     }
 }
Ejemplo n.º 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);
        }