/// <summary> /// Creates and setups the Selection UI. /// </summary> /// <param name="turret">The turret the option selects</param> /// <param name="shop">The Shop (allows the game to select the turret when the player clicks the panel)</param> /// <param name="lookup">The turret type to glyph lookup</param> public void Init(TurretBlueprint turret, Gameplay.Shop shop, TypeSpriteLookup lookup) { _turretBlueprint = turret; // Turret text displayName.text = turret.displayName; tagline.text = turret.tagline; // Icon and Glyph icon.sprite = turret.shopIcon; TurretGlyphSo glyphSo = lookup.GetForType(turret.prefab.GetComponent <Turret>().GetType()); glyph.sprite = glyphSo.glyph; glyph.color = glyphSo.body; // Turret stats var turretPrefab = turret.prefab.GetComponent <Turret>(); damage.SetData(turretPrefab.damage); rate.SetData(turretPrefab.fireRate); range.SetData(turretPrefab.range); // Turret's Modules if (turret.modules.Count == 0) { modulesSection.SetActive(false); } else { foreach (Module module in turret.modules) { GameObject mod = Instantiate(moduleUI, modulesLayout.transform); mod.name = "_" + mod.name; mod.GetComponentInChildren <TurretModulesIcon>().SetData(module); } } // Colors tagline.color = turret.accent; modulesTitle.color = turret.accent; bg.color = turret.accent; modulesBg.color = turret.accent * new Color(1, 1, 1, .16f); damage.SetColor(turret.accent); rate.SetColor(turret.accent); range.SetColor(turret.accent); // Adds the click event to the card bg.GetComponent <Button>().onClick.AddListener(delegate { MakeSelection(shop); }); }
/// <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); }); }