// So my 3 generals classes :
public class Spell {
private Element[] elements;
public float isElementGlyph(List<Vector2> dot)
{
return elements[0].glyph.IsInside(point);
}
}
public class Element {
public readonly Glyph glyph;
}
public class Glyph {
private List<List<Vector2>> polygon;
...
public isInside(List<Vector2> dot) {...}
}
// Then i have something like that
public class Fire : Element {
public Fire()
{
glyph = new Glyph();
...
}
}
public class FireBall : Spell {
public FireBall(elements) {
this.elements = elements
}
}
// And so in another class :
public class Module {
getSpell(List<Vector2> dot) {
*...*
}
}
#get class by his attribute
1 messages ยท Page 1 of 1 (latest)
so Vector2 is a grid position?
and getSpell trying to? I just trying to figure out what spell do you want to find with a Vector2
Yea and no ๐ no because the user will draw a glyph but we don't really care about the initial position
I want to get the correct spell because i have like FireBall, FireTornade and idk FireTorch (some invention because there is only FireBall xD but there will be more)
hm
Ok i misstype but that was a list of list of vector so my bad
still dont really get it, but you need to keep track of the instances either way
So i need to create an instance per spell ?
somehow you gotta access the spell info, if you store it inside, or you have to make that data static
if you need to instantiate a class (for whatever reason) for each spell casting, usually there is a separate class like SpellDefinition that contains the data
the caster class just uses a reference to the definition to access its information
because you dont want each spell to contain ALL data
How will the SpellDefinition be like ?
and yea i want a spell to just have his information and not the info of another spell
how are you storing your other data? where you reading them from? ScriptableObjects, database, json, etc?
if you hardcoding everything then this is though 
Well for now it's hardcoding but then it will be json
a json for all the element and another one for all the spells
to provide some help, right now, the best you can do without turning your structure upside down is to make a singleton class that you can access
and make a List<Spell> which contains one instance of your spells
and you can iterate through and look for the right one