| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  | using System; | 
					
						
							|  |  |  | using System.Collections; | 
					
						
							|  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [RequireComponent(typeof(BoxCollider))] | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  | public partial class ArrowWall : MonoBehaviour | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     [SerializeField] private TrapSettings _settings; | 
					
						
							|  |  |  |     [SerializeField] private ParticleSystem _particles; | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  |     [SerializeField] private Killbox _killbox; | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private float _killTimer = -1; | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public void Trigger() | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         // TODO: pressure plate 'click' sound | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // set kill timer to zero, start counting | 
					
						
							|  |  |  |         _killTimer = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  |     private void Update() | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  |         if (_killTimer < 0) return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  |         // TODO: implications for time freeze | 
					
						
							|  |  |  |         _killTimer += Time.deltaTime; | 
					
						
							|  |  |  |         if (_killTimer > _settings.ArrowWall.delay) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             // TODO: arrow whoosh noises | 
					
						
							|  |  |  |             // reset | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             _particles.Play(); | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             // kill player | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  |             _killbox.KillPlayer(); | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             _killTimer = -1; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  |     public void Reset() | 
					
						
							| 
									
										
										
										
											2021-03-18 17:25:34 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         _killTimer = -1; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-22 16:45:42 +00:00
										 |  |  | } |