NGUI写 卡牌拖放的 检查 非常简单 射线都是NGUI封装好的 大家可以来看看代码就知道了
public class Dragable : UIDragDropItem
{protected override void OnDragDropRelease(GameObject surface)
{
base.OnDragDropRelease(surface);
if (surface != null && surface.tag=="FightArea")
{
int needCrystal = GetComponent<Card>().crystalCount;
Hero1Crystal hero1crystal = GameObject.Find("hero1_crystal").GetComponent<Hero1Crystal>();
bool isSuccess = hero1crystal.ConsumeCrystal(needCrystal);
if (isSuccess)
{
transform.parent.GetComponent<MyCard>().RemoveCard(gameObject);
surface.GetComponent<FightCard>().AddCard(gameObject);
}
else
{
transform.parent.GetComponent<MyCard>().UpdateShow();
}
}
else
{
transform.parent.GetComponent<MyCard>().UpdateShow();
}
}
}