Exemplo n.º 1
0
    // Update is called once per frame
    public void InGameUIPlayerInfoUnitUpdate()
    {
        if (!GameCommon.IsPositionInScreen(role.transform.position))
        {
            gameObject.SetActive(false);
            return;
        }
        showTime -= Time.deltaTime;
        if (showTime <= 0)
        {
            gameObject.SetActive(false);
        }
        else
        {
            gameObject.SetActive(true);
        }

        //血条

        float toval = (float)role.life / (float)role.propertys.GetProperty(enCharacterProperty.life);

        if (Mathf.Abs(toval - lifeSprite.fillAmount) > 0.01f)
        {
            showTime = 3f;
        }

        float addval = (toval - lifeSprite.fillAmount) * 0.1f;

        lifeSprite.fillAmount = toval + addval;
        //更新位置
        if (Camera.main == null || UICamera.currentCamera == null)
        {
            return;
        }

        transform.position = GameCommon.WorldPosToNGUIPos(
            Camera.main,
            UICamera.currentCamera,
            role.transform.position + new Vector3(0, role.boxSize.y, 0));//+ basePos;
        transform.localPosition += basePos;
    }