示例#1
0
    //------------------------------------------------------------------------------------------
    // Update
    //------------------------------------------------------------------------------------------
    private void Update()
    {
        var rate = dirt.CleaningRate();

        ChangeAlpha(1.0f - 1.0f * rate);
        if (rate >= 1 && !cleaned)
        {
            Data.initialPlayerPos = this.transform.position;
            EffectGenerator.CleanFX(new CleanFX.Param(new Vector2(1, 4)), transform.position);
            cleaned = true;
        }
    }
示例#2
0
    //------------------------------------------------------------------------------------------
    // Update
    //------------------------------------------------------------------------------------------
    private void Update()
    {
        if (beingSwept && !wasCleaned)
        {
            sweepCount++;

            float a = Mathf.Max(1 - (sweepCount * 1.0f / sweepLevel), 0.0f);
            a           = a * alphaRate + (1 - alphaRate);
            targetAlpha = defaultAlpha * a;

            if (sweepCount >= sweepLevel)
            {
                targetAlpha = 0;
                dirtManager.DirtCleaned(amount);
                wasCleaned = true;

                var collider = GetComponent <BoxCollider2D>();
                var size     = collider.size * transform.lossyScale;
                var offset   = collider.offset * transform.lossyScale;
                EffectGenerator.CleanFX(new CleanFX.Param(size), transform.position + (Vector3)offset);

                SoundPlayer.Play(audios[(int)AudioType.End]);
            }

            SoundPlayer.Play(audios[(int)AudioType.Cleaning]);
            beingSwept = false;
        }
        currentAlpha = Mathf.Lerp(currentAlpha, targetAlpha, 0.2f);
        var color = spriteRenderer.color;

        color.a = currentAlpha;
        spriteRenderer.color = color;


        timer += Time.deltaTime;
        hsvController.brightnessMultiply = Mathf.Lerp(brightnessMin, brightnessMax, Mathf.Sin(timer * Mathf.PI * 2 * blinkSpeed) * 0.5f + 0.5f);
    }