| 
									
										
										
										
											2021-01-06 15:10:11 +00:00
										 |  |  | using System; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | using UnityEngine.Scripting; | 
					
						
							| 
									
										
										
										
											2021-01-10 15:20:28 +00:00
										 |  |  | using Random = UnityEngine.Random; | 
					
						
							| 
									
										
										
										
											2021-01-06 15:10:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | public class BeatSpawner : ShootInputBase | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-01-10 15:20:28 +00:00
										 |  |  |     [SerializeField] private int spawnOnBeat = 2; | 
					
						
							|  |  |  |     [SerializeField] private float xMin = -10; | 
					
						
							|  |  |  |     [SerializeField] private float xMax = 10; | 
					
						
							| 
									
										
										
										
											2021-01-06 15:10:11 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     private AudioBeatManager _audio; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     private bool _shoot; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private void Awake() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         _audio = FindObjectOfType<AudioBeatManager>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public void OnBeat(int beat) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-01-10 15:20:28 +00:00
										 |  |  |         _shoot = beat % spawnOnBeat == 0; | 
					
						
							|  |  |  |         if (_shoot) | 
					
						
							|  |  |  |             transform.position = new Vector3(Random.Range(xMin, xMax), transform.position.y, transform.position.z); | 
					
						
							| 
									
										
										
										
											2021-01-06 15:10:11 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public override bool IsShooting() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (!_shoot) return false; | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  |         _shoot = false; | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |