test: main model
This commit is contained in:
parent
f721cee708
commit
859d34e3bb
5 changed files with 114 additions and 13 deletions
|
@ -3,26 +3,31 @@
|
|||
public int Score { private set; get; }
|
||||
|
||||
public readonly int SpawnRate;
|
||||
private bool _needsToSpawn;
|
||||
public readonly int GrowIterations;
|
||||
|
||||
public Model(int spawnRate) : this(0, spawnRate) { }
|
||||
public float GrowPercentage { private set; get; }
|
||||
|
||||
public Model(int score, int spawnRate) {
|
||||
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) {
|
||||
Score = score;
|
||||
SpawnRate = spawnRate;
|
||||
GrowIterations = growIterations;
|
||||
}
|
||||
|
||||
public void AddScore() {
|
||||
Score++;
|
||||
if (Score % SpawnRate == 0)
|
||||
_needsToSpawn = true;
|
||||
}
|
||||
NeedsToAnimate = NeedsToSpawn = false;
|
||||
|
||||
public bool NeedsToSpawn() {
|
||||
bool needs = _needsToSpawn;
|
||||
_needsToSpawn = false;
|
||||
|
||||
return needs;
|
||||
if (Score % GrowIterations == 0) {
|
||||
GrowPercentage = Score / (float)(SpawnRate * GrowIterations);
|
||||
NeedsToAnimate = true;
|
||||
}
|
||||
if (Score % (SpawnRate * GrowIterations) == 0)
|
||||
NeedsToSpawn = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue