예제 #1
0
    void HandleLine(string rawLine)
    {
        CLM.LINE line = CLM.Interpret(rawLine);

        StopHandlingLine();
        handlingLine = StartCoroutine(HandlingLine(line));
    }
예제 #2
0
    void HandleLine(string rawLine)
    {
        CLM.LINE line = CLM.Interpret(rawLine);

        //now we need to handle the line. This requires a loop full of waiting for input since the line consists of multiple segments that have to be handled individually.
        StopHandlingLine();
        handlingLine = StartCoroutine(HandlingLine(line));
    }
예제 #3
0
    IEnumerator HandlingLine(CLM.LINE line)
    {
        //next trigger controls also the progression through a line by its segments, so it must be reset
        _next = false;
        int lineProgress = 0; //Progress through the segments of a line

        while (lineProgress < line.segments.Count)
        {
            _next = false;//reset at the start of cheap loop
            CLM.LINE.SEGMENT segment = line.segments[lineProgress];

            //always run the first segment automatically
            if (lineProgress > 0)
            {
                if (segment.trigger == CLM.LINE.SEGMENT.TRIGGER.autoDelay)  //if it's a segment that need a yield {
                {
                    for (float timer = segment.autoDelay; timer >= 0; timer -= Time.deltaTime)
                    {
                        yield return(new WaitForEndOfFrame());

                        if (_next)
                        {
                            break; //Because the user must be able to skip a wait time if he wants to here
                        }
                    }
                }
                else if (segment.trigger == CLM.LINE.SEGMENT.TRIGGER.autoDelayBlock) //same, but the user won't be able to skip the wait
                {
                    for (float timer = segment.autoDelay; timer >= 0; timer -= Time.deltaTime)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                else
                {
                    while (!_next)
                    {
                        yield return(new WaitForEndOfFrame()); //wait until the player trigger the next segment
                    }
                }
            }
            _next = false;

            //the segment now needs to build and run.
            segment.Run();

            while (segment.isRunning)
            {
                yield return(new WaitForEndOfFrame());

                if (_next)
                {
                    if (!segment.architect.skip)
                    {
                        segment.architect.skip = true;
                    }
                    else
                    {
                        segment.ForceFinish(); //for the finish if the user triggered
                    }
                    _next = false;
                }
            }

            lineProgress++;

            yield return(new WaitForEndOfFrame());
        }
        //Handling all actions set a the end of the line
        for (int i = 0; i < line.actions.Count; i++)
        {
            HandleAction(line.actions[i]);
        }
        handlingLine = null;
    }
예제 #4
0
    IEnumerator HandlingLine(CLM.LINE line)
    {
        _next = false;
        int lineProgress = 0; /// progress trough the line

        while (lineProgress < line.segments.Count)
        {
            _next = false; /// reset at the start of the loop
            CLM.LINE.SEGMENT segment = line.segments[lineProgress];
            /// always running automatically at the beginning of line, and wait for the input for procedding
            if (lineProgress > 0)
            {
                if (segment.trigger == CLM.LINE.SEGMENT.TRIGGER.autoDelay)
                {
                    for (float timer = segment.autoDelayTime; timer >= 0; timer -= Time.deltaTime)
                    {
                        yield return(new WaitForEndOfFrame());

                        if (_next)
                        {
                            break; /// allow to termination the delay when "next" is triggered, prevent from unskippable timer
                        }
                    }
                }
                else
                {
                    while (!_next)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
            }
            _next = false;

            segment.Run();
            while (segment.isRunning)
            {
                yield return(new WaitForEndOfFrame());

                if (_next)
                {
                    if (!segment.architect.skip)
                    {
                        segment.architect.skip = true;
                    }
                    else
                    {
                        segment.ForceFinish();
                    }
                    _next = false;
                }
            }
            lineProgress++;

            yield return(new WaitForEndOfFrame());
        }
        for (int i = 0; i < line.actions.Count; i++)
        {
            handleActions(line.actions[i]);
        }
        handlingLine = null;
    }
    IEnumerator HandlingLine(CLM.LINE line)
    {
        _next = false;
        int lineProgress = 0;

        while (lineProgress < line.segments.Count)
        {
            _next = false;
            CLM.LINE.SEGMENT segment = line.segments[lineProgress];

            if (lineProgress > 0)
            {
                if (segment.trigger == CLM.LINE.SEGMENT.TRIGGER.autoDelay)
                {
                    for (float timer = segment.autoDelay; timer >= 0; timer -= Time.deltaTime)
                    {
                        yield return(new WaitForEndOfFrame());

                        if (_next)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    while (!_next)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
            }
            _next = false;

            segment.Run();
            while (segment.isRunning)
            {
                yield return(new WaitForEndOfFrame());

                if (_next)
                {
                    if (!segment.architect.skip)
                    {
                        segment.architect.skip = true;
                    }
                    else
                    {
                        segment.ForceFinish();
                    }
                    _next = false;
                }
            }

            lineProgress++;

            yield return(new WaitForEndOfFrame());
        }
        for (int i = 0; i < line.actions.Count; i++)
        {
            HandleAction(line.actions[i]);
        }
        handlingLine = null;
    }
예제 #6
0
    IEnumerator HandlingLine(CLM.LINE line)
    {
        //since the "next" trigger controls the flow of a chapter by moving through lines and yet also controls the progression through a line by
        //its segments, it must be reset.
        _next = false;
        int lineProgress = 0;        //progress through the segments of a line.

        while (lineProgress < line.segments.Count)
        {
            _next = false;            //reset at the start of each loop.
            CLM.LINE.SEGMENT segment = line.segments[lineProgress];

            //always run the first segment automatically. But wait for the trigger on all proceding segments.
            if (lineProgress > 0)
            {
                if (segment.trigger == CLM.LINE.SEGMENT.TRIGGER.autoDelay)
                {
                    for (float timer = segment.autoDelay; timer >= 0; timer -= Time.deltaTime)
                    {
                        yield return(new WaitForEndOfFrame());

                        if (_next)
                        {
                            break;                            //allow the termination of a delay when "next" is triggered. Prevents unskippable wait timers.
                        }
                    }
                }
                else
                {
                    while (!_next)
                    {
                        yield return(new WaitForEndOfFrame());                       //wait until the player says move to the next segment.
                    }
                }
            }
            _next = false;            //next could have been triggered during an event above.

            //the segment now needs to build and run.
            segment.Run();

            while (segment.isRunning)
            {
                yield return(new WaitForEndOfFrame());

                //allow for auto completion of the current segment for skipping purposes.
                if (_next)
                {
                    //rapidly complete the text on first advance, force it to finish on the second.
                    if (!segment.architect.skip)
                    {
                        segment.architect.skip = true;
                    }
                    else
                    {
                        segment.ForceFinish();
                    }
                    _next = false;
                }
            }

            lineProgress++;

            yield return(new WaitForEndOfFrame());
        }

        //Line is finished. Handle all the actions set at the end of the line.
        for (int i = 0; i < line.actions.Count; i++)
        {
            HandleAction(line.actions[i]);
        }

        handlingLine = null;
    }