示例#1
0
    /// <summary>
    /// 更新技能冷却
    /// </summary>
    /// <param name="button">技能按钮</param>
    /// <param name="skill">技能数据</param>
    private bool UpdateSkillCooldown(RectTransform button, PlayerShipSkillVO skill)
    {
        //cd
        Animator  animator = button.GetComponent <Animator>();
        Transform cdBox    = button.Find("CDImage").GetComponent <Transform>();
        Image     cdMask   = button.Find("CDImage/CD").GetComponent <Image>();
        TMP_Text  cdField  = button.Find("CDImage/Label_CDTimes").GetComponent <TMP_Text>();

        float cooldown = 0;

        if (skill != null)
        {
            PlayerSkillCDVO cdVO = m_SkillProxy.GetActiveCDVO(skill.GetID());
            if (cdVO != null)
            {
                cooldown = cdVO.GetRemainingTime();
            }

            if (cooldown > 0.0f)
            {
                cdBox.gameObject.SetActive(true);

                cdMask.fillAmount = cdVO.GetProgress();
                cdField.text      = string.Format("{0:N1}", cooldown);
            }
            else
            {
                cdBox.gameObject.SetActive(false);
            }
        }
        else
        {
            cdBox.gameObject.SetActive(false);
        }

        if (animator)
        {
            animator.SetInteger("State", cooldown > 0 ? 2 : 0);
        }

        return(cooldown > 0.0f);
    }