mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 10:06:58 +00:00
20 lines
405 B
C#
20 lines
405 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(TowerHealth))]
|
|
public class Tower : MonoBehaviour
|
|
{
|
|
private TowerHealth _towerHealth;
|
|
|
|
private void Start()
|
|
{
|
|
_towerHealth = GetComponent<TowerHealth>();
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.TryGetComponent(out Enemy enemy))
|
|
_towerHealth.TakeDamage(enemy.Damage);
|
|
}
|
|
}
|