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

47 lines
1.1 KiB
C#
Raw Normal View History

2021-03-18 18:25:34 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
2021-03-22 17:45:42 +01:00
public partial class ArrowWall : MonoBehaviour
2021-03-18 18:25:34 +01:00
{
[SerializeField] private TrapSettings _settings;
[SerializeField] private ParticleSystem _particles;
2021-03-22 17:45:42 +01:00
[SerializeField] private Killbox _killbox;
2021-03-18 18:25:34 +01:00
private float _killTimer = -1;
2021-03-22 17:45:42 +01:00
public void Trigger()
2021-03-18 18:25:34 +01:00
{
// TODO: pressure plate 'click' sound
// set kill timer to zero, start counting
_killTimer = 0;
}
2021-03-22 17:45:42 +01:00
private void Update()
2021-03-18 18:25:34 +01:00
{
2021-03-22 17:45:42 +01:00
if (_killTimer < 0) return;
2021-03-18 18:25:34 +01: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 17:45:42 +01:00
_killbox.KillPlayer();
2021-03-18 18:25:34 +01:00
_killTimer = -1;
}
}
2021-03-22 17:45:42 +01:00
public void Reset()
2021-03-18 18:25:34 +01:00
{
_killTimer = -1;
}
2021-03-22 17:45:42 +01:00
}