Inheritance: Microsoft.Xna.Framework.Game
        /// <summary>
        /// Erzeugt eine neue Instanz eines ProfileSettingsScreen-Objekts und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public GeneralSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "General";

            InputItem playerNameInput = new InputItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Player Name:",
                inputText: Config.Default ["profile", "name", "Player"]
            );
            playerNameInput.OnValueSubmitted += () => {
                Config.Default ["profile", "name", String.Empty] = playerNameInput.InputText;
            };
            settingsMenu.Add (playerNameInput);

            // Languages
            LanguageOption languageOption = new LanguageOption (
                section: "language",
                name: "current",
                configFile: Config.Default
            );
            ComboBox languageItem = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Language"
            );
            languageItem.AddEntries (languageOption);
            settingsMenu.Add (languageItem);
        }
Example #2
0
        /// <summary>
        /// Erzeugt ein neues AudioSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public AudioSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Audio";

            foreach (KeyValuePair<string, HashSet<Sound>> soundCategory in soundCategories) {
                string volumeName = soundCategory.Key;
                HashSet<Sound> sounds = soundCategory.Value;

                SliderItem slider = new SliderItem (
                    screen: this,
                    drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                    text: volumeName,
                    max: 100,
                    min: 0,
                    value: 50
                );
                slider.OnValueChanged = (time) => {
                    float volume = (float)slider.Value / 100f;
                    foreach (Sound sound in sounds) {
                        AudioManager.SetVolume (soundType: sound, volume: volume);
                    }
                };
                settingsMenu.Add (slider);
                UpdateSliders += () => {
                    float volume = 0f;
                    foreach (Sound sound in sounds) {
                        volume += AudioManager.Volume (soundType: sound) * 100f;
                    }
                    volume /= sounds.Count;
                    slider.Value = (int)volume;
                };
            }
            UpdateSliders ();
        }
Example #3
0
 /// <summary>
 /// Erzeugt ein neues CreditsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
 /// </summary>
 public ErrorScreen(GameCore game, Exception ex)
     : base(game)
 {
     string msg = CreateMessage (ex);
     Log.Error (ex);
     dialog = new ErrorDialog (screen: this, drawOrder: DisplayLayer.Dialog, message: msg);
     dialog.Bounds.Size = new ScreenPoint (screen: this, x: 0.750f, y: 0.750f);
 }
Example #4
0
        /// <summary>
        /// Erzeugt ein neues CreativeMainScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public CreativeMainScreen(GameCore game)
            : base(game)
        {
            buttons = new Container (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            buttons.ItemAlignX = HorizontalAlignment.Center;
            buttons.ItemAlignY = VerticalAlignment.Center;

            Button newKnotButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "NEW\nKnot",
                onClick: (time) => NextScreen = new CreativeModeScreen (Game, new Knot ())
            );
            newKnotButton.SetCoordinates (left: 0.100f, top: 0.150f, right: 0.300f, bottom: 0.350f);

            Button loadKnotButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "LOAD\nKnot",
                onClick: (time) => NextScreen = new CreativeLoadScreen (Game)
            );
            loadKnotButton.SetCoordinates (left: 0.675f, top: 0.300f, right: 0.875f, bottom: 0.475f);

            Button newChallengeButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "NEW\nChallenge",
                onClick: (time) => NextScreen = new ChallengeCreateScreen (Game)
            );
            newChallengeButton.SetCoordinates (left: 0.250f, top: 0.525f, right: 0.600f, bottom: 0.750f);

            Button backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(

                                                    s is CreativeMainScreen
                                                    || s is CreativeLoadScreen
                                                    || s is ChallengeCreateScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.825f, top: 0.850f, right: 0.975f, bottom: 0.950f);

            buttons.Add (newKnotButton);
            buttons.Add (loadKnotButton);
            buttons.Add (newChallengeButton);
            buttons.Add (backButton);
            buttons.IsVisible = true;

            // die Linien
            lines.AddPoints (0.000f, 0.150f,
                             0.300f, 0.350f, 0.100f, 0.070f, 0.600f, 0.750f, 0.250f,
                             0.525f, 0.875f, 0.300f, 0.675f, 0.475f, 0.950f, 0.000f
                            );

            lines.AddPoints (0.975f, 0.850f, 0.825f, 0.950f, 0.975f, 0.850f);
        }
