Пример #1
0
    // TEMPORARY HANDLING OF ANIMATION
    public IEnumerator TempAni(List <InstructionObject> toAnimate)
    {
        foreach (InstructionObject joe in toAnimate)
        {
            if (joe.instruction == "NucleosomeClass.CreateNucleosome")
            {
                NucleosomeClass.CreateNucleosome(joe.TranscriptionSimObject);
            }
            else if (joe.instruction == "TranscriptionFactorClass.CreateTranscriptionFactor")
            {
                TranscriptionFactorClass.CreateTranscriptionFactor(joe.TranscriptionSimObject);
            }
            else if (joe.instruction == "TranscriptionalMachineryClass.CreateTranscriptionalMachinery")
            {
                TranscriptionalMachineryClass.CreateTranscriptionalMachinery(joe.TranscriptionSimObject);
            }

            if (joe.instruction == "ObjectsOnDNA.DeleteObject")
            {
                ObjectsOnDNA.DeleteObject(joe.TranscriptionSimObject);
            }

            if ((joe.instruction.Contains("0") || joe.instruction.Contains("1") || joe.instruction.Contains("2") ||
                 joe.instruction.Contains("3") || joe.instruction.Contains("4") || joe.instruction.Contains("5") ||
                 joe.instruction.Contains("6") || joe.instruction.Contains("7") || joe.instruction.Contains("8") ||
                 joe.instruction.Contains("9")) && !joe.instruction.Contains("Init"))
            {
                var xPos = Convert.ToSingle(joe.instruction);

                ObjectsOnDNA.MoveObject(joe.TranscriptionSimObject, xPos);
            }


            if (joe.instruction == "'Binding'" || joe.instruction == "'Unbinding'" || joe.instruction == "'Stable'")
            {
                ObjectsOnDNA.ChangeSubtype(joe.TranscriptionSimObject, joe.instruction);
            }
            else if (joe.instruction.Contains("Crick") || joe.instruction.Contains("Watson"))
            {
                ObjectsOnDNA.ChangeSubtype(joe.TranscriptionSimObject, joe.instruction);
            }

            if (joe.instruction == "WAIT")
            {
                ObjectsOnDNA.MakeWait(joe.TranscriptionSimObject);
            }
        }

        yield return(0);
    }
Пример #2
0
    public IEnumerator parseList(LinkedList <List <InstructionObject> > ll)
    {
        LinkedListNode <List <InstructionObject> > cursor;

        cursor = ll.First;


        while (cursor != null)
        {
//			yield return StartCoroutine_Auto (TimeStep.instance.JustWait ());

            foreach (InstructionObject current in cursor.Value)
            {
                int  x;
                bool isNumeric = int.TryParse(current.instruction, out x);
                Debug.Log("CHAAAAAAAAAAAAAAAAAAAD" + x);

                //Create TF
                if (current.instruction == "TranscriptionFactorClass.CreateTranscriptionFactor")
                {
                    yield return(TranscriptionFactorClass.CreateTranscriptionFactor(current.TranscriptionSimObject));
                }

                //Create Nucleosome
                if (current.instruction == "NucleosomeClass.CreateNucleosome")
                {
                    yield return(NucleosomeClass.CreateNucleosome(current.TranscriptionSimObject));
                }

                //Create TM
                if (current.instruction == "TranscriptionalMachineryClass.CreateTranscriptionalMachinery")
                {
                    yield return(TranscriptionalMachineryClass.CreateTranscriptionalMachinery(current.TranscriptionSimObject));
                }

                //Delete ObjectsOnDNA
                if (current.instruction == "ObjectsOnDNA.DeleteObject")
                {
                    Debug.Log("Here " + current.TranscriptionSimObject.MainType);
                    ObjectsOnDNA.DeleteObject(current.TranscriptionSimObject);
                    yield return(0);
                }

                //Move Handling
                else if (isNumeric)
                {
                    //Extract coordinates and place into xyz array


                    GameObject[] nucleosomes                = GameObject.FindGameObjectsWithTag("Nucleosome");
                    GameObject[] transcriptionFactors       = GameObject.FindGameObjectsWithTag("TranscriptionFactor");
                    GameObject[] transcriptionalMachineries = GameObject.FindGameObjectsWithTag("TranscriptionalMachinery");

                    float convertPos = (current.TranscriptionSimObject.StartPosition / 3.5f) - .6f;

                    //Nucleosome move handling
                    if (current.TranscriptionSimObject.MainType == "Nucleosome")
                    {
                        foreach (GameObject nuc in nucleosomes)
                        {
                            if (convertPos == nuc.transform.position.x)
                            {
                                Debug.Log("Nuc positions equal");

                                syncList.Add(new syncObj(nuc, x));
                                //iTween.MoveTo(nuc, iTween.Hash("x", x, "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                nuc.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                            else
                            {
                                Debug.Log("Nucleosomes not equal");
                                Debug.Log("ConvertPos = " + convertPos + " Current.start = " + current.TranscriptionSimObject.StartPosition + " Nuc.start = " + nuc.transform.position.x);
                            }
                        }
                    }

                    //Transcription Factor move handling
                    if (current.TranscriptionSimObject.MainType == "Transcription_Factor")
                    {
                        foreach (GameObject tf in transcriptionFactors)
                        {
                            if (convertPos == tf.transform.position.x)
                            {
                                Debug.Log("TF positions equal");

                                syncList.Add(new syncObj(tf, x));
                                //iTween.MoveTo(tf, iTween.Hash("x", xyz[0], "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                tf.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                        }
                    }

                    //Transcriptional Machinery move handling
                    if (current.TranscriptionSimObject.MainType == "Transcriptional_Machinery")
                    {
                        foreach (GameObject tm in transcriptionalMachineries)
                        {
                            if (convertPos == tm.transform.position.x)
                            {
                                Debug.Log("TM positions equal");

                                syncList.Add(new syncObj(tm, x));

                                //iTween.MoveTo(tm, iTween.Hash("x", convertPos, "time", 5));

                                current.TranscriptionSimObject.StartPosition = x;
                                tm.transform.position = new Vector3((x / 3.5f) - .6f, .3f, 0);
                            }
                            else
                            {
                                Debug.Log("ConvertPos = " + convertPos + " Current.start = " + current.TranscriptionSimObject.StartPosition + " TM.start = " + tm.transform.position.x);
                            }
                        }
                    }
                }

                if (current.instruction == "JustWait")
                {
                    Debug.Log("KNOWS TO WAIT");
                    yield return(TimeStep.instance.JustWait());

                    Debug.Log("TRIED TO WAIT");
                }

                foreach (syncObj s in syncList)
                {
                    Debug.Log("obj shit" + s.gObj.name);
                    iTween.MoveTo(s.gObj, iTween.Hash("x", s.coord, "time", 5));
                    Debug.Log("Sync coords: " + s.coord);
                }
            }
            yield return(new WaitForSeconds(6));

            syncList.Clear();
            cursor = cursor.Next;
        }
    }