Пример #1
0
    /// <summary>
    /// 更新位置
    /// </summary>
    public void UpdatePositon()
    {
        if (!Visible)
        {
            return;
        }
        if (UID == 0)
        {
            return;
        }
        Client.IEntity entity = RoleStateBarManager.GetEntity(UID);
        if (entity == null)
        {
            return;
        }

        RoleStateBarManager mgr = DataManager.Manager <RoleStateBarManager>();
        Vector3             pos = Vector3.zero;

        if (entity.GetEntityType() == EntityType.EntityType_Player)
        {
            bool bRide = (bool)entity.SendMessage(Client.EntityMessage.EntityCommond_IsRide, null);
            if (bRide)
            {
                pos = mgr.GetNodeWorldPos(UID, "MountName", offsetY);
            }
            else
            {
                pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
            }
        }
        else
        {
            pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
        }

        Camera mainCamera = Util.MainCameraObj.GetComponent <Camera>();
        Camera uiCamera   = Util.UICameraObj.GetComponent <Camera>();

        if (null == uiCamera || null == mainCamera)
        {
            return;
        }
        pos = mainCamera.WorldToViewportPoint(pos);
        //bool isVisible = (mainCamera.orthographic || pos.z > 0f) && (/*!disableIfInvisible || */(pos.x > 0f && pos.x < 1f && pos.y > 0f && pos.y < 1f));
        //if (Visible != isVisible)
        //{
        //    SetVisible(isVisible);
        //    if (Visible)
        //    {
        //        AdjustStatusPos();
        //    }
        //}
        pos = uiCamera.ViewportToWorldPoint(pos);
        m_tsTran.position = pos;
        pos   = m_tsTran.localPosition;
        pos.x = Mathf.FloorToInt(pos.x);
        pos.y = Mathf.FloorToInt(pos.y);
        pos.z = 0f;
        m_tsTran.localPosition = pos;
    }