static void Main(string[] args) { Environment.player = new Player(); Environment.Environments[0] = new Village(); Environment.Environments[1] = new Forest(); Environment.Environments[2] = new Ice(); (Environment.GetEnvironment("Village") as Village).Start(); }
/// <summary> /// logiken för varje tile som spelaren går till /// ska den köra en encounter? /// har spelaren hittat något quest-relaterat /// ska spelaren gå till en annan värld /// </summary> /// <param name="player">referens till spelaren</param> /// <param name="doEncounter">true/false för att göra encounter</param> public void Enter(ref Player player, bool doEncounter) { if (Destination.Equals(Zones.None)) { Symbol = player.Symbol; double chance = Program.Random.NextDouble(); if (doEncounter && chance >= ENCOUNTER_CHANCE) { EncounterData encounter = new EncounterData(); encounter.Generate(Zone); if (encounter.enemy != null) { Combat.Start(ref player, ref encounter.enemy); } if (player.Quest.KillObjective != null) { if (player.Quest.KillObjective.Name.Equals(encounter.enemy.Name)) { player.Quest.Complete(); } } if (encounter.loot != null && encounter.enemy.Dead) { bool validInput = false; while (!validInput) { Console.Clear(); Console.WriteLine(string.Format("The {0} dropped {1}.\n" + "Would you like to pick it up?", encounter.enemy.Name, encounter.loot.Name)); Console.Write("Y/N: "); string input = Console.ReadLine().ToLower(); switch (input) { case "y": validInput = true; player.Inventory.AddItem(encounter.loot); break; case "yes": validInput = true; player.Inventory.AddItem(encounter.loot); break; case "n": validInput = true; break; case "no": validInput = true; break; } } } } else if (doEncounter && Zone.Equals(Zones.Forest)) { if (player.Quest.CollectObjective == null) { return; } chance = Program.Random.NextDouble(); if (chance >= 0d && player.Quest.CollectObjective.Name.Equals("Lumber")) { if (player.Inventory.GetItemByName("Axe") != null) { bool validInput = false; while (!validInput) { Console.Clear(); Console.WriteLine("You've found a pristine tree to chop down.\n" + "You have an axe in your backpack, do you want to chop it down?"); Console.Write("Y/N: "); string input = Console.ReadLine().ToLower(); switch (input) { case "y": validInput = true; player.Inventory.AddItem(new Lumber()); break; case "yes": validInput = true; player.Inventory.AddItem(new Lumber()); break; case "n": validInput = true; break; case "no": validInput = true; break; } } } else { Console.WriteLine("You've found a pristine tree to chop down.\n" + "But you seem to lack the proper tools to chop it down."); } } } } else { switch (Zone) { case Zones.Village: (Environment.GetEnvironment(Destination.ToString()) as Forest).Start(this); break; case Zones.Forest: if (Destination == Zones.Ice) { if (Environment.player.Inventory.GetItemByName("Spike-shoes") != null) { (Environment.GetEnvironment(Destination.ToString()) as Ice).Start(this); } else { Console.Clear(); Console.WriteLine("You can't go here yet, it's too dangerous.\n" + "Get yourself a pair of spike-shoes."); Console.WriteLine("\nPress <Enter> to continue..."); Console.ReadLine(); (Environment.GetEnvironment("Forest") as Forest).Start(new Tile(0, 0, WALKABLE, Zones.Ice)); } } else { (Environment.GetEnvironment(Destination.ToString()) as Village).Start(this); } break; case Zones.Ice: (Environment.GetEnvironment(Destination.ToString()) as Forest).Start(this); break; } } }