Roses/Assets/Scripts/Presenter/SaveSystem/LoadGame.cs
2024-04-17 10:16:55 +02:00

27 lines
No EOL
805 B
C#

using Domain;
namespace Presenter.SaveSystem {
public class LoadGame {
private readonly IGameRepository _repository;
private readonly Score _score;
private readonly IExpressionInput _expressionInput;
private readonly IRoseSpawner _spawner;
public LoadGame(IGameRepository repository, Score score, IExpressionInput expressionInput, IRoseSpawner spawner) {
_repository = repository;
_score = score;
_expressionInput = expressionInput;
_spawner = spawner;
}
public void Run() {
Score newScore = _repository.LoadScore();
_score.SetFromOtherScore(newScore);
_expressionInput.UpdateView(_score.Value, _score.GrowPercentage);
int roses = _score.Value / (_score.SpawnRate * _score.GrowIterations);
for (int i = 0; i < roses; i++)
_spawner.SpawnRose();
}
}
}