Exemple #1
0
        // menu that asks player which to do after each dungeon move:
        // 1: view inventory, 2: view minimap, 3: inspect room
        // 4-7 move up, down, left, right respectively provided available
        // 8: fight monster if available
        private void PerformMainMenuChoice(Hero hero, Dungeon dungeon)
        {
            var menuChoice = View.AskForMainMenuChoice(dungeon, hero);

            switch (menuChoice)
            {
            // View Inventory
            case 1:
                PerformInventoryChoice(hero);
                PerformMainMenuChoice(hero, dungeon);
                break;

            // View Minimap
            case 2:
                View.ShowDungeonMinimap(dungeon, hero);
                PerformMainMenuChoice(hero, dungeon);
                break;

            // Inspect Room
            case 3:
                View.ShowRoomInformation(hero.Room);
                PerformMainMenuChoice(hero, dungeon);
                break;

            // Move Up
            case 4:
                if (dungeon.CanMoveUp())
                {
                    dungeon.MoveUp();
                }
                break;

            // Move Down
            case 5:
                if (dungeon.CanMoveDown())
                {
                    dungeon.MoveDown();
                }
                break;

            // Move Left
            case 6:
                if (dungeon.CanMoveLeft())
                {
                    dungeon.MoveLeft();
                }
                break;

            // Move Right
            case 7:
                if (dungeon.CanMoveRight())
                {
                    dungeon.MoveRight();
                }
                break;

            case 8:
                if (hero.Room.HasMonster())
                {
                    // fight monster
                    var monster = hero.Room.Monster;
                    hero.Fight(monster);
                    // remove monster from room if it has died
                    if (!monster.IsAlive())
                    {
                        dungeon.CurrentRoom.Monster = null;
                    }
                }
                break;
            }
        }
Exemple #2
0
 // Assign hero to a dungeon  for initial start game
 private void PutHeroInDungeon(Hero hero, Dungeon dungeon)
 {
     // hero starts in entry room
     hero.Room = dungeon.CurrentRoom;
 }