/// <summary> /// Creates the UI /// </summary> /// <param name="initModule">The module the card is for</param> /// <param name="shop">The shop script</param> /// <param name="lookup">The TypeSpriteLookup to get the glyph</param> public void Init(Module initModule, Gameplay.Shop shop, TypeSpriteLookup lookup) { module = initModule; bg.color = initModule.accentColor; displayName.text = initModule.displayName; tagline.text = initModule.tagline; tagline.color = initModule.accentColor; icon.SetData(initModule); effect.text = initModule.effectText; effect.color = initModule.accentColor; // Adds the any glyph if (initModule.GetValidTypes() == null) { TurretGlyphSo glyphSo = lookup.GetForType(null); Transform glyph = Instantiate(glyphPrefab, applicableGlyphs.transform).transform; glyph.name = "_" + glyph.name; glyph.Find("Body").GetComponent <HexagonSprite>().color = glyphSo.body; glyph.Find("Shade").GetComponent <HexagonSprite>().color = glyphSo.shade; glyph.Find("Glyph").GetComponent <Image>().sprite = glyphSo.glyph; } // Adds the glyph for every turret the module supports else { foreach (Type turretType in initModule.GetValidTypes()) { TurretGlyphSo glyphSo = lookup.GetForType(turretType); Transform glyph = Instantiate(glyphPrefab, applicableGlyphs).transform; glyph.name = "_" + glyph.name; glyph.Find("Body").GetComponent <HexagonSprite>().color = glyphSo.body; glyph.Find("Shade").GetComponent <HexagonSprite>().color = glyphSo.shade; glyph.Find("Glyph").GetComponent <Image>().sprite = glyphSo.glyph; } } // When the card is clicked, the game picks the module bg.GetComponent <Button>().onClick.AddListener(delegate { MakeSelection(shop); }); }
/// <summary> /// Sets the data /// </summary> /// <param name="module">The module the icon is for</param> public void SetData(Module module) { icon.SetData(module); text.text = module.displayName; }