Example #1
0
        public ScreenInputProcessResult ProcessInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult();

            switch (_screenState)
            {
            case GameScreenState.World:
                result = ProcessWorldInput(key);
                break;

            case GameScreenState.LookAt:
                result = ProcessLookAtInput(key);
                break;

            case GameScreenState.HotBarUse:
                result = ProcessHotBarUseInput(key);
                break;

            case GameScreenState.TalkTo:
                // Overengineering in the flesh...
                result = _talkToScreen.ProcessInput(key, endDialogueCallback: () =>
                {
                    _screenState  = GameScreenState.World;
                    _talkToScreen = null;
                });

                if (result.SwitchState == GameState.World)
                {
                    _screenState = GameScreenState.World;
                }

                break;
            }

            return(result);
        }
Example #2
0
        public static TalkToScreen CreateOrDefault(Character currentCharacter)
        {
            var talkToScreen = new TalkToScreen();
            var labels       = currentCharacter.CurrentScene.GetConversableCharacters()
                               .Select((o, i) =>
                                       new UiLabel
            {
                Text    = o.Name,
                Row     = i,
                OnPress = (_, __) =>
                {
                    talkToScreen.CurrentDialogue = o.Dialogue;
                }
            }
                                       ).ToList();

            if (labels.Any())
            {
                talkToScreen.TalkToList = new UiSelectList(labels);
                return(talkToScreen);
            }

            return(null);
        }
Example #3
0
        public ScreenInputProcessResult ProcessWorldInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult();

            switch (key)
            {
            case KeyMapping.ShowTalkMenu:
            {
                _talkToScreen = TalkToScreen.CreateOrDefault(_currentCharacter);

                if (_talkToScreen != null)
                {
                    _screenState = GameScreenState.TalkTo;
                }
                else
                {
                    _gameLog.WriteLine("There is no one you can talk to here.");
                }

                result.RerenderFlag = true;

                break;
            }

            case KeyMapping.ShowLookMenu:
            {
                var labels = _currentCharacter.CurrentScene.GetObservableObjects()
                             .Except(new[] { _currentCharacter })
                             .Select((o, i) =>
                                     new UiLabel
                    {
                        Text    = o.Name,
                        Row     = i,
                        OnPress = (_, __) =>
                        {
                            _gameLog.WriteLine($"{_currentCharacter.Inspect(o).Response}");
                        }
                    }
                                     ).ToList();

                if (labels.Any())
                {
                    _lookAtList = new UiSelectList(labels);

                    _screenState = GameScreenState.LookAt;
                }
                else
                {
                    _gameLog.WriteLine("There is nothing to look at here.");
                }

                result.RerenderFlag = true;

                break;
            }

            case KeyMapping.ShowStats:
                result.SwitchState  = GameState.Stats;
                result.RerenderFlag = true;
                break;

            case KeyMapping.SlideRight:
                _bottomMenuState++;

                if (!Enum.IsDefined(typeof(GameScreenBottomMenuState), _bottomMenuState))
                {
                    _bottomMenuState = GameScreenBottomMenuState.Help;
                }
                result.RerenderFlag = true;

                break;

            case KeyMapping.SlideLeft:
                _bottomMenuState--;

                if (!Enum.IsDefined(typeof(GameScreenBottomMenuState), _bottomMenuState))
                {
                    _bottomMenuState = GameScreenBottomMenuState.Hotbar;
                }
                result.RerenderFlag = true;

                break;

            case KeyMapping.HotBar_1:
                if (_currentCharacter.HotBar.Slot1.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot1;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_2:
                if (_currentCharacter.HotBar.Slot2.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot2;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_3:
                if (_currentCharacter.HotBar.Slot3.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot3;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_4:
                if (_currentCharacter.HotBar.Slot4.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot4;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_5:
                if (_currentCharacter.HotBar.Slot5.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot5;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_6:
                if (_currentCharacter.HotBar.Slot6.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot6;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_7:
                if (_currentCharacter.HotBar.Slot7.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot7;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_8:
                if (_currentCharacter.HotBar.Slot8.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot8;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_9:
                if (_currentCharacter.HotBar.Slot9.IsOccupied)
                {
                    _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot9;
                    _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);

                    _screenState        = GameScreenState.HotBarUse;
                    result.RerenderFlag = true;
                }
                break;

            case KeyMapping.HotBar_10:
                result.SwitchState  = GameState.Fight;
                result.RerenderFlag = true;
//                    if (_currentCharacter.HotBar.Slot10.IsOccupied)
//                    {
//                        _currentCharacter.HotBar.SelectedSlot = _currentCharacter.HotBar.Slot10;
//                        _currentCharacter.HotBar.SelectedSlot.UpdateCharacterSelectList(_currentCharacter);
//
//                        _screenState = GameScreenState.HotBarUse;
//                        result.RerenderFlag = true;
//                    }
                break;
            }

            return(result);
        }