How can I map each element of _CharacterRow (a List) to each private var in CharObject (a class)?
I assume I’ll need to dynamically build a List out of the private elements of CharOject but how can this be done?
Also, is this the way I should be going about this?
I’m aware I can propbably save a lot of time and effort by simply using a List within CharObject instead of idividual variables, but I’m not sure it would result in the effect I want.
Below are detailes for better understanding.
I have a List I call _CharacterRow. This stores information about a character for example:
_CharacterRow[0] = 1
_CharacterRow[1] = MyCharName
_CharacterRow[2] = 0
_CharacterRow[3] = 0
_CharacterRow[4] = 0-0-0-0
The elements of this list represent the following:
id
name
currentHP
maxHP
items
items is a string containing ids separated by “-”'s. My client recognizes these ids after being split to populate an inventory.
Now here’s where I can use the help. I have a CharObject class that I want this data to be stored in. As it stands now, all the variables are separate and represent an element of the List _CharacterRow.
Again, for example:
public class CharObject
{
private int _id;
private string _name;
private Stat _hp;
private sting _items;
// Public Get/Set functions for each var below...
}
Notice the Stat type of _hp. Stat looks as follows:
public class Stat
{
private int _current;
private int _max;
private int _temp;
// Public Get/Set functions for each var below...
}