예제 #1
0
        public override ViewModel Index()
        {
            var menu = new Menu();
            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Visit the Tolbooth Tavern",
                    Id = '1',
                    ActionResult = Actions.GoTo<InnController>
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Browse Ye Olde Store",
                    Id = '2',
                    ActionResult = Actions.GoTo<StoreController>
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Enter the Dungeon",
                    Id = '3',
                    ActionResult = Actions.GoTo<DungeonController>,
                    OnInputAccepted = () => _gameWorld.SetRequiredNumberOfMonstersInCurrentDungeonLevelBeforeBoss(_dice)
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Inventory",
                    Id = '4',
                    ActionResult = Actions.GoTo<InventoryController>
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Spell Book",
                    Id = '5',
                    ActionResult = Actions.GoTo<SpellBookController>
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Exit to main menu",
                    Id = '6',
                    ActionResult = Actions.GoBack
                });

            var viewModel = ViewModel.CreateWithMenu<TownViewModel>(menu);

            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.AsciiArt = _asciiArtRepository.GetTownArt();

            return viewModel;
        }
        public override ViewModel Index()
        {
            var menu = new Menu();

            menu.AddMenuItem(new MenuItem { Text = "New Game", Id = '1', ActionResult = Actions.GoTo<NewGameController> });
            menu.AddMenuItem(new MenuItem { Text = "Load Game", Id = '2', ActionResult = Actions.GoTo<LoadGameController> });
            menu.AddMenuItem(new MenuItem { Text = "Exit", Id = '3', ActionResult = Actions.GoBack });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "Null Quest: it's pretty awesome.";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #3
0
        public override ViewModel Index()
        {
            var menu = new Menu();

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Rest",
                    Id = '1',
                    ActionResult = Actions.Reload,
                    OnInputAccepted = () =>
                    {
                        _gameWorld.Player.Rest();
                        _title = "Your health and energy has been restored.";
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Save Game",
                    Id = '2',
                    ActionResult = Actions.Reload,
                    OnInputAccepted = () =>
                    {
                        _saveGameRepository.SaveGame(SaveGameData.FromGameWorld(_gameWorld));
                        _title = "Your game has been saved.";
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Exit",
                    Id = '3',
                    ActionResult = Actions.GoBack
                });

            var viewModel = ViewModel.CreateWithMenu<InnViewModel>(menu);

            viewModel.Title = _title;
            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.AsciiArt = _asciiArtRepository.GetInnArt();

            return viewModel;
        }
예제 #4
0
        public override ViewModel Index()
        {
            var menu = new Menu();
            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Keep moving forward",
                    Id = '1',
                    ActionResult = GetNextEncounter(),
                    OnInputAccepted = () => _lastAction = LastAction.MovedForward
                });
            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Inventory",
                    Id = '2',
                    ActionResult = Actions.GoTo<InventoryController>,
                    OnInputAccepted = () => _lastAction = LastAction.MenuNavigation
                });
            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Spell Book",
                    Id = '3',
                    ActionResult = Actions.GoTo<SpellBookController>,
                    OnInputAccepted = () => _lastAction = LastAction.MenuNavigation
                });
            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Run away back to town",
                    Id = '4',
                    ActionResult = Actions.GoBack
                });

            DungeonViewModel viewModel = ViewModel.CreateWithMenu<DungeonViewModel>(menu);

            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.DungeonName = string.Format("{0} (Level {1})", _gameWorld.GetCurrentDungeonName(), _gameWorld.CurrentDungeonLevel);
            viewModel.Information = _encounterDetails ?? "This is the dungeon - it isn't a very friendly place. Hallways go off in seemingly every direction, with no end in sight. A skeleton sits upright against a wall in the corner. No doubt an adventurer that came before you...";
            viewModel.AsciiArt = _asciiArtRepository.GetDungeonArt(_gameWorld.CurrentDungeonLevel);

            _encounterDetails = null;

            return viewModel;
        }
