private ItemBar AddItem(BagItem item, string key, string eventKey, string count) { ItemBar bar = new ItemBar(); SimpleProto model = SingletonManager.Get <FreeUiManager>().GetUIData(key); if (model == null) { Debug.LogWarningFormat("item '{0}' is not defined.", key); return(null); } FreePrefabComponent ff = new FreePrefabComponent(); ff.parentObject = parentBag; int realCount = 1; if (!string.IsNullOrEmpty(count)) { realCount = int.Parse(count); } TipUtil.AddTip(eventKey, new TipData(item.cat, item.id, realCount)); ff.Initial(model.Ss[2], model.Ss[3]); ff.SetValues("TEXT_ItemNumber" + FreeMessageConstant.SpilterField + count); ff.SetEvents(""); ff.SetAllEventKey(eventKey); bar.prefab = ff; bar.value = model.Ss[2].Split(FreeMessageConstant.SpliterStyle)[1]; return(bar); }
private void RefreshBag(Contexts context, PlayerEntity player) { if (CurrentBag != null && (lastBag == null || lastBag != CurrentBag)) { lastBag = CurrentBag; foreach (ItemBar prefab in bagDic) { ReturnObject(prefab); } bagDic.Clear(); List <BagItem> items = new List <BagItem>(); for (int i = 0; i < CurrentBag.Ins[0]; i++) { string key = CurrentBag.Ss[i * 3 + 1]; string eventKey = CurrentBag.Ss[i * 3 + 2]; string count = CurrentBag.Ss[i * 3 + 3]; BagItem item = new BagItem(); item.key = key; item.eventKey = eventKey; item.count = count; item.cat = CurrentBag.Ins[i * 2 + 1]; item.id = CurrentBag.Ins[i * 2 + 2]; items.Add(item); } items.Sort(new BagItemSorter()); foreach (BagItem item in items) { ItemBar prefab = AddItem(item, item.key, item.eventKey, item.count); if (prefab != null) { bagDic.Add(prefab); } } SetWeight(); } }