Example #5
0
 /// <summary>
 /// Erzeugt ein neues IGameScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
 /// </summary>
 public Screen(GameCore game)
 {
     Game = game;
     NextScreen = this;
     CurrentRenderEffects = new RenderEffectStack (screen: this, defaultEffect: new StandardEffect (screen: this));
     PostProcessingEffect = new StandardEffect (screen: this);
     InputManager = new InputManager (screen: this);
     BackgroundColor = Design.ScreenBackground;
 }
        /// <summary>
        /// Erzeugt ein neues ControlSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public ControlSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Controls";

            // Die statischen Initialierer der folgenden Inputhandler müssen geladen sein, egal, ob der User bereits
            // im Spiel war oder nicht, denn davon hängt es ab, ob sie bereits auf natürliche Weise initialiert wurden.
            // Falls das nicht der Fall ist, rufen wir über Reflection den statischen Initialierer auf, ohne die Klassen
            // sonst irgendwie anzutasten. Das ist sauberer als eine statische Methode statt des Initialierers zu verwenden,
            // da man diese an vielen Stellen aufrufen müsste, nur um den sehr unwahrscheinlichen Fall, dass noch nichts
            // initialisiert ist, abzudecken. Die statischen Initialisierer hingegen werden von der Laufzeitumgebung
            // in allen Fällen bis auf genau diesen hier im Einstellungsmenü automatisch aufgerufen.
            KeyBindingListener.InitializeListeners (
                typeof (InputManager),
                typeof (KnotInputHandler),
                typeof (EdgeColoring),
                typeof (EdgeRectangles)
            );

            // Lade die Standardbelegung
            Dictionary<PlayerAction, Keys> defaultReversed = KeyBindingListener.DefaultKeyAssignment.ReverseDictionary ();

            // Iteriere dazu über alle gültigen PlayerActions...
            foreach (PlayerAction action in PlayerAction.Values) {
                string actionName = action.Name;

                if (defaultReversed.ContainsKey (action)) {
                    // Erstelle das dazugehörige Options-Objekt...
                    KeyOption option = new KeyOption (
                        section: "controls",
                        name: actionName,
                        defaultValue: defaultReversed [action],
                        configFile: Config.Default
                    );

                    // Erstelle ein KeyInputItem zum Festlegen der Tastenbelegung
                    KeyInputItem item = new KeyInputItem (
                        screen: this,
                        drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                        text: actionName,
                        option: option
                    );
                    item.OnValueChanged += () => KeyBindingListener.ControlSettingsChanged ();

                    // Füge es in das Menü ein
                    settingsMenu.Add (item);
                }
                else {
                    Log.Debug ("Key binding ", actionName, " not found!");
                }
            }
        }
Example #7
0
        public MenuScreen(GameCore game)
            : base(game)
        {
            // die Linien
            lines = new Lines (screen: this, drawOrder: DisplayLayer.Dialog, lineWidth: 6);

            // der Mauszeiger
            pointer = new MousePointer (this);

            // häufig verwendete Positionen und Größen
            ScreenContentBounds = new Bounds (screen: this, relX: 0.075f, relY: 0.180f, relWidth: 0.850f, relHeight: 0.650f);
            ScreenTitleBounds = new Bounds (this, 0.075f, 0.075f, 0.900f, 0.050f);
        }
Example #8
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public JunctionEditorScreen(GameCore game)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromLeft (0.60f));
            // der Input-Handler
            knotInput = new KnotInputHandler (screen: this, world: world);
            // der Mauszeiger
            pointer = new MousePointer (screen: this);
            // der Maus-Handler für die 3D-Modelle
            modelMouseHandler = new ModelMouseHandler (screen: this, world: world);

            // der Knoten-Renderer
            knotRenderer = new JunctionEditorRenderer (screen: this, position: Vector3.Zero);
            world.Add (knotRenderer);

            // visualisiert die BoundingSpheres
            debugBoundings = new DebugBoundings (screen: this, position: Vector3.Zero);
            world.Add (debugBoundings);

            // Hintergrund
            SkyCube skyCube = new SkyCube (screen: this, position: Vector3.Zero, distance: 10000);
            world.Add (skyCube);

            // Backbutton
            backButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = new StartScreen (Game)
            );
            backButton.AddKey (Keys.Escape);
            backButton.IsVisible = true;

            // Menü
            settingsMenu = new Menu (this, DisplayLayer.Overlay + DisplayLayer.Menu);
            settingsMenu.Bounds = Bounds.FromRight (0.40f).FromBottom (0.9f).FromLeft (0.8f);
            settingsMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            settingsMenu.RelativeItemHeight = 0.030f;

            float[] validJunctionCounts = new float[] { 1, 2, 3 };
            optionJunctionCount = new FloatOption (
                section: "debug",
                name: "debug_junction_count",
                defaultValue: validJunctionCounts.At (-1),
                validValues: validJunctionCounts,
                configFile: Config.Default
            );
            itemJunctionCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Junctions #"
            );
            itemJunctionCount.AddEntries (optionJunctionCount);
            itemJunctionCount.ValueChanged += OnJunctionCountChanged;

            Direction[] validDirections = Direction.Values;
            optionJuctionDirection = new DistinctOption [3];
            itemJunctionDirection = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                DistinctOption option = new DistinctOption (
                    section: "debug",
                    name: "debug_junction_direction" + i.ToString (),
                    defaultValue: validDirections [i * 2],
                    validValues: validDirections.Select (d => d.Name),
                    configFile: Config.Default
                );
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Direction ") + i.ToString ()
                );
                item.AddEntries (option);
                optionJuctionDirection [i] = option;
                item.ValueChanged += OnDirectionsChanged;
                itemJunctionDirection [i] = item;
            }

            itemBumpRotation = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Bump Angle ") + i.ToString ()
                );
                item.ValueChanged += OnAnglesChanged;
                itemBumpRotation [i] = item;
            }

            itemModels = new ComboBox [3];
            for (int i = 0; i < 3; ++i) {
                ComboBox item = new ComboBox (
                    screen: this,
                    drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                    text: Localizer.Localize ("Model ") + i.ToString ()
                );
                item.ValueChanged += OnModelsChanged;
                itemModels [i] = item;
            }

            OnDirectionsChanged (null);
            OnJunctionCountChanged (null);

            world.Camera.PositionToTargetDistance = 180;
        }
