public static void Load(Game game) { shipStart = game.Content.Load<SoundEffect>(@"Sounds\Effects\ShipStart"); Model skyboxModel = game.Content.Load<Model>(@"Skybox\Skybox"); skybox = new Skybox(game.GraphicsDevice, skyboxModel); effect = new BasicEffect(game.GraphicsDevice); graphicsDevice = game.GraphicsDevice; Vector3 cameraPosition = new Vector3(0, 200, 500); galaxyCamera = new Camera(cameraPosition, new Vector3(0, 0, 0), 500, MathHelper.PiOver2); }
/// <summary> /// Setta le posizioni dei pulsanti e delle stringhe /// </summary> void CreateInterface(string GUIFolder) { Vector3 cameraPosition = new Vector3(0, 200, 500); galaxyCamera = new Camera(cameraPosition, new Vector3(0, 0, 0), 500, MathHelper.PiOver2); zoom = 0; int w = GraphicSettings.ScreenBounds.Width / 2; int h = 3 * GraphicSettings.ScreenBounds.Height / 4; buttons = new List<Button>(); Texture2D buttonTexture = Game.Content.Load<Texture2D>(GUIFolder + "MM-CE"); int wb = buttonTexture.Width / 2; int hb = buttonTexture.Height / 2; buttons.Add(new Button(new Rectangle(w - wb, h - hb, buttonTexture.Width, buttonTexture.Height), "Nuovo gioco", "NewGame")); buttons[0].LoadTextureAndFont(buttonTexture, font); buttonTexture = Game.Content.Load<Texture2D>(GUIFolder + "MM-NE"); buttons.Add(new Button(new Rectangle(w + wb, h - hb - buttonTexture.Height, buttonTexture.Width, buttonTexture.Height), "Continua gioco", "ContinueGame")); buttons[1].LoadTextureAndFont(buttonTexture, font); buttonTexture = Game.Content.Load<Texture2D>(GUIFolder + "MM-NW"); buttons.Add(new Button(new Rectangle(w - wb - buttonTexture.Width, h - hb - buttonTexture.Height, buttonTexture.Width, buttonTexture.Height), "Carica gioco", "LoadGame")); buttons[2].LoadTextureAndFont(buttonTexture, font); buttonTexture = Game.Content.Load<Texture2D>(GUIFolder + "MM-SE"); buttons.Add(new Button(new Rectangle(w + wb, h + hb, buttonTexture.Width, buttonTexture.Height), "Crediti", "Credits")); buttons[3].LoadTextureAndFont(buttonTexture, font); buttonTexture = Game.Content.Load<Texture2D>(GUIFolder + "MM-SW"); buttons.Add(new Button(new Rectangle(w - wb - buttonTexture.Width, h + hb, buttonTexture.Width, buttonTexture.Height), "Impostazioni", "Settings")); buttons[4].LoadTextureAndFont(buttonTexture, font); string s = "Esci dal gioco"; GraphicsDevice device = Game.GraphicsDevice; Vector2 buttonDimensions = font.MeasureString(s) + new Vector2(20, 10); Vector2 buttonPosition = new Vector2(GraphicSettings.ScreenBounds.Width, GraphicSettings.ScreenBounds.Height) - (buttonDimensions + new Vector2(20, 20)); Color[] data = new Color[(int)(buttonDimensions.X * buttonDimensions.Y)]; Texture2D txt = new Texture2D(device, (int)(buttonDimensions.X), (int)(buttonDimensions.Y)); for (int i = 0; i < data.Length; ++i) data[i] = new Color(64, 64, 64, 128); txt.SetData(data); buttons.Add(new Button(new Rectangle((int)buttonPosition.X, (int)buttonPosition.Y, (int)buttonDimensions.X, (int)buttonDimensions.Y), s, "ExitButton")); buttons[5].LoadTextureAndFont(txt, font); foreach (Button b in buttons) b.SetTextPosition(); }