public override int chooseOponent(int oponentIndex, List <Base> b) { Console.WriteLine($"Hero chose oponent at index {oponentIndex}"); object conv = b[oponentIndex]; Adder a = new Adder(); a.OnMultipleOfFiveReached += () => // oponent name in Event handler { Console.WriteLine("WOW"); if (conv is Dragon) { Dragon he = (Dragon)(conv); Console.WriteLine("His name in EVENT handler is " + he.getName()); } else if (conv is Hero) { // Get his name Hero he = (Hero)(conv); Console.WriteLine("His name in EVENT handler is " + he.getName()); } }; int iAnswer = a.Add(); // Hero can attack other Heroes, but Dragon cannot attack other dragons if (conv is Dragon) { // Get his name // Get his name Dragon he = (Dragon)(conv); // Console.WriteLine("His name is " + he.getName()); return(oponentIndex); } else if (conv is Hero) { // Get his name Hero he = (Hero)(conv); // Console.WriteLine("His name is " + he.getName()); return(oponentIndex); } return(-1); }
public override int chooseOponent(int oponentIndex, List <Base> b) { Console.WriteLine($"Hero has chosen his oponent at index {oponentIndex}"); object conv = b[oponentIndex]; Adder a = new Adder(); a.OnShouldFireEvent += () => // oponent name in Event handler { if (conv is Dragon) { Dragon he = (Dragon)(conv); Console.WriteLine("His name in EVENT HANDLER is " + he.getName()); } else if (conv is Hero) { // Get his name Hero he = (Hero)(conv); Console.WriteLine("His name in EVENT HANDLER is " + he.getName()); } }; int iAnswer = a.Add(); // Hero can attack other Heroes, but Dragon cannot attack other dragons if (conv is Dragon) { return(-1); // Dragon cannot attack other dragons } else if (conv is Hero) { return(oponentIndex); } return(-1); }