Example #9
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
                            );
        }
Example #10
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public VisualTestsScreen(GameCore game)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromLeft (0.60f));

            // der Knoten-Renderer
            knotRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            world.Add (knotRenderer);

            // Hintergrund
            //SkyCube skyCube = new SkyCube (screen: this, position: Vector3.Zero, distance: world.Camera.MaxPositionDistance + 500);
            //world.Add (skyCube);

            // Menü
            settingsMenu = new Menu (this, DisplayLayer.Overlay + DisplayLayer.Menu);
            settingsMenu.Bounds = Bounds.FromRight (0.40f).FromBottom (0.9f).FromLeft (0.8f);
            settingsMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            settingsMenu.RelativeItemHeight = 0.030f;

            float[] validEdgeCounts = new float[] { 500, 1000, 2000, 3000, 4000, 5000, 7500, 10000, 15000 };
            optionEdgeCount = new FloatOption (
                section: "visualtests",
                name: "edgecount",
                defaultValue: validEdgeCounts.At (0),
                validValues: validEdgeCounts,
                configFile: Config.Default
            ) { Verbose = false };
            optionEdgeCount.Value = validEdgeCounts.At (0);
            itemEdgeCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Edges:"
            );
            itemEdgeCount.AddEntries (optionEdgeCount);
            itemEdgeCount.ValueChanged += OnEdgeCountChanged;

            itemDisplayTime = new InputItem (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "Time:",
                inputText: ""
            );

            itemFPS = new InputItem (
                screen: this,
                drawOrder: DisplayLayer.Overlay + DisplayLayer.MenuItem,
                text: "FPS:",
                inputText: ""
            );

            OnEdgeCountChanged (null);
        }
Example #11
0
 public SilentAudioManager(GameCore game)
     : base(game)
 {
 }
