public void InitDiscoveryItem(string formula)
 {
     discovery = GameObject.FindObjectOfType<MoleculeDiscovery>();
     Formula = formula;
     molecule = ComplexMoleculeData.Parse(Formula);
     formulaText = GetComponentInChildren<Text>();
     formulaText.text = molecule.GetAsFormattedText(formulaText.fontSize);
     MathesCount = GetComponentsInChildren<Text>().Where(c => c.name == "MatchesCount").FirstOrDefault();
     MatchesPanel = GetComponentsInChildren<Image>().Where(c => c.name == "MatchesPanel").FirstOrDefault();
     MatchesPanel.enabled = false;
 }
Example #2
0
    // Use this for initialization
    public void StartDiscovery(string formula)
    {
        gameObject.SetActive(true);

        discoveryComplexMoleculeData = ComplexMoleculeData.Parse(formula);

        Clear();

        var formulas = new List<string>();
        formulas.Add(formula);
        var list = DiscoveryFormulas.Where(c => c != formula).ToList();
        for( int i = 0; i < 19; i++)
        {
            var index = Random.Range(0, list.Count);
            formulas.Add(list[index]);
        }

        TryCount = 5;

        var rectTransf = DiscoveryPrefab.GetComponent<RectTransform>();
        for (int i = 0; i < formulas.Count; i++)
        {
            var x = i%4;
            var y = i/4;

            var f = (GameObject)Instantiate(DiscoveryPrefab, Vector3.zero,
                Quaternion.identity);
            f.transform.parent = transform;
            f.transform.localScale = Vector3.one;

            f.transform.localPosition = new Vector3(-400 + x*(rectTransf.sizeDelta.x + 20 + Random.Range(-10, 10)),
                y*rectTransf.sizeDelta.y * 2 - 200 + 20 + Random.Range(-10, 10));

            var item = f.GetComponent<MoleculeDiscoveryItem>();
            item.InitDiscoveryItem(formulas[i]);
        }
        TryCount = 0;
        UpdateTryRemain(5);
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        ItemKey = ContainerFormula;
        _molecules = ComplexMoleculeData.Parse(ContainerFormula);
        foreach (var child in GetComponentsInChildren<Transform>())
        {
            if (child.CompareTag(FormulaLabelTag))
            {
                _formulaLabel = child.gameObject.GetComponent<Text>();
            }

            if (child.CompareTag(ProgressObjectTag))
            {
                _progressObject = child;
            }

        }
        if (_formulaLabel != null)
            _formulaLabel.text = ComplexMoleculeData.Parse(ContainerFormula).GetAsFormattedText(18);

        UpdateTargetHeight();
    }