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); }
/// <summary> /// Creates a new light /// </summary> /// <param name="x">x-position</param> /// <param name="y">y-position</param> /// <param name="z">z-position</param> /// <param name="r_x">x-rotation</param> /// <param name="r_y">y-rotation</param> /// <param name="r_z">z-rotation</param> private void drawLight(double x, double y, double z, double r_x, double r_y, double r_z) { Model3D light = new Model3D(this, "light", x, y, z, r_x, r_y, r_z); worldObjects.Add(light); }