Example #12
0
        /// <summary>
        /// Erzeugt ein neues CreativeLoadScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public CreativeLoadScreen(GameCore game)
            : base(game)
        {
            savegameMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            savegameMenu.Bounds.Position = ScreenContentBounds.Position;
            savegameMenu.Bounds.Size = new ScreenPoint (this, 0.300f, ScreenContentBounds.Size.Relative.Y);
            savegameMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            savegameMenu.ItemAlignX = HorizontalAlignment.Left;
            savegameMenu.ItemAlignY = VerticalAlignment.Center;
            savegameMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            savegameMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            savegameMenu.RelativeItemHeight = Design.DataItemHeight;

            lines.AddPoints (.000f, .050f, .030f, .970f, .620f, .895f, .740f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f);

            title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Load Knot");
            title.Bounds.Position = ScreenTitleBounds.Position;
            title.Bounds.Size = ScreenTitleBounds.Size;
            title.ForegroundColorFunc = (s) => Color.White;

            infoTitle = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Knot Info:");
            infoTitle.Bounds.Position = new ScreenPoint (this, 0.45f, 0.62f);
            infoTitle.Bounds.Size = new ScreenPoint (this, 0.900f, 0.050f);
            infoTitle.ForegroundColorFunc = (s) => Color.White;

            knotInfo = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            knotInfo.Bounds.Position = new ScreenPoint (this, 0.47f, 0.70f);
            knotInfo.Bounds.Size = new ScreenPoint (this, 0.300f, 0.500f);
            knotInfo.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            knotInfo.ItemAlignX = HorizontalAlignment.Left;
            knotInfo.ItemAlignY = VerticalAlignment.Center;

            // Erstelle einen Parser für das Dateiformat
            KnotFileIO fileFormat = new KnotFileIO ();
            // Erstelle einen Spielstand-Loader
            loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots");

            // Preview
            Bounds previewBounds = new Bounds (this, 0.45f, 0.1f, 0.48f, 0.5f);
            previewWorld = new World (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.GameWorld,
                bounds: previewBounds
            );
            previewRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            previewWorld.Add (previewRenderer);
            previewBorder = new Border (
                screen: this,
                drawOrder: DisplayLayer.GameWorld,
                bounds: previewBounds,
                lineWidth: 2,
                padding: 0
            );
            previewInput = new KnotInputHandler (screen: this, world: previewWorld);
            previewMouseHandler = new ModelMouseHandler (screen: this, world: previewWorld);

            backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is CreativeLoadScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);
            backButton.AlignX = HorizontalAlignment.Center;

            startButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Load",
                onClick: (time) => NextScreen = new CreativeModeScreen (game: Game, knot: loader.FileFormat.Load (previewKnotMetaData.Filename))
            );
            startButton.IsVisible = false;
            startButton.AddKey (Keys.Enter);
            startButton.SetCoordinates (left: 0.630f, top: 0.910f, right: 0.730f, bottom: 0.960f);
            startButton.AlignX = HorizontalAlignment.Center;
        }
Example #13
0
 public Knot3AudioManager(GameCore game)
     : base(game)
 {
 }
Example #14
0
 /// <summary>
 /// Erzeugt ein neues CreditsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
 /// </summary>
 public CreditsScreen(GameCore game)
     : base(game)
 {
     text = "...";
 }
Example #15
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines ChallengeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt, einem Spielerknoten playerKnot und dem Knoten challengeKnot, den der Spieler nachbauen soll.
        /// </summary>
        public ChallengeModeScreen(GameCore game, Challenge challenge)
            : base(game)
        {
            // world
            PlayerWorld = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromRight (percent: 0.5f));
            ChallengeWorld = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds.FromLeft (percent: 0.5f));
            ChallengeWorld.Camera = PlayerWorld.Camera;
            PlayerWorld.OnRedraw += () => ChallengeWorld.Redraw = true;
            ChallengeWorld.OnRedraw += () => PlayerWorld.Redraw = true;
            // input
            playerKnotInput = new KnotInputHandler (screen: this, world: PlayerWorld);
            challengeKnotInput = new KnotInputHandler (screen: this, world: ChallengeWorld);
            // overlay
            overlay = new Overlay (screen: this, world: PlayerWorld);
            // pointer
            pointer = new MousePointer (screen: this);
            // model mouse handler
            playerModelMouseHandler = new ModelMouseHandler (screen: this, world: PlayerWorld);
            challengeModelMouseHandler = new ModelMouseHandler (screen: this, world: ChallengeWorld);

            // knot renderer
            PlayerKnotRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            PlayerWorld.Add (PlayerKnotRenderer);
            ChallengeKnotRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            ChallengeWorld.Add (ChallengeKnotRenderer);

            // debug displays
            debugBoundings = new DebugBoundings (screen: this, position: Vector3.Zero);

            // edge movements
            PlayerEdgeMovement = new EdgeMovement (screen: this, world: PlayerWorld, knotRenderer: PlayerKnotRenderer, position: Vector3.Zero);
            PlayerEdgeMovement.KnotMoved = OnKnotMoved;

            // assign the specified challenge
            Challenge = challenge;
            // assign the specified player knot
            PlayerKnot = challenge.Start.Clone () as Knot;
            // assign the specified target knot
            ChallengeKnotRenderer.RenderKnot (challenge.Target);
            // assign the specified start knot
            PlayerKnotRenderer.RenderKnot (PlayerKnot);

            SkyCube playerSkyCube = new SkyCube (screen: this, position: Vector3.Zero, distance: 10000);
            PlayerWorld.Add (playerSkyCube);
            SkyCube challengeSkyCube = new SkyCube (screen: this, position: Vector3.Zero, distance: 10000);
            ChallengeWorld.Add (challengeSkyCube);

            // Die Spielzeit-Anzeige
            playTimeDisplay = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: String.Empty);
            playTimeDisplay.Bounds.Position = new ScreenPoint (this, 0.800f, 0.01f);
            playTimeDisplay.Bounds.Size = new ScreenPoint (this, 0.15f, 0.04f);
            playTimeDisplay.BackgroundColorFunc = (s) => Design.WidgetBackground;
            playTimeDisplay.ForegroundColorFunc = (s) => Design.WidgetForeground;
            playTimeDisplay.AlignX = HorizontalAlignment.Center;
            playTimeBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                         widget: playTimeDisplay, lineWidth: 2, padding: 0);
            //Undo-Button
            undoButton = new Button (screen: this,
                                     drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                     name: "Undo",
                                     onClick: (time) => OnUndo ());
            undoButton.SetCoordinates (left: 0.55f, top: 0.900f, right: 0.65f, bottom: 0.95f);

            undoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: undoButton, lineWidth: 2, padding: 0);
            undoButton.AlignX = HorizontalAlignment.Center;
            undoButton.IsVisible = false;

            // Redo-Button
            redoButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Redo",
                onClick: (time) => OnRedo ()
            );
            redoButton.SetCoordinates (left: 0.70f, top: 0.900f, right: 0.80f, bottom: 0.95f);

            redoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: redoButton, lineWidth: 2, padding: 0);
            redoButton.AlignX = HorizontalAlignment.Center;
            redoButton.IsVisible = false;

            // die Linien
            lines = new Lines (screen: this, drawOrder: DisplayLayer.Dialog, lineWidth: 2);
            lines.AddPoints (0.500f, 0.000f, 0.500f, 1.000f);

            // Status
            state = ChallengeModeState.Start;
        }
Example #16
0
        public SettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Settings";

            spriteBatch = new SpriteBatch (GraphicsDevice);

            navigationMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            navigationMenu.Bounds.Position = ScreenContentBounds.Position;
            navigationMenu.Bounds.Size = new ScreenPoint (this, 0.200f, ScreenContentBounds.Size.Relative.Y);
            navigationMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            navigationMenu.ItemAlignX = HorizontalAlignment.Left;
            navigationMenu.ItemAlignY = VerticalAlignment.Center;

            MenuEntry profileButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "General",
            onClick: (time) => {
                game.SkipNextScreenEffect =true;
                NextScreen = new GeneralSettingsScreen (Game);
            }
            );
            MenuEntry graphicsButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Graphics",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new GraphicsSettingsScreen (Game);
            }
            );
            MenuEntry audioButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Audio",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new AudioSettingsScreen (Game);
            }
            );
            MenuEntry controlsButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Controls",
            onClick: (time) =>  {
                game.SkipNextScreenEffect =true;
                NextScreen = new ControlSettingsScreen (Game);
            }
            );

            navigationMenu.Add (profileButton);
            navigationMenu.Add (graphicsButton);
            navigationMenu.Add (audioButton);
            navigationMenu.Add (controlsButton);

            initalizeDebugButton ();

            lines.AddPoints (0.000f, 0.050f,
                             0.030f, 0.970f,
                             0.760f, 0.895f,
                             0.880f, 0.970f,
                             0.970f, 0.050f,
                             1.000f
                            );

            backButton = new MenuEntry (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is SettingsScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);
            backButton.AlignX = HorizontalAlignment.Center;

            // this menu contains the actual settings and is filled in the subclasses
            settingsMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            settingsMenu.Bounds.Position = ScreenContentBounds.Position + navigationMenu.Bounds.Size.OnlyX;
            settingsMenu.Bounds.Size = ScreenContentBounds.Size - navigationMenu.Bounds.Size.OnlyX;;
            settingsMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            settingsMenu.ItemAlignX = HorizontalAlignment.Left;
            settingsMenu.ItemAlignY = VerticalAlignment.Center;
            settingsMenu.RelativeItemHeight = Design.DataItemHeight;
        }
        /// <summary>
        /// Erzeugt ein neues GraphicsSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public GraphicsSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Graphics";

            CheckBoxItem itemShowArrows = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Arrows",
                option: new BooleanOption ("video", "arrows", false, Config.Default)
            );
            settingsMenu.Add (itemShowArrows);

            // blinking stars
            BooleanOption optionBlinkingStars = new BooleanOption ("video", "stars-blinking", true, Config.Default);
            CheckBoxItem itemBlinkingStars = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Blinking Stars",
                option: optionBlinkingStars
            );
            itemBlinkingStars.OnValueChanged += () => {
                (game as Knot3Game).NotAvailableOnXNA ();
            };
            settingsMenu.Add (itemBlinkingStars);

            // star count
            float[] validStarCounts = {
                100, 250, 500, 750, 1000, 1250, 1500, 2000, 2500, 3000, 5000
            };
            FloatOption optionStarCount = new FloatOption (
                section: "video",
                name: "stars-count",
                defaultValue: validStarCounts [4],
                validValues: validStarCounts,
                configFile: Config.Default
            );
            ComboBox itemStarCount = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Number of stars"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemStarCount.AddEntries (optionStarCount);
            settingsMenu.Add (itemStarCount);

            // show sun
            BooleanOption optionShowSun = new BooleanOption ("video", "show-sun", false, Config.Default);
            CheckBoxItem itemShowSun = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Sun",
                option: optionShowSun
            );
            settingsMenu.Add (itemShowSun);

            // day cycle
            float[] validDayCycles = {
                10, 20, 30, 60, 120, 300, 600, 900, 1200, 3600, 7200
            };
            FloatOption optionDayCycle = new FloatOption (
                section: "video",
                name: "day-cycle-seconds",
                defaultValue: validDayCycles [3],
                validValues: validDayCycles,
                configFile: Config.Default
            );
            ComboBox itemDayCycle = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Day cycle in seconds"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemDayCycle.AddEntries (optionDayCycle);
            settingsMenu.Add (itemDayCycle);

            // selective rendering
            CheckBoxItem itemSelectiveRender = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Selective Rendering",
                option: new BooleanOption ("video", "selectiveRendering", false, Config.Default)
            );
            settingsMenu.Add (itemSelectiveRender);

            // auto camera when moving
            CheckBoxItem itemAutoCameraMove = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Auto Camera (edge move)",
                option: new BooleanOption ("video", "auto-camera-move", true, Config.Default)
            );
            settingsMenu.Add (itemAutoCameraMove);

            // auto camera
            CheckBoxItem itemAutoCamera = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Auto Camera",
                option: new BooleanOption ("video", "auto-camera-nomove", false, Config.Default)
            );
            settingsMenu.Add (itemAutoCamera);

            // Resolutions
            string currentResolution = GraphicsManager.GraphicsDevice.DisplayMode.Width.ToString ()
                                       + "x"
                                       + GraphicsManager.GraphicsDevice.DisplayMode.Height.ToString ();

            DisplayModeCollection modes = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes;
            HashSet<string> reso = new HashSet<string> ();
            foreach (DisplayMode mode in modes) {
                reso.Add (mode.Width + "x" + mode.Height);
            }
            reso.Add ("1024x600");
            string[] validResolutions = reso.ToArray ();
            validResolutions = validResolutions.OrderBy (x => Decimal.Parse (x.Split ('x') [0], System.Globalization.NumberStyles.Any)).ToArray ();
            DistinctOption optionResolution = new DistinctOption (
                section: "video",
                name: "resolution",
                defaultValue: currentResolution,
                validValues: validResolutions,
                configFile: Config.Default
            );
            ComboBox itemResolution = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Resolution"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemResolution.AddEntries (optionResolution);
            settingsMenu.Add (itemResolution);

            // Supersampling
            float[] validSupersamples = {
                1f, 1.25f, 1.5f, 1.75f, 2f
            };
            FloatOption optionSupersamples = new FloatOption (
                section: "video",
                name: "Supersamples",
                defaultValue: 2f,
                validValues: validSupersamples,
                configFile: Config.Default
            );
            ComboBox itemSupersamples = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Supersamples"
            ) {
                NameWidth = 0.75f,
                ValueWidth = 0.25f
            };
            itemSupersamples.AddEntries (optionSupersamples);
            settingsMenu.Add (itemSupersamples);

            // fullscreen
            BooleanOption optionFullscreen = new BooleanOption ("video", "fullscreen", false, Config.Default);
            CheckBoxItem itemFullscreen = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Fullscreen",
                option: optionFullscreen
            );
            itemFullscreen.OnValueChanged += () => Game.IsFullScreen = optionFullscreen.Value;
            settingsMenu.Add (itemFullscreen);

            // Model quality
            SliderItem sliderModelQuality = new SliderItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Model Quality",
                max: 1000,
                min: 0,
                value: 0
            );
            sliderModelQuality.Value = (int)(Primitive.ModelQualityOption.Value * 1000f);
            sliderModelQuality.OnValueChanged = (time) => {
                float quality = (float)sliderModelQuality.Value / 1000f;
                Primitive.ModelQualityOption.Value = quality;
                Primitive.OnModelQualityChanged (time);
            };
            settingsMenu.Add (sliderModelQuality);

            // Rendereffects
            RenderEffectOption optionRenderEffect = new RenderEffectOption (
                section: "video",
                name: "current-world-effect",
                configFile: Config.Default
            );
            ComboBox itemRenderEffect = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Render Effect"
            );
            itemRenderEffect.ValueChanged += (time) => {
                RenderEffectLibrary.RenderEffectChanged (Config.Default ["video", "current-world-effect", "default"], time);
            };
            itemRenderEffect.AddEntries (optionRenderEffect);
            settingsMenu.Add (itemRenderEffect);

            // Projector Mode
            BooleanOption optionProjectorMode = new BooleanOption ("debug", "projector-mode", false, Config.Default);
            CheckBoxItem itemProjectorMode = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Video projector mode",
                option: optionProjectorMode
            );
            itemProjectorMode.OnValueChanged += () => {
                if (optionProjectorMode.Value) {
                    new ProjectorDesign ().Apply ();
                    Config.Default ["video", "camera-overlay", false] = false;
                    Config.Default ["video", "profiler-overlay", false] = false;
                    Config.Default ["video", "current-world-effect", "default"] = "default";
                    Config.Default ["video", "Supersamples", 2f] = 2f;
                    Config.Default ["video", "arrows", false] = false;
                    Config.Default ["language", "current", "en"] = "de";
                    Config.Default ["video", "day-cycle-seconds", 60] = 10;
                }
                else {
                    new HfGDesign ().Apply ();
                }
                NextScreen = new StartScreen (game);
            };
            settingsMenu.Add (itemProjectorMode);
        }
