private GameObject createSelector() { try { Destroy(this.selector); Destroy(GameObject.Find("Selector_CA")); } catch (Exception) { } GameObject selector = IconCA.ImageOBJ(name: "Selector_CA"); selector.transform.SetParent(GenericNotification.transform); if (shadow == null) { Texture2D texture2D = new Texture2D(1, 1); texture2D.SetPixel(0, 0, Color.gray); texture2D.wrapMode = TextureWrapMode.Repeat; texture2D.Apply(); shadow = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(.5f, .5f)); } selector.GetComponent <Image>().sprite = shadow; selector.transform.position = Vector3.zero; selector.GetComponent <RectTransform>().sizeDelta = new Vector2(ItemIconSize, ItemIconSize); return(selector); }
public void PopulateTier(ItemTier tier, bool allAvaiable) { if (selector == null) { selector = createSelector(); } setSelectorPos(0); //List<ItemIndex> tier1 = ItemCatalog.tier1ItemList; List <ItemIndex> tierItems = getAvaiableItems(tier); if (allAvaiable) { switch (tier) { case ItemTier.Tier1: tierItems = RoR2.ItemCatalog.tier1ItemList; break; case ItemTier.Tier2: tierItems = RoR2.ItemCatalog.tier2ItemList; break; case ItemTier.Tier3: tierItems = RoR2.ItemCatalog.tier3ItemList; break; default: break; } } int line = 0; int itemIndex = 0; for (int i = 0; i < tierItems.Count; i++) { ItemDef item = ItemCatalog.GetItemDef(tierItems[i]); if (String.IsNullOrEmpty(item.pickupIconPath)) { return; } //GenericNotification.gameObject IconCA icon = new IconCA(item, GenericNotification, ItemIconSize); iconsCA.Add(icon); if (i % ItemsInLine == 0) { line++; itemIndex = 0; } int x = (int)(-GenericNotification.GetComponent <RectTransform>().sizeDelta.x / 2 + 20 + itemIndex++ *ItemIconSize); int y = (int)(-25 + (-line + 3) * ItemIconSize); icon.SetPos(x, y); } }
public void PopulateEquipment(bool allAvaiable) { if (selector == null) { selector = createSelector(); } setSelectorPos(0); //List<ItemIndex> tier1 = ItemCatalog.tier1ItemList; List <EquipmentIndex> allEquipments = RoR2.EquipmentCatalog.equipmentList; List <PickupIndex> avaiableEquipment = Run.instance.availableEquipmentDropList; int line = 0; int itemIndex = 0; if (allAvaiable) { for (int i = 0; i < allEquipments.Count; i++) { EquipmentDef item = EquipmentCatalog.GetEquipmentDef(allEquipments[i]); if (String.IsNullOrEmpty(item.pickupIconPath)) { return; } //GenericNotification.gameObject IconCA icon = new IconCA(item, GenericNotification, ItemIconSize); iconsCA.Add(icon); if (i % ItemsInLine == 0) { line++; itemIndex = 0; } int x = (int)(-GenericNotification.GetComponent <RectTransform>().sizeDelta.x / 2 + 20 + itemIndex++ *ItemIconSize); int y = (int)(-25 + (-line + 3) * ItemIconSize); icon.SetPos(x, y); } } else { for (int i = 0; i < avaiableEquipment.Count; i++) { EquipmentDef item = EquipmentCatalog.GetEquipmentDef(avaiableEquipment[i].equipmentIndex); if (String.IsNullOrEmpty(item.pickupIconPath)) { return; } //GenericNotification.gameObject IconCA icon = new IconCA(item, GenericNotification, ItemIconSize); iconsCA.Add(icon); if (i % ItemsInLine == 0) { line++; itemIndex = 0; } int x = (int)(-GenericNotification.GetComponent <RectTransform>().sizeDelta.x / 2 + 20 + itemIndex++ *ItemIconSize); int y = (int)(-25 + (-line + 3) * ItemIconSize); icon.SetPos(x, y); } } }