36 lines
No EOL
951 B
C#
36 lines
No EOL
951 B
C#
using Domain;
|
|
|
|
namespace Presenter {
|
|
public class ExpressionClick {
|
|
private readonly Score _score;
|
|
private readonly IScoreView _view;
|
|
private readonly IRoseGrow _grow;
|
|
private readonly IInputCallback _onInputReceived;
|
|
private readonly IRoseSpawner _spawner;
|
|
|
|
private bool CanSpawn => _score.Value % (_score.GrowIterations * _score.SpawnRate) == 0;
|
|
|
|
public ExpressionClick(Score score, IScoreView view, IRoseSpawner spawner, IRoseGrow grow, IInputCallback inputCallback) {
|
|
_score = score;
|
|
_view = view;
|
|
_spawner = spawner;
|
|
_grow = grow;
|
|
_onInputReceived = inputCallback;
|
|
}
|
|
|
|
public void Execute() {
|
|
_score.Add();
|
|
_view.UpdateView(_score.Value);
|
|
_onInputReceived.OnInputReceived();
|
|
|
|
if (CanSpawn) {
|
|
if(_score.Roses > Score.InitialRosesThreshold)
|
|
_spawner.SpawnRose();
|
|
else
|
|
_spawner.SpawnInitialRose();
|
|
}
|
|
if (_score.Value % _score.GrowIterations == 0)
|
|
_grow.GrowStep();
|
|
}
|
|
}
|
|
} |