Example #1
0
    public static bool GetEntityLocation(ENTITY_ID viewID, ref entity_location location)
    {
        IntPtr locationPtr = getEntityLocation(viewID);

        if (locationPtr == IntPtr.Zero)
        {
            Trace.LogWarning("getEntityLocation 获取Entity位置错误");
            return(false);
        }

        location = IntPtrHelper.toData <entity_location>(locationPtr);

        return(true);
    }
Example #2
0
        public void onActorLocationChange(UActorLocationChangeMsgData msgData)
        {
            if (!m_wnd.IsVisible())
            {
                return;
            }

            if (msgData == null)
            {
                return;
            }

            if (m_CurNPCUID <= 0)
            {
                return;
            }

            // 获取NPC位置
            entity_location location = new entity_location();

            if (!GameLogicAPI.GetEntityLocation((int)m_CurNPCUID, ref location))
            {
                return;
            }
            Vector3 NPCPosition = new Vector3(location.x, location.y, location.z);

            // 玩家自己的位置
            if (EntityFactory.MainHeroView == null || !EntityFactory.MainHeroView.IsValid)
            {
                return;
            }
            Vector3 selfPositon = msgData.vNewPos;

            // 与NPC距离超过20M,关闭NPC窗口
            if (Vector3.Distance(NPCPosition, selfPositon) > 20)
            {
                m_wnd.SetVisible(false);
                //onClickClose();
            }
        }