Exemple #1
0
        public override void OnEnter()
        {
            var flowchart = GetFlowchart();

            if (targetBlock != null)
            {
                // Check if calling your own parent block
                if (ParentBlock != null && ParentBlock.Equals(targetBlock))
                {
                    // Just ignore the callmode in this case, and jump to first command in list
                    Continue(0);
                    return;
                }

                // Callback action for Wait Until Finished mode
                Action onComplete = null;
                if (callMode == CallMode.WaitUntilFinished)
                {
                    onComplete = delegate {
                        flowchart.SelectedBlock = ParentBlock;
                        Continue();
                    };
                }

                if (targetFlowchart == null ||
                    targetFlowchart.Equals(GetFlowchart()))
                {
                    // If the executing block is currently selected then follow the execution
                    // onto the next block in the inspector.
                    if (flowchart.SelectedBlock == ParentBlock)
                    {
                        flowchart.SelectedBlock = targetBlock;
                    }

                    StartCoroutine(targetBlock.Execute(startIndex, onComplete));
                }
                else
                {
                    // Execute block in another Flowchart
                    targetFlowchart.ExecuteBlock(targetBlock, startIndex, onComplete);
                }
            }

            if (callMode == CallMode.Stop)
            {
                StopParentBlock();
            }
            else if (callMode == CallMode.Continue)
            {
                Continue();
            }
        }