Пример #1
0
        public OptionsState(StateContext context) : base(context)
        {
            InputMap.AddMapping(Terminal.TK_UP, ActionType.MoveUp);
            InputMap.AddMapping(Terminal.TK_DOWN, ActionType.MoveDown);
            InputMap.AddMapping(Terminal.TK_LEFT, ActionType.MoveLeft);
            InputMap.AddMapping(Terminal.TK_RIGHT, ActionType.MoveRight);
            InputMap.AddMapping(Terminal.TK_ENTER, ActionType.Activate);

            var speedPicker = new Picker <GameSpeed>("Speed", HandleChangeSpeed);

            speedPicker.AddOption("Slow", GameSpeed.Slow);
            speedPicker.AddOption("Medium", GameSpeed.Medium);
            speedPicker.AddOption("Fast", GameSpeed.Fast);
            speedPicker.SelectOption(Context.Settings.Speed);

            var themePicker = new Picker <PaletteId>("Palette", HandleChangeTheme);

            themePicker.AddOption("Default", PaletteId.Default);
            themePicker.AddOption("Monochrome", PaletteId.Monochrome);
            themePicker.SelectOption(Context.Settings.PaletteId);

            Menu = new Menu();
            Menu.AddItem(themePicker);
            Menu.AddItem(speedPicker);
            Menu.AddItem(new Button("Return", () => RequestPopState()));
        }
Пример #2
0
        public MenuState(StateContext context) : base(context)
        {
            InputMap.AddMapping(Terminal.TK_UP, ActionType.MoveUp);
            InputMap.AddMapping(Terminal.TK_DOWN, ActionType.MoveDown);
            InputMap.AddMapping(Terminal.TK_ENTER, ActionType.Activate);

            Menu = new Menu();
            Menu.AddItem(new Button("Play", () => RequestPushState(StateId.Play)));
            Menu.AddItem(new Button("Options", () => RequestPushState(StateId.Options)));
            Menu.AddItem(new Button("Quit", () => RequestClearStack()));
        }
Пример #3
0
        public GameOverState(StateContext context) : base(context)
        {
            InputMap.AddMapping(Terminal.TK_UP, ActionType.MoveUp);
            InputMap.AddMapping(Terminal.TK_DOWN, ActionType.MoveDown);
            InputMap.AddMapping(Terminal.TK_LEFT, ActionType.MoveLeft);
            InputMap.AddMapping(Terminal.TK_RIGHT, ActionType.MoveRight);
            InputMap.AddMapping(Terminal.TK_ENTER, ActionType.Activate);

            Menu = new Menu();
            Menu.AddItem(new Button("Retry", Retry));
            Menu.AddItem(new Button("Cancel", () => RequestPopState()));
        }
Пример #4
0
        public PlayState(StateContext context) : base(context)
        {
            InputMap.AddMapping(Terminal.TK_UP, ActionType.MoveUp);
            InputMap.AddMapping(Terminal.TK_DOWN, ActionType.MoveDown);
            InputMap.AddMapping(Terminal.TK_LEFT, ActionType.MoveLeft);
            InputMap.AddMapping(Terminal.TK_RIGHT, ActionType.MoveRight);
            InputMap.AddMapping(Terminal.TK_ESCAPE, ActionType.Escape);

            Snake     = new Snake(10, 10, context.Settings.Speed, 10);
            GameField = new Rectangle(2, 3, context.Screen.Width - 4, context.Screen.Height - 5);

            PlaceRandomFood();
        }
Пример #5
0
        public PauseState(StateContext context) : base(context)
        {
            InputMap.AddMapping(Terminal.TK_UP, ActionType.MoveUp);
            InputMap.AddMapping(Terminal.TK_DOWN, ActionType.MoveDown);
            InputMap.AddMapping(Terminal.TK_ENTER, ActionType.Activate);
            InputMap.AddMapping(Terminal.TK_ESCAPE, ActionType.Escape);

            Menu = new Menu();
            Menu.AddItem(new Button("Resume", () => RequestPopState()));
            Menu.AddItem(new Button("Cancel", PressCancel));

            PauseTimer  = new Timer(20, () => PauseVisible = !PauseVisible);
            Transparent = true;
        }