示例#1
0
    public void SetState(ZaapObject.ZaapState zaapState)
    {
        bool highLight = false;

        switch (zaapState)
        {
        case ZaapObject.ZaapState.Normal:
            PlayParticles(m_highLightParticleSystems, play: false);
            PlayParticles(m_openParticleSystems, play: false);
            m_openingAudio.get_gameObject().SetActive(false);
            m_highlightLoopAudio.get_gameObject().SetActive(false);
            break;

        case ZaapObject.ZaapState.Highlight:
        case ZaapObject.ZaapState.Clicked:
            PlayParticles(m_highLightParticleSystems, play: true);
            PlayParticles(m_openParticleSystems, play: false);
            highLight = true;
            m_openingAudio.get_gameObject().SetActive(false);
            m_highlightLoopAudio.get_gameObject().SetActive(true);
            break;

        case ZaapObject.ZaapState.Open:
            PlayParticles(m_highLightParticleSystems, play: true);
            PlayParticles(m_openParticleSystems, play: true);
            highLight = true;
            m_openingAudio.get_gameObject().SetActive(true);
            m_highlightLoopAudio.get_gameObject().SetActive(false);
            break;
        }
        for (int i = 0; i < m_animatedSprites.Length; i++)
        {
            if (m_animatedSprites[i].animationCoroutine != null)
            {
                this.StopCoroutine(m_animatedSprites[i].animationCoroutine);
            }
            m_animatedSprites[i].animationCoroutine = this.StartCoroutine(AnimateSpriteColorCoroutine(m_animatedSprites[i], highLight));
        }
        if (m_scaleCoroutine != null)
        {
            this.StopCoroutine(m_scaleCoroutine);
        }
        m_scaleCoroutine = this.StartCoroutine(ScaleCoroutine(highLight));
        if (m_animateGroundFXCoroutine != null)
        {
            this.StopCoroutine(m_animateGroundFXCoroutine);
        }
        m_animateGroundFXCoroutine = this.StartCoroutine(AnimateGroundFXCoroutine(zaapState));
    }
示例#2
0
    private IEnumerator AnimateGroundFXCoroutine(ZaapObject.ZaapState zaapState)
    {
        WaitForEndOfFrame wait = new WaitForEndOfFrame();
        float             highLightStartValue = m_highLightCurrentValue;
        float             openStartValue      = m_openCurrentValue;
        float             highLightEndValue   = 0f;
        float             openEndValue        = 0f;

        switch (zaapState)
        {
        case ZaapObject.ZaapState.Highlight:
        case ZaapObject.ZaapState.Clicked:
            highLightEndValue = 1f;
            break;

        case ZaapObject.ZaapState.Open:
            highLightEndValue = 1f;
            openEndValue      = 1f;
            break;
        }
        for (float f = 0f; f < 1f; f += Time.get_deltaTime() / m_groundEffectDuration)
        {
            m_highLightCurrentValue = Mathf.Lerp(highLightStartValue, highLightEndValue, f);
            m_openCurrentValue      = Mathf.Lerp(openStartValue, openEndValue, f);
            materialPropertyBlock.SetFloat(m_highLightID, m_highLightCurrentValue);
            materialPropertyBlock.SetFloat(m_openID, m_openCurrentValue);
            m_groundIcon.SetPropertyBlock(materialPropertyBlock);
            yield return(wait);
        }
        m_highLightCurrentValue = highLightEndValue;
        m_openCurrentValue      = openEndValue;
        materialPropertyBlock.SetFloat(m_highLightID, m_highLightCurrentValue);
        materialPropertyBlock.SetFloat(m_openID, m_openCurrentValue);
        m_groundIcon.SetPropertyBlock(materialPropertyBlock);
        m_animateGroundFXCoroutine = null;
    }