1
This commit is contained in:
43
Assets/Artists/Scripts/Props/Prop_C4.cs
Normal file
43
Assets/Artists/Scripts/Props/Prop_C4.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user