世界坐标转换为NGUI坐标办法举例

来源:互联网 发布:剑三捏脸数据不合法 编辑:程序博客网 时间:2024/06/08 01:53
    //伤害结算    public static Camera nguiCamera;//在游戏开始时必须初始化NGUI相机,用于计算范围伤害    public static void HurtAccount(List<Damageable> targetList, Vector3 position, float searchRange, float damage)    {        for (int i = 0; i < targetList.Count; i++)        {            Vector3 myPos = nguiCamera.WorldToScreenPoint(position);            Vector3 targetPos = nguiCamera.WorldToScreenPoint(targetList[i].transform.position);            float distance = (targetPos - myPos).magnitude;            if (distance < searchRange)            {                targetList[i].Hurt(damage);            }        }    }

0 0
原创粉丝点击