public void OnAddItem(BagItem item) { //OnAddItem(bagitem.Index, bagitem.Data); var index = item.Index; var data = item.Data; TinyLogger.Instance.DebugLog("$ Bag add Item start"); if (!System.Object.ReferenceEquals(null, data)) { //if (!System.Object.ReferenceEquals(null, data.Icon)) { // change the element with given texture. if (index < BtnList.Count) { //Sprite sp = MineResource.Instance.LoadSprite(data.Icon); //Sprite sp = MineResource.Instance.LoadSpriteFromAB(Application.dataPath + "/AssetBundles/skillicons", // data.Icon); TinyLogger.Instance.DebugLog("$ bag add +1"); IconData icd = IconManager.Instance.GetIconData(data.IconID); if (!System.Object.ReferenceEquals(icd, null)) { TinyLogger.Instance.DebugLog("$ bag sprite "); Sprite sp = MineResource.Instance.LoadSpriteFromAB(icd.Path, icd.Name); TinyLogger.Instance.DebugLog("$ bag sprite loaded"); if (!System.Object.ReferenceEquals(null, sp)) { BtnList[index].sprite = sp; if (item.Count <= 1) { Texts[index].enabled = false; } else { Texts[index].enabled = true; Texts[index].text = item.Count.ToString(); } TinyLogger.Instance.DebugLog("$ bag sprite assign"); } else { TinyLogger.Instance.DebugLog("$ failed to load sprite!"); } } } } } }
public void AddItem(BagItem item, bool alterUI = true) { var index = item.Index; ItemIndexes.Add(index); if (Items.Count <= index) { Items.Add(index, item); } else { Items[index] = item; } if (alterUI) { TheView.OnAddItem(item); } }
public void LoadContent() { { BagItem bi = new BagItem(); bi.Index = 0; bi.Data = ItemManager.Instance.GetItemData(1000001); bi.Count = 1; bi.MaxCount = 9; //Items.Add(bi.Index, bi); //AddItem(bi.Index, bi.Data, false); AddItem(bi, false); } { BagItem bi = new BagItem(); bi.Index = 1; bi.Data = ItemManager.Instance.GetItemData(1000002); bi.Count = 2; bi.MaxCount = 9; //Items.Add(bi.Index, bi); //AddItem(bi.Index, bi.Data, false); AddItem(bi, false); } { BagItem bi = new BagItem(); bi.Index = 3; bi.Data = ItemManager.Instance.GetItemData(1000003); bi.Count = 3; bi.MaxCount = 9; //Items.Add(bi.Index, bi); //AddItem(bi.Index, bi.Data, false); AddItem(bi, false); } }