using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 可交互物件基类
///
public class Interactable : Event
{
void Start()
{
//检查触发器
if (GetComponent() == null)
{
Debug.LogError(this.GetType() + ": 没有碰撞盒");
}
else if(GetComponent().isTrigger == false)
{
Debug.LogError(this.GetType() + ": 碰撞盒没有设置为触发器");
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.TryGetComponent(out PlayerInteract playerInteract))
{
playerInteract.SetCatched(this);
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.TryGetComponent(out PlayerInteract playerInteract))
{
playerInteract.CancleCatched(this);
}
}
}