public void SetFocus(UITattooChooseItem item) { if (_focusItem != null) { _focusItem.OnFocused(false); } _focusItem = item; item.OnFocused(true); if (!buttonOK.gameObject.activeInHierarchy) { buttonOK.gameObject.SetActive(true); } buttonOK.isEnabled = item.CanBear; }
public void Initialize(EnumTattooPart part, UITattoo uiTattoo) { OnDisable(); _selectedPart = part; _uiTattoo = uiTattoo; //list all tattoos, including those equipped on body _ttList = new List <UITattooChooseItem>(); //tattoos in bag List <ItemInventory> bagTTList = PlayerInfo.Instance.PlayerInventory.itemList.FindAll( delegate(ItemInventory ii) { return(ii.ItemData.type == ItemType.tattoo); }); foreach (ItemInventory ii in bagTTList) { TattooData td = DataManager.Instance.GetTattooData(ii.ItemID); if (td.applicableParts.Contains(part)) { GameObject go = NGUITools.AddChild(ttGrid.gameObject, itemPrefab); UITattooChooseItem uiItem = go.GetComponent <UITattooChooseItem>(); uiItem.SetData(td, ii, false, this); _ttList.Add(uiItem); } } //tattoos burnt on body foreach (KeyValuePair <EnumTattooPart, ItemInventory> kvp in PlayerInfo.Instance.playerTattoos.tattooDict) { if (kvp.Key != _selectedPart) { TattooData td = DataManager.Instance.GetTattooData(kvp.Value.ItemID); if (td.applicableParts.Contains(part)) { GameObject go = NGUITools.AddChild(ttGrid.gameObject, itemPrefab); UITattooChooseItem uiItem = go.GetComponent <UITattooChooseItem>(); uiItem.SetData(td, kvp.Value, true, this); _ttList.Add(uiItem); } } } NGUITools.FindInParents <UIDraggablePanel>(ttGrid.gameObject).ResetPosition(); ttGrid.repositionNow = true; labelTitle.text = string.Format("{0} ({1})", Localization.instance.Get("IDS_BUTTON_GLOBAL_EQUIP"), Localization.instance.Get(Utils.k_tattoo_part_names[(int)_selectedPart])); if (_ttList.Count > 0) { SetFocus(_ttList[0]); } else { buttonOK.gameObject.SetActive(false); } }