예제 #1
0
    /// <summary>
    /// Handle an event on a line segment.
    /// </summary>
    /// <param name="_event">Event.</param>
    /// <param name="segment">Segment.</param>
    public static void HandleEvent(string _event, CLM.LINE.SEGMENT segment)
    {
        if (_event.Contains("("))
        {
            //get all actions delimitted by a comma
            string[] actions = _event.Split(' ');
            for (int i = 0; i < actions.Length; i++)
            {
                NovelController.instance.HandleAction(actions[i]);
            }
            return;
        }

        string[] eventData = _event.Split(' ');

        switch (eventData[0])
        {
        case "txtSpd":
            EVENT_TxtSpd(eventData[1], segment);
            break;

        case "/txtSpd":
            segment.architect.speed = 1;
            segment.architect.charactersPerFrame = 1;
            break;
        }
    }
예제 #2
0
    public static void HandleEvents(string _Events, CLM.LINE.SEGMENT segment)
    {
        if (_Events.Contains("("))
        {
            string[] actions = _Events.Split(' ');
            for (int i = 0; i < actions.Length; i++)
            {
                NovelController.instance.handleActions(actions[i]);
            }
            return;
        }
        string[] eventData = _Events.Split(' ');
        print("data" + eventData[0]);
        switch (eventData[0])
        {
        case "txtSpd":
            EVENTS_txtSpd(eventData[1], segment);
            print(eventData[1]);
            break;

        case "/txtSpd":
            segment.architect.speed = 1;
            segment.architect.charactersPerFrame = 1;
            break;
        }
    }
예제 #3
0
    /// <summary>
    /// Change the text speed of the segment's textArchitect.
    /// </summary>
    /// <param name="data">Data.</param>
    /// <param name="seg">Seg.</param>
    static void EVENT_TxtSpd(string data, CLM.LINE.SEGMENT seg)
    {
        string[] parts = data.Split(',');
        float    delay = float.Parse(parts[0]);
        int      charactersPerFrame = int.Parse(parts[1]);

        seg.architect.speed = delay;
        seg.architect.charactersPerFrame = charactersPerFrame;
    }
예제 #4
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;
    }
예제 #5
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;
    }
예제 #7
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;
    }