Beispiel #1
0
    public override void OnUpdate()
    {
        if (m_gun == null)
        {
            return;
        }
        if (Scope == null || ScopeImage == null)
        {
            return;
        }

        if (m_gun.isAimed && !m_gun.isReloading)
        {
            if (ShowDistance)
            {
                GetDistance();
            }
            //add a little fade in to avoid the impact of appearing once
            m_alpha = Mathf.Lerp(m_alpha, 1.0f, Time.deltaTime * FadeSpeed);
            foreach (GameObject go in OnScopeDisable)
            {
                go.SetActive(false);
            }
            returnedAim = false;
        }
        else
        {
            m_alpha = Mathf.Lerp(m_alpha, 0.0f, Time.deltaTime * FadeSpeed);
            if (m_alpha < 0.1f)
            {
                if (!returnedAim && m_gun.Info != null)
                {
                    m_gun.SetToAim();
                    returnedAim = true;
                }
                foreach (GameObject go in OnScopeDisable)
                {
                    go.SetActive(true);
                }
            }
        }
        if (ShowDistance && DistanceText)
        {
            DistanceText.text = m_dist.ToString("00") + "<size=10>m</size>";
        }
        Alpha.alpha = m_alpha;
    }