示例#1
0
        static void Main(string[] args)
        {
            Player          player  = new Player("David", 1, 9, 200, 10);
            SpecificMonster monster = new SpecificMonster("Evil", 0, 40, 10);

            Meny.GameMeny(player, monster);
        }
示例#2
0
        public static void Battle(Player p, SpecificMonster s)
        {
            bool keepGoing = true;

            while (keepGoing)

            {
                Console.WriteLine($"Uh oh! A {s.Name} appeared!");
                Console.WriteLine($"You hit the monster, dealing {p.Dmg} damage");
                Console.WriteLine("Uuoooah *slurp*");
                Console.WriteLine($"The monster hits you, dealing {s.Dmg} damage");
                LooseHealthPlayer(p, s);
                LooseHealthMonster(p, s);
                if (BattleWinner(p, s) && p.Hp != 0)
                {
                    GetExp(p, s);

                    break;
                }
                else if (p.Hp == 0)
                {
                    Console.WriteLine("You were killed by the monster :(");
                    break;
                }

                Console.WriteLine($"{p.Name}: {p.Hp}");
                Console.WriteLine($"{s.Name}: {s.Hp}");
                Console.WriteLine("[press enter to continue]");
                Console.ReadLine();
            }
        }
示例#3
0
        public static bool BattleWinner(Player p, SpecificMonster s)
        {
            if (s.Hp <= 0)
            {
                Console.WriteLine($"You killed the monster, gaining {s.Exp} experience! \n");

                return(true);
            }

            return(false);
        }
示例#4
0
        public static void GameMeny(Player p, SpecificMonster s)
        {
            GameHeader();

            GameData data = new GameData();

            List <SpecificMonster> monsterList = data.TestData();

            Random random = new Random();

            while (true)
            {
                if (p.Hp == 0)
                {
                    break;
                }

                if (p.Lvl == 10)
                {
                    Console.WriteLine("Congratulations, you won the game!");
                    break;
                }


                Console.WriteLine("1. Go Adventuring");
                Console.WriteLine("2. Show details about your character");
                Console.WriteLine("3. Exit game");
                Console.Write("> ");
                string input = Console.ReadLine();

                switch (input)
                {
                case "1":
                    if (GameMechanics.AdventureChance())
                    {
                        s = monsterList[0];     // random.Next(1, 5)

                        GameMechanics.Battle(p, s);
                    }
                    break;

                case "2":
                    break;

                case "3":
                    break;
                }
            }
        }
示例#5
0
 public static void LooseHealthMonster(Player p, SpecificMonster s)
 {
     s.Hp = s.Hp - p.Dmg;
 }
示例#6
0
 public static void LooseHealthPlayer(Player p, SpecificMonster s)
 {
     p.Hp = p.Hp - s.Dmg;
 }
示例#7
0
 public static void GetExp(Player p, SpecificMonster s)
 {
     p.Exp += s.Exp;
     LvlUp(p);
     Console.WriteLine($"You are level {p.Lvl}, and you have {p.Exp} exp and {p.Hp} hp");
 }