feat: particles and new bank

This commit is contained in:
Gerard Gascón 2024-04-18 23:21:03 +02:00
parent 349552674d
commit 60265f3417
220 changed files with 13248 additions and 4917 deletions

View file

@ -4,19 +4,22 @@ namespace Presenter {
public class ExpressionClick {
private readonly Score _score;
private readonly IExpressionInput _view;
private readonly IRoseGrow _grow;
private readonly IRoseSpawner _spawner;
private bool CanSpawn => _score.Value % (_score.GrowIterations * _score.SpawnRate) == 0;
public ExpressionClick(Score score, IExpressionInput view, IRoseSpawner spawner) {
public ExpressionClick(Score score, IExpressionInput view, IRoseSpawner spawner, IRoseGrow grow) {
_score = score;
_view = view;
_spawner = spawner;
_grow = grow;
}
public void Execute() {
_score.Add();
_view.UpdateView(_score.Value, _score.GrowPercentage);
_grow.Grow();
if (CanSpawn)
_spawner.SpawnRose();

View file

@ -0,0 +1,5 @@
namespace Presenter {
public interface IRoseGrow {
void Grow();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b4eb28a89ae145bdb882722e9ecf03ae
timeCreated: 1713473538

View file

@ -3,6 +3,7 @@ using Domain;
using Presenter;
using Presenter.SaveSystem;
using UnityEngine;
using View.Scene;
using View.UI;
namespace View {
@ -23,7 +24,9 @@ namespace View {
IRoseSpawner spawner = FindObjectOfType<RoseSpawner>();
ExpressionClick = new ExpressionClick(Score, inputCollections, spawner);
IRoseGrow grow = FindObjectOfType<GrowParticlesSpawner>();
ExpressionClick = new ExpressionClick(Score, inputCollections, spawner, grow);
CustomInput = new CustomInput();

View file

@ -0,0 +1,15 @@
using System;
using Presenter;
using UnityEngine;
using Animator = FramedAnimator.Animator;
namespace View.Scene {
public class GrowParticle : MonoBehaviour {
[SerializeField] private Animator animator;
private void Start() {
animator.OnAnimationEnd += _ => Destroy(gameObject);
animator.PlayUntil(1f);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c22bc0b51046461fa4028a91ea32f73c
timeCreated: 1713469874

View file

@ -0,0 +1,26 @@
using System;
using Presenter;
using UnityEngine;
using Random = UnityEngine.Random;
namespace View.Scene {
public class GrowParticlesSpawner : MonoBehaviour, IRoseGrow {
[SerializeField] private GrowParticle growParticle;
[SerializeField] private Transform growParticlePositions;
[SerializeField, Range(0, 180)] private float angleRange;
public void Grow() {
float randomRotation = Random.Range(-angleRange / 2f, angleRange / 2f);
Instantiate(growParticle, growParticlePositions.position, Quaternion.Euler(0f, 0f, randomRotation));
}
private void OnDrawGizmosSelected() {
Gizmos.color = Color.red;
float angle = angleRange / 2f + 90f;
Vector3 lineOffset = new(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
Gizmos.DrawLine(growParticlePositions.position, growParticlePositions.position + lineOffset * 5f);
lineOffset = new Vector3(-Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
Gizmos.DrawLine(growParticlePositions.position, growParticlePositions.position + lineOffset * 5f);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: eb8eb037cd4e4a6c882f7276a0b9d91c
timeCreated: 1713473715

View file

@ -21,8 +21,6 @@ namespace View.UI {
[SerializeField] private Animation growAnimation;
[SerializeField] private Animation endAnimation;
[SerializeField] private ParticleSystem growParticle;
private void Start() {
_click = FindObjectOfType<Dependencies>().ExpressionClick;
_customInput = FindObjectOfType<Dependencies>().CustomInput;
@ -52,8 +50,6 @@ namespace View.UI {
if (animator.CurrentAnimation == "Rosa_Grow")
animator.PlayUntil(IsLastGrowState(score, growPercentage) ? 1f : growPercentage);
growParticle.Play();
text.text = score.ToString();
_firstUpdate = false;
}