示例#1
0
        /// <summary>
        /// run the block in a coroutine way
        /// </summary>
        IEnumerator RunBlock(Block block)
        {
            //check if stopped
            if (mRunningProcess == null)
            {
                yield break;
            }

            //check flow
            if (ControlCmdtor.SkipRunByControlFlow(block))
            {
                yield break;
            }

            if (!block.Disabled)
            {
                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.RunBlock, block));
                yield return(GetBlockInterpreter(block).Run(block));

                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.FinishBlock, block));
            }

            if (block.NextBlock != null)
            {
                yield return(RunBlock(block.NextBlock));
            }
        }
示例#2
0
        /// <summary>
        /// run the block in a coroutine way
        /// </summary>
        IEnumerator RunBlock(Block block)
        {
            //check flow
            if (ControlCmdtor.SkipRunByControlFlow(block))
            {
                yield break;
            }

            if (!block.Disabled)
            {
                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.RunBlock, block));
                yield return(GetBlockInterpreter(block).Run(block));

                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.FinishBlock, block));
            }

            if (block.NextBlock != null)
            {
                //判断是事件Block ("当")
                if ((block.PreviousConnection == null) && (block.NextConnection != null))
                {
                    block.Workspace.EventNextBlock = block.NextBlock;
                }
                else
                {
                    yield return(RunBlock(block.NextBlock));
                }
            }
        }
示例#3
0
        /// <summary>
        /// check if the block is skipped running by the control flow: break, continue..
        /// </summary>
        public static bool SkipRunByControlFlow(Block block)
        {
            ControlCmdtor loopCmdtor = FindParentControlCmdtor(block);

            if (loopCmdtor != null)
            {
                return(loopCmdtor.NeedBreak || loopCmdtor.NeedContinue);
            }
            return(false);
        }
示例#4
0
        protected override void Execute(Block block)
        {
            ControlCmdtor loopCmdtor = ControlCmdtor.FindParentControlCmdtor(block);

            if (loopCmdtor == null)
            {
                throw new Exception("blocks of \"break\" and \"continue\" can only be put in blocks of loop control types");
            }

            switch (block.GetFieldValue("FLOW"))
            {
            case "BREAK":
                loopCmdtor.SetFlowState(ControlFlowType.Break);
                return;

            case "CONTINUE":
                loopCmdtor.SetFlowState(ControlFlowType.Continue);
                return;
            }
        }
        /// <summary>
        /// run the block in a coroutine way
        /// </summary>
        IEnumerator RunBlock(Block block)
        {
            Game.commands.AddPuzzle(block.GetHashCode());
            //Debug.LogFormat("<color=blue>RunBlock {0}</color>", block.GetHashCode());
            //check flow
            if (ControlCmdtor.SkipRunByControlFlow(block))
            {
                yield break;
            }

            if (!block.Disabled)
            {
                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.RunBlock, block));
                yield return(GetBlockInterpreter(block).Run(block));

                CSharp.Interpreter.FireUpdate(new InterpreterUpdateState(InterpreterUpdateState.FinishBlock, block));
            }

            if (block.NextBlock != null)
            {
                yield return(RunBlock(block.NextBlock));
            }
        }