Spawn-managed Spawner objects
GameSystem object that summarizes residual machine score pause control flags etc.
Assume you have
Spawner only needs to reference the GameSystem object.
The code that changes Spawner's behavior depending on the score is Spawner's own behavior, so
in the Spawner.Move logic (MonoBehavior.Update if you are using it directly)
Check GameSystem.Score and change the spawn control parameters when the conditions are met.
Method 1: If you want to add one point at a time, you can use the remainder of the division.
int score;
voidAddScore()
{
int n = 20;
score++;
if(score%n==0)
{
AddSpawnRate();
}
}
Method 2: Introduce variables for determination if additional points change.
int score;
int bucket;
voidAddScore(int value)
{
int n = 20;
score+=value;
bucket+=value;
while(bucket>=n)
{
bucket-=n;
AddSpawnRate();
}
}
© 2024 OneMinuteCode. All rights reserved.