Hi all, I’ve run into something bizar and was hoping someone could take a look to see if I’m missing something obvious.
There are a couple of pieces of information that have led me to the conclusion posted in the title.
First of all, I have no error messages. As far as I can tell, there is nothing erroneous about the code.
Second, when using Visual Studio to debug with breakpoints, everything runs as expected, there aren’t any lines of code being skipped when they shouldn’t be.
Thirdly, and this is what led me to make a post here, when I have the setter property of the relevant variable print the new value to the console every time it changes, it never goes above 1 (it should), but also never goes back to 0 (default).
So, hopefully that gave a reasonable image of the issue I’m having, if not please feel free to ask for more info.
Now on to the code that I’m using, first of all, the get/set properties:
private int _currWave;
private int currWave
{
get => _currWave;
set {
_currWave = value;
Debug.Log("currWave = " + value);
}
}
Next, there are only two places the variable value could possibly be modified (in the same class).
When going to a new wave of enemies:
public void nextWave()
{
if (!this.hasEnemies)
return;
try
{
waves[currWave].Activate();
}
catch (IndexOutOfRangeException)
{
if (!infiniteWaves)
Finished();
else
Reset();
} finally
{
currWave++;
}
}
When the room is enabled or reset:
private void OnEnable()
{
Reset();
}
public void Reset()
{
if (!hasEnemies)
return;
currWave = 0;
finished = false;
foreach (Wave wave in waves)
wave.Reset();
nextWave();
}
Here is a screenshot of the console outputs I’m getting:
The only conclusion I can think of right now is that the variable somehow returns to a value of 0, because it never goes above 1. But at the same time, the setter property should be logging that to the console if/when it happens, but it never does…
I am at a complete loss, if you have any idea how this could be happening please let me know.
All replies are appreciated!