示例#1
0
        static void Start(ref Map map, ref Player player)
        {
            List <string> menuItems = new List <string>();
            int           choice;

            // Refactored by Michiel and Alex
            do
            {
                Console.Clear();
                map.GetLocation().Description();
                choice = ShowMenu(map, ref menuItems);

                if (choice != menuItems.Count())
                {
                    if (validDirections.Contains(menuItems[choice]))
                    {
                        map.Move(menuItems[choice]);
                    }

                    switch (menuItems[choice])
                    {
                    case ACTION_TREASURE:
                        Console.WriteLine("You return to Mana with your spoils and live a happy life");
                        Console.WriteLine("");
                        Console.WriteLine("Thanks for playing!");
                        Console.WriteLine("Made by: Thom Martens, Kevin Rademacher and Bas Overvoorde");
                        Console.ReadKey();
                        break;

                    case ACTION_STATS:
                        player.HasBuff(player);
                        player.ShowStats(player);
                        Console.ReadKey();
                        break;

                    case ACTION_INV:
                        player.ShowInventory();
                        Console.ReadKey();
                        break;

                    case ACTION_SEARCH:
                        Console.Clear();

                        Dictionary <string, Objects> list = map.GetLocation().GetItems();
                        Objects[] obj = list.Values.ToArray();
                        for (int i = 0; i < obj.Count(); i++)
                        {
                            if (obj[i].GetAcquirable())
                            {
                                Console.WriteLine("{0}", obj[i].GetName());
                                player.PickupItem(obj[i]);
                            }
                            Console.ReadKey();
                        }
                        break;

                    case ACTION_FIGHT:
                        // Add code for fighting here

                        break;

                    case ACTION_RUN:
                        map.Run();
                        Console.WriteLine("You run away to {0}", map.GetLocation().GetName());
                        Console.ReadKey();
                        break;

                    case ACTION_BOSS:
                        //add code for bossfight here
                        break;

                    case ACTION_INN:

                        player.SetHealth();
                        Console.WriteLine("You have been healed!");
                        Console.ReadKey();
                        break;
                    }
                }
            }
            // When the choice is equal to the total item it means exit has been chosen.
            while (choice < menuItems.Count() - 1);
        }
示例#2
0
        static void Start(ref Map map, ref Player player)
        {
            List<string> menuItems = new List<string>();
            int choice;

            // Refactored by Michiel and Alex
            do
            {
                Console.Clear();
                if (Game.JustDied) break;
                map.GetLocation().Description();
                if (Game.JustDied) break;
                choice = ShowMenu(map, ref menuItems);

                if ( choice != menuItems.Count() )
                {
                    if ( validDirections.Contains( menuItems[choice] ) )
                    {
                        map.Move( menuItems[choice] );
                    }

                    switch ( menuItems[choice] )
                    {
                        case ACTION_SEARCH:
                            Console.Clear();
                            foreach (var item in map.GetLocation().GetItems())
                            {
                                item.Value.Description();
                                player.PickupItem(item.Value);
                            }
                            player.ShowInventory();
                            Console.WriteLine("Press any key to continue...");
                            Console.ReadKey();
                            // Add code to perform an item pickup
                        break;

                        case ACTION_FIGHT:
                            map.GetLocation().Fight();
                        break;

                        case ACTION_RUN:
                            // Add code for running here
                        break;

                        default:
                            if(map.GetLocation().quiz)
                            {
                                if (map.GetLocation().quizQuestions.Contains(menuItems[choice]))
                                {
                                    if(choice == map.GetLocation().quizAnswer)
                                    {
                                        map.GetLocation().OnQuizGoodAnswer();
                                    }
                                    else
                                    {
                                        map.GetLocation().OnQuizBadAnswer();
                                    }
                                }
                            }
                        break;
                    }
                }
            } 
            // When the choice is equal to the total item it means exit has been chosen.
            while ( choice < menuItems.Count() - 1);
        }