Exemplo n.º 1
0
    void Update()
    {
        float colorLevelK = 0;

        if (colorLevel > 0)
        {
            float dd = Vector3.Distance(transform.position, positionLastFrame);
            crossedDistanceSinceColorCharge += dd;

            colorLevel = 1f - crossedDistanceSinceColorCharge / distanceAutonomy;
            if (colorLevel < 0)
            {
                colorLevel = 0;
            }
            else
            {
                colorLevelK = Mathf.Sqrt(colorLevel);                 // Sqrt makes a slow-start fast-end curve
            }
            pixelPainter.color    = color;
            pixelPainter.color.a *= colorLevelK;
            pixelPainter.Update(transform.position.x, transform.position.y);
        }

        if (materialRef != null)
        {
            Color matColor = color;
            matColor.r       *= colorLevelK;
            matColor.g       *= colorLevelK;
            matColor.b       *= colorLevelK;
            materialRef.color = matColor;
        }

        positionLastFrame = transform.position;
    }
Exemplo n.º 2
0
    void Update()
    {
        float colorLevelK = 0;

        if (colorLevel > 0)
        {
            Vector3 pos = transform.position;

            float dd = Vector3.Distance(pos, positionLastFrame);
            if (dd > 100f)
            {
                dd = 0;
                positionLastFrame = pos;
            }
            crossedDistanceSinceColorCharge += dd;

            colorLevel = 1f - crossedDistanceSinceColorCharge / distanceAutonomy;
            if (colorLevel < 0)
            {
                colorLevel = 0;
            }
            else if (PolyPaintManager.Instance.decreaseCurve != null)
            {
                colorLevelK = Mathf.Clamp01(
                    PolyPaintManager.Instance.decreaseCurve.Evaluate(colorLevel));
            }
            else
            {
                colorLevelK = Mathf.Sqrt(colorLevel);                 // Sqrt makes a slow-start fast-end curve
            }
            if (pixelPainter != null)
            {
                pixelPainter.color    = color;
                pixelPainter.color.a *= colorLevelK;
                pixelPainter.Update(pos.x, pos.y);
            }
            if (polyPainter != null)
            {
                Color pcolor = color;
                pcolor.a         *= colorLevelK;
                polyPainter.Color = pcolor;
                polyPainter.Update(new Vector2(pos.x, pos.y));
            }

            // Check revealed zones
            if (hiddenPaintingRef != null)
            {
                hiddenPaintingRef.CheckReveal(pos.x, pos.y, colorIndex);
            }
        }
        else
        {
            if (polyPainter != null)
            {
                polyPainter.Finish();
            }
        }

        if (optionalMaterialRef != null)
        {
            Color matColor = color;
            matColor.r *= colorLevelK;
            matColor.g *= colorLevelK;
            matColor.b *= colorLevelK;
            optionalMaterialRef.color = matColor;
        }

        positionLastFrame = transform.position;
    }