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