예제 #5
0
        public override ViewModel Index()
        {
            var menu = new Menu();

            menu.AddMenuItem(
                new MenuItem
                {
                    Text = "Exit",
                    Id = '1',
                    ActionResult = Actions.GoBack
                });

            var viewModel = ViewModel.CreateWithMenu<StoreViewModel>(menu);

            viewModel.Title = "We're closed. Go away.";
            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.AsciiArt = _asciiArtRepository.GetStoreArt();

            return viewModel;
        }
예제 #6
0
        public override ViewModel Index()
        {
            var menu = new Menu();
            menu.Prompt = "Select save game slot: ";

            var saveGameSlots = _saveGameRepository.GetSaveGameSlots()
                .Where(x => !x.IsEmpty)
                .Select((x, i) => new { SaveGameData = x, Index = i + 1 }).ToList();

            foreach (var item in saveGameSlots.OrderBy(x => x.SaveGameData.Id))
            {
                menu.AddMenuItem(
                    new MenuItem
                    {
                        ActionResult = Actions.PopAndGoTo<TownController>,
                        Text = item.SaveGameData.Title,
                        Id = item.Index.ToString()[0],
                        OnInputAccepted = () =>
                        {
                            item.SaveGameData.LoadToGameWorld(_gameWorld);
                        }
                    });
            }

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = (saveGameSlots.Count + 1).ToString()[0]
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "Three slots to choose from. Which one will it be?";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #7
0
        public override ViewModel Index()
        {
            var menu = new Menu();

            menu.AddMenuItem(new MenuItem { Text = "Goodbye, cruel world!", Id = '1', ActionResult = Actions.GoBack });

            var viewModel = ViewModel.CreateWithMenu<HelloWorldViewModel>(menu);

            viewModel.Message = "Hello, world!";
            viewModel.MessageArt = @"
              _    _      _ _                             _     _ _
             | |  | |    | | |                           | |   | | |
             | |__| | ___| | | ___    __      _____  _ __| | __| | |
             |  __  |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
             | |  | |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
             |_|  |_|\___|_|_|\___( )   \_/\_/ \___/|_|  |_|\__,_(_)
                      |/

            ";

            return viewModel;
        }
예제 #8
0
        public override ViewModel Index()
        {
            var menu = new Menu();
            var id = 1;

            if (_currentSpell == null)
            {
                var spellBook = _gameWorld.Player.SpellBook.ToList();

                foreach (var x in spellBook
                    .Skip(_pageIndex * PageSize)
                    .Take(PageSize)
                    .Select((spell, index) => new { Spell = spell, Index = (_pageIndex * PageSize) + index }))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = x.Spell.GetLeveledName(),
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _currentSpell = x.Spell;
                            _currentSpellIndex = x.Index;
                            _title = x.Spell.GetLeveledName();
                            _information = x.Spell.GetDescription();
                        }
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                if (_pageIndex > 0)
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Previous",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () => _pageIndex--
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                if (spellBook.Count > ((_pageIndex * PageSize) + PageSize))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Next",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () => _pageIndex++
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Back",
                        ActionResult = Actions.GoBack
                    });
            }
            else
            {
                if (_currentSpell is INonCombatSpell && _currentSpell.CanCast(_gameWorld.Player, new NonCombatContext()))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Cast",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            var logEntry = ((INonCombatSpell)_currentSpell).Cast(_dice, _gameWorld.Player);

                            _title = string.Format("Cast {0}", _currentSpell.GetLeveledName());
                            _information = logEntry != null ? logEntry.Text : null;

                            _currentSpell = null;
                            _currentSpellIndex = -1;
                            if ((_pageIndex * PageSize) > _gameWorld.Player.SpellBook.Count())
                            {
                                _pageIndex--;
                            }
                        }
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                };

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Move to top",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _gameWorld.Player.MoveSpellToTopOfSpellBook(_currentSpell, _currentSpellIndex);
                            _currentSpell = null;
                            _currentSpellIndex = -1;
                        }
                    });
                id++;

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Back",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _title = DefaultTitle;
                            _information = DefaultInformation;
                            _currentSpell = null;
                            _currentSpellIndex = -1;
                        }
                    });
            }

            var viewModel = ViewModel.CreateWithMenu<SpellBookViewModel>(menu);

            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.Title = _title;
            viewModel.Information = _information;
            viewModel.AsciiArt = _asciiArtRepository.GetSpellBookArt();

            return viewModel;
        }
