using UnityEngine;
using System.Collections;

public class RenderDelay : Render
{
    private Render render;
    private float waitChunk;
    private bool started = false;

	public RenderDelay(Render r, float delay)
    {
        render = r;
        renderDuration = render.Duration + delay;
        nextRenderDelay = delay + render.NextRenderDelay;
        waitChunk = delay / renderDuration;
        ForTurn = render.ForTurn;
    }

    private void Start()
    {
        render.Initialize();
        started = true;
    }

    override public void RenderProgress(float progressFactor)
    {
        if (progressFactor > waitChunk)
        {
            if (!started)
                Start();
            float subprogress = (progressFactor - waitChunk) / (1 - waitChunk);
            render.RenderProgress(subprogress); 
            render.CheckTriggers(subprogress);            
        }
    }
}
