-2
I’m having a little problem and I can’t seem to solve it.
I have a class (matrix 0~999) called pTest
, she is already instantiated everything straight.
After I instantiate I copy a structure that is from the player (contains information of name, level, etc.) of another class to link within the pTest
.
For example:
pTest[0].Player = g_kNPCGener.kMonster[0].MOB;
If I do so in a method:
pTest[0].Player = g_kNPCGener.kMonster[0].MOB;
pTest[1].Player = g_kNPCGener.kMonster[0].MOB;
pTest[0].Player.Name = "Grim";
the pTest[1].Player.Name
will also be worth "Grim".
The structure pTest[0].Player
is the same structure (struct) of Monster.List[0].NPC
;
public class TmController
{
public MobTest[] pTest = new MobTest[1000];
// methods..
public void init()
{
pTest[0].Player = g_kNPCGener.kMonster[0].MOB;
pTest[0].Mode = 1;
pTest[1].Player = g_kNPCGener.kMonster[0].MOB;
pTest[1].Mode = 1;
}
public TmController()
{
for (int i = 0; i < pTest.Length; i++)
{
pTest[i] = new MobTest();
}
}
}
public class MobTest : TmController
{
public STRUCT_MOB Player;
public int Mode;
public MobTest()
{
Player = STRUCT_MOB.Clear();
Mode = 0;
}
}
remembering that if I change the property Mode
of the object pTest[0]
, for example: pTest[0].Mode = 5
, it makes no change in pTest[1].Mode
.
How to solve this?