void Update()
    {
        y += INCREMENT * paralaxSpeed * LevelManager.GetMultiplierByCurrentLevelDifficulty();
        MaterialPropertiesHandler.SetOffset(GetComponent <MeshRenderer>(), 0, y);

        if (lastLevelDifficulty != LevelManager.CurrentLevelDifficulty)
        {
            lastLevelDifficulty = LevelManager.CurrentLevelDifficulty;
            Destroy(gameObject.GetComponent <ColorFadeEffect>());
            componentAdded = false;
        }

        if (!componentAdded)
        {
            ColorFadeEffect tempComponent = gameObject.AddComponent <ColorFadeEffect>();

            if (enableChangeColor)
            {
                tempComponent.renderColor = LevelManager.GetCurrentColorByCurrentLevelDifficulty();
                tempComponent.ResetComponent();
            }
            else
            {
                tempComponent.renderColor = Color.white;
            }

            componentAdded = true;
        }

        gameObject.GetComponent <ColorFadeEffect>().speedTransition *= LevelManager.GetMultiplierByCurrentLevelDifficulty() / 4f;
    }
    public void BecomeBlack()
    {
        tempColor.a = 0;

        Image imageComponent = GetComponent <Image>();

        if (imageComponent != null)
        {
            imageComponent.color = tempColor;
        }

        Text textComponent = GetComponent <Text>();

        if (textComponent != null)
        {
            textComponent.color = tempColor;
        }

        Renderer shaderRenderer = GetComponent <Renderer>();

        if (shaderRenderer != null)
        {
            v         = 0;
            tempColor = Color.HSVToRGB(h, s, v);
            MaterialPropertiesHandler.SetAlbedoColor(shaderRenderer, tempColor);
        }
    }
    private void ChangeColors()
    {
        Renderer modelRenderer = transform.GetChild(0).GetComponent <Renderer>();

        MaterialPropertiesHandler.SetAlbedoColor(modelRenderer, LevelManager.GetCurrentColorByCurrentLevelDifficulty());

        if (transform.childCount > 1)
        {
            ParticleSystem.MainModule mainModule = transform.GetChild(1).GetComponent <ParticleSystem>().main;
            mainModule.startColor = new ParticleSystem.MinMaxGradient(LevelManager.GetCurrentColorByCurrentLevelDifficulty());
        }
    }
    private void StartRenderColorsAndHSV()
    {
        Image imageComponent = GetComponent <Image>();

        if (imageComponent != null)
        {
            tempColor = imageComponent.color;

            if (applyFadeIn)
            {
                tempColor.a = 0;
            }
            else
            {
                tempColor.a = alphaIntensity;
            }

            imageComponent.color = tempColor;
        }

        SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();

        if (spriteRenderer != null)
        {
            tempColor = spriteRenderer.color;

            if (applyFadeIn)
            {
                tempColor.a = 0;
            }
            else
            {
                tempColor.a = alphaIntensity;
            }

            spriteRenderer.color = tempColor;

            existsSpriteRenderer = true;
        }
        else
        {
            existsSpriteRenderer = false;
        }

        Text textComponent = GetComponent <Text>();

        if (textComponent != null)
        {
            tempColor = textComponent.color;

            if (applyFadeIn)
            {
                tempColor.a = 0;
            }
            else
            {
                tempColor.a = alphaIntensity;
            }

            textComponent.color = tempColor;
        }

        Renderer shaderRenderer = GetComponent <Renderer>();

        if (shaderRenderer != null && !existsSpriteRenderer)
        {
            Color.RGBToHSV(renderColor, out h, out s, out v);

            if (applyFadeIn)
            {
                v = 0;
            }
            else
            {
                v = alphaIntensity;
            }

            tempColor = Color.HSVToRGB(h, s, v);
            MaterialPropertiesHandler.SetAlbedoColor(shaderRenderer, tempColor);
        }
    }
    void Update()
    {
        //CheckChangeAttributes();

        speedTransition = speedTransition > speedTransitionMax ? speedTransitionMax : speedTransition;
        speedTransition = speedTransition < speedTransitionMin ? speedTransitionMin : speedTransition;

        if (waitTimeToStart > 0 && !timerForWaitTime.IsReachTimeGoal())
        {
            if (!timerForWaitTimeInitiated)
            {
                timerForWaitTime.Restart();
                timerForWaitTimeInitiated = true;
            }
        }
        else if (waitTimeToStart <= 0 || timerForWaitTime.IsReachTimeGoal())
        {
            if (!timerForRuntimeInitiated)
            {
                timerForRuntime.Restart();
                timerForRuntimeInitiated = true;
                StartInterpolate();
            }

            Image imageComponent = GetComponent <Image>();
            if (imageComponent != null)
            {
                if (repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a          = interpolate.GetCurrentPingPongValue();
                    imageComponent.color = tempColor;
                }
                else if (!repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a          = interpolate.GetCurrentValue();
                    imageComponent.color = tempColor;
                }
            }

            SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
            if (spriteRenderer != null)
            {
                if (repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a          = interpolate.GetCurrentPingPongValue();
                    spriteRenderer.color = tempColor;
                }
                else if (!repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a          = interpolate.GetCurrentValue();
                    spriteRenderer.color = tempColor;
                }

                existsSpriteRenderer = true;
            }
            else
            {
                existsSpriteRenderer = false;
            }

            Text textComponent = GetComponent <Text>();
            if (textComponent != null)
            {
                if (repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a         = interpolate.GetCurrentPingPongValue();
                    textComponent.color = tempColor;
                }
                else if (!repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    tempColor.a         = interpolate.GetCurrentValue();
                    textComponent.color = tempColor;
                }
            }

            Renderer shaderRenderer = GetComponent <Renderer>();
            if (shaderRenderer != null && !existsSpriteRenderer)
            {
                if (repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    v         = interpolate.GetCurrentPingPongValue();
                    tempColor = Color.HSVToRGB(h, s, v);
                    MaterialPropertiesHandler.SetAlbedoColor(shaderRenderer, tempColor);
                }
                else if (!repeat && !timerForRuntime.IsReachTimeGoal())
                {
                    v         = interpolate.GetCurrentValue();
                    tempColor = Color.HSVToRGB(h, s, v);
                    MaterialPropertiesHandler.SetAlbedoColor(shaderRenderer, tempColor);
                }
            }

            //UpdateChildren();
        }

        #region debug tests
        // print(
        //    "[BASE] R (" + baseColor.r + ") - " +
        //    "G (" + baseColor.g + ") - " +
        //    "B (" + baseColor.b + ") - " +
        //    "A (" + baseColor.a + ")\n" +
        //    "--------------------------------\n" +
        //    "[TEMP] R (" + tempBaseColor.r + ") - " +
        //    "G (" + tempBaseColor.g + ") - " +
        //    "B (" + tempBaseColor.b + ") - " +
        //    "A (" + tempBaseColor.a + ")\n" +
        //    "--------------------------------\n" +
        //    "[" + cont + "] Timer: " + timer.GetElapsed() + "s"
        //);
        #endregion

        CheckChangeAttributes();
    }