using System;
using Cute;
using UnityEngine;
using Wizard;

public class UserTicketCountContents : MonoBehaviour
{
	public struct ItemColumn
	{
		public int UserGoodsId;

		public string IconTextureName;

		public int PossetionNumber;

		public string unitFormat;

		public string TimeLimit { get; set; }
	}

	[SerializeField]
	private UIButton ButtonChangeScene;

	[SerializeField]
	private UILabel ButtonLabel;

	[SerializeField]
	private UILabel ItemNameLabel;

	[SerializeField]
	private UILabel InfoLabel;

	[SerializeField]
	private UITexture IconTexture;

	[SerializeField]
	private UILabel _timeLimitLabel;

	public void SetData(ItemColumn item, Action onClick)
	{
		int userGoodsId = item.UserGoodsId;
		IconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(item.IconTextureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true));
		ItemNameLabel.text = string.Format(item.unitFormat, UserGoods.getUserGoodsName(UserGoods.Type.Item, item.UserGoodsId), item.PossetionNumber.ToString());
		InfoLabel.text = Data.Master.GetItemText("ITI_" + userGoodsId);
		if (string.IsNullOrEmpty(item.TimeLimit))
		{
			_timeLimitLabel.gameObject.SetActive(value: false);
		}
		else
		{
			_timeLimitLabel.gameObject.SetActive(value: true);
			_timeLimitLabel.text = Data.SystemText.Get("Shop_0193", item.TimeLimit);
		}
		UIManager.SetObjectToGrey(ButtonChangeScene.gameObject, b: false);
		ButtonChangeScene.gameObject.SetActive(value: true);
		ButtonChangeScene.onClick.Clear();
		SceneTransition.TransitionData transitionData;
		switch (userGoodsId)
		{
		case 1:
			ButtonLabel.text = Data.SystemText.Get("Arena_NewMode");
			ButtonChangeScene.onClick.Add(new EventDelegate(delegate
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
				transitionData = new SceneTransition.TransitionData("2pick");
				SceneTransition.ChangeScene(transitionData, null);
			}));
			break;
		case 2:
			ButtonLabel.text = Data.SystemText.Get("Colosseum_0001");
			if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.COLOSSEUM))
			{
				UIManager.SetObjectToGrey(ButtonChangeScene.gameObject, b: true);
			}
			else if (Data.ArenaData.ColosseumData.IsColosseumPeriod)
			{
				ButtonChangeScene.onClick.Add(new EventDelegate(delegate
				{
					transitionData = new SceneTransition.TransitionData("colosseum");
					SceneTransition.ChangeScene(transitionData, null);
				}));
			}
			else
			{
				UIManager.SetObjectToGrey(ButtonChangeScene.gameObject, b: true);
			}
			break;
		case 2001:
		case 2002:
		case 2004:
			ButtonLabel.text = Data.SystemText.Get("Bingo_0023");
			ButtonChangeScene.onClick.Add(new EventDelegate(delegate
			{
				UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Bingo);
			}));
			break;
		default:
			if (Data.Load.data.UserItemNotStartList.Contains(userGoodsId))
			{
				ButtonChangeScene.gameObject.SetActive(value: false);
			}
			if (Item.IsSpotCardBuildDeckTicket(userGoodsId))
			{
				ButtonLabel.text = Data.SystemText.Get("Shop_0200");
				GiftTransition giftTransition = Data.Master.GiftTransitionList.Find((GiftTransition data) => data._rewardType == 4 && data._rewardDetailId == userGoodsId);
				if (giftTransition != null)
				{
					ButtonChangeScene.onClick.Add(new EventDelegate(delegate
					{
						transitionData = new SceneTransition.TransitionData("deck_pack");
						transitionData.Status = giftTransition._buttons[0]._transitionData.Status;
						SceneTransition.ChangeScene(transitionData, null);
					}));
				}
			}
			else if (Item.IsLeaderSkinTicket(userGoodsId))
			{
				ButtonLabel.text = Data.SystemText.Get("Shop_0192");
				GiftTransition giftTransition2 = Data.Master.GiftTransitionList.Find((GiftTransition data) => data._rewardType == 4 && data._rewardDetailId == userGoodsId);
				if (giftTransition2 != null)
				{
					ButtonChangeScene.onClick.Add(new EventDelegate(delegate
					{
						transitionData = new SceneTransition.TransitionData("leader_skin");
						transitionData.Status = giftTransition2._buttons[0]._transitionData.Status;
						SceneTransition.ChangeScene(transitionData, null);
					}));
				}
			}
			else
			{
				if (userGoodsId < 10001)
				{
					break;
				}
				ButtonLabel.text = Data.SystemText.Get("Mail_0022");
				if (Data.Master.GiftTransitionList.Find((GiftTransition data) => data._rewardType == 4 && data._rewardDetailId == userGoodsId) != null)
				{
					if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.SHOP_CARDPACK_MAINTENANCE))
					{
						UIManager.SetObjectToGrey(ButtonChangeScene.gameObject, b: true);
						break;
					}
					ButtonChangeScene.onClick.Add(new EventDelegate(delegate
					{
						transitionData = new SceneTransition.TransitionData("card_pack");
						transitionData.Status = userGoodsId;
						SceneTransition.ChangeScene(transitionData, null);
					}));
				}
				else
				{
					ButtonChangeScene.gameObject.SetActive(value: false);
				}
			}
			break;
		}
		ButtonChangeScene.onClick.Add(new EventDelegate(delegate
		{
			onClick.Call();
		}));
	}
}
