Beispiel #1
0
    public NucleotideCouple buildCoupleFromOneSingle(Nucleotide n, bool reverse = false)
    {
        if (n.isPaired)
        {
            return(null);
        }
        GameObject couple = Instantiate(couplePrefab) as GameObject;

        couple.transform.position = n.transform.position;
        couple.transform.rotation = n.transform.rotation;

        if (!reverse)
        {
            couple.gameObject.GetComponent <NucleotideCouple>().setType(n.type, getPairType(n.type));
            Color c = n.getColor();
            couple.gameObject.GetComponent <NucleotideCouple>().setLeftColor(c);
            couple.gameObject.GetComponent <NucleotideCouple>().setRightColor(Color.white);
        }
        else
        {
            couple.gameObject.GetComponent <NucleotideCouple>().setType(getPairType(n.type), n.type);
            Color c = n.getColor();
            couple.gameObject.GetComponent <NucleotideCouple>().setRightColor(c);
            couple.gameObject.GetComponent <NucleotideCouple>().setLeftColor(Color.white);
        }
        couple.gameObject.GetComponent <NucleotideCouple>().tag = "NucleotideCouple";

        Destroy(n.gameObject);
        return(couple.gameObject.GetComponent <NucleotideCouple>());
    }
Beispiel #2
0
    public NucleotideCouple buildHalfCoupleChainFromOneSingle(Nucleotide chain)
    {
        if (chain.isPaired)
        {
            return(null);
        }

        chain = getHeadOfSingleChain(chain);
        Nucleotide nhead = chain;

        NucleotideCouple n    = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
        NucleotideCouple head = n;

        n.setLeftColor(chain.getColor());
        n.setType(chain.type, Nucleotide.Type.Empty);
        n.needHelix = false;
        while (chain.next)
        {
            chain  = chain.next;
            n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
            n.next.setLeftColor(chain.getColor());
            n.next.setType(chain.type, Nucleotide.Type.Empty);
            n.next.prev               = n;
            n.next.needHelix          = false;
            n.next.transform.rotation = nhead.transform.rotation;
            n = n.next;
        }
        head.transform.rotation = nhead.transform.rotation;
        head.transform.position = nhead.transform.position;
        head.broadcastUpdateTransform();
        destroySingleChain(chain);
        return(head);
    }
Beispiel #3
0
    public NucleotideCouple buildCoupleChainFromTwoSingles(Nucleotide c1, Nucleotide c2, Vector3 position = default(Vector3))
    {
        if (c1.isPaired || c2.isPaired)
        {
            return(null);
        }

        if (getLengthOfSingleChain(c1) != getLengthOfSingleChain(c2))
        {
            return(null);
        }

        c1 = getHeadOfSingleChain(c1);
        if (c1 == getHeadOfSingleChain(c2))
        {
            return(null);
        }

        c2 = getTailOfSingleChain(c2);

        NucleotideCouple n    = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
        NucleotideCouple head = n;

        n.setLeftColor(c1.getColor());
        n.setRightColor(c2.getColor());
        n.setType(c1.type, c2.type);
        while (c1.next)
        {
            c1     = c1.next;
            c2     = c2.prev;
            n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>();
            n.next.setLeftColor(c1.getColor());
            n.next.setRightColor(c2.getColor());
            n.next.setType(c1.type, c2.type);
            n.next.prev = n;
            n           = n.next;
        }
        head.transform.position = position;
        head.broadcastUpdateTransform();
        destroySingleChain(c1);
        destroySingleChain(c2);
        return(n);
    }