Loading Assets/Scripts/Domain/Model.cs +4 −8 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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; } } } No newline at end of file Assets/Scripts/Presenter/ExpressionClick.cs +4 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ namespace Presenter { private readonly IExpressionInput _view; private readonly IRoseSpawner _spawner; private bool CanSpawn => _model.Score % (_model.GrowIterations * _model.SpawnRate) == 0; public ExpressionClick(Model model, IExpressionInput view, IRoseSpawner spawner) { _model = model; _view = view; Loading @@ -16,9 +18,9 @@ namespace Presenter { _model.AddScore(); _view.UpdateView(_model.Score); if (_model.NeedsToSpawn) { if (CanSpawn) _spawner.SpawnRose(); } } } } No newline at end of file Assets/Scripts/Tests/ModelTests.cs +0 −54 Original line number Diff line number Diff line Loading @@ -3,60 +3,6 @@ using NUnit.Framework; namespace Tests { public class ModelTests { [Test] public void NoPress_NoAnimation() { Model sut = new(20, 5); Assert.IsFalse(sut.NeedsToAnimate); } [Test] public void NotEnoughPresses_NoAnimation() { Model sut = new(20, 5); sut.AddScore(); Assert.IsFalse(sut.NeedsToAnimate); } [Test] public void EnoughPresses_Animation() { Model sut = new(20, 5); for (int i = 0; i < 5; i++) sut.AddScore(); Assert.IsTrue(sut.NeedsToAnimate); } [Test] public void NoPress_NoSpawn() { Model sut = new(20, 5); Assert.IsFalse(sut.NeedsToSpawn); } [Test] public void NotEnoughPresses_NoSpawn() { Model sut = new(20, 5); sut.AddScore(); Assert.IsFalse(sut.NeedsToSpawn); } [Test] public void EnoughPresses_Spawn() { Model sut = new(20, 5); for (int i = 0; i < 20 * 5; i++) { sut.AddScore(); } Assert.IsTrue(sut.NeedsToSpawn); } [Test] public void OneIteration_UpdatesGrowPercentage() { Model sut = new(5, 5); Loading Assets/Scripts/View/UI/ExpressionInput.cs +1 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,7 @@ namespace View.UI { } public void UpdateView(int score) { int frameDifference = score % _model.SpawnRate; animator.PlayUntil(frameDifference / (float)_model.SpawnRate); animator.PlayUntil(_model.GrowPercentage); text.text = score.ToString(); } } Loading Loading
Assets/Scripts/Domain/Model.cs +4 −8 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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; } } } No newline at end of file
Assets/Scripts/Presenter/ExpressionClick.cs +4 −2 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ namespace Presenter { private readonly IExpressionInput _view; private readonly IRoseSpawner _spawner; private bool CanSpawn => _model.Score % (_model.GrowIterations * _model.SpawnRate) == 0; public ExpressionClick(Model model, IExpressionInput view, IRoseSpawner spawner) { _model = model; _view = view; Loading @@ -16,9 +18,9 @@ namespace Presenter { _model.AddScore(); _view.UpdateView(_model.Score); if (_model.NeedsToSpawn) { if (CanSpawn) _spawner.SpawnRose(); } } } } No newline at end of file
Assets/Scripts/Tests/ModelTests.cs +0 −54 Original line number Diff line number Diff line Loading @@ -3,60 +3,6 @@ using NUnit.Framework; namespace Tests { public class ModelTests { [Test] public void NoPress_NoAnimation() { Model sut = new(20, 5); Assert.IsFalse(sut.NeedsToAnimate); } [Test] public void NotEnoughPresses_NoAnimation() { Model sut = new(20, 5); sut.AddScore(); Assert.IsFalse(sut.NeedsToAnimate); } [Test] public void EnoughPresses_Animation() { Model sut = new(20, 5); for (int i = 0; i < 5; i++) sut.AddScore(); Assert.IsTrue(sut.NeedsToAnimate); } [Test] public void NoPress_NoSpawn() { Model sut = new(20, 5); Assert.IsFalse(sut.NeedsToSpawn); } [Test] public void NotEnoughPresses_NoSpawn() { Model sut = new(20, 5); sut.AddScore(); Assert.IsFalse(sut.NeedsToSpawn); } [Test] public void EnoughPresses_Spawn() { Model sut = new(20, 5); for (int i = 0; i < 20 * 5; i++) { sut.AddScore(); } Assert.IsTrue(sut.NeedsToSpawn); } [Test] public void OneIteration_UpdatesGrowPercentage() { Model sut = new(5, 5); Loading
Assets/Scripts/View/UI/ExpressionInput.cs +1 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,7 @@ namespace View.UI { } public void UpdateView(int score) { int frameDifference = score % _model.SpawnRate; animator.PlayUntil(frameDifference / (float)_model.SpawnRate); animator.PlayUntil(_model.GrowPercentage); text.text = score.ToString(); } } Loading