refactor: Moved spawn logic to the presenter
This commit is contained in:
parent
859d34e3bb
commit
dd9640fc39
4 changed files with 9 additions and 67 deletions
|
@ -7,9 +7,6 @@
|
|||
|
||||
public float GrowPercentage { private set; get; }
|
||||
|
||||
public bool NeedsToSpawn { private set; get; }
|
||||
public bool NeedsToAnimate { private set; get; }
|
||||
|
||||
public Model(int spawnRate, int growIterations) : this(0, spawnRate, growIterations) { }
|
||||
|
||||
public Model(int score, int spawnRate, int growIterations) {
|
||||
|
@ -20,14 +17,13 @@
|
|||
|
||||
public void AddScore() {
|
||||
Score++;
|
||||
NeedsToAnimate = NeedsToSpawn = false;
|
||||
|
||||
if (Score % GrowIterations == 0) {
|
||||
GrowPercentage = Score / (float)(SpawnRate * GrowIterations);
|
||||
NeedsToAnimate = true;
|
||||
float relativeScore = Score % (GrowIterations * SpawnRate);
|
||||
if (relativeScore == 0 && Score != 0)
|
||||
relativeScore = GrowIterations * SpawnRate;
|
||||
GrowPercentage = relativeScore / (SpawnRate * GrowIterations);
|
||||
}
|
||||
if (Score % (SpawnRate * GrowIterations) == 0)
|
||||
NeedsToSpawn = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue