59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ArrowWall : MonoBehaviour
|
|
{
|
|
// delay between trap triggering and firing
|
|
[SerializeField] private float _delay = 1.0f;
|
|
[SerializeField] private TrapSettings _settings;
|
|
|
|
[SerializeField] private ParticleSystem _particles;
|
|
[SerializeField] private Killbox _killbox;
|
|
|
|
private float? _triggered = null;
|
|
|
|
public void Trigger()
|
|
{
|
|
// TODO: pressure plate 'click' sound
|
|
|
|
// set triggered time
|
|
_triggered = Time.time;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!_triggered.HasValue) return;
|
|
|
|
var elapsed = Time.time - _triggered.Value;
|
|
|
|
// TODO: implications for time freeze
|
|
if (elapsed > _delay)
|
|
{
|
|
// TODO: arrow whoosh noises
|
|
|
|
_particles.Play();
|
|
|
|
// kill player
|
|
_killbox.KillPlayer();
|
|
|
|
Reset();
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!_triggered.HasValue) return;
|
|
|
|
if (_settings.SafeTime > _settings.ArrowWall.SafeResetTime)
|
|
{
|
|
Reset();
|
|
}
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
_triggered = null;
|
|
}
|
|
} |