31 lines
No EOL
1.1 KiB
C#
31 lines
No EOL
1.1 KiB
C#
using System;
|
|
using Pooling;
|
|
using Presenter;
|
|
using UnityEngine;
|
|
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;
|
|
|
|
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 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);
|
|
}
|
|
}
|
|
} |