Example #18
0
        /// <summary>
        /// Erzeugt ein neues DebugSettingsScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt.
        /// </summary>
        public DebugSettingsScreen(GameCore game)
            : base(game)
        {
            MenuName = "Debug";

            CheckBoxItem showOverlay = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Overlay",
                option: new BooleanOption ("video", "camera-overlay", false, Config.Default)
            );
            settingsMenu.Add (showOverlay);

            CheckBoxItem showFps = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show FPS",
                option: new BooleanOption ("video", "fps-overlay", false, Config.Default)
            );
            settingsMenu.Add (showFps);

            CheckBoxItem showProfiler = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Profiler",
                option: new BooleanOption ("video", "profiler-overlay", false, Config.Default)
            );
            settingsMenu.Add (showProfiler);

            CheckBoxItem showBoundings = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Bounding Boxes",
                option: new BooleanOption ("debug", "show-boundings", false, Config.Default)
            );
            settingsMenu.Add (showBoundings);

            CheckBoxItem showStartEdgeArrow = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Show Start Edge Direction",
                option: new BooleanOption ("debug", "show-startedge-direction", false, Config.Default)
            );
            settingsMenu.Add (showStartEdgeArrow);

            string[] unprojectMethods = { "SelectedObject", "NearFarAverage" };
            DistinctOption unprojectOption = new DistinctOption ("debug", "unproject", unprojectMethods [0], unprojectMethods, Config.Default);
            ComboBox unprojectItem = new ComboBox (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Unproject"
            );
            unprojectItem.AddEntries (unprojectOption);
            settingsMenu.Add (unprojectItem);

            /*
            CheckBoxItem shaderPascal = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Use Pascal's Shader",
                option: new BooleanOptionInfo ("video", "pascal-shader", false, Options.Default)
            );te
            settingsMenu.Add (shaderPascal);

            CheckBoxItem shaderCel = new CheckBoxItem (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                text: "Use Cel Shader",
                option: new BooleanOptionInfo ("video", "cel-shading", false, Options.Default)
            );
            settingsMenu.Add (shaderCel);
            */
        }
