//Estructuras de control public virtual IEnumerator repetir() { Transform theRobot = (Transform)Init.robotInstance; RobotBehaviour behaviour = (RobotBehaviour)theRobot.GetComponent <RobotBehaviour>(); int i = 0; Type type = behaviour.GetType(); int n = int.Parse((string)arguments[0]); string sentenceName = (string)arguments[1]; if (n > i) { for (i = 0; i < n; i++) { MethodInfo methodInfo = type.GetMethod(sentenceName); behaviour.StartCoroutine(methodInfo.Name, 0); } } else { UI.runtimeErrorMsg = I18N.getValue("the_number_of_repetitions_was_not_specified"); } yield return(new WaitForSeconds(0)); //Fin de ejecucion UI.executingCurrentLine = false; }
/** Efectiviza la animacion de la instruccion */ void executeLine(int lineNo) { // FIXME: Aqui deberia delegarse al robot a fin de que realice la animacion string status = I18N.getValue("exec_line") + (currentLine + 1) + ": " + sentences[lineNo]; statusText = status; // Invocar ejecucion visual via reflection try { object result = null; // Recuperar el BigBang, y a partir de alli el Robot que se tenga configurado Transform theRobot = (Transform)Init.robotInstance; RobotBehaviour behaviour = (RobotBehaviour)theRobot.GetComponent <RobotBehaviour>(); Type type = behaviour.GetType(); // Pruebas para argumentos. Esto igualmente se recibe desde libreria string sentence = (string)sentences[lineNo]; string sentenceName = sentence.Substring(0, sentence.Contains("(") ? sentence.IndexOf("(") : sentence.Length); // Cargar los parametros segun la instruccion que sea. FIXME: Deshardcode if (sentence.Contains("(")) { behaviour.resetArguments(); string sentenceArgs = sentence.Substring(sentence.IndexOf("("), sentence.Length - sentence.IndexOf("(")); sentenceArgs = sentenceArgs.Replace("(", "").Replace(")", "").Replace(" ", ""); string[] args = sentenceArgs.Split(","[0]); for (int i = 0; i < args.Length; i++) { behaviour.addArgument(args[i]); } } MethodInfo methodInfo = type.GetMethod(sentenceName); // ParameterInfo[] parameters = methodInfo.GetParameters(); // Invocar a la corutina encargada de ejecutar la visualizacion behaviour.StartCoroutine(methodInfo.Name, 0); } catch (Exception e) { Debug.Log("Exception!! " + e.ToString()); statusText = I18N.getValue("unknown_line") + (currentLine + 1) + ": " + sentences[currentLine]; run = false; } }