25 lines
549 B
C#
25 lines
549 B
C#
using UnityEngine;
|
|
|
|
public class Hammer : MonoBehaviour
|
|
{
|
|
private float _life = 3;
|
|
private void Awake()
|
|
{
|
|
Destroy(gameObject, _life);
|
|
}
|
|
|
|
private void OnCollisionEnter2D(Collision2D collision)
|
|
{
|
|
var mapElement = collision.collider.GetComponent<MapElement>();
|
|
if(mapElement!=null)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
if (mapElement?.ElementSO.ElementType==MapElementType.BreakableWall)
|
|
{
|
|
mapElement.Hit();
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|
|
|