Beispiel #1
0
        private ScreenInputProcessResult ProcessHotBarUseInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult();

            switch (key)
            {
            case KeyMapping.Cancel:
                _screenState        = GameScreenState.World;
                result.RerenderFlag = true;
                break;

            case KeyMapping.PreviousItem:
                _currentCharacter.HotBar.SelectedSlot.PrevItem();
                result.RerenderFlag = true;
                break;

            case KeyMapping.NextItem:
                _currentCharacter.HotBar.SelectedSlot.NextItem();
                result.RerenderFlag = true;
                break;

            case KeyMapping.Confirm:
                _currentCharacter.HotBar.SelectedSlot.PressCurrentItem();
                _currentCharacter.HotBar.SelectedSlot = null;
                _screenState        = GameScreenState.World;
                result.RerenderFlag = true;
                break;
            }

            return(result);
        }
Beispiel #2
0
        private ScreenInputProcessResult ProcessLookAtInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult();

            switch (key)
            {
            case KeyMapping.Cancel:
                _screenState        = GameScreenState.World;
                result.RerenderFlag = true;
                break;

            case KeyMapping.PreviousItem:
                _lookAtList.PrevItem();
                result.RerenderFlag = true;
                break;

            case KeyMapping.NextItem:
                _lookAtList.NextItem();
                result.RerenderFlag = true;
                break;

            case KeyMapping.Confirm:
                _lookAtList.PressCurrentItem();
                _screenState        = GameScreenState.World;
                result.RerenderFlag = true;
                break;
            }

            return(result);
        }
Beispiel #3
0
        public ScreenInputProcessResult ProcessInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult();

            switch (key)
            {
            case ConsoleKey.Q:
                result.SwitchState  = GameState.World;
                result.RerenderFlag = true;
                break;

            case ConsoleKey.UpArrow:
                PrevItem();
                result.RerenderFlag = true;
                break;

            case ConsoleKey.DownArrow:
                NextItem();
                result.RerenderFlag = true;
                break;

            case ConsoleKey.LeftArrow:
                AdjustBaseSkillValue(-1);
                result.RerenderFlag = true;
                break;

            case ConsoleKey.RightArrow:
                AdjustBaseSkillValue(1);
                result.RerenderFlag = true;
                break;
            }

            return(result);
        }
Beispiel #4
0
        public ScreenInputProcessResult ProcessInput(ConsoleKey key)
        {
            var result = new ScreenInputProcessResult
            {
                RerenderFlag = true
            };

            var prevChar = _activeCharacter;

            _activeCharacter = Fight.Queue.First().Character;

            if (prevChar != _activeCharacter)
            {
                _gameLog.WriteLine($"{_activeCharacter.Name}'s turn.");

                Fight.BeginTurn(_activeCharacter);

                return(result);
            }

            var fightResult = _activeCharacter.FightComponent.Process(key);

            var fightUpdateResult = Fight.UpdateFight();

            fightUpdateResult.DeadChars.ForEach(c =>
            {
                _gameLog.WriteLine($"{c.Character.Name} ({c.Faction}) died.");
            });

            switch (fightUpdateResult.FightOutcome)
            {
            case FightOutcome.PlayerWin:
                _gameLog.WriteLine("");
                _gameLog.WriteLine(LexicalHelper.GetVictoryString());
                _gameLog.WriteLine("");

                result.SwitchState = GameState.World;
                Fight.PostFight();
                break;

            case FightOutcome.PlayerLose:
                _gameLog.WriteLine("");
                _gameLog.WriteLine(LexicalHelper.GetDefeatString());
                _gameLog.WriteLine("");

                result.SwitchState = GameState.GameOver;
                break;
            }

            if (fightResult.TurnEnd || _activeCharacter?.Stats.ActionPoints == 0)
            {
                Fight.EndCurrentTurn();
                _activeCharacter    = null;
                result.RerenderFlag = true;
                return(result);
            }

            return(result);
        }
Beispiel #5
0
        public ScreenInputProcessResult ProcessInput(ConsoleKey key, Action endDialogueCallback)
        {
            var result = new ScreenInputProcessResult();

            switch (key)
            {
            case ConsoleKey.Q:
                if (CurrentDialogue == null)
                {
                    result.SwitchState  = GameState.World;
                    result.RerenderFlag = true;
                }

                break;

            case ConsoleKey.UpArrow:
                TalkToList.PrevItem();
                result.RerenderFlag = true;
                break;

            case ConsoleKey.DownArrow:
                TalkToList.NextItem();
                result.RerenderFlag = true;
                break;

            case ConsoleKey.Enter:
                TalkToList.PressCurrentItem();

                if (CurrentDialogue != null)
                {
                    TalkToList = new UiSelectList(
                        CurrentDialogue.Choices.Select((c, i) => new UiLabel
                    {
                        Row     = i,
                        Text    = $"  {c.Text}",
                        OnPress = (_, __) =>
                        {
                            CurrentDialogue = c.NextDialogue;
                            if (CurrentDialogue == null)
                            {
                                endDialogueCallback();
                            }
                        }
                    }).ToList()
                        );
                }
                result.RerenderFlag = true;
                break;
            }

            return(result);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }