26 lines
No EOL
1 KiB
C#
26 lines
No EOL
1 KiB
C#
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);
|
|
}
|
|
}
|
|
} |