1
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
"GUID:96f476e982d6fb945bfc9140ba094b7f",
|
||||
"GUID:4b4c1437c0fb823428900cb008a49c07",
|
||||
"GUID:cca11dcf158d04c4eb80eb346d39e2ad",
|
||||
"GUID:37151e2099022af42afa90e2ee1b768a"
|
||||
"GUID:37151e2099022af42afa90e2ee1b768a",
|
||||
"GUID:2dbcdde5f5df6a343a36c62f12bd6fae"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -25,15 +25,24 @@ namespace BITFALL.Props
|
||||
foreach (var x in rangeSensor.Get())
|
||||
{
|
||||
if (x.TryGetComponent<Entity>(out var entity) is false) continue;
|
||||
if(entity.TryGetComponent<IStunObject>(out var stunObject))
|
||||
{
|
||||
stunObject.Stun(Vector3.Distance(transform.position, entity.transform.position), 0.5f);
|
||||
}
|
||||
if (damaged.TryAdd(entity.Id))
|
||||
{
|
||||
entity.Invoke<DamageMessage>(new DamageMessage()
|
||||
DamageService.Singleton.Execute(new DamageMessage()
|
||||
{
|
||||
Target = entity,
|
||||
Damage = (int)damageCurve.Evaluate(Vector3.Distance(transform.position,
|
||||
entity.transform.position))
|
||||
});
|
||||
|
||||
// entity.Invoke<DamageMessage>(new DamageMessage()
|
||||
// {
|
||||
// Target = entity,
|
||||
// Damage = (int)damageCurve.Evaluate(Vector3.Distance(transform.position,
|
||||
// entity.transform.position))
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,18 +1,61 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Sensors;
|
||||
using BITKit.Tween;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class Prop_Flashbang : MonoBehaviour
|
||||
namespace BITFALL.Props
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public class Prop_Flashbang : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private float fuse;
|
||||
|
||||
[SerializeField] private float duration = 5;
|
||||
[SerializeField] private Light light;
|
||||
[SerializeReference,SubclassSelector] private ISensor _sensor;
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(fuse));
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
await _sensor.Execute();
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
foreach (var x in _sensor.Get())
|
||||
{
|
||||
if (x.TryGetComponent<IEntity>(out var entity) is false) continue;
|
||||
if (entity.TryGetComponent<IStunObject>(out var stunObject) is false) continue;
|
||||
var distance = Vector3.Distance(transform.position, x.transform.position);
|
||||
stunObject.Stun(distance, duration);
|
||||
BIT4Log.Log<Prop_Flashbang>($"目标:{x.name} 距离:{distance} 眩晕时间:{duration}");
|
||||
}
|
||||
|
||||
light.enabled = true;
|
||||
var currentIntensity = light.intensity;
|
||||
await BITween.CreateSequence()
|
||||
.Append(
|
||||
BITween.MoveToForward(Set, currentIntensity, 0, 0.2f)
|
||||
)
|
||||
//.Append(UniTask.Create(Dispose))
|
||||
.Play();
|
||||
if(destroyCancellationToken.IsCancellationRequested) return;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
private UniTask Dispose()
|
||||
{
|
||||
if (destroyCancellationToken.IsCancellationRequested) return UniTask.CompletedTask;
|
||||
Destroy(gameObject);
|
||||
return UniTask.CompletedTask;;
|
||||
}
|
||||
private void Set(float weight)
|
||||
{
|
||||
if (light)
|
||||
light.intensity = weight;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user