Esempio n. 1
0
    private void NewStrip(Vector3 startPos)
    {
        //Profiler.BeginSample("aaa");
        //++TmpDebug.Instance.newStripsPerFrame;

        PolyPaintStrip prevStrip = null;

        if (currentStrip != null)
        {
            prevStrip = currentStrip;
        }

        GameObject stripObj = new GameObject();

        stripObj.transform.position = startPos;
        stripObj.name           = "generated_paint_strip";
        currentStrip            = stripObj.AddComponent <PolyPaintStrip>();
        stripBeginPos           = startPos;
        currentStrip.CanImpress = !moonPaint;

        if (prevStrip != null)
        {
            prevStrip.Next = currentStrip;
        }

        //Profiler.EndSample();
    }
Esempio n. 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...
            }
        }
    }