Esempio n. 1
0
        public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements)
        {
            CodeExpression valueExpr = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], null) ?? new CodePrimitiveExpression(null);

            statements.Add(Variable_ScriptGenerator.CreateVarValueSetStatement(bdi, valueExpr));
            return(true);
        }
 public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements)
 {
     if (bdi.paramBlocks[0] != null && bdi.paramBlocks[0].b.GetType() == typeof(Variable_Block))
     {
         CodeExpression          left = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(float));
         CodePrimitiveExpression codePrimitiveExpression = new CodePrimitiveExpression(0f);
         CodeStatement           codeStatement           = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], codePrimitiveExpression);
         if (codeStatement == null)
         {
             throw new Exception("error: setVar0F");
         }
         CodeStatement codeStatement2 = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.Subtract, new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(typeof(Time)), "deltaTime")));
         if (codeStatement2 == null)
         {
             throw new Exception("error: setVarDeltaTime");
         }
         CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi);
         if (array == null)
         {
             throw new Exception("error: childStatements");
         }
         ArrayUtility.Insert(ref array, 0, codeStatement);
         CodeStatement codeStatement3 = new CodeConditionStatement(new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.LessThanOrEqual, codePrimitiveExpression), array);
         CodeStatement value          = new CodeConditionStatement(new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.GreaterThan, codePrimitiveExpression), codeStatement2, codeStatement3);
         statements.Add(value);
         return(true);
     }
     Debug.LogError("Invalid variable type");
     return(false);
 }
Esempio n. 3
0
        public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements)
        {
            CodeExpression codeExpression = (bdi.paramBlocks[1] == null) ? new CodePrimitiveExpression(0) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], typeof(int));

            if (codeExpression == null)
            {
                throw new Exception("Error: startVal");
            }
            CodeExpression codeExpression2 = (bdi.paramBlocks[2] == null) ? new CodePrimitiveExpression(0) : BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[2], typeof(int));

            if (codeExpression2 == null)
            {
                throw new Exception("Error: endVal");
            }
            CodeStatement  codeStatement   = null;
            CodeExpression codeExpression3 = null;
            CodeStatement  codeStatement2  = null;

            if (bdi.paramBlocks[0] == null)
            {
                string cleanEventVariableName = BloxScriptGenerator.GetCleanEventVariableName("", true);
                statements.Add(new CodeVariableDeclarationStatement(typeof(int), cleanEventVariableName, new CodePrimitiveExpression(0)));
                CodeVariableReferenceExpression left = new CodeVariableReferenceExpression(cleanEventVariableName);
                codeStatement   = new CodeAssignStatement(left, codeExpression);
                codeExpression3 = new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.LessThan, codeExpression2);
                codeStatement2  = new CodeAssignStatement(left, new CodeBinaryOperatorExpression(left, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1)));
            }
            else
            {
                codeStatement = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], codeExpression);
                if (codeStatement == null)
                {
                    throw new Exception("Error: initSt");
                }
                CodeExpression codeExpression4 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[0], typeof(int));
                if (codeExpression4 == null)
                {
                    throw new Exception("error: getVarVal");
                }
                codeExpression3 = new CodeBinaryOperatorExpression(codeExpression4, CodeBinaryOperatorType.LessThan, codeExpression2);
                codeStatement2  = Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.paramBlocks[0], new CodeBinaryOperatorExpression(codeExpression4, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1)));
                if (codeExpression4 == null)
                {
                    throw new Exception("error: incSt");
                }
            }
            CodeStatement[] array = BloxScriptGenerator.CreateChildBlockCodeStatements(bdi);
            if (array == null)
            {
                throw new Exception("Error: childStatements");
            }
            statements.Add(new CodeIterationStatement(codeStatement, codeExpression3, codeStatement2, array));
            return(true);
        }
Esempio n. 4
0
        public override bool CreateBlockCodeStatements(BloxBlockEd bdi, CodeStatementCollection statements)
        {
            if (!Array_Add_ScriptGenerator.IsValidContext(bdi.contextBlock))
            {
                return(false);
            }
            CodeExpression codeExpression = BloxScriptGenerator.CreateBlockCodeExpression(bdi.contextBlock, typeof(Array));

            if (codeExpression == null)
            {
                return(false);
            }
            CodeExpression valueExpr = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(BloxUtil)), "ArrayClear", codeExpression);

            if (bdi.contextBlock.b.GetType() == typeof(Variable_Block))
            {
                statements.Add(Variable_ScriptGenerator.CreateVarValueSetStatement(bdi.contextBlock, valueExpr));
                return(true);
            }
            statements.Add(BloxScriptGenerator.CreateMemberSetExpression(bdi.contextBlock, valueExpr, typeof(Array)));
            return(true);
        }