Example #1
0
        public override async Task <StmtResult> Eval(EvalContext context)
        {
            //Debug.Log("if begins");
            await base.Eval(context);

            //object condResult = Cond.Eval();
            object condResult = Inst.CommandMgr.Sense(context, Cond.type);

            if (condResult is bool)
            {
                bool condValue = (bool)condResult;
                if ((condValue ^ Cond.Value) && Then != null)
                {
                    return(await Then.Eval(context));
                }
                if (Else != null)
                {
                    return(await Else.Eval(context));
                }
                return(StmtResult.None);
            }
            else
            {
                throw new LangException("condition in if is not boolean");
            }
        }
Example #2
0
        public override async Task <StmtResult> Eval(EvalContext context)
        {
            //Debug.Log("repeat begins");
            await base.Eval(context);

            while (true)
            {
                //Debug.Log("repeatbody begins");
                StmtResult result = await Body.Eval(context);

                if (result == StmtResult.Break || context.Target.isActiveAndEnabled == false)
                {
                    return(StmtResult.None);
                }
                Block newbody = (Block)Body;
                if (newbody.Statements.Count == 1 && newbody.Statements[0] is If)
                {
                    //임시방편
                    await new WaitForSeconds(0.2f);
                }
            }
        }
Example #3
0
 public async void Execute(EvalContext context, Stmt program)
 {
     ExecutingPrograms++;
     try
     {
         await program.Eval(context);
     }
     catch (CancelException ex)
     {
         Debug.Log(ex);
     }
     catch (NullTargetException ex)
     {
         Debug.Log(ex);
     }
     catch (Exception ex)
     {
         Debug.LogError(ex);
     }
     finally
     {
         ExecutingPrograms--;
     }
 }