I’m pretty advent on solving my own problems and I’ve come a long way with C# in just a couple months. Now, however, I have hit a wall. It’s going to be hard to show you examples as I’m running about 30 scripts right now and a hierarchy / inheritance system.
http://puu.sh/atTME/1926fde149.png In my hierarchy, I have these enemies which are assigned to a list. This list is used to instantiate the enemies into the scene instead of instantiating from prefab. There are no scene changes btw.
I have a level up system for each enemy that happens after every 3 waves which I do like this:
if (_levelCounter % 3 == 0)
{
for (int i = 0; i < 5; i++)
{
grabNormalEnemies[i].MStatSet.LevelUp();
print(grabNormalEnemies[i].name + " " + grabNormalEnemies[i].MStatSet.Health.Max);
_levelStopper++;
if (_levelStopper == 5)
{
_levelCounter++;
}
}
}
According to the print, the health stat is increasing. However, the actual value I have showing on the object remains unchanged.
void Awake()
{
disableMovement = true;
_dmgShow = "Critical Hit!" + "\n" + (_gunPowMaxDesu * 3).ToString();
showDMG.text = _dmgShow;
showDMG.text = "";
_moveDesu = Random.Range(1, 5);
_statSet = Zombie1Stat.zombie1Spawn();
_shootAnimCur = (MStatSet.moveSPD.Max * MStatSet.moveSPD.Current) / MStatSet.moveSPD.Max;
animation["Walk"].speed = _shootAnimCur;
print(MStatSet.Health.Max);
}
As you can see, when the new enemy instantiates, I have a print to show me its health max. It still shows the base value despite the level up happening.
public void LevelUp()
{
Health.EnemyIncrease();
armor.EnemyIncrease();
Power.EnemyIncrease();
moveSPD.EnemyIncrease();
points.EnemyIncrease();
}
Here is my levelup method in the 2nd part of the hierarchy. The base class is here (which uses getters and setters)
public void EnemyIncrease()
{
Max += IncreaseRate;
Current = Max;
if (Max <= Min)
{
Max = Min;
}
if (iMax > 0)
{
iMax += iIncreaseRate;
iCurrent = iMax;
}
}
Since I am instantiating from the hierarchy, not prefabs. I’m wondering why my level up is not actually saving the values that it is changing to the object itself? Why are my enemies still showing the base stats and not actually changing at all?
Please ask specific questions if you need more info. I have a lot of code written so I am trying not to clutter the post.