44 lines
994 B
C#
44 lines
994 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using BITKit;
|
|
using Cysharp.Threading.Tasks.Triggers;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Props
|
|
{
|
|
public class Prop_C4 : MonoBehaviour,IDescription
|
|
{
|
|
[SerializeField] private int countdown = 45;
|
|
|
|
[SerializeField] private new Light light;
|
|
|
|
private float _initialLightIntensity;
|
|
|
|
private readonly IntervalUpdate explosionCountdown=new();
|
|
|
|
private void Start()
|
|
{
|
|
_initialLightIntensity = light.intensity;
|
|
|
|
explosionCountdown.Interval = countdown;
|
|
|
|
explosionCountdown.Reset();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
light.intensity =Mathf.Lerp( _initialLightIntensity,0, (float)explosionCountdown.Remaining % 1);
|
|
|
|
if (explosionCountdown.AllowUpdate)
|
|
{
|
|
GetComponentInChildren<Prop_Explosive>().Explosion(gameObject);
|
|
}
|
|
}
|
|
public string Name=>"C4: 预计剩余时间: "+explosionCountdown.Remaining.ToString("F2")+"s";
|
|
}
|
|
}
|
|
|