Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        _dnaSequenceGenerator = new DnaSequenceGenerator();
        char[] bases = _dnaSequenceGenerator.GenerateSequence(_size);
        correct = new bool[_size];
        pairs   = new Dictionary <int, String[]>();
        for (var i = 0; i < bases.Length; i++)
        {
            bool       isWrong = Random.value <= mistakeRate;
            GameObject b       = Instantiate(baseTemplate, new Vector2(i * 1.2f, this.transform.position.x), this.transform.rotation);
            b.name = bases[i].ToString() + i.ToString();
            b.GetComponentInChildren <BaseButoonAppearance>().label = bases[i].ToString();
            b.GetComponentInChildren <BaseButoonAppearance>().color = DnaSequenceGenerator.getBaseColor(bases[i]);
            b.GetComponentInChildren <BaseButoonAppearance>().id    = i;
            b.GetComponentInChildren <SpriteRenderer>().sprite      = (bases[i].Equals('A') || bases[i].Equals('T') ? tx2d : tx3d);
            b.transform.parent = this.gameObject.transform;

            char       match = _dnaSequenceGenerator.BaseMatch(bases[i], isWrong);
            GameObject c     = Instantiate(baseTemplate, new Vector2(i * 1.2f, this.transform.position.y - 2f), this.transform.rotation);
            c.name = match.ToString() + i.ToString();
            c.GetComponentInChildren <BaseButoonAppearance>().label = match.ToString();
            c.GetComponentInChildren <BaseButoonAppearance>().color = DnaSequenceGenerator.getBaseColor(match);
            c.GetComponentInChildren <BaseButoonAppearance>().id    = i;
            c.GetComponentInChildren <SpriteRenderer>().sprite      = (match.Equals('A') || match.Equals('T') ? tx2d : tx3d);
            c.GetComponentInChildren <SpriteRenderer>().flipY       = true;
            c.GetComponentInChildren <SpriteRenderer>().gameObject.transform.Translate(0, 0.5f, 0);

            c.transform.parent = this.gameObject.transform;

            correct[i] = isWrong;
            pairs[i]   = new string[] { bases[i].ToString(), match.ToString() };
        }
    }
    private void OnMouseDown()
    {
        char newLabel = DnaSequenceGenerator.GetNextBase(this.label[0]);

        this.gameObject.GetComponentInChildren <TextMeshPro>().text = newLabel.ToString();
        label = newLabel.ToString();

        this.gameObject.GetComponentInChildren <SpriteRenderer>().color = DnaSequenceGenerator.getBaseColor(newLabel);

        this.gameObject.GetComponentInChildren <SpriteRenderer>().sprite = ((label.Equals("A") || label.Equals("T")) ? tx2d : tx3d);
    }
 // Start is called before the first frame update
 void Start()
 {
     _gameObjects          = new Queue <GameObject>();
     _dnaSequenceGenerator = new DnaSequenceGenerator();
     score = int.Parse(scoreLabel.text);
 }