public static void GameControls() { ConsoleOutput.GameDescription(); Location currentLocation = Location.MapSetUp(); Avatar avatar = Avatar.setupAvatar(); Enemy enemy = Enemy.SetupEnemy(); ConsoleOutput.DescribeLocation(currentLocation); for(;;) { SplitInput(); switch (words[0]) { case "north": case "n": // testMethod(direction, avatar, enemy); if (currentLocation.North!= null) { if(Location.RoomOpen(currentLocation.North, avatar) == false) { break; } else { currentLocation = currentLocation.North; Avatar.AvatarMove(currentLocation, avatar, enemy); ControlCounter ++; } } else { Console.WriteLine("In diese Richtung gibt es keinen Weg! Bitte gehe in eine andere Richtung!"); } break; case "east": case "e": if (currentLocation.East!= null) { if(Location.RoomOpen(currentLocation.East, avatar) == false) { break; } else { currentLocation = currentLocation.East; Avatar.AvatarMove(currentLocation, avatar, enemy); ControlCounter ++; } } else { Console.WriteLine("In diese Richtung gibt es keinen Weg! Bitte gehe in eine andere Richtung!"); } break; case "south": case "s": if (currentLocation.South!= null) { if(Location.RoomOpen(currentLocation.South, avatar) == false) { break; } else { currentLocation = currentLocation.South; Avatar.AvatarMove(currentLocation, avatar, enemy); ControlCounter ++; } } else { Console.WriteLine("In diese Richtung gibt es keinen Weg! Bitte gehe in eine andere Richtung!"); } break; case "west": case "w": if (currentLocation.West != null) { if(Location.RoomOpen(currentLocation.West, avatar) == false) { break; } else { currentLocation = currentLocation.West; Avatar.AvatarMove(currentLocation, avatar, enemy); ControlCounter ++; } } else { Console.WriteLine("In diese Richtung gibt es keinen Weg! Bitte gehe in eine andere Richtung!"); } break; case "take": case "t": try { if(words[1] != "") { Items.TakeItem(words[1],currentLocation, avatar); } else { ConsoleOutput.TakeWrongInput(); } } catch { ConsoleOutput.TakeWrongInput(); } break; case "drop": case "d": try { if(words[1] != "") { Items.DropItem(words[1],currentLocation); } else { ConsoleOutput.DropWrongInput(); } } catch { ConsoleOutput.DropWrongInput(); } break; case "Inventory": case "i": Items.ShowInventory(avatar); break; case "look": case "l": ConsoleOutput.DescribeLocation(currentLocation); break; case "used": case "u": try{ if(words[1] != "") { Items.UseItem(words[1]); } else { ConsoleOutput.UsedWrongInput(); } } catch { ConsoleOutput.UsedWrongInput(); } break; case "help": case "h": Console.WriteLine("help(h), look(l), inventory(i), take(t) item, drop(d) item, used(u) item (mit used kannst du im Sekretariat eine Bombe bauen),getinformation(g), quit(q)"); break; case "quit": case "q": Environment.Exit(0); break; case "attack": case "a": try { if(words[1] != "") { if(enemy.CurrentRoom == avatar.CurrentRoom) { Attack.AttackEnemy(words[1] ,currentLocation, avatar, enemy); } else { Console.WriteLine("Du kannst diesen Knopf nicht benützten. Bitte drücke h für Hilfe!"); break; } } } catch { ConsoleOutput.AttackWrongInput(); } break; case "getinformation": case "g": try { if(words[1] != "") { Items.GetInformation(words[1]); } else { Console.WriteLine("Falsche eingabe"); } } catch { } break; default: Console.WriteLine("Du kannst diesen Knopf nicht benützten. Bitte drücke h für Hilfe!"); break; } } }
public static void AttackEnemy(string _words, Location location, Avatar avatar, Enemy enemy) { Random rnd = new Random(); string [] _arr = new string[] { "stein", "schere", "papier" }; Console.WriteLine("Dieser Kampf basiert auf Stein, Schere,Papier."); if (_words.ToLower() == enemy.Name.ToLower()) { for (;;) { int i = rnd.Next(0, 3); Console.WriteLine("Wähle weise: "); string Input = Console.ReadLine().ToLower(); if (Input == "q" || Input == "quit") { Environment.Exit(0); } else if (Input != _arr[0] && Input != _arr[1] && Input != _arr[2]) { Console.WriteLine("Wrong Input."); } else if (Input == _arr[i]) { ConsoleOutput.AttackDraw(); } else if ((Input == _arr[0]) && (_arr[1] == _arr[i]) || (Input == _arr[1]) && (_arr[2] == _arr[i]) || (Input == _arr[2]) && (_arr[0] == _arr[i])) { enemy.Health = enemy.Health - 1; ConsoleOutput.EnemyHit(Input, _arr[i]); } else { Avatar.Characters["Hatice"].Health = Avatar.Characters["Hatice"].Health - 1; ConsoleOutput.AvatarHit(Input, _arr[i]); } Console.WriteLine(enemy.Name + " Lebenspunkte: " + enemy.Health); Console.WriteLine(Avatar.Characters["Hatice"].Name + " Lebenspunkte: " + Avatar.Characters["Hatice"].Health); if (enemy.Health == 0) { enemy.Life = false; ConsoleOutput.AvatarWin(); Items.DropLoot(_words, location, enemy); break; } else if (Avatar.Characters["Hatice"].Health == 0) { ConsoleOutput.AvatarLose(); Environment.Exit(1); } } } else { Console.WriteLine("Du hast einen Falschen Namen eingegeben"); } }