public static void Menu(Player player) { Console.Write("{0}\nHP:{1}\nATK:{2}-{3}\nScore:{4}\nWhat are you going to do:", player.name, player.hp, player.minatk, player.maxatk, player.score); string todo = Console.ReadLine(); switch (todo) { case "adv": GameFuction.ToBattle(player, GameFuction.RandomEngage()); break; case "item": GameFuction.ShowItem(player); break; case "quit": GameFuction.GameQuit(); break; default: Console.Write("Unknow command\n"); Menu(player); break; } }
//public static void RandomAward(Player player) public static void Initialize() { Console.Write("Please input your name:"); string name = Console.ReadLine(); Player player = new Player(name); if (player != null) { Console.Write("Welcome {0} to the World of Omega!\n", player.name); GameFuction.Menu(player); } }
/*public void Equip(Item item) * { * this.hp += item.addhp; * this.atk += item.addatk; * this.equip = item; * Console.Write ("{0} equiped {1}.\n", this.name, this.equip.name); * }*/ public void UseItem(Item item) { if (this.inventory [item.name] > 0) { this.maxatk += item.addatk; this.minatk += item.addatk; this.hp += item.addhp; this.inventory [item.name]--; Console.Write("You used a {0}.\n", item.name); GameFuction.Menu(this); } else { Console.Write("You don't have that item\n."); GameFuction.Menu(this); } }
public static void ShowItem(Player player) { foreach (KeyValuePair <string, int> pair in player.inventory) { Console.WriteLine("{0}:{1} ", pair.Key, pair.Value); } Console.Write("input item name to use:"); string itemname = Console.ReadLine(); switch (itemname) { case "health potion": player.UseItem(new HealthPotion("health potion")); break; default: Console.Write("You don't have that item.\n"); GameFuction.Menu(player); break; } }
public static void Battle(int flag, Player player, Mob mob) { if (player.hp <= 0 || mob.hp <= 0) { if (player.hp <= 0) { GameFuction.GameOver(player); } else { Console.Write("You killed {0}\n", mob.name); if (mob.award != null) { mob.DeathAward(player); Console.Write("You've gained a {0}.\n", mob.award.name); } player.score += mob.score; GameFuction.Menu(player); } } else { if (flag == 0) { player.Atk(mob); flag = 1; System.Threading.Thread.Sleep(1000); Battle(flag, player, mob); } else { mob.Atk(player); flag = 0; System.Threading.Thread.Sleep(1000); Battle(flag, player, mob); } } }
public static void Main(string[] args) { GameFuction.Initialize(); }