Beispiel #1
0
        public int FightMenu(ref Player player)
        {
            string        input;
            int           choice;
            int           damage = 0;
            List <string> menu   = new List <string>();

            menu.Add(ACTION_BASICATTACK);
            menu.Add(ACTION_PUNCH);
            menu.Add(ACTION_KICK);

            do
            {
                if (!player.IsAlive())
                {
                    Program.Dead();
                    return(0);
                }

                for (int i = 0; i < menu.Count(); i++)
                {
                    Console.WriteLine("{0} - {1}", i + 1, menu[i]);
                }
                Console.WriteLine("Please enter your choice: 1 - {0}", menu.Count());
                input = Console.ReadLine();
            } while (!int.TryParse(input, out choice) || (choice > menu.Count() || choice < 0));

            choice -= 1;

            switch (menu[choice])
            {
            case ACTION_BASICATTACK:
                damage = player.BasicAttack(ref player, 0);
                Console.WriteLine("You have dealt {0} damage!", damage);
                return(damage);

            case ACTION_PUNCH:
                damage = player.Punch(ref player, 0);
                Console.WriteLine("You have dealt {0} damage!", damage);
                return(damage);

            case ACTION_KICK:
                damage = player.Kick(ref player, 0);
                Console.WriteLine("You have dealt {0} damage!", damage);
                return(damage);
            }
            return(damage);
        }