using Cute;
using UnityEngine;

namespace Wizard.Lottery;

public class LotteryBigChanceTreasureBox : LotteryTreasureBox
{
	[SerializeField]
	private GameObject _parentTreasureObj;

	[SerializeField]
	private GameObject _centerLine;

	[SerializeField]
	private UISprite _backGround;

	[SerializeField]
	private UILabel _labelOverTrasureBox;

	[SerializeField]
	private UISprite _touchBg;

	[SerializeField]
	private UILabel _labelCenter;

	protected override void UpdateInfoLabel()
	{
		switch (_lotteryRewardData.state)
		{
		case LotteryRewardData.eLotteryRewardState.Unapplied:
			_labelInfoText.gameObject.SetActive(value: true);
			break;
		case LotteryRewardData.eLotteryRewardState.Applied:
		case LotteryRewardData.eLotteryRewardState.WaitResult:
			_labelInfoText.fontSize = 13;
			_labelInfoText.gameObject.SetActive(value: true);
			break;
		default:
			_labelInfoText.gameObject.SetActive(value: false);
			break;
		}
	}

	protected override void UpdateStatusText()
	{
		switch (_lotteryRewardData.state)
		{
		case LotteryRewardData.eLotteryRewardState.Unapplied:
			_labelStatus.text = Data.SystemText.Get("Mission_0087");
			_labelInfoText.color = LabelDefine.TEXT_COLOR_ORANGE;
			_labelOverTrasureBox.text = Data.SystemText.Get("Mission_0010");
			break;
		case LotteryRewardData.eLotteryRewardState.Applied:
		case LotteryRewardData.eLotteryRewardState.WaitResult:
			_labelStatus.text = Data.SystemText.Get("Mission_0089");
			_labelStatus.color = LabelDefine.TEXT_COLOR_ORANGE;
			break;
		case LotteryRewardData.eLotteryRewardState.NotReceived:
			_labelCenter.text = Data.SystemText.Get("Mission_0091");
			_labelCenter.color = LabelDefine.TEXT_COLOR_ORANGE;
			break;
		case LotteryRewardData.eLotteryRewardState.Received:
			_labelCenter.text = Data.SystemText.Get("Mission_0092");
			break;
		case LotteryRewardData.eLotteryRewardState.NotAchieved:
			_labelCenter.text = Data.SystemText.Get("Mission_0059");
			break;
		default:
			_labelStatus.text = string.Empty;
			break;
		}
	}

	protected override void UpdateRewardImage()
	{
		if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.Received)
		{
			string textureRewardImage = string.Empty;
			if (_lotteryRewardData.IsSpecial)
			{
				string path = "thumbnail_lottery";
				textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.Lottery, isfetch: true);
				_labelRewardNum.gameObject.SetActive(value: false);
			}
			else if (_lotteryRewardData.NormalGotRewardList.Count > 0)
			{
				string textureName = _lotteryRewardData.NormalGotRewardList[0].TextureName;
				textureRewardImage = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
				_labelRewardNum.gameObject.SetActive(value: true);
				_labelRewardNum.text = _lotteryRewardData.NormalGotRewardList[0].RewardGotNum.ToString();
			}
			SetTextureRewardImage(textureRewardImage);
			_labelCenter.gameObject.SetActive(value: true);
			_backGround.gameObject.SetActive(value: false);
			_labelTreasureTouch.gameObject.SetActive(value: false);
			_touchBg.gameObject.SetActive(value: false);
			return;
		}
		if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.Unapplied)
		{
			_centerLine.SetActive(value: true);
			UIManager.SetObjectToGrey(_spriteTreasureImage.gameObject, b: true);
			_textureRewardImage.gameObject.SetActive(value: false);
			_labelRewardNum.gameObject.SetActive(value: false);
			_backGround.gameObject.SetActive(value: false);
			_labelOverTrasureBox.gameObject.SetActive(value: true);
			return;
		}
		_textureRewardImage.gameObject.SetActive(value: false);
		_labelRewardNum.gameObject.SetActive(value: false);
		_spriteTreasureImage.gameObject.SetActive(value: true);
		if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotReceived)
		{
			_labelTreasureTouch.gameObject.SetActive(value: true);
			_labelTreasureTouch.text = GetTouchText();
			_backGround.gameObject.SetActive(value: false);
			_touchBg.gameObject.SetActive(value: true);
			_labelCenter.gameObject.SetActive(value: true);
		}
		else
		{
			_labelTreasureTouch.gameObject.SetActive(value: false);
			if (_lotteryRewardData.state == LotteryRewardData.eLotteryRewardState.NotAchieved)
			{
				_labelCenter.gameObject.SetActive(value: true);
				_backGround.gameObject.SetActive(value: false);
			}
		}
	}

	protected override void UpdateNonActiveColor()
	{
		switch (_lotteryRewardData.state)
		{
		case LotteryRewardData.eLotteryRewardState.Received:
			if (_lotteryRewardData.IsSpecial)
			{
				SetNonActiveColor(isNonActive: false);
			}
			else
			{
				SetNonActiveColor(isNonActive: true);
			}
			break;
		case LotteryRewardData.eLotteryRewardState.Unapplied:
		case LotteryRewardData.eLotteryRewardState.NotAchieved:
			SetNonActiveColor(isNonActive: true);
			break;
		case LotteryRewardData.eLotteryRewardState.Applied:
		case LotteryRewardData.eLotteryRewardState.WaitResult:
		case LotteryRewardData.eLotteryRewardState.NotReceived:
			SetNonActiveColor(isNonActive: false);
			break;
		default:
			_labelStatus.text = string.Empty;
			break;
		}
	}

	protected override void SetNonActiveColor(bool isNonActive)
	{
		UIManager.SetObjectToGrey(_parentTreasureObj, isNonActive);
	}
}
