48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DamageNumbersPro;
|
|
using DarkTonic.MasterAudio;
|
|
using DragonLi.Core;
|
|
using DragonLi.Frame;
|
|
using Mirror;
|
|
using UnityEngine;
|
|
|
|
public class DamageBox : MonoBehaviour, IDamagable
|
|
{
|
|
|
|
public float Health { get; set; }
|
|
|
|
public bool isDie;
|
|
[SoundGroup]
|
|
public string audioSound;
|
|
|
|
private void Start()
|
|
{
|
|
isDie = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Implemenet this function to receive damage
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <param name="info"></param>
|
|
/// <param name="_sender"></param>
|
|
public void ApplyDamage(float value, object info, Transform _sender)
|
|
{
|
|
DamageNumber prefab = MRDamage.Ins.GetCurrent();
|
|
DamageNumber newDamageNumber = prefab.Spawn(_sender.position, value);
|
|
if (Health <= 0&& !isDie)
|
|
{
|
|
isDie = true;
|
|
//破碎效果
|
|
MasterAudio.PlaySound3DAtTransform(audioSound, transform);
|
|
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
|
{
|
|
gameObject.SetActive(false);
|
|
}, 2f);
|
|
}
|
|
}
|
|
|
|
}
|