| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 | using System.Collections;using UnityEngine;using UI.CommonGame;using FairyGUI;using System.Collections.Generic;using System;namespace GFGGame{    public class RewardView : BaseWindow    {        private UI_RewardUI _ui;        private List<ItemData> _listItemDatas;        private Action onSuccess = null;        private List<GMovieClip> _effects = new List<GMovieClip>();        // private List<GoWrapper> _wrappers = new List<GoWrapper>();        private const int maxHeight = 1030;        public override void Dispose()        {            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            _ui = UI_RewardUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            _ui.m_comListReward.m_listReward.SetVirtual();            _ui.m_comListReward.m_listReward.itemRenderer = RenderListRewardItem;            // _ui.m_comListReward.m_listReward.onClickItem.Add(OnClickListReward);            _ui.m_bg.onClick.Add(this.Hide);        }        protected override void OnShown()        {            base.OnShown();            if ((this.viewData as object[]).Length > 0)            {                _listItemDatas = (this.viewData as object[])[0] as List<ItemData>;                onSuccess = (this.viewData as object[])[1] as Action;            }            else            {                _listItemDatas = this.viewData as List<ItemData>;            }            _ui.m_comListReward.m_listReward.numItems = _listItemDatas.Count;            _ui.m_comListReward.m_listReward.ResizeToFit();            if (_ui.m_comListReward.m_listReward.height > maxHeight)            {                _ui.m_comListReward.m_listReward.height = maxHeight;            }        }        protected override void OnHide()        {            if (onSuccess != null)            {                onSuccess();            }            base.OnHide();            _effects.Clear();        }        private void RenderListRewardItem(int index, GObject obj)        {            // obj.data = _listItemDatas[index];            UI_ListRewardItem item = UI_ListRewardItem.Proxy(obj);            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_listItemDatas[index].id);            item.m_comRewardItem.m_txtName.text = itemCfg.name;            // item.m_txtCount.text = _listItemDatas[index].num==1?"": string.Format("x{0}", _listItemDatas[index].num);            item.m_comRewardItem.m_txtCount.text = string.Format("x{0}", _listItemDatas[index].num);            item.m_comRewardItem.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);            item.m_comRewardItem.m_imgOnceBonus.visible = _listItemDatas[index].isOnceBonus;            string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_zl");            int childIndex = _ui.m_comListReward.m_listReward.ItemIndexToChildIndex(index);            if (_effects.Count <= childIndex)            {                _effects.Add(item.m_effect);                item.m_effect.SetPlaySettings(0, -1, 1, -1);            }            if (item.m_comRewardItem.target.data == null)            {                item.m_comRewardItem.target.onClick.Add(OnClickListReward);            }            item.m_comRewardItem.target.data = _listItemDatas[index];        }        private void OnClickListReward(EventContext context)        {            if (this.ShowTips)            {                ItemData data = (context.sender as GObject).data as ItemData;                GoodsItemTipsController.ShowItemTips(data.id);            }        }        private bool _showTips = true;        /// <summary>        /// 是否展示物品详情,默认展示        /// </summary>        private bool ShowTips        {            get { return _showTips; }            set { _showTips = value; }        }    }}
 |