Exemplo n.º 1
0
        public override LuaValue Execute(LuaTable enviroment, out bool isBreak)
        {
            LuaValue condition = Condition.Evaluate(enviroment);

            if (condition.GetBooleanValue() == true)
            {
                return(ThenBlock.Execute(enviroment, out isBreak));
            }
            else
            {
                foreach (ElseifBlock elseifBlock in ElseifBlocks)
                {
                    condition = elseifBlock.Condition.Evaluate(enviroment);

                    if (condition.GetBooleanValue() == true)
                    {
                        return(elseifBlock.ThenBlock.Execute(enviroment, out isBreak));
                    }
                }

                if (ElseBlock != null)
                {
                    return(ElseBlock.Execute(enviroment, out isBreak));
                }
            }

            isBreak = false;
            return(null);
        }
Exemplo n.º 2
0
        protected override bool OnExecute(GameState state, Hero hero)
        {
            if (Condition == null)
            {
                return(true);
            }

            if (Condition.Evaluate(state, hero))
            {
                if (ThenBlock != null)
                {
                    return(ThenBlock.Execute(state, hero));
                }
            }
            else if (ElseBlock != null)
            {
                return(ElseBlock.Execute(state, hero));
            }

            return(true);
        }