IsExecuting() public method

Returns true if the Block is executing a command.
public IsExecuting ( ) : bool
return bool
コード例 #1
0
        /**
         * Start executing a specific child block in the flowchart.
         * The block must be in an idle state to be executed.
         * Returns true if the Block started execution.
         */
        public virtual bool ExecuteBlock(Block block, Action onComplete = null)
        {
            // Block must be a component of the Flowchart game object
            if (block == null ||
                block.gameObject != gameObject)
            {
                return(false);
            }

            // Can't restart a running block, have to wait until it's idle again
            if (block.IsExecuting())
            {
                return(false);
            }

            // Execute the first command in the command list
            block.Execute(onComplete);

            return(true);
        }
コード例 #2
0
        public override void OnEnter()
        {
            if (blockName.Value == "")
            {
                Continue();
            }

            if (flowchart == null)
            {
                flowchart = GetFlowchart();
            }

            Block block = flowchart.FindBlock(blockName.Value);

            if (block == null ||
                !block.IsExecuting())
            {
                Continue();
            }

            block.Stop();

            Continue();
        }
コード例 #3
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;
                }

                if (targetBlock.IsExecuting())
                {
                    Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running.");
                    Continue();
                    return;
                }

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

                // Find the command index to start execution at
                int index = startIndex;
                if (startLabel.Value != "")
                {
                    int labelIndex = targetBlock.GetLabelIndex(startLabel.Value);
                    if (labelIndex != -1)
                    {
                        index = labelIndex;
                    }
                }

                if (targetFlowchart == null ||
                    targetFlowchart.Equals(GetFlowchart()))
                {
                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    StartCoroutine(targetBlock.Execute(index, onComplete));
                }
                else
                {
                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    // Execute block in another Flowchart
                    targetFlowchart.ExecuteBlock(targetBlock, index, onComplete);
                }
            }

            if (callMode == CallMode.Stop)
            {
                StopParentBlock();
            }
            else if (callMode == CallMode.Continue)
            {
                Continue();
            }
        }
コード例 #4
0
        public override void OnEnter()
        {
            //Randomiser
            int randomWeightTotal = 0;

            foreach (WeightedBlockCallClass block in targetBlocks)
            {
                randomWeightTotal += block.bias;
            }
            int randomWeight = UnityEngine.Random.Range(0, randomWeightTotal);

            int curBlockIndex = 0;

            foreach (WeightedBlockCallClass block in targetBlocks)
            {
                if (randomWeight - block.bias <= 0)
                {
                    targetBlock = block.targetBlock;
                }
                else
                {
                    randomWeightTotal -= block.bias;
                }
            }
            if (targetBlock == null)
            {
                Debug.LogError("Issue with the randomising system");
            }
            //

            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;
                }

                if (targetBlock.IsExecuting())
                {
                    Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running.");
                    Continue();
                    return;
                }

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

                // Find the command index to start execution at
                int index = startIndex;
                if (startLabel.Value != "")
                {
                    int labelIndex = targetBlock.GetLabelIndex(startLabel.Value);
                    if (labelIndex != -1)
                    {
                        index = labelIndex;
                    }
                }

                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;
                    }

                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    StartCoroutine(targetBlock.Execute(index, onComplete));
                }
                else
                {
                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    // Execute block in another Flowchart
                    targetFlowchart.ExecuteBlock(targetBlock, index, onComplete);
                }
            }

            if (callMode == CallMode.Stop)
            {
                StopParentBlock();
            }
            else if (callMode == CallMode.Continue)
            {
                Continue();
            }
        }
コード例 #5
0
ファイル: Call.cs プロジェクト: 1194451658/fungus
        public override void OnEnter()
        {
            var flowchart = GetFlowchart();

            if (targetBlock != null)
            {
                // 如果目标block,是自己
                //  * 则,从命令0,开始重头执行
                // 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;
                }

                // target block如果已经执行中
                //  * 报warning错!
                if (targetBlock.IsExecuting())
                {
                    Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running.");
                    Continue();
                    return;
                }

                // Callback action for Wait Until Finished mode
                Action onComplete = null;

                // 等待命令执行完成,并继续的模式
                if (callMode == CallMode.WaitUntilFinished)
                {
                    onComplete = delegate {
                        // 选中当前命令的block
                        flowchart.SelectedBlock = ParentBlock;
                        // 并继续播放
                        Continue();
                    };
                }

                // Find the command index to start execution at
                int index = startIndex;
                if (startLabel.Value != "")
                {
                    int labelIndex = targetBlock.GetLabelIndex(startLabel.Value);
                    if (labelIndex != -1)
                    {
                        index = labelIndex;
                    }
                }

                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;
                    }

                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    StartCoroutine(targetBlock.Execute(index, onComplete));
                }
                else
                {
                    if (callMode == CallMode.StopThenCall)
                    {
                        StopParentBlock();
                    }
                    // Execute block in another Flowchart
                    targetFlowchart.ExecuteBlock(targetBlock, index, onComplete);
                }
            }

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