44 lines
885 B
C#
44 lines
885 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class cardPlace : MonoBehaviour
|
|
{
|
|
private Transform parent;
|
|
public GameObject tower;
|
|
public string Tag;
|
|
public bool isInTrigger { get; set; }
|
|
|
|
// Start is called before the first frame update
|
|
|
|
private void Start()
|
|
{
|
|
|
|
isInTrigger = false;
|
|
}
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (!isInTrigger&& collision.tag.Equals(Tag))
|
|
{
|
|
//Debug.Log("物体第一次进入触发器");
|
|
isInTrigger = true;
|
|
tower = collision.gameObject;
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
if (isInTrigger&&collision.tag.Equals(Tag))
|
|
{
|
|
//Debug.Log("物体退出触发器");
|
|
|
|
isInTrigger = false;
|
|
tower = null;
|
|
}
|
|
}
|
|
|
|
|
|
}
|