// Main Couroutine for compiling the OAL of Animation script and then starting the visualisation of Animation public IEnumerator Animate() { Fillers = new List <GameObject>(); lock (this.AnimationBoolLock) { if (this.AnimationIsRunning) { yield break; } else { this.AnimationIsRunning = true; } } bool Success; AnimationCommandStorage ACS = null; Debug.Log("In try block"); List <Anim> animations = AnimationData.Instance.getAnimList(); Anim selectedAnimation = AnimationData.Instance.selectedAnim; if (animations != null) { if (animations.Count > 0 && selectedAnimation.AnimationName.Equals("")) { selectedAnimation = animations[0]; } } OALProgram Program = OALProgram.Instance; List <AnimClass> MethodsCodes = selectedAnimation.GetMethodsCodesList(); //Filip string Code = selectedAnimation.Code; //toto potom mozno pojde prec Debug.Log("Code: "); Debug.Log(Code); foreach (AnimClass classItem in MethodsCodes) //Filip { CDClass Class = Program.ExecutionSpace.getClassByName(classItem.Name); foreach (AnimMethod methodItem in classItem.Methods) { CDMethod Method = Class.getMethodByName(methodItem.Name); //ak je methodItem.Code nie je prazdny retazec tak parsuj //if (!string.IsNullOrWhiteSpace(methodItem.Code)) //toto asi uz nebude potrebne //{ EXEScopeMethod MethodBody = OALParserBridge.Parse(methodItem.Code); Method.ExecutableCode = MethodBody; //} /*else {//// * Method.ExecutableCode = null; * }///*/ } } if (Program.ExecutionSpace.getClassByName(startClassName).getMethodByName(startMethodName) == null) { Debug.Log("Error, Method not found"); } //najdeme startMethod z daneho class stringu a method stringu, ak startMethod.ExecutableCode je null tak return null alebo yield break EXEScopeMethod MethodExecutableCode = Program.ExecutionSpace.getClassByName(startClassName).getMethodByName(startMethodName).ExecutableCode; if (MethodExecutableCode == null) { Debug.Log("Warning, EXEScopeMethod of selected Method is null"); yield break; } OALProgram.Instance.SuperScope = MethodExecutableCode;//StartMethod.ExecutableCode //OALProgram.Instance.SuperScope = OALParserBridge.Parse(Code); //Method.ExecutableCode dame namiesto OALParserBridge.Parse(Code) pre metodu ktora bude zacinat ACS = new AnimationCommandStorage(); bool temp = Program.PreExecute(ACS); Debug.Log("Done executing: " + temp.ToString()); ACS.ClearSteps(); Success = true; if (Success) { Debug.Log("We have " + ACS.AnimationSteps.Count() + " anim sequences"); foreach (List <AnimationCommand> AnimationSequence in ACS.AnimationSteps) { BarrierSize = AnimationSequence.Count; Debug.Log("Filling barrier of size " + BarrierSize); CurrentBarrierFill = 0; if (!AnimationSequence.Any()) { continue; } if (AnimationSequence[0].IsCall) { foreach (AnimationCommand Command in AnimationSequence) { StartCoroutine(Command.Execute()); } yield return(StartCoroutine(BarrierFillCheck())); } else { foreach (AnimationCommand Command in AnimationSequence) { Command.Execute(); } } } } Debug.Log("Over"); lock (this.AnimationBoolLock) { this.AnimationIsRunning = false; } }
public void SetMethodCode(string className, string methodName, string code) //Filip { int index = methodName.IndexOf("("); methodName = methodName.Substring(0, index); // remove "(...)" from method name if (string.IsNullOrWhiteSpace(code)) { AnimClass classItem = MethodsCodes.FirstOrDefault(c => c.Name.Equals(className)); //alebo SingleOrDefault if (classItem != null) { AnimMethod methodItem = classItem.Methods.FirstOrDefault(m => m.Name.Equals(methodName)); //alebo SingleOrDefault if (methodItem != null) { CDMethod Method = OALProgram.Instance.ExecutionSpace.getClassByName(className).getMethodByName(methodName); Method.ExecutableCode = null; classItem.Methods.Remove(methodItem); if (classItem.Methods.Count == 0) { MethodsCodes.Remove(classItem); } } } } else { bool classExist = false; foreach (AnimClass classItem in MethodsCodes) { if (classItem.Name.Equals(className)) { classExist = true; bool methodExist = false; foreach (AnimMethod methodItem in classItem.Methods) { if (methodItem.Name.Equals(methodName)) { methodExist = true; methodItem.Code = code; break; } } if (!methodExist) { AnimMethod Method = new AnimMethod(methodName, code); classItem.Methods.Add(Method); } break; } } if (!classExist) { AnimMethod Method = new AnimMethod(methodName, code); AnimClass Class = new AnimClass(className); Class.Methods.Add(Method); MethodsCodes.Add(Class); } } }