void InitStoreLootItem(StoreInfo info, C2G.StoreLootInfoGetAck ack) { m_store_loot_info = ack; m_BottomToggle.value = true; Array.ForEach(m_Grid.GetComponentsInChildren(typeof(StoreItem), true), i => DestroyImmediate(i.gameObject)); for (int i = 0; i < info.m_LootItem.Count; ++i) { StoreItem item = NGUITools.AddChild(m_Grid.gameObject, StoreItemPrefab).GetComponent <StoreItem>(); pd_StoreLootInfo loot_info = null; if (ack.infos != null) { loot_info = ack.infos.Find(e => e.loot_id == info.m_LootItem[i].ID); } item.Init(info.m_LootItem[i], loot_info); } m_Grid.Reposition(); UIScrollView scroll = m_Grid.GetComponentInParent <UIScrollView>(); if (scroll != null) { scroll.ResetPosition(); } UpdateBottomDesc(); }
void OnLootItem(C2G.StoreLootItem packet, C2G.StoreLootItemAck ack) { if (packet.is_free == true) { if (m_StoreLootInfo == null) { m_StoreLootInfo = new pd_StoreLootInfo(); m_StoreLootInfo.loot_id = m_ItemLoot.ID; m_StoreLootInfo.available_count = m_ItemLoot.refresh_count; m_StoreLootInfo.daily_index = Network.DailyIndex; m_StoreLootInfo.weekly_index = Network.WeeklyIndex; } m_StoreLootInfo.available_count--; m_StoreLootInfo.available_time = Network.Instance.ServerTime.AddMinutes(m_ItemLoot.refresh_free); m_Free.SetActive(false); m_Normal.SetActive(true); } else { Network.PlayerInfo.UseGoods(m_ItemLoot.Price); } GameMain.Instance.UpdatePlayerInfo(); LootItemInfo loot_item_info = null; if (ack.loot_item != null) { ItemManager.Instance.Add(ack.loot_item); loot_item_info = new LootItemInfo(ack.loot_item.item_idn, ack.loot_item.add_piece_count); } else { RuneManager.Instance.Add(ack.loot_rune); loot_item_info = new LootItemInfo(ack.loot_rune.rune_idn, 0); } Popup.Instance.Show(ePopupMode.LootItem, loot_item_info, this); GameMain.Instance.GetCurrentMenu().GetComponent <Store>().UpdateStoreLootFree(); }
void OnLootCreature(C2G.LootCreature packet, C2G.LootCreatureAck ack) { if (packet.is_free == true) { if (m_StoreLootInfo == null) { m_StoreLootInfo = new pd_StoreLootInfo(); m_StoreLootInfo.loot_id = m_ItemLoot.ID; m_StoreLootInfo.available_count = m_ItemLoot.refresh_count; m_StoreLootInfo.daily_index = Network.DailyIndex; m_StoreLootInfo.weekly_index = Network.WeeklyIndex; } m_StoreLootInfo.available_count--; if (m_StoreLootInfo.available_count > 0 || (m_ItemLoot.refresh_count == 0 && m_ItemLoot.refresh_free > 0)) { m_StoreLootInfo.available_time = Network.Instance.ServerTime.AddMinutes(m_ItemLoot.refresh_free); } m_Free.SetActive(false); m_Normal.SetActive(true); m_NeedTicket.SetActive(m_ItemLoot.refresh_free > 0); } else { Network.PlayerInfo.UseGoods(m_ItemLoot.Price); } Network.Instance.LootCreature(ack.creature_loot_data); Popup.Instance.Show(ePopupMode.LootCharacter, ack.creature_loot_data.creature.creature_idx, false, true, this); GameMain.Instance.UpdatePlayerInfo(); GameMain.Instance.GetCurrentMenu().GetComponent <Store>().UpdateStoreLootFree(); }
public void Init(StoreLootItem item, pd_StoreLootInfo loot_info) { m_ItemLoot = item; gameObject.SetActive(true); m_Event.SetActive(false); m_Bonus.SetActive(false); m_SpriteStoreItem.spriteName = item.Image; m_ItemName.text = item.Name; m_NeedTicket.SetActive(false); m_UseIcon.spriteName = item.Price.goods_type.ToString(); m_Price.text = Localization.Format("GoodsFormat", item.Price.goods_value); bool bFree = false; if (item.refresh_count > 0) { m_StoreLootInfo = loot_info; if (m_StoreLootInfo == null) { m_StoreLootInfo = new pd_StoreLootInfo(); m_StoreLootInfo.daily_index = Network.DailyIndex; m_StoreLootInfo.weekly_index = Network.WeeklyIndex; m_StoreLootInfo.available_count = item.refresh_count; m_StoreLootInfo.available_time = DateTime.MinValue; } if (m_StoreLootInfo.daily_index != Network.DailyIndex || m_StoreLootInfo.available_count > 0 && m_StoreLootInfo.available_time <= Network.Instance.ServerTime) { bFree = true; if (m_StoreLootInfo.daily_index != Network.DailyIndex) { if (m_StoreLootInfo.available_time > Network.Instance.ServerTime) { bFree = false; } else { m_StoreLootInfo.daily_index = Network.DailyIndex; m_StoreLootInfo.weekly_index = Network.WeeklyIndex; m_StoreLootInfo.available_count = item.refresh_count; m_StoreLootInfo.available_time = DateTime.MinValue; } } m_LabelNeedTicket.text = Localization.Format("StoreFreeLimit", item.refresh_count, m_StoreLootInfo.available_count); } m_NeedTicket.SetActive(true); } else if (item.refresh_free > 0) { m_StoreLootInfo = loot_info; if (m_StoreLootInfo == null) { m_StoreLootInfo = new pd_StoreLootInfo(); m_StoreLootInfo.daily_index = Network.DailyIndex; m_StoreLootInfo.weekly_index = Network.WeeklyIndex; m_StoreLootInfo.available_count = item.refresh_count; m_StoreLootInfo.available_time = DateTime.MinValue; } if (m_StoreLootInfo.available_time <= Network.Instance.ServerTime) { bFree = true; } m_NeedTicket.SetActive(!bFree); } m_LabelDescTop.text = item.DescTop; m_LabelDescTop.gameObject.SetActive(item.DescTop != ""); if (item.DescBottom != "") { m_LabelNeedTicket.text = item.DescBottom; m_NeedTicket.SetActive(true); } m_Free.SetActive(bFree); m_Normal.SetActive(!bFree); Network.Instance.NotifyMenu.is_store_free_loot |= bFree; }