Example #19
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines ChallengeCreateScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game.
        /// </summary>
        public ChallengeCreateScreen(GameCore game)
            : base(game)
        {
            startKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            startKnotMenu.Bounds = ScreenContentBounds.FromLeft (0.47f).FromTop (0.98f);
            startKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            startKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            startKnotMenu.RelativeItemHeight = Design.DataItemHeight;

            targetKnotMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu);
            targetKnotMenu.Bounds = ScreenContentBounds.FromRight (0.47f).FromTop (0.98f);
            targetKnotMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc;
            targetKnotMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc;
            targetKnotMenu.RelativeItemHeight = Design.DataItemHeight;

            challengeName = new InputItem (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, "Name:", String.Empty);
            challengeName.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.Size.OnlyY + new ScreenPoint (this, 0f, 0.050f);
            challengeName.Bounds.Size = new ScreenPoint (this, 0.375f, 0.040f);
            challengeName.OnValueChanged += () => TryConstructChallenge ();
            challengeName.NameWidth = 0.2f;
            challengeName.ValueWidth = 0.8f;

            createButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Create!",
                onClick: OnCreateChallenge
            );
            createButton.Bounds.Position = ScreenContentBounds.Position + ScreenContentBounds.FromLeft (0.50f).Size + new ScreenPoint (this, 0f, 0.050f);
            createButton.Bounds.Size = new ScreenPoint (this, 0.125f, 0.050f);

            createButtonBorder = new Border (this, DisplayLayer.ScreenUI + DisplayLayer.MenuItem, createButton, 4, 4);
            createButton.AlignX = HorizontalAlignment.Center;

            startKnotMenu.Bounds.Padding = targetKnotMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f);
            startKnotMenu.ItemAlignX = targetKnotMenu.ItemAlignX = HorizontalAlignment.Left;
            startKnotMenu.ItemAlignY = targetKnotMenu.ItemAlignY = VerticalAlignment.Center;

            lines.AddPoints (.000f, .050f, .030f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f);

            title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Create Challenge");
            title.Bounds.Position = ScreenTitleBounds.Position;
            title.Bounds.Size = ScreenTitleBounds.Size;
            title.ForegroundColorFunc = (s) => Color.White;

            // Erstelle einen Parser für das Dateiformat
            KnotFileIO fileFormat = new KnotFileIO ();
            // Erstelle einen Spielstand-Loader
            loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots");

            backButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Back",
                onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is ChallengeCreateScreen)).ElementAt (0)
            );
            backButton.AddKey (Keys.Escape);
            backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f);

            backButton.AlignX = HorizontalAlignment.Center;
        }
Example #20
0
        /// <summary>
        /// Erzeugt eine neue Instanz eines CreativeModeScreen-Objekts und initialisiert diese mit einem Knot3Game-Objekt game, sowie einem Knoten knot.
        /// </summary>
        public CreativeModeScreen(GameCore game, Knot knot)
            : base(game)
        {
            // die Spielwelt
            world = new World (screen: this, drawOrder: DisplayLayer.GameWorld, bounds: Bounds);
            // der Input-Handler
            knotInput = new KnotInputHandler (screen: this, world: world);
            // das Overlay zum Debuggen
            overlay = new Overlay (screen: this, world: world);
            // der Mauszeiger
            pointer = new MousePointer (screen: this);
            // der Maus-Handler für die 3D-Modelle
            modelMouseHandler = new ModelMouseHandler (screen: this, world: world);

            // der Knoten-Renderer
            knotRenderer = new KnotRenderer (screen: this, position: Vector3.Zero);
            world.Add (knotRenderer);

            // visualisiert die BoundingSpheres
            debugBoundings = new DebugBoundings (screen: this, position: Vector3.Zero);
            world.Add (debugBoundings);

            // der Input-Handler zur Kanten-Verschiebung
            edgeMovement = new EdgeMovement (screen: this, world: world, knotRenderer : knotRenderer, position: Vector3.Zero);
            edgeMovement.KnotMoved = OnKnotMoved;

            // der Input-Handler zur Kanten-Einfärbung
            edgeColoring = new EdgeColoring (screen: this);

            // Flächen zwischen Kanten
            edgeRectangles = new EdgeRectangles (screen: this);

            // assign the specified knot
            Knot = knot;

            // Hintergrund
            Sky skyCube = new Sky (screen: this, position: Vector3.Zero);
            world.Add (skyCube);

            // Sonne
            Sun sun = new Sun (screen: this);
            world.Add (sun);

            // Undo-Button
            undoButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Undo",
                onClick: (time) => OnUndo ()
            );
            undoButton.SetCoordinates (left: 0.05f, top: 0.900f, right: 0.15f, bottom: 0.95f);
            undoButton.AlignX = HorizontalAlignment.Center;
            undoButton.IsVisible = false;

            undoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: undoButton, lineWidth: 2, padding: 0);

            // Redo-Button
            redoButton = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "Redo",
                onClick: (time) => OnRedo ()
            );
            redoButton.SetCoordinates (left: 0.20f, top: 0.900f, right: 0.30f, bottom: 0.95f);
            redoButton.AlignX = HorizontalAlignment.Center;
            redoButton.IsVisible = false;

            redoButtonBorder = new Border (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                                           widget: redoButton, lineWidth: 2, padding: 0);

            invisible = new Button (
                screen: this,
                drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem,
                name: "menu",
            onClick: (time) => {
                // erstelle einen neuen Pausedialog
                knotInput.IsEnabled = false;
                Dialog pauseDialog = new CreativePauseDialog (screen: this, drawOrder: DisplayLayer.Dialog, knot: Knot);
                // füge ihn in die Spielkomponentenliste hinzu
                pauseDialog.Close += (t) => knotInput.IsEnabled = true;
                AddGameComponents (time, pauseDialog);
            }
            );
            invisible.SetCoordinates (left: 1.00f, top: 1.00f, right: 1.10f, bottom: 1.10f);
            invisible.IsVisible = true;
            invisible.AddKey (Keys.Escape);
        }