Hello.
I'm making a political satire strategy game, similar to that of Plants vs Zombies. For this I need a working round timer script, however the code I wrote doesn't seem to be working properly. I want to avoid coroutines, but if I must use them, then I will.
void StartRound(float RoundTime)
{
RoundTime = 60;
InvokeRepeating("GenerateMexican", 5, 5);
Debug.Log("Round started");
do
{
RoundTime -= Time.deltaTime;
if (RoundTime <= 0)
{
CancelInvoke("GenerateMexican");
Debug.Log("Round ended");
}
} while (RoundTime > 0);
}
(The function is invoked by the click of a button)
The problem is, the round immediately starts and ends, the value, as I watch it in the editor, never changes either, even if I set it to something outside of the range of 0-60. I am unsure why this is happening.
Thanks in advance!
Sidenote: The function I'm invoking is GenerateMexican, not intended to be offensive, it's just a satire game about Mexicans revolting against Donald Trump.