feat: new grow particles
This commit is contained in:
parent
5c91bad902
commit
a06779c5c1
343 changed files with 9318 additions and 12650 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Domain;
|
||||
using Pooling;
|
||||
using Presenter;
|
||||
using UnityEngine;
|
||||
|
@ -7,25 +8,31 @@ using Random = UnityEngine.Random;
|
|||
namespace View.Scene {
|
||||
public class GrowParticlesSpawner : MonoBehaviour, IInputCallback {
|
||||
[SerializeField] private GrowParticle growParticle;
|
||||
[SerializeField] private Transform growParticlePositions;
|
||||
[SerializeField, Range(0, 180)] private float angleRange;
|
||||
[SerializeField] private Transform[] growParticlePositions;
|
||||
|
||||
private Score _score;
|
||||
|
||||
private void Awake() {
|
||||
growParticle.CreatePool();
|
||||
}
|
||||
|
||||
public void OnInputReceived() {
|
||||
float randomRotation = Random.Range(-angleRange / 2f, angleRange / 2f);
|
||||
growParticle.Spawn(growParticlePositions.position, Quaternion.Euler(0, 0, randomRotation));
|
||||
private void Start() {
|
||||
_score = FindObjectOfType<Dependencies>().Score;
|
||||
}
|
||||
|
||||
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);
|
||||
public void OnInputReceived() {
|
||||
float randomRotation = Random.Range(0, 360);
|
||||
growParticle.Spawn(GetGrowParticlePosition(), Quaternion.Euler(0, 0, randomRotation));
|
||||
}
|
||||
|
||||
private Vector3 GetGrowParticlePosition() {
|
||||
float iterationStep = 1f / _score.SpawnRate;
|
||||
for (int i = 0; i < growParticlePositions.Length; i++) {
|
||||
if (_score.GrowPercentage < (i + 1) * iterationStep)
|
||||
return growParticlePositions[i].position;
|
||||
}
|
||||
|
||||
return growParticlePositions[^1].position;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue