Пример #1
0
        // Constructor
        public Pause(Scene baseScene = null)
        {
            active         = false;
            this.baseScene = baseScene;

            // Create menus
            baseMenu = new Menu(
                new String[]
            {
                "Resume", "Restart",
                "Settings", "Quit"
            },
                new Menu.Callback[]
            {
                // Resume
                delegate(Object self)
                {
                    Pause p  = (Pause)self;
                    p.active = false;
                },
                // Restart
                delegate(Object self)
                {
                    GameField gf = (GameField)baseScene;
                    gf.Reset();
                },
                // Settings
                delegate(Object self)
                {
                    Pause p      = (Pause)self;
                    p.inSettings = true;
                    p.settings.SetCursorPos(2);
                },
                // Quit
                delegate(Object self)
                {
                    GameField gf = (GameField)baseScene;
                    gf.StartQuitting();
                },
            }
                );

            bool audioState = baseScene.IsAudioEnabled();

            // Create settings
            settings = new Menu(
                new String[] {
                "Fullscreen",
                "Audio: " + (audioState ? "On" : "Off"),
                "Back"
            },
                new Menu.Callback[] {
                // Fullscreen
                delegate(Object o) { baseScene.ToggleFullscreen(); },
                // Audio
                delegate(Object o) {
                    Pause p = (Pause)o;
                    p.baseScene.ToggleAudio();
                    bool state = p.baseScene.IsAudioEnabled();
                    p.settings.RenameButton(1, "Audio: " + (state ? "On" : "Off"));
                },
                // Quit
                delegate(Object o) {
                    ((Pause)o).inSettings = false;
                    if (settingsMode)
                    {
                        Disable();
                    }
                },
            }
                );
        }
Пример #2
0
        // Initialize
        public override void Init()
        {
            const float FADE_SPEED = 1.0f;

            // Get global components
            Global    gs     = (Global)globalScene;
            AssetPack assets = gs.GetAssets();

            trans = gs.GetTransition();

            // Get assets
            bmpFont    = assets.GetBitmap("font");
            bmpLogo    = assets.GetBitmap("logo");
            bmpIntro   = assets.GetBitmap("intro");
            sPause     = assets.GetSample("pause");
            sMenuMusic = assets.GetSample("menu");

            // Create a "shallow" stage
            stage = new Stage(assets, true);

            // Create menu
            menu = new Menu(
                new String[]
            {
                "Play Game",
                "Settings",
                "Quit"
            },
                new Menu.Callback[]
            {
                // Resume
                delegate(Object self)
                {
                    changingToGame = true;

                    // Fade out music
                    audio.FadeCurrentLoopedSample(500, 0.0f);

                    // Change to game
                    trans.Activate(Transition.Mode.In, 2.0f, delegate {
                        sceneMan.ChangeScene("game");
                    });
                },
                // Settings
                delegate(Object self)
                {
                    settings.Activate(true);
                },
                // Quit
                delegate(Object self)
                {
                    changingToGame = false;
                    // Quit
                    trans.Activate(Transition.Mode.In, 2.0f, eventMan.Terminate);
                },
            }
                );

            // Create "settings"
            settings = new Pause(this);

            // Set some default values
            scale      = 1.0f;
            phase      = -1;
            alphaTimer = (float)Math.PI / 2.0f;

            // Fade out
            trans.Activate(Transition.Mode.Out, FADE_SPEED, null);
        }