revival/game/Assets/Scripts/Traps/ArrowWall.cs

53 lines
1.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class ArrowWall : MonoBehaviour
{
[SerializeField] private TrapSettings _settings;
[SerializeField] private ParticleSystem _particles;
private float _killTimer = -1;
private void OnTriggerEnter(Collider other)
{
if (!other.TryGetComponent(out PlayerDeath _)) return;
// TODO: pressure plate 'click' sound
// set kill timer to zero, start counting
_killTimer = 0;
}
private void OnTriggerStay(Collider other)
{
// bail if the other thing cant die
if (!other.TryGetComponent(out PlayerDeath playerDeath)) return;
// TODO: implications for time freeze
_killTimer += Time.deltaTime;
if (_killTimer > _settings.ArrowWall.delay)
{
// TODO: arrow whoosh noises
// reset
_particles.Play();
// kill player
playerDeath.Respawn();
_killTimer = -1;
}
}
private void OnTriggerExit(Collider other)
{
if (!other.TryGetComponent(out PlayerDeath _)) return;
_killTimer = -1;
}
}