using FairyGUI; using UI.CommonGame; using System.Collections; using System.Collections.Generic; namespace GFGGame { public class GetBonusView : BaseWindow { private UI_GetBonusUI _ui; private List _bonusList; protected override void OnInit() { base.OnInit(); _ui = UI_GetBonusUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; _ui.m_listBonus.itemRenderer = UpdateBonusItem; _ui.m_listBonus.onClickItem.Add(OnClickListBonusItem); } protected override void OnShown() { base.OnShown(); _bonusList = this.viewData as List; if (_bonusList != null) { _ui.m_listBonus.numItems = _bonusList.Count; } else { _ui.m_listBonus.numItems = 0; } if (_ui.m_listBonus.numItems > 4) { _ui.m_listBonus.columnGap = 40; } else { _ui.m_listBonus.columnGap = 60; } int targetY = (int)(this.viewCom.y + _ui.target.y + _ui.target.height); GuideController.TryGuideByGuideId(null, ConstGuideId.GET_BONUS_VIEW, 1, false, "恭喜你,获得了第一份奖励,点击图标可以查看物品信息,点击半透明区域继续", targetY); Timers.inst.AddUpdate(UpdateToCheckGuide); } protected override void OnHide() { base.OnHide(); GuideController.HideGuide(); GuideController.TryCompleteGuide(ConstGuideId.GET_BONUS_VIEW); TryCompleteGuide(); GetSuitItemController.TryShow(0); Timers.inst.Remove(UpdateToCheckGuide); } private void OnClickListBonusItem(EventContext context) { GComponent item = context.data as GComponent; int itemId = (int)item.data; GoodsItemTipsController.ShowItemTips(itemId); } private void UpdateBonusItem(int index, GObject item) { ItemData itemData = _bonusList[index] as ItemData; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id); UI_BonusItem listItem = UI_BonusItem.Proxy(item); listItem.m_goodsItem.m_txtNumber.text = "x" + itemData.num; listItem.m_txtOwned.SetVar("count", "" + ItemDataManager.GetItemNum(itemData.id)).FlushVars(); listItem.m_goodsItem.m_txtName.text = itemCfg.name; listItem.m_goodsItem.m_iconItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg); listItem.m_iconBonusOnce.visible = itemData.isOnceBonus; RarityIconController.UpdateRarityIcon(listItem.m_goodsItem.m_iconItem.m_rarity, itemData.id, true); listItem.target.data = itemData.id; } private void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; GuideController.TryGuide(null, ConstGuideId.GET_BONUS_FIRST, 1, "恭喜你,获得了第一份奖励,点击图标可以查看物品信息,点击半透明区域继续", false, 0, true, false, (int)(this.viewCom.y + _ui.target.y + _ui.target.height)); } private void TryCompleteGuide() { GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.GET_BONUS_FIRST); GuideController.TryCompleteGuideIndex(cfg.id, 1); GuideController.TryCompleteGuide(ConstGuideId.GET_BONUS_FIRST, 1); } } }