Exemplo n.º 1
0
        public async void Initialize()
        {
            this.machine.Frame = 0;

            this.homeState = HomeStates.Home;

            this.title = AssetStore.Title;
            this.maps  = AssetStore.ParallaxMaps;
            this.tiles = AssetStore.Tiles;

            cursor = AssetStore.OpaCursorAnimator;

            this.menuStart.Initialize(machine, cursor, menuEntries);
            this.menu1Por2P.Initialize(machine, cursor, menu1Por2Pentries);

            frameScroll = 0;

            hiScore       = this.machine.BatteryRam.ReadInt((int)BatteryRamAddress.HiScore);
            hiScoreString = "hiscore: " + hiScore;

            this.fontWidth = this.machine.Screen.Font.FontSheet.TileWidth;

            this.machine.Audio.PlayLoop("homeSound");

            await this.machine.ExecuteAsync(() => this.game.SaveNameAndScoreIfNeededAsync());

            cursor.Start();
        }
Exemplo n.º 2
0
        public HomePage(Game game)
        {
            this.game       = game;
            this.machine    = game.Machine;
            this.menuStart  = new Menu();
            this.menu1Por2P = new Menu();

            this.menuStart.MenuSelectedCallback = (menuPosition) =>
            {
                if (menuPosition == 0)
                {
                    this.machine.Audio.Play("selectSound");
                    this.homeState = HomeStates.P1OrP2;
                }
                else if (menuPosition == 1)
                {
                    this.machine.Audio.Play("selectSound");

                    // clique sur Credits
                    this.homeState = HomeStates.Credits;
                }
                else
                {
                    // clique sur Hall Of Fame
                    this.machine.Audio.Stop("homeSound");
                    this.machine.Audio.Play("startSound");
                    this.game.NavigateWithFade(typeof(HallOfFamePage));
                }
            };

            this.menuStart.BackCallback = () =>
            {
                this.machine.Audio.Play("selectSound");
                homeState = HomeStates.Home;
            };

            this.menu1Por2P.MenuSelectedCallback = (menuPosition) =>
            {
                if (menuPosition == 0)
                {
                    this.machine.Audio.Play("startSound");
                    this.homeState = HomeStates.Quit;
                    this.Player    = Players.Solo;
                }
                else
                {
                    this.machine.Audio.Play("startSound");
                    // != de Solo == 2 players
                    this.Player    = Players.Player2;
                    this.homeState = HomeStates.Quit;
                }
            };

            this.menu1Por2P.BackCallback = () =>
            {
                this.machine.Audio.Play("selectSound");
                homeState = HomeStates.Menu;
            };

            Action <int> handlerMove = (menuPosition) =>
            {
                this.machine.Audio.Play("menuSound", 0.5, false);
            };

            this.menuStart.CursorMoveCallback  = handlerMove;
            this.menu1Por2P.CursorMoveCallback = handlerMove;
        }
Exemplo n.º 3
0
        public void Updated()
        {
            var gamepad = this.machine.GamepadGlobal;

            switch (homeState)
            {
            case HomeStates.Home:

                // detection du bouton Start
                if (gamepad.IsPressed(GamepadKeys.ButtonA))
                {
                    this.machine.Audio.Play("selectSound");

                    gamepad.WaitForRelease(() =>
                    {
                        homeState = HomeStates.Menu;
                    });
                }
                break;

            case HomeStates.Menu:

                menuStart.Update();
                break;

            case HomeStates.P1OrP2:

                menu1Por2P.Update();
                break;

            case HomeStates.Credits:

                if (gamepad.IsButtonsPressed)
                {
                    this.machine.Audio.Play("selectSound");

                    gamepad.WaitForRelease(() =>
                    {
                        this.menuStart.MenuPosition = 0;
                        this.homeState = HomeStates.Home;
                    });
                }

                break;

            case HomeStates.Quit:

                this.machine.Audio.Stop("homeSound");

                if (Player == Players.Solo)
                {
                    game.NavigateWithFade(typeof(PlayPage));
                }
                else
                {
                    game.NavigateWithFade(typeof(MultiPlayPage));
                }

                break;
            }
        }