Esempio n. 1
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;
        }
    }
Esempio n. 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;
        string     Code    = selectedAnimation.Code;

        Debug.Log("Code: ");
        Debug.Log(Code);
        OALProgram.Instance.SuperScope = OALParserBridge.Parse(Code);

        foreach (CDClass Class in Program.ExecutionSpace.ClassPool)
        {
            EXECommandQueryCreate CreateCommand = new EXECommandQueryCreate(Class.Name);
            Program.SuperScope.Commands.Insert(0, CreateCommand);
        }

        ACS = new AnimationCommandStorage();
        bool temp = Program.PreExecute(ACS);

        Debug.Log("Done executing: " + temp.ToString());
        ACS.ClearSteps();
        Success = true;

        ////
        originalText = Code;
        ScriptParser.Instance.Parse(Code);
        my_index = 0;
        ////

        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();
                    }
                }
            }
        }
        lock (this.AnimationBoolLock)
        {
            this.AnimationIsRunning = false;
        }
    }