OK, I have the following two types (I've stripped them down for ease of reading):
I have a list of 10 Master Units (e.g. tanks, planes etc.) with preloaded data - these just store the info for each type of unit.
I'm then trying to create a list of player units which inherit the data from Master Units (e.g. I don't want to have to reload the same data) but I'm getting an error as indicated below (again, I've stripped this down a bit):
So basically I'm trying to create a new TPlayerUnit from an existing TMasterUnit so the TPlayerUnit not only inherits the type definition but the data as well. I'm still new to OOP, but I the way I understand it, this is acheivable, but I guess the syntax is incorrect.
Does anyone know the correct way of doing this?
Type TMasterUnit Field name$, description$, img:TImage Field unitType$, squadSize, ap, minSpeed, maxSpeed, radius, hp, defense, bays Field hit, hitType$, attacks, shots, minDamage, maxDamage, minRange, maxRange End Type Type TPlayerUnit Extends TMasterUnit Field player, curStatus Field x, y, rot End Type
I have a list of 10 Master Units (e.g. tanks, planes etc.) with preloaded data - these just store the info for each type of unit.
I'm then trying to create a list of player units which inherit the data from Master Units (e.g. I don't want to have to reload the same data) but I'm getting an error as indicated below (again, I've stripped this down a bit):
For Local p = 1 To 4 For Local mu:TMasterUnit = EachIn masterUnits Local pu:TPlayerUnit = mu 'ERROR HERE 'unable to convert from TMasterUnit to TPlayuerUnit pu.player = p ListAddLast(playerUnits, pu) Next Next
So basically I'm trying to create a new TPlayerUnit from an existing TMasterUnit so the TPlayerUnit not only inherits the type definition but the data as well. I'm still new to OOP, but I the way I understand it, this is acheivable, but I guess the syntax is incorrect.
Does anyone know the correct way of doing this?