1
This commit is contained in:
24
Assets/Artists/Scripts/Props/BITFALL.Props.Runtime.asmdef
Normal file
24
Assets/Artists/Scripts/Props/BITFALL.Props.Runtime.asmdef
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "BITFALL.Props.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:508392158bd966c4d9c21e19661a441d",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:ea5474181b324dd49a5976cd68f44f18",
|
||||
"GUID:bea3628e8b592ae47ade218cb9ec98db"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
55
Assets/Artists/Scripts/Props/Prop_BouncingBetty.cs
Normal file
55
Assets/Artists/Scripts/Props/Prop_BouncingBetty.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Sensors;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Props
|
||||
{
|
||||
public class Prop_BouncingBetty : MonoBehaviour
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private ISensor rangeSensor;
|
||||
[SerializeReference, SubclassSelector] private IReference[] vfxTags;
|
||||
[SerializeField] private AnimationCurve damageCurve;
|
||||
[SerializeField] private LayerMask physicsLayer;
|
||||
[SerializeField] private float explosionRadius;
|
||||
[SerializeField] private float jumpForce;
|
||||
[SerializeField] private new Rigidbody rigidbody;
|
||||
private bool isTriggered;
|
||||
public async void OnDetected(Collider _collider)
|
||||
{
|
||||
if (isTriggered) return;
|
||||
isTriggered = true;
|
||||
var damaged = new List<ulong>() ;
|
||||
rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
|
||||
try
|
||||
{
|
||||
await Task.Delay(1000,destroyCancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DI.Get<VFXService>().Spawn(new Location(transform), vfxTags.Select(x=>x.Value).ToArray());
|
||||
foreach (var x in rangeSensor.Get())
|
||||
{
|
||||
if (!x.TryGetComponent<Entity>(out var entity)) continue;
|
||||
if(damaged.Contains(entity.Id))continue;
|
||||
entity.Invoke<DamageMessage>(new DamageMessage()
|
||||
{
|
||||
Target = entity,
|
||||
Damage = (int)damageCurve.Evaluate(Vector3.Distance(transform.position, entity.transform.position))
|
||||
});
|
||||
damaged.Add(entity.Id);
|
||||
}
|
||||
PhysicsHelper.Explosion(transform.position,explosionRadius,physicsLayer,1024*8);
|
||||
damaged.Clear();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
43
Assets/Artists/Scripts/Props/Prop_Grenade.cs
Normal file
43
Assets/Artists/Scripts/Props/Prop_Grenade.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Sensors;
|
||||
using UnityEngine;
|
||||
|
||||
public class Prop_Grenade : MonoBehaviour
|
||||
{
|
||||
[SerializeReference, SubclassSelector] private ISensor rangeSensor;
|
||||
[SerializeReference, SubclassSelector] private IReference[] vfxTags;
|
||||
[SerializeField] private LayerMask physicsLayer;
|
||||
[SerializeField] private float explosionRadius;
|
||||
[SerializeField] private float fuse;
|
||||
[SerializeField] private AnimationCurve damageCurve;
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(fuse), destroyCancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DI.Get<VFXService>().Spawn(new Location(transform), vfxTags.Select(x => x.Value).ToArray());
|
||||
foreach (var x in rangeSensor.Get())
|
||||
{
|
||||
if (x.TryGetComponent<Entity>(out var entity) is false)continue;
|
||||
entity.Invoke<DamageMessage>(new DamageMessage()
|
||||
{
|
||||
Target = entity,
|
||||
Damage = (int)damageCurve.Evaluate(Vector3.Distance(transform.position, entity.transform.position))
|
||||
});
|
||||
}
|
||||
PhysicsHelper.Explosion(transform.position,explosionRadius,physicsLayer,1024*8);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user