Пример #1
0
        public override void Init()
        {
            _menuFont = ContentManager.Load <SpriteFont>("default");
            InputMapProvider.GetContextById(Contexts.Menu)?.Activate();

            _menu = new Menu(IntentProvider, SpriteBatch, _menuFont);

            var viewport = ScreenManager.Game.GraphicsDevice.Viewport;

            _menu.Position = new Vector2(viewport.Width / 2, viewport.Height / 2);

            var start = new MenuItem {
                Text = "Start"
            };

            start.OnSelected += (sender, args) =>
            {
                InputMapProvider.GetContextById(Contexts.Menu).Deactivate();
                ScreenManager.Push <GameplayScreen>();
            };

            var quit = new MenuItem {
                Text = "Quit"
            };

            quit.OnSelected += (sender, args) =>
            {
                ScreenManager.Game.Exit();
            };

            _menu.AddMenuItem(start);
            _menu.AddMenuItem(quit);

            base.Init();
        }
Пример #2
0
 public override void Init()
 {
     base.Init();
     _defaultFont = ContentManager.Load <SpriteFont>("default");
     _blank       = ContentManager.Load <Texture2D>("blank");
     _viewport    = ScreenManager.Game.GraphicsDevice.Viewport;
     _position    = new Vector2((_viewport.Width - _defaultFont.MeasureString(Text).X) / 2, _viewport.Height / 2);
     InputMapProvider.GetContextById(Contexts.Menu).Activate();
 }
Пример #3
0
        public override void OnEnter()
        {
            _systemsManager.ResetSystems();
            foreach (var entity in _entityRepository.GetAll().ToList())
            {
                Entity.Destroy(entity);
            }

            InputMapProvider.GetContextById(Contexts.Gameplay).Activate();
            SetupStage();
        }
Пример #4
0
        public override void Update(GameTime gameTime, bool isActive)
        {
            if (IntentProvider.GetIntents().Any(x => x is ConfirmIntent))
            {
                InputMapProvider.GetContextById(Contexts.Menu).Deactivate();

                Session.TryGet(SessionKeys.CurrentStageId, out int stageId);
                Session.Set(SessionKeys.CurrentStageId, stageId + 1);

                var gameplay = ScreenManager.Peek <GameplayScreen>();
                ScreenManager.Push <GameplayScreen>();
            }
        }
Пример #5
0
        public override void Update(GameTime gameTime, bool isActive)
        {
            var intents = IntentProvider.GetIntents().ToArray();

            if (!intents.Any())
            {
                return;
            }

            if (intents[0] is ConfirmIntent)
            {
                InputMapProvider.GetContextById(Contexts.Menu).Deactivate();

                var gameplay = ScreenManager.Peek <GameplayScreen>();
                ScreenManager.Push <GameplayScreen>();
            }
        }
Пример #6
0
 public void Handle(PlayerDied message)
 {
     InputMapProvider.GetContextById(Contexts.Gameplay).Deactivate();
     ScreenManager.Push <GameOverScreen>();
 }
Пример #7
0
 public void Handle(StageCleared message)
 {
     InputMapProvider.GetContextById(Contexts.Gameplay).Deactivate();
     ScreenManager.Push <StageClearScreen>();
 }
Пример #8
0
 public override void OnEnter()
 {
     InputMapProvider.GetContextById(Contexts.Menu).Activate();
 }