| using System.Collections.Generic;  | 
| using System.Linq;  | 
| using UnityEngine;  | 
| using UnityEngine.UI;  | 
|   | 
| public class ChooseItemsWin : UIBase  | 
| {  | 
|     [SerializeField] ItemCell itemCell;  | 
|     [SerializeField] Text nameText;  | 
|     [SerializeField] Text descText;  | 
|     [SerializeField] ScrollerController scroller;  | 
|     [SerializeField] Button openButton;  | 
|     [SerializeField] Text txtChooseNum;  | 
|     [SerializeField] CellView _InitCell;  | 
|   | 
|     string guid;  | 
|     int itemID;  | 
|     int itemCount;  | 
|     int[][] selectArray;  | 
|     protected override void InitComponent()  | 
|     {  | 
|         openButton.AddListener(() =>  | 
|         {  | 
|             if (BoxGetItemModel.Instance.TrySendUse())  | 
|             {   | 
|                 CloseWindow();  | 
|             }  | 
|         });  | 
|     }  | 
|   | 
|     protected override void Start()  | 
|     {  | 
|         _InitCell.cellIdentifier = _InitCell.cellIdentifier + this.GetInstanceID().ToString();  | 
|     }  | 
|   | 
|   | 
|     protected override void OnPreOpen()  | 
|     {  | 
|         BoxGetItemModel.Instance.countChangeAction += OnCountChangeAction;  | 
|         scroller.OnRefreshCell += OnRefreshCell;  | 
|         itemID = ItemTipUtility.mainTipData.baseInfo.itemId;  | 
|         itemCount = ItemTipUtility.mainTipData.baseInfo.count;  | 
|         guid = ItemTipUtility.mainTipData.guid;  | 
|         InitItemsData();  | 
|   | 
|         itemCell.Init(new ItemCellModel(itemID, false, itemCount));  | 
|         var itemConfig = ItemConfig.Get(itemID);  | 
|         nameText.text = itemConfig.ItemName;  | 
|         descText.text = itemConfig.Description;  | 
|   | 
|         if (string.IsNullOrEmpty(guid))  | 
|         {  | 
|             //预览  | 
|             openButton.SetActive(false);  | 
|         }  | 
|         else  | 
|         {  | 
|             BoxGetItemModel.Instance.ClearAll();  | 
|             openButton.SetActive(true);  | 
|         }  | 
|   | 
|         int nowChooseItemCount = BoxGetItemModel.Instance.GetNowChooseItemCount();  | 
|         txtChooseNum.text = Language.Get("L1100", Language.Get("L1107"),  | 
|         UIHelper.AppendColor(TextColType.DarkGreen, $"{nowChooseItemCount}/{itemCount}"));  | 
|           | 
|         CreateScroller();  | 
|     }  | 
|   | 
|     protected override void OnPreClose()  | 
|     {  | 
|         scroller.OnRefreshCell -= OnRefreshCell;  | 
|     }  | 
|   | 
|     void CreateScroller()  | 
|     {  | 
|         scroller.Refresh();  | 
|         for (int i = 0; i < selectArray.Length; i++)  | 
|         {  | 
|             scroller.AddCell(ScrollerDataType.Header, i);  | 
|         }  | 
|         scroller.Restart();  | 
|     }  | 
|   | 
|   | 
|     void OnRefreshCell(ScrollerDataType type, CellView cell)  | 
|     {  | 
|   | 
|         var _cell = cell as ChooseItemsCell;  | 
|         _cell.Display(selectArray[cell.index], guid);  | 
|     }  | 
|   | 
|   | 
|   | 
|     void InitItemsData()  | 
|     {  | 
|         selectArray = BoxGetItemModel.Instance.GetSelectItemsByID(itemID);  | 
|     }  | 
|   | 
|   | 
|   | 
|     private void OnCountChangeAction()  | 
|     {  | 
|         int nowChooseItemCount = BoxGetItemModel.Instance.GetNowChooseItemCount();  | 
|         txtChooseNum.text = Language.Get("L1100", Language.Get("L1107"),  | 
|         UIHelper.AppendColor(TextColType.DarkGreen, $"{nowChooseItemCount}/{itemCount}"));  | 
|     }  | 
|   | 
|   | 
|   | 
| }  | 
|   | 
|   |