//Enqueues the Variables once parsed private Queue <Variable> VariableSetup() { Queue <Variable> varQueue = new Queue <Variable>(); // Before The code block is returned it is checked to make sure all parameters are correct if (inputField1 != null && inputField1.GetComponent <TMP_InputField>() != null) { varQueue.Enqueue(GetVariable(inputField1.GetComponent <TMP_InputField>().text)); } if (inputField2 != null && inputField1.GetComponent <TMP_InputField>() != null) { varQueue.Enqueue(GetVariable(inputField2.GetComponent <TMP_InputField>().text)); } if (condBlockSetup != null) { codeBlock = condBlockSetup.Invoke(); } else if (inputField3 != null && inputField1.GetComponent <TMP_InputField>() != null) { varQueue.Enqueue(GetVariable(inputField3.GetComponent <TMP_InputField>().text)); } while (varQueue.Count < 3) { //If the varQueue doesnt have 3 it fills the rest with blank Variables varQueue.Enqueue(new Variable()); } return(varQueue); }
//Start method called when level starts public void Start() { // Instantiates a code block relative to the block type switch (blockType) { case CodeBlockType.Add: codeBlock = new Add(); break; case CodeBlockType.Subtract: codeBlock = new Subtract(); break; case CodeBlockType.Multiply: codeBlock = new Multiply(); break; case CodeBlockType.Divide: codeBlock = new Divide(); break; case CodeBlockType.VariableSet: codeBlock = new VariableSet(); break; case CodeBlockType.Output: codeBlock = new OutputBlock(); break; //Contents of these cases sent to a delegate as has to be run later when the code list is being ran //Use of an Anynmous delegate //Using this as it will only be used once and there will be variation between a couple anonymous methods case CodeBlockType.If: condBlockSetup = () => { return(new IfBlock(gameObject, inputField3.GetComponent <TMP_InputField>().text)); }; break; case CodeBlockType.While: condBlockSetup = () => { return(new WhileBlock(gameObject, inputField3.GetComponent <TMP_InputField>().text)); }; break; } }