public void initView() { NovicePacksPush novicePacksPush = NewPeoperGiftPackageManager.Instance.getNovicePacksPush(); if (novicePacksPush == null) { Debug.LogWarning("服务器推送的NovicePacksPush数据null,检测客户端或者服务器推送的数据."); return; } base.FindTransform("ButtonBuyPro").FindChild("BtnConfirmText").GetComponent <Text>().set_text(GameDataUtils.GetChineseContent(301027, false)); XinShouLiBao xinShouLiBao = DataReader <XinShouLiBao> .Get(novicePacksPush.pack.id); if (xinShouLiBao != null) { Icon icon = DataReader <Icon> .Get(xinShouLiBao.Chinese); if (icon != null) { ResourceManager.SetSprite(base.FindTransform("IconImage").GetComponent <Image>(), ResourceManager.GetIconSprite(icon.icon)); } } base.FindTransform("Count").GetComponent <Text>().set_text("X" + novicePacksPush.pack.price); ListPool pool = this.m_ItemPool; pool.Release(); pool.Create(novicePacksPush.pack.items.get_Count(), delegate(int index) { DropItem dropItem = novicePacksPush.pack.items.get_Item(index); int typeId = dropItem.typeId; long count = dropItem.count; ItemShow.SetItem(pool.Items.get_Item(index), typeId, count, false, UINodesManager.T2RootOfSpecial, 3000); }); }
private void Do(int C, int P, int M, bool noisy, bool useRAII, Func <List <int>, int> test) { var pool = ListPool <int> .Create(C); void testCore(List <int> lst) { var len = lst.Count; Assert.AreEqual(0, len); var L = test(lst); len = lst.Count; Assert.AreEqual(L, len); } if (useRAII) { Run(() => pool.New(), o => o.List, o => o.Dispose(), testCore, P, M, noisy); } else { Run(() => pool.Allocate(), o => o, o => pool.Free(o), testCore, P, M, noisy); } }
public void PooledList_GottenTooBig() { var bigPool = ListPool <int> .Create(1, 16, 2048); var smallPool = ListPool <int> .Create(1, 16, 16); TooBig(() => PooledList <int> .New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 1024); TooBig(() => bigPool.New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 2048); TooBig(() => smallPool.New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 16); }
private async Task <byte[]> ReadData(NetworkStream stream) { using (var tempDataBundle = ListPool <byte> .Create()) { while (stream.DataAvailable) { int receivedBytes = await stream.ReadAsync(_dataBundleBuffer, 0, _dataBundleBuffer.Length); tempDataBundle.Value.AddRange(_dataBundleBuffer.Take(receivedBytes)); } return(tempDataBundle.Value.ToArray()); } }
private void SetItems() { List <ShouChong> list = DataReader <ShouChong> .DataList; int loop = 1; int i; for (i = 0; i < list.get_Count(); i++) { int id = list.get_Item(i).Reward.get_Item(0); XDict <int, long> itemDic = FirstPayManager.Instance.GetRewardItems(id); ListPool pool = this.m_ItemPool; if (i == 1) { pool = this.m_ItemPool2; } if (i == 2) { pool = this.m_ItemPool3; } pool.Create(itemDic.Count, delegate(int index) { if (index < itemDic.Count && index < pool.Items.get_Count()) { ItemShow.SetItem(pool.Items.get_Item(index), itemDic.ElementKeyAt(index), itemDic.ElementValueAt(index), false, UINodesManager.T2RootOfSpecial, 3000); Vector3 localScale = new Vector3(0.7f, 0.7f, 0.7f); if (index == 0) { localScale = new Vector3(0.85f, 0.85f, 0.85f); } pool.Items.get_Item(index).GetComponent <RectTransform>().set_localScale(localScale); } if (i == list.get_Count() && itemDic.Count == pool.Items.get_Count()) { if (loop == 3) { this.PlaySpineOfItems(); } loop++; } }); } }
public void Init(DefendFightBtlResultNty result) { if (result != null) { List <ItemBriefInfo> normalDrops = new List <ItemBriefInfo>(); base.FindTransform("Gold").get_gameObject().SetActive(false); base.FindTransform("Exp").get_gameObject().SetActive(false); for (int i = 0; i < result.normalDropItems.get_Count(); i++) { int cfgId = result.normalDropItems.get_Item(i).cfgId; long count = result.normalDropItems.get_Item(i).count; Items item = BackpackManager.Instance.GetItem(cfgId); if (item != null) { if (item.secondType == 15) { base.FindTransform("Gold").get_gameObject().SetActive(true); base.FindTransform("GoldNum").GetComponent <Text>().set_text(count.ToString()); } else if (item.secondType == 16) { base.FindTransform("Exp").get_gameObject().SetActive(true); base.FindTransform("ExpNum").GetComponent <Text>().set_text(count.ToString()); } else { normalDrops.Add(result.normalDropItems.get_Item(i)); } } } ListPool pool1 = base.FindTransform("Items").GetComponent <ListPool>(); pool1.Create(normalDrops.get_Count(), delegate(int index) { if (index < normalDrops.get_Count() && index < normalDrops.get_Count()) { int cfgId2 = normalDrops.get_Item(index).cfgId; long count2 = normalDrops.get_Item(index).count; Debug.LogError(string.Concat(new object[] { "普通掉落:", cfgId2, " ", count2 })); pool1.Items.get_Item(index).GetComponent <SpecialInstancePassItem>().SetData(cfgId2, count2); } }); ListPool pool2 = base.FindTransform("Item2s").GetComponent <ListPool>(); base.FindTransform("extral").get_gameObject().SetActive(result.extendDropItems.get_Count() > 0); pool2.Create(result.extendDropItems.get_Count(), delegate(int index) { if (index < result.extendDropItems.get_Count() && index < pool2.Items.get_Count()) { int cfgId2 = result.extendDropItems.get_Item(index).cfgId; long count2 = result.extendDropItems.get_Item(index).count; Debug.LogError(string.Concat(new object[] { "额外掉落:", cfgId2, " ", count2 })); pool2.Items.get_Item(index).GetComponent <SpecialInstancePassItem>().SetData(cfgId2, count2); } }); } }
public void PooledList_ArgumentChecking() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => ListPool <int> .Create(4, -1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => ListPool <int> .Create(4, 16, -1)); }
public void PooledList_Simple2() { var pool = ListPool <string> .Create(4, 16); PooledList_Simple_Impl(pool); }