using Cute;
using UnityEngine;
using Wizard.Scripts.Network.Data.TaskData.Arena;

namespace Wizard;

public class RewardConfirmViewItem : MonoBehaviour
{
	[SerializeField]
	private UITexture _textureSleeve;

	[SerializeField]
	private UITexture _textureEmblem;

	[SerializeField]
	private UITexture _textureSkin;

	[SerializeField]
	private UITexture _textureDegree;

	[SerializeField]
	private UITexture _textureMyPageBG;

	[SerializeField]
	private UILabel _labelRewardItemName;

	[SerializeField]
	private UITexture _textureEmblem1;

	[SerializeField]
	private UITexture _textureEmblem2;

	[SerializeField]
	private UILabel _labelEmblemRewardItemName1;

	[SerializeField]
	private UILabel _labelEmblemRewardItemName2;

	public void Initialize(UserGoods userGoods, int number)
	{
		SetTexture(userGoods);
		string presentItemName = AreaSelInfo.GetPresentItemName((int)userGoods.GoodsType, userGoods.Id);
		_labelRewardItemName.SetWrapText(presentItemName + Data.SystemText.Get("Common_0040", number.ToString()));
	}

	public void InitializeForTwoEmblem(Wizard.Scripts.Network.Data.TaskData.Arena.Reward emblemReward1, Wizard.Scripts.Network.Data.TaskData.Arena.Reward emblemReward2)
	{
		_textureSleeve.gameObject.SetActive(value: false);
		_textureEmblem.gameObject.SetActive(value: false);
		_textureSkin.gameObject.SetActive(value: false);
		_textureDegree.gameObject.SetActive(value: false);
		_labelRewardItemName.gameObject.SetActive(value: false);
		_textureEmblem1.gameObject.SetActive(value: true);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(emblemReward1.UserGoodsData.Id.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true);
		_textureEmblem1.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath);
		_textureEmblem2.gameObject.SetActive(value: true);
		string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(emblemReward2.UserGoodsData.Id.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true);
		_textureEmblem2.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
		_labelEmblemRewardItemName1.gameObject.SetActive(value: true);
		string presentItemName = AreaSelInfo.GetPresentItemName((int)emblemReward1.UserGoodsData.GoodsType, emblemReward1.UserGoodsData.Id);
		_labelEmblemRewardItemName1.SetWrapText(presentItemName + Data.SystemText.Get("Common_0040", emblemReward1.num.ToString()));
		_labelEmblemRewardItemName2.gameObject.SetActive(value: true);
		string presentItemName2 = AreaSelInfo.GetPresentItemName((int)emblemReward2.UserGoodsData.GoodsType, emblemReward2.UserGoodsData.Id);
		_labelEmblemRewardItemName2.SetWrapText(presentItemName2 + Data.SystemText.Get("Common_0040", emblemReward2.num.ToString()));
	}

	private void SetTexture(UserGoods userGoods)
	{
		_textureSleeve.gameObject.SetActive(value: false);
		_textureEmblem.gameObject.SetActive(value: false);
		_textureSkin.gameObject.SetActive(value: false);
		_textureDegree.gameObject.SetActive(value: false);
		_textureEmblem1.gameObject.SetActive(value: false);
		_textureEmblem2.gameObject.SetActive(value: false);
		_labelEmblemRewardItemName1.gameObject.SetActive(value: false);
		_labelEmblemRewardItemName2.gameObject.SetActive(value: false);
		_textureMyPageBG.gameObject.SetActive(value: false);
		switch (userGoods.GoodsType)
		{
		case UserGoods.Type.Sleeve:
		{
			_textureSleeve.gameObject.SetActive(value: true);
			long existingSleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(userGoods.Id);
			Sleeve sleeve = Data.Master.SleeveMgr.Get(existingSleeveId);
			if (sleeve.IsPremiumSleeve)
			{
				UIManager.GetInstance().getUIBase_CardManager().SetSleeveTexture(_textureSleeve, sleeve.sleeve_id);
				break;
			}
			string assetTypePath4 = Toolbox.ResourcesManager.GetAssetTypePath(existingSleeveId.ToString(), ResourcesManager.AssetLoadPathType.SleeveTexture, isfetch: true);
			_textureSleeve.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath4);
			break;
		}
		case UserGoods.Type.Emblem:
		{
			_textureEmblem.gameObject.SetActive(value: true);
			string assetTypePath3 = Toolbox.ResourcesManager.GetAssetTypePath(userGoods.Id.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true);
			_textureEmblem.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath3);
			break;
		}
		case UserGoods.Type.Skin:
		{
			_textureSkin.gameObject.SetActive(value: true);
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(userGoods.Id.ToString(), ResourcesManager.AssetLoadPathType.ClassCharaSkinThumbnail, isfetch: true);
			_textureSkin.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
			break;
		}
		case UserGoods.Type.Degree:
		{
			_textureDegree.gameObject.SetActive(value: true);
			string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(userGoods.Thumbnail, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
			_textureDegree.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath);
			break;
		}
		case UserGoods.Type.MyPageBG:
			_textureMyPageBG.gameObject.SetActive(value: true);
			_textureMyPageBG.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath("thumbnail_mypage_custom_bg", ResourcesManager.AssetLoadPathType.Item, isfetch: true));
			break;
		}
	}
}
