Exemplo n.º 1
0
    /// <summary>
    /// Plays the given state on all controlled flow blocks.
    /// </summary>
    /// <param name='state'>
    /// Flow state.
    /// </param>
    public void PlayFlow(FlowBlock.FlowState state)
    {
        Debug.Log("Playing flow: " + state + " on scene: " + name);
        finishedBlocks = 0;

        foreach (FlowBlock currentBlock in blocks)
        {
            currentBlock.PlayState(state);
            currentBlock.OnPlayingFinished += OnFlowBlockFinished;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Raised when the give flow block finishes playing. Used to test if all flow blocks finished playing and, if true, to raise the corresponding event.
    /// </summary>
    /// <param name='block'>
    /// The block that finished playing.
    /// </param>
    public void OnFlowBlockFinished(PlayableBlock block)
    {
        finishedBlocks++;

        if (finishedBlocks == blocks.Length)
        {
            // All finished, raise corresponding event
            FlowBlock.FlowState state = (block as FlowBlock).State;

            Debug.Log("Finished flow: " + state + " on scene: " + name);

            switch (state)
            {
            case FlowBlock.FlowState.Intro:
                if (OnIntroFinished != null)
                {
                    OnIntroFinished(this);
                }
                break;

            case FlowBlock.FlowState.Idle:
                if (OnIdleFinished != null)
                {
                    OnIdleFinished(this);
                }
                break;

            case FlowBlock.FlowState.Outro:
                if (OnOutroFinished != null)
                {
                    OnOutroFinished(this);
                }
                break;
            }
        }
    }