//Which Attack was chosen - baseras på int-indexet som valdes i YourAttack och OpponentAttack och returnerar valda attacken public Attack WhichAttack(int index) { Attack whichYourAttack = new Attack(); if (index == 1) { whichYourAttack = new Rock(); } else if (index == 2) { whichYourAttack = new Paper(); } else if (index == 3) { whichYourAttack = new Scissors(); } else if (index == 4) { whichYourAttack = new Lizard(); } else { whichYourAttack = new Spock(); } return(whichYourAttack); }
//Info om alla Attacker public void Attacks() { //Skapar instanser av attackerna och lägger till de i en lista så att man ska kunna köra deras metoder som visar dess info. Console.Clear(); List <Attack> attacks = new List <Attack>(); Rock rock = new Rock(); attacks.Add(rock); Paper paper = new Paper(); attacks.Add(paper); Scissors scissors = new Scissors(); attacks.Add(scissors); Lizard lizard = new Lizard(); attacks.Add(lizard); Spock spock = new Spock(); attacks.Add(spock); Snap snap = new Snap(); attacks.Add(snap); Block block = new Block(); attacks.Add(block); int attackIndex = 0; while (1 == 1) { Console.Clear(); //Använder samma princip som vid karaktärerna, men instanserar även den valda attackens transformationer så att den kan visa info om de. Console.WriteLine("The Attacks:"); for (int i = 0; i < 5; i++) { Console.WriteLine(i + 1 + ". " + attacks[i].name); if (i == attackIndex - 1) { attacks[i].Info(); Console.WriteLine(); Console.WriteLine("Transformations: "); attacks[i].Transform(); attacks[i].TransformationInfo(); } Console.WriteLine(); } //Visar info om The Behavioral Transformations, samma princip som förrut men med mer matte i indexeringarna då deras relaterade siffror är högre Console.WriteLine("The Behavioral Transformations: "); for (int i = 0; i < 2; i++) { Console.WriteLine(i + 6 + ". " + attacks[i + 5].name); if (i == attackIndex - 6) { attacks[i + 5].BehavioralInfo(); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("8. Go Back to Info Menu"); string attackSelection = Console.ReadLine(); bool attackSuccess = int.TryParse(attackSelection, out attackIndex); while (attackSuccess == false || attackIndex < 1 || attackIndex > 8) { Console.WriteLine("Please write the number of one of the attacks!"); attackSelection = Console.ReadLine(); attackSuccess = int.TryParse(attackSelection, out attackIndex); } Console.WriteLine(); if (attackIndex == 8) { break; } } }