40 lines
966 B
C#
40 lines
966 B
C#
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;
|
|
using UnityEngine.Animations;
|
|
|
|
namespace BITFALL.Props
|
|
{
|
|
public class Prop_BouncingBetty : MonoBehaviour
|
|
{
|
|
[SerializeField] private float jumpForce;
|
|
[SerializeField] private new Rigidbody rigidbody;
|
|
private bool isTriggered;
|
|
public async void OnDetected(Collider _collider)
|
|
{
|
|
if (isTriggered) return;
|
|
rigidbody.isKinematic = false;
|
|
rigidbody.useGravity = true;
|
|
if(TryGetComponent<ParentConstraint>(out var parentConstraint))
|
|
Destroy(parentConstraint);
|
|
isTriggered = true;
|
|
rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
|
|
try
|
|
{
|
|
await Task.Delay(1000,destroyCancellationToken);
|
|
GetComponentInChildren<Prop_Explosive>().Explosion(gameObject);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|