예제 #9
0
        private ViewModel GetChooseSaveGameSlotViewModel()
        {
            var menu = new Menu();
            menu.Prompt = "Select save game slot: ";

            var saveGameSlots = _saveGameRepository.GetSaveGameSlots().ToList();

            foreach (var saveGameSlot in saveGameSlots.OrderBy(x => x.Id))
            {
                menu.AddMenuItem(
                    new MenuItem
                    {
                        ActionResult = Actions.Reload,
                        Text = saveGameSlot.Title,
                        Id = saveGameSlot.Id.ToString()[0],
                        OnInputAccepted = () =>
                        {
                            _gameInfo.SaveGameSlotPosition = saveGameSlot.Id;
                            if (saveGameSlot.IsEmpty)
                            {
                                _gameInfo.Step = GameCreationStep.Race;
                            }
                            else
                            {
                                _gameInfo.Step = GameCreationStep.ConfirmOverwrite;
                            }
                        }
                    });
            }

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = (saveGameSlots.Max(x => x.Id) + 1).ToString()[0]
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "Three slots to choose from. Which one will it be?";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #10
0
        private ViewModel GetSelectRaceViewModel()
        {
            var menu = new Menu();
            menu.Prompt = "Select your race: ";

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Human",
                    Id = '1',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Race = Race.Human;
                        _gameInfo.Step = GameCreationStep.Class;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Elf",
                    Id = '2',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Race = Race.Elf;
                        _gameInfo.Step = GameCreationStep.Class;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Orc",
                    Id = '3',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Race = Race.Orc;
                        _gameInfo.Step = GameCreationStep.Class;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Dwarf",
                    Id = '4',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Race = Race.Dwarf;
                        _gameInfo.Step = GameCreationStep.Class;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = '5'
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "I'm not racist, but you'll have to choose your race now.";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #11
0
        private ViewModel GetSelectClassViewModel()
        {
            var menu = new Menu();
            menu.Prompt = "Select your class: ";

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Fighter",
                    Id = '1',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Class = Class.Fighter;
                        _gameInfo.Step = GameCreationStep.RollForStats;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Wizard",
                    Id = '2',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Class = Class.Wizard;
                        _gameInfo.Step = GameCreationStep.RollForStats;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Thief",
                    Id = '3',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Class = Class.Thief;
                        _gameInfo.Step = GameCreationStep.RollForStats;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Cleric",
                    Id = '4',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Class = Class.Cleric;
                        _gameInfo.Step = GameCreationStep.RollForStats;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Bard",
                    Id = '5',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Class = Class.Bard;
                        _gameInfo.Step = GameCreationStep.RollForStats;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = '6'
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "Now's your chance to move up in the world. Choose your class.";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #12
0
        private ViewModel GetRollForStatsViewModel()
        {
            var menu = new Menu();
            menu.Prompt = "What'll it be? ";

            _gameInfo.Stats = _statsGenerator.GenerateStats(_gameInfo.Race, _gameInfo.Class);

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.PopAndGoTo<TownController>,
                    Text = "Accept and start game",
                    Id = '1',
                    OnInputAccepted = () =>
                    {
                        var saveGameData =
                            _saveGameRepository.CreateGame(
                                _gameInfo.CharacterName,
                                _gameInfo.SaveGameSlotPosition,
                                _gameInfo.Race,
                                _gameInfo.Class,
                                _gameInfo.Stats);

                        saveGameData.LoadToGameWorld(_gameWorld);
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Roll again",
                    Id = '2'
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = '3'
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "Here are your stats. If you don't like them, roll again.";
            viewModel.TitleArt = string.Format(@"    Strength : {0}
               Endurance : {1}
               Dexterity : {2}
             Agility : {3}
            Intelligence : {4}
              Wisdom : {5}
            Luck : {6}{7}",
                _gameInfo.Stats.Strength.ToString().PadRight(2),
                _gameInfo.Stats.Endurance.ToString().PadRight(2),
                _gameInfo.Stats.Dexterity.ToString().PadRight(2),
                _gameInfo.Stats.Agility.ToString().PadRight(2),
                _gameInfo.Stats.Intelligence.ToString().PadRight(2),
                _gameInfo.Stats.Wisdom.ToString().PadRight(2),
                _gameInfo.Stats.Luck.ToString().PadRight(2),
                string.Join("", Enumerable.Repeat(Environment.NewLine, 16)));

            return viewModel;
        }
예제 #13
0
        private ViewModel GetConfirmOverwriteViewModel()
        {
            var menu = new Menu();
            menu.Prompt = "Confirm overwrite? ";

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "Yes",
                    Id = '1',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Step = GameCreationStep.Race;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.Reload,
                    Text = "No",
                    Id = '2',
                    OnInputAccepted = () =>
                    {
                        _gameInfo.Step = GameCreationStep.ChooseSaveGameSlot;
                    }
                });

            menu.AddMenuItem(
                new MenuItem
                {
                    ActionResult = Actions.GoBack,
                    Text = "Cancel",
                    Id = '3'
                });

            var viewModel = ViewModel.CreateWithMenu<MainMenuViewModel>(menu);

            viewModel.Message = "A game already exists in that slot. Do you want to throw it all away and start anew?";
            viewModel.TitleArt = _asciiArtRepository.GetTitleArt();

            return viewModel;
        }
예제 #14
0
        public override ViewModel Index()
        {
            var menu = new Menu();
            var id = 1;

            if (_currentItem == null)
            {
                var inventory = _gameWorld.Player.Inventory.Where(item => item.Quantity > 0).ToList();

                foreach (var x in inventory
                    .Skip(_pageIndex * PageSize)
                    .Take(PageSize)
                    .Select((item, index) => new { Item = item, Index = (_pageIndex * PageSize) + index }))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = x.Item.GetLeveledName() + (x.Item.Quantity > 1 ? string.Format(" ({0})", x.Item.Quantity) : ""),
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _currentItem = x.Item;
                            _currentItemIndex = x.Index;
                            _title = x.Item.GetLeveledName();
                            _information = x.Item.GetDescription();
                        }
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                if (_pageIndex > 0)
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Previous",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () => _pageIndex--
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                if (inventory.Count > ((_pageIndex * PageSize) + PageSize))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Next",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () => _pageIndex++
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                }

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Back",
                        ActionResult = Actions.GoBack
                    });
            }
            else
            {
                if (_currentItem is INonCombatItem && _currentItem.CanUse(_gameWorld.Player, new NonCombatContext()))
                {
                    var menuItem = new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = _currentItem is Weapon ? "Equip" : "Use",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            var logEntry = ((INonCombatItem)_currentItem).Use(_dice, _gameWorld.Player);

                            _title = (_currentItem is Weapon ? "Equipped " : "Used 1 ") + _currentItem.GetLeveledName();
                            _information = logEntry != null ? logEntry.Text : null;

                            _currentItem = null;
                            _currentItemIndex = -1;
                            if ((_pageIndex * PageSize) > _gameWorld.Player.Inventory.Count(item => item.Quantity > 0))
                            {
                                _pageIndex--;
                            }
                        }
                    };

                    menu.AddMenuItem(menuItem);
                    id++;
                };

                if (!(_currentItem is Weapon) || !_currentItem.Equals(Weapon.BareHands))
                {
                    menu.AddMenuItem(
                        new MenuItem
                        {
                            Id = id.ToString()[0],
                            Text = "Discard",
                            ActionResult = Actions.Reload,
                            OnInputAccepted = () =>
                            {
                                _title = DefaultTitle;
                                _information = "Discarded 1 " + _currentItem.Name;

                                _gameWorld.Player.RemoveItemFromInventory(_currentItem);
                                _currentItem = null;
                                _currentItemIndex = -1;
                                if ((_pageIndex * PageSize) > _gameWorld.Player.Inventory.Count(item => item.Quantity > 0))
                                {
                                    _pageIndex--;
                                }
                            }
                        });
                    id++;
                }

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Move to top",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _gameWorld.Player.MoveItemToTopOfInventory(_currentItem, _currentItemIndex);
                            _currentItem = null;
                            _currentItemIndex = -1;
                        }
                    });
                id++;

                menu.AddMenuItem(
                    new MenuItem
                    {
                        Id = id.ToString()[0],
                        Text = "Back",
                        ActionResult = Actions.Reload,
                        OnInputAccepted = () =>
                        {
                            _title = DefaultTitle;
                            _information = DefaultInformation;
                            _currentItem = null;
                            _currentItemIndex = -1;
                        }
                    });

            }

            var viewModel = ViewModel.CreateWithMenu<InventoryViewModel>(menu);

            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.Title = _title;
            viewModel.Information = _information;
            viewModel.AsciiArt = _asciiArtRepository.GetInventoryArt();

            return viewModel;
        }
