Character PlayerOne = new Character; PlayerOne = new BladeWarrior(); PlayerOne = new FistWarrior(); PlayerOne = new Archer(); PlayerOne = new RedMage(); PlayerOne = new BlueMage();
I know through polymorphism, a BladeWarrior can be a Character but it cant be the other way around. My problem is that when I try to access an element of an array. Player for example, I cant access functions and variables from the BladeWarrior class. It's only letting me access variables and functions from the Character class which the BladeWarrior class inherits from.
I'm going to need to be able to access Bladewarrior functions/variables if Im going to want 2 characters to fight.
I was thinking I could use the "as" function to set PlayerOne as the specific object . Not exactly like this:
string s = objArray[i] as string;
The line of code above is just to get an idea of which "as" Im talking about.
What is a solution to this problem? Your time and effort is much appreciated. Thank you in advanced.