Esempio n. 1
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines StartScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt.
        /// </summary>
        public StartScreen(GameCore game)
            : base(game)
        {
            // leere den Screen-Stack beim Öffnen dieses Screens
            ClearScreenHistory = true;

            // der Container für die Buttons
            buttons = new Container (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.Menu);

            // logo
            logo = this.LoadTexture (name: "logo");
            if (Config.Default ["debug", "projector-mode", false]) {
                logo = ContentLoader.InvertTexture (screen: this, texture: logo);
            }

            // create a new SpriteBatch, which can be used to draw textures
            spriteBatch = new SpriteBatch (GraphicsDevice);

            // menu
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemAlignY = VerticalAlignment.Center;

            Button creativeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Creative",
                onClick: (time) => NextScreen = new CreativeMainScreen (Game)
            );
            creativeButton.SetCoordinates (left: 0.700f, top: 0.250f, right: 0.960f, bottom: 0.380f);

            Button challengeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Challenge",
                onClick: (time) => NextScreen = new ChallengeStartScreen (Game)
            );
            challengeButton.SetCoordinates (left: 0.000f, top: 0.050f, right: 0.380f, bottom: 0.190f);

            Button settingsButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Settings",
                onClick: (time) => NextScreen = new GeneralSettingsScreen (Game)
            );
            settingsButton.SetCoordinates (left: 0.260f, top: 0.840f, right: 0.480f, bottom: 0.950f);

            Button exitButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: String.Empty, // "Exit",
                onClick: (time) => Game.Exit ()
            );

            exitButton.AddKey (Keys.Escape);
            exitButton.SetCoordinates (left: 0.815f, top: 0.585f, right: 0.895f, bottom: 0.705f);
            exitButton.BackgroundTexture = this.LoadTexture ("exit300");
            if (Config.Default ["debug", "projector-mode", false]) {
                exitButton.BackgroundTexture = ContentLoader.InvertTexture (screen: this, texture: exitButton.BackgroundTexture);
            }

            buttons.Add (creativeButton);
            buttons.Add (challengeButton);
            buttons.Add (settingsButton);
            buttons.Add (exitButton);

            // Linien:

            lines.AddPoints (
                0.000f,
                0.050f,
                0.380f,
                0.250f,
                0.960f,
                0.380f,
                0.700f,
                0.160f,
                1.000f
            );

            lines.AddPoints (0.000f,
                             0.190f,
                             0.620f,
                             0.785f,
                             0.800f,
                             0.565f, // Exit oben.
                             0.910f, // Exit rechts.
                             0.730f, // Exit unten.
                             0.480f,
                             0.950f,
                             0.260f,
                             0.840f,
                             0.520f,
                             1.000f
                            );
        }
Esempio n. 2
0
 /// <summary>
 /// Wird aufgerufen, wenn auf den Button zum Erstellen der Challenge gedrückt wird
 /// </summary>
 private void OnCreateChallenge(GameTime time)
 {
     if (TryConstructChallenge ()) {
         Log.Debug ("Save Challenge: ", selectedChallenge);
         try {
             selectedChallenge.Save (false);
             NextScreen = new ChallengeStartScreen (Game);
         }
         catch (FileAlreadyExistsException) {
             ConfirmDialog confirm = new ConfirmDialog (
                 screen: this,
                 drawOrder: DisplayLayer.Dialog,
                 title: "Warning",
                 text: "Do you want to overwrite the existing challenge?"
             );
             confirm.Submit += (r) => {
                 selectedChallenge.Save (true);
                 NextScreen = new ChallengeStartScreen (Game);
             };
             AddGameComponents (null, confirm);
         }
     }
 }