using System;
using UnityEngine;

namespace Wizard.Lottery;

public class LotteryMissionTreasureBox : LotteryTreasureBox
{
	[SerializeField]
	private UILabel _categoryLabel;

	[SerializeField]
	protected UISprite _categoryLabelLine;

	public void Initialize(LotteryRewardData data, string categoryText, Action onClickEvent)
	{
		_categoryLabel.text = categoryText;
		SetData(data, string.Empty, onClickEvent);
		switch (data.state)
		{
		case LotteryRewardData.eLotteryRewardState.Applied:
		case LotteryRewardData.eLotteryRewardState.Received:
		case LotteryRewardData.eLotteryRewardState.NotAchieved:
			UIManager.SetObjectToGrey(_spriteTreasureImage.gameObject, b: true);
			break;
		default:
			UIManager.SetObjectToGrey(_spriteTreasureImage.gameObject, b: false);
			break;
		case LotteryRewardData.eLotteryRewardState.NotReceived:
			break;
		}
		if (data.MissionData.IsTimeOver)
		{
			UIManager.SetObjectToGrey(_spriteTreasureImage.gameObject, b: true);
		}
	}

	protected override void UpdateStatusText()
	{
		LotteryRewardData.eLotteryRewardState state = _lotteryRewardData.state;
		base.UpdateStatusText();
		if (state == LotteryRewardData.eLotteryRewardState.NotAchieved)
		{
			_labelStatus.text = Data.SystemText.Get("Mission_0059");
		}
		if (_lotteryRewardData.MissionData != null && _lotteryRewardData.MissionData.IsTimeOver)
		{
			_labelStatus.text = Data.SystemText.Get("Mission_0078");
		}
	}

	public virtual void SetCategoryLabelLineWitdh(int width)
	{
		_categoryLabelLine.width = width;
	}
}
