public Player() { this.name = ""; this.level = FileSetup.LevelRead(Game.levelFile); this.health = 100; hunger = 100; this.entityType = EntityType.PLAYER; storage = new Item[Files.GetFileSize(Game.itemFile, false)]; coins = FileSetup.CoinRead(Game.coinFile); }
public Player(string name, string itemPlayerFile) { this.name = name; this.level = FileSetup.LevelRead(Game.levelFile); this.health = 100; hunger = 100; this.entityType = EntityType.PLAYER; storage = new Item[Files.GetFileSize(itemPlayerFile, false)]; coins = FileSetup.CoinRead(Game.coinFile); age = 0; }
// Will be used to start the game in the main function public static void Run() { UserInput userMessage = new UserInput(""); UserInput userInt = new UserInput(0); string message; FileSetup.PlayerFileRead(ref player, ref npc, playerFile, itemFile); if (monsters.Length <= 0) { FileSetup.MonsterFileWrite(ref monsters, monsterFile); } FileSetup.MonsterFileRead(ref monsters, monsterFile); player.name = userMessage.GetUserMessage("What is your name? "); player.age = userInt.GetUserInt("How old are you? "); player.level = FileSetup.LevelRead(levelFile); bool run = true; // Infinite loop used to make it so the game keeps running while (run) { Console.Clear(); Console.Write("What would you like to do? Explore or visit the shop? "); message = Console.ReadLine().ToLower(); // Used to give the user some options switch (message) { case "explore": Console.Clear(); MonsterExplore(); if (player.health <= 0) { Console.WriteLine("You have died. The program will now close."); Thread.Sleep(2500); run = false; } break; case "shop": Console.Clear(); Shop(); break; default: break; } } }