| //--------------------------------------------------------  | 
| //    [Author]:           玩个游戏  | 
| //    [  Date ]:           Wednesday, September 26, 2018  | 
| //--------------------------------------------------------  | 
| using UnityEngine;  | 
| using UnityEngine.UI;  | 
| using System.Collections.Generic;  | 
|   | 
|   | 
| public class CustomizedGiftCell : CellView  | 
| {  | 
|     [SerializeField] Text title;  | 
|     [SerializeField] Text saleValue;  | 
|     [SerializeField] Text limiteBuyCntText;  | 
|     [SerializeField] List<CustomizedItemCell> itemCells;  | 
|     [SerializeField] Button buyBtn;  | 
|     [SerializeField] Text priceText;  | 
|     [SerializeField] Button haveBtn;  | 
|     [SerializeField] Image buyYetImg;  | 
|     [SerializeField] Image haveYetImg;  | 
|     [SerializeField] ImageEx ImgSale;  | 
|     int girdIndex = 0;  | 
|     TextEx orgPrice;  | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     public void Display(int index)  | 
|     {  | 
|         OperationRechargeGiftAct act;  | 
|         if (!OperationTimeHepler.Instance.TryGetOperation(CustomizedGiftModel.operaType, out act))  | 
|         {  | 
|             return;  | 
|         }  | 
|         //免费礼包  | 
|         if (CustomizedGiftModel.Instance.IsFree(index))  | 
|         {  | 
|             ImgSale.SetActive(false);  | 
|             buyBtn.SetActive(false);  | 
|             buyYetImg.SetActive(false);  | 
|             limiteBuyCntText.SetActive(false);  | 
|             haveBtn.SetActive(true);  | 
|             title.text = Language.Get("CustomizedGift02");  | 
|             int totalBuyCnt = CustomizedGiftModel.Instance.GetBuyTotalCnt();  | 
|             var awardInfo = act.buyCountGifts[index];  | 
|             for (int i = 0; i < itemCells.Count; i++)  | 
|             {  | 
|                 if (i < awardInfo.AwardItemList.Length)  | 
|                 {  | 
|                     var award = awardInfo.AwardItemList[i];  | 
|                     itemCells[i].button.interactable = true;  | 
|                     itemCells[i].SetActive(true);  | 
|                     var itemData = new ItemCellModel((int)award.ItemID, false, award.ItemCount);  | 
|                     itemCells[i].Init(itemData);  | 
|                     itemCells[i].button.SetListener(() =>  | 
|                     {  | 
|                         ItemTipUtility.Show((int)award.ItemID);  | 
|                     });  | 
|                 }  | 
|                 else  | 
|                 {  | 
|                     itemCells[i].SetActive(false);  | 
|                 }  | 
|             }  | 
|             haveBtn.SetColorful(null, totalBuyCnt >= awardInfo.NeedBuyCount);  | 
|             haveBtn.interactable = totalBuyCnt >= awardInfo.NeedBuyCount;  | 
|             haveBtn.SetListener(() =>  | 
|             {  | 
|                 CustomizedGiftModel.Instance.SendGetAward(awardInfo.NeedBuyCount);  | 
|             });  | 
|   | 
|             if (index == act.buyCountGifts.Count - 1 && CustomizedGiftModel.Instance.GetBuyGiftState(awardInfo.NeedBuyCount) == 2)  | 
|             {  | 
|                 haveYetImg.SetActive(true);  | 
|                 haveBtn.SetActive(false);  | 
|             }  | 
|             else  | 
|             {  | 
|                 haveYetImg.SetActive(false);  | 
|                 haveBtn.SetActive(true);  | 
|             }  | 
|         }  | 
|         //付费礼包  | 
|         else  | 
|         {  | 
|             haveBtn.SetActive(false);  | 
|             haveYetImg.SetActive(false);  | 
|             limiteBuyCntText.SetActive(true);  | 
|             ImgSale.SetActive(true);  | 
|   | 
|             int actCtgIndex = index - 1;  | 
|             int ctgID = act.ctgIDs[actCtgIndex];  | 
|   | 
|             CustomizedRechargeModel.Instance.ShowUIItems(itemCells, ctgID);  | 
|   | 
|             var ctgConfig = CTGConfig.Get(ctgID);  | 
|             title.text = ctgConfig.Title;  | 
|             saleValue.text = Language.Get("RechargeGiftActWin3", ctgConfig.Percentage);  | 
|             var countInfo = CustomizedGiftModel.Instance.GetBuyCntInfo(ctgID);  | 
|             int buyCnt = countInfo.x;  | 
|             int totalCnt = countInfo.y;  | 
|             limiteBuyCntText.text = Language.Get("RechargeGiftActWin4", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.Green, buyCnt + "/" + totalCnt, true));  | 
|             buyBtn.SetActive(buyCnt < totalCnt);  | 
|             buyBtn.SetListener(() =>  | 
|             {  | 
|                 RechargeManager.Instance.CTG(ctgID);  | 
|             });  | 
|             buyYetImg.SetActive(buyCnt >= totalCnt);  | 
|             OrderInfoConfig orderConfig;  | 
|             RechargeManager.Instance.TryGetOrderInfo(ctgID, out orderConfig);  | 
|             priceText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.PayRMBNumOnSale));  | 
|   | 
|             var obj = buyBtn.FindComponent("Text", "Txt_orgPrice");  | 
|             if (obj != null)  | 
|                 orgPrice = obj as TextEx;  | 
|   | 
|             if (orgPrice != null)  | 
|             {  | 
|                 orgPrice.SetActive(PlayerDatas.Instance.baseData.IsActive90Off);  | 
|                 orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.PayRMBNum));  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
|   | 
| }  | 
|   | 
|   | 
|   | 
|   |