public void SetDisplay() { AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber()); AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber()); Atom display = atom; if (!data.IsDiscovered()) { info = Game.Instance.gameData.GetUknownInfo(); display = Game.Instance.gameData.GetUknown(); } else if (!hasBeenDiscovered) { exclamationImage.gameObject.SetActive(true); hasBeenDiscovered = true; clickButton.onClick.RemoveAllListeners(); clickButton.onClick.AddListener(() => { MakeOld(); ElementsPage.Instance.ClickAtom(atom); AudioManager.Instance.PlaySound(clickSound); }); } // Display Stuff atomNumber.text = display.GetAtomicNumber() == -1 ? "" : "" + display.GetAtomicNumber(); atomAbbreviationText.text = display.GetAbbreviation(); Color c = info.GetCategoryColor(); background.color = c; c *= .6f; c.a = 1f; lowBackground.color = c; }
public void Setup(Atom a) { atom = a; AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber()); AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber()); if (!data.IsDiscovered()) { info = Game.Instance.gameData.GetUknownInfo(); data = Game.Instance.gameData.GetUknownData(); a = Game.Instance.gameData.GetUknown(); } // Color Color c = info.GetCategoryColor(); background.color = c; c *= .6f; c.a = 1f; darkBackground.color = c; var sizeDelta = rect == null ? Vector2.zero : rect.sizeDelta; // Name Text { var size = nameText.GetPreferredValues(a.GetName(), Mathf.Infinity, nameText.rectTransform.rect.height); size.y = nameText.rectTransform.sizeDelta.y; size.x += 15f; if (size.x > sizeDelta.x) { sizeDelta.x = size.x; } nameText.text = a.GetName(); } // Curr Amo Text { string text = "Amount:\n " + data.GetCurrAmo(); var size = currAmoText.GetPreferredValues(text, Mathf.Infinity, currAmoText.rectTransform.rect.height); size.y = currAmoText.rectTransform.sizeDelta.y; size.x += 15f; if (size.x > sizeDelta.x) { sizeDelta.x = size.x; } currAmoText.text = text; } // Passive Gain Text { string text = "(+" + data.GetPassiveGain() + ")"; var size = passiveGainText.GetPreferredValues(text, Mathf.Infinity, passiveGainText.rectTransform.rect.height); size.y = passiveGainText.rectTransform.sizeDelta.y; size.x += 15f; if (size.x > sizeDelta.x) { sizeDelta.x = size.x; } passiveGainText.text = text; } rect.sizeDelta = sizeDelta; LateUpdate(); }