Exemplo n.º 1
0
 private void InitDrakMarketItem(int index, DarkMarketItem data, bool isReloadIcon = true)
 {
     //IL_014a: Unknown result type (might be due to invalid IL or missing references)
     //IL_016b: Unknown result type (might be due to invalid IL or missing references)
     //IL_0184: Unknown result type (might be due to invalid IL or missing references)
     if (data == null)
     {
         SetActive((Enum)(UI)index, false);
     }
     else
     {
         Transform ctrl = GetCtrl((UI)index);
         if (data.saleType == 1)
         {
             SetEvent((Enum)(UI)index, "BUY_NORMAL", data.id);
             SetActive(ctrl, UI.SPR_GOLD_ITEM_BG, false);
             SetActive(ctrl, UI.SPR_GEM_ITEM_BG, true);
             SetLabelText(ctrl, UI.LBL_GEM_SALE_PRICE, $"x{data.saleNum}");
         }
         else if (data.saleType == 2)
         {
             SetEvent((Enum)(UI)index, "BUY_NORMAL", data.id);
             SetActive(ctrl, UI.SPR_GOLD_ITEM_BG, true);
             SetLabelText(ctrl, UI.LBL_GOLD_SALE_PRICE, $"x{data.saleNum}");
             SetActive(ctrl, UI.SPR_GEM_ITEM_BG, false);
         }
         else if (data.saleType == 200)
         {
             SetEvent((Enum)(UI)index, "BUY_IAP", data.id);
         }
         int num = 100 - Mathf.RoundToInt(data.saleNum / data.baseNum * 100f);
         if (num < 30)
         {
             SetColor(ctrl, UI.LBL_SALE_PERCENT, normalSale);
         }
         else if (num < 70)
         {
             SetColor(ctrl, UI.LBL_SALE_PERCENT, mediumSale);
         }
         else
         {
             SetColor(ctrl, UI.LBL_SALE_PERCENT, hotSale);
         }
         if (num > 60)
         {
             SetActive(ctrl, UI.OBJ_HOT, true);
         }
         else
         {
             SetActive(ctrl, UI.OBJ_HOT, false);
         }
         if (num > 0)
         {
             SetLabelText(ctrl, UI.LBL_SALE_PERCENT, $"-{num}%");
         }
         else
         {
             SetLabelText(ctrl, UI.LBL_SALE_PERCENT, $"{num}%");
         }
         SetFontStyle(ctrl, UI.LBL_SALE_PERCENT, 2);
         SetLabelText(ctrl, UI.LBL_ITEM_NAME, data.name);
         if (data.rewards != null && data.rewards.Count > 0)
         {
             string empty = string.Empty;
             SetLabelText(text: (data.rewards[0].num > 1000000) ? $"x{(float)data.rewards[0].num / 1000000f}M" : ((data.rewards[0].num <= 1000) ? $"x{data.rewards[0].num}" : $"x{(float)data.rewards[0].num / 1000f}K"), root: ctrl, label_enum: UI.LBL_ITEM_SALE_NUM);
         }
         else
         {
             SetLabelText(ctrl, UI.LBL_ITEM_SALE_NUM, string.Empty);
         }
         if (data.usedCount >= data.limit)
         {
             SetSliderValue(ctrl, UI.SLD_BUY_PROGRESS, 0f);
             SetActive(ctrl, UI.LBL_SALE_PROGRESS, false);
             SetActive(ctrl, UI.OBJ_OUT_OFF_STOCK, true);
             SetButtonEnabled((Enum)(UI)index, false);
         }
         else
         {
             float value = 1f - (float)data.usedCount / (float)data.limit;
             SetSliderValue(ctrl, UI.SLD_BUY_PROGRESS, value);
             SetActive(ctrl, UI.LBL_SALE_PROGRESS, true);
             SetLabelText(ctrl, UI.LBL_SALE_PROGRESS, $"{data.limit - data.usedCount}/{data.limit}");
             SetActive(ctrl, UI.OBJ_OUT_OFF_STOCK, false);
             SetButtonEnabled((Enum)(UI)index, true);
         }
         if (isReloadIcon)
         {
             UITexture spro = FindCtrl(ctrl, UI.IMG_ICON).GetComponent <UITexture>();
             ResourceLoad.LoadBlackMarketIconTexture(spro, data.imgId, delegate(Texture tex)
             {
                 if (spro != null)
                 {
                     spro.mainTexture = tex;
                 }
             });
         }
     }
 }