Im writing a really simple class that is to be the foundation of an adventuregame in D3D... Just for me to learn DirectX
Anyway I have defined an abstract baseclass "Entity" which can represent any given object in the world, rock, bridge, weapon etc.
In this baseclass I have an abstract sub called "WhenSpellCasted" which has these parameters
Spell as CSpell <-- the spell casted
Strength as double <--how strong the spell was (depending on the magic capabilities of the caster
Naturally I want any item to respond one way or another to a spell, perhaps reveal hidden items, or nothing happens...
Then I create an object CMan : inherits Entity
This class has lots of properties that a man has... and I also implement then sub "WhenSpellCasted" that looks kinda like this
VB Code:
public sub WhenSpellcasted(byval spell as cspell, byval strength as double) 'The spell object affects the attributes of the object it was cast on spell.applymagic(Me,strength) end sub
Now here is the problem:
I define a class of magician
VB Code:
public class CMagician : inherits Entity private m_Mana as double = 0 ppublic Sub CastSpell(byval target as Entity, byval strength as double) target.WhenSpellCasted(myfirespell,10)
Here I get an error saying that the entity object can't be implicitly converted to a CMan object...
Why is that? The whole point of using base classes if for the purpose Im using it as...?
Kidn regards
Henrik




Reply With Quote