예제 #15
0
        public override ViewModel Index()
        {
            CombatViewModel viewModel = null;

            while (_combatSteps.MoveNext())
            {
                switch (_combatSteps.Current)
                {
                    case CombatStep.Start:
                    {
                        viewModel = ViewModel.CreateWithAutoReloadInput<CombatViewModel>(this, "Thar be monsters here...", 500);
                        break;
                    }
                    case CombatStep.PlayerAction:
                    {
                        var menu = new Menu();
                        foreach (var item in _combatEngine.CombatContext.Player.GetAllowedActions(_combatEngine.CombatContext).Select((a, i) => new { Action = a, Index = i + 1 }))
                        {
                            menu.AddMenuItem(
                                new MenuItem
                                {
                                    Text = item.Action.Name,
                                    Id = item.Index.ToString()[0],
                                    ActionResult = Actions.Reload,
                                    OnInputAccepted = () => _combatEngine.ApplyPlayerAction(item.Action)
                                });
                        }

                        viewModel = ViewModel.CreateWithMenu<CombatViewModel>(menu);
                        break;
                    }
                    case CombatStep.MonsterActionStart:
                    {
                        viewModel = ViewModel.CreateWithAutoUpdateInput<CombatViewModel>(
                            "Monster attacking...",
                            theViewModel => {},
                            new AutoReloadInput(this),
                            500);
                        break;
                    }
                    case CombatStep.MonsterActionEnd:
                    {
                        viewModel = ViewModel.CreateWithAutoReloadInput<CombatViewModel>(this);
                        break;
                    }
                    case CombatStep.PlayerDead:
                    {
                        var menu = new Menu();
                        menu.AddMenuItem(
                            new MenuItem
                            {
                                Text = "Exit to Main Menu",
                                Id = '1',
                                ActionResult = Actions.PopToNearest<GameLaunchedController>
                            });

                        viewModel = ViewModel.CreateWithAutoUpdateInput<CombatViewModel>(
                            "Sad trombone.",
                            theViewModel => {},
                            menu,
                            1000);
                        break;
                    }
                    case CombatStep.MonsterDead:
                    {
                        var menu = new Menu();
                        menu.AddMenuItem(
                            new MenuItem
                            {
                                Text = "Continue",
                                Id = '1',
                                ActionResult = Actions.GoBack
                            });

                        viewModel = ViewModel.CreateWithAutoUpdateInput<CombatViewModel>(
                            "It's happy dance time!",
                            theViewModel => { },
                            menu,
                            1000);
                        break;
                    }
                    case CombatStep.CombatEnded:
                    {
                        var menu = new Menu();
                        menu.AddMenuItem(
                            new MenuItem
                            {
                                Text = "Continue",
                                Id = '1',
                                ActionResult = Actions.GoBack
                            });

                        viewModel = ViewModel.CreateWithAutoUpdateInput<CombatViewModel>(
                            "",
                            theViewModel => { },
                            menu);
                        break;
                    }
                }

                break;
            }

            viewModel.Stats = StatsViewModel.FromPlayer(_gameWorld.Player);
            viewModel.DungeonName = string.Format("{0} (Level {1})", _gameWorld.GetCurrentDungeonName(), _gameWorld.CurrentDungeonLevel);
            viewModel.Information = GetInformation(_combatEngine.CombatContext.CombatLog);
            viewModel.CombatLog = GetCombatLog(_combatEngine.CombatContext.CombatLog);
            viewModel.AsciiArt = GetAsciiArt();

            return viewModel;
        }