Example #1
0
 public void Finish()
 {
     if (currentStrip != null && !currentStrip.Finished)
     {
         //Debug.Log("End");
         currentStrip.Finish();
         if (moonPaint)
         {
             currentStrip.Fade();
         }
     }
 }
Example #2
0
    void Update()
    {
        // If fading is active
        if (fadeIndex >= 0 && fadeIndex < colors.Length)
        {
            // If there is at least 2 triangles, apply fading.
            if (mesh.vertices.Length >= 4)
            {
                int d = 0, i = 0;
                for (int a = 0; a < 255; a += 32)
                {
                    i = fadeIndex + d;
                    if (i < colors.Length)
                    {
                        colors[i].a = (byte)a;
                    }
                    ++d;
                }

                mesh.colors32 = colors;
            }

            ++fadeIndex;

            // If fading reached the end of the strip
            if (fadeIndex == colors.Length)
            {
                if (next != null)
                {
                    // Start fading the next strip

                    PolyPaintStrip next_script = next.GetComponent <PolyPaintStrip>();
                    // Only not impressible nexts are automatically faded
                    // (only moon paint can't persist. Other kinds of paint are fading
                    // only during impression process, which works a different way)
                    if (!next_script.CanImpress)
                    {
                        next_script.Fade();
                    }
                }
                Destroy();
            }
        }
        else if (Finished && CanImpress)
        {
            if (requestedImpress)
            {
                if (!IsFading)
                {
                    PostImpress();
                    Fade();
                }
            }
            else
            {
                if (!hasBeenQueued)
                {
                    impressQueue.Add(this);
                    hasBeenQueued = true;

                    if (impressQueue.Count >= IMPRESS_QUEUE_MAX_LENGTH)
                    {
                        // Dequeue all in a single persist request
                        foreach (PolyPaintStrip strip in impressQueue)
                        {
                            strip.RequestImpress();
                            //strip.Fade();
                        }
                        impressQueue.Clear();
                    }
                }
                // else, waiting for next dequeueing...
            }
        }
    }