Run-and-capture/Assets/UnitView.cs
2021-12-22 23:29:44 +03:00

39 lines
730 B
C#

using System;
using DefaultNamespace.Weapons;
using UnityEngine;
public class UnitView : MonoBehaviour
{
public Action OnStep;
public Action OnAttackEnd;
public Action OnAttack;
public Action<float> OnHit;
public GameObject charBarCanvas;
private void Step()
{
OnStep?.Invoke();
}
private void AttackEnd()
{
OnAttackEnd?.Invoke();
}
private void Attack()
{
OnAttack?.Invoke();
}
private void OnTriggerEnter(Collider other)
{
WeaponView weaponView = other.GetComponent<WeaponView>();
if (weaponView != null)
{
OnHit?.Invoke(weaponView.Weapon.damage);
Destroy(other);
}
}
}