示例#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);
        }