示例#1
0
    public void fillDebugWindow(String name)
    {
        if (name == "NULL")
        {
            debugName.text  = "Debug Window";
            debugField.text = "";
            return;
        }
        string[] nameFormat = name.Split('_');
        string   ClassName  = nameFormat[0];

        if (ClassName != currentClassName)
        {
            currentClassName = ClassName;
        }

        CDClass selectedClass = OALProgram.Instance.ExecutionSpace.getClassByName(ClassName);
        string  attributes    = "\nAttributes:\n";

        if (selectedClass.Attributes != null)
        {
            foreach (CDAttribute attribute in selectedClass.Attributes)
            {
                attributes += attribute.Name;
                attributes += ": ";
                attributes += attribute.Type;

                if (selectedClass.Instances.Count > 0)
                {
                    if (selectedClass.Instances[0].State.ContainsKey(attribute.Name) && (selectedClass.Instances[0].State[attribute.Name] != EXETypes.UnitializedName))
                    {
                        attributes += " = ";
                        attributes += selectedClass.Instances[0].State[attribute.Name];
                    }
                }
                attributes += '\n';
            }
        }
        debugName.text = "Class: " + ClassName + '\n' + "Method: " + nameFormat[1] + '\n' + attributes;
        try
        {
            debugField.text = File.ReadAllText(@"Methods/" + name + ".oal");
        }
        catch (IOException e)
        {
            debugField.text = "";
        }
    }
示例#2
0
    // 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;
        }
    }