using System;
using System.Collections.Generic;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.Bingo;
using Wizard.Lottery;
using Wizard.Scripts.Network.Data.TableData;

public class AchievementWindowBase : MonoBehaviour
{
	public enum AchievementType
	{
		None,
		Reward,
		Nonattainment,
		AlreadyReceived,
		PointRunning,
		PointClear,
		PointReceived
	}

	public GameObject goButtonReward;

	public UITexture achievementIconTexture;

	public UILabel labelAchievementTitle;

	public UILabel labelAchievementData;

	public UILabel labelAchievementCount;

	public UILabel _missionWaitLabel;

	public UILabel _labelMissionPeriod;

	public UILabel _labelMissionNotice;

	public UISprite _titleLine;

	public UILabel alreadyReceived;

	[NonSerialized]
	public int type;

	[NonSerialized]
	public int iType = -1;

	[NonSerialized]
	public int level;

	[NonSerialized]
	public string strAchievementData = "3種類のスリーブを使う。";

	[SerializeField]
	private UILabel LabelDetailBtn;

	[SerializeField]
	private UITable StarTable;

	[SerializeField]
	private UISprite StarOriginal;

	[SerializeField]
	private GameObject MailReceive;

	[SerializeField]
	private UIGauge GaugeUI;

	[SerializeField]
	private UILabel GaugeLabel;

	[SerializeField]
	private UISprite _Separator;

	[SerializeField]
	private UIWidget _StarsWidget;

	[SerializeField]
	private UILabel _labelTopRight;

	[SerializeField]
	private UILabel _missionStartTime;

	[SerializeField]
	private UILabel _missionTimeOver;

	[SerializeField]
	private UILabel _applyFinish;

	private const int ACHIEVEMENT_STARS_MAX = 5;

	private ResourceHandler _resourceHandler;

	private const string SPRITE_PREFIX_BUTTON_BLUE = "btn_common_02_s_";

	private int _viewMailId;

	private QuestRewardInfo _questRewardInfo;

	private Action _onReceivceAchievementSuccess;

	private CrossoverRewardInfo _crossoverRewardInfo;

	private const int BINGO_MISSION_SPRITE_WIDTH = 752;

	private void Awake()
	{
		LabelDetailBtn.text = Data.SystemText.Get("Common_0022");
	}

	public void SetType(AchievementType typeBase)
	{
		labelAchievementCount.gameObject.SetActive(typeBase != AchievementType.AlreadyReceived);
		alreadyReceived.gameObject.SetActive(typeBase == AchievementType.AlreadyReceived || typeBase == AchievementType.PointReceived);
		goButtonReward.SetActive(typeBase != AchievementType.AlreadyReceived && typeBase != AchievementType.PointReceived);
		UIManager.SetObjectToGrey(goButtonReward, typeBase == AchievementType.Nonattainment || typeBase == AchievementType.PointRunning);
	}

	public void SetActiveGaugeUI(bool isActive)
	{
		GaugeUI.gameObject.SetActive(isActive);
	}

	public void OnRewardClick()
	{
		AchievementReceiveRewardTask achievementReceiveRewardTask = new AchievementReceiveRewardTask();
		achievementReceiveRewardTask.SetParameter(type, level);
		StartCoroutine(Toolbox.NetworkManager.Connect(achievementReceiveRewardTask, OnRequestRewardAchievement, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
	}

	public void OnDetail()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(Data.SystemText.Get("Mission_0007"));
		dialogBase.SetText(strAchievementData);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
	}

	private void OnRequestRewardAchievement(NetworkTask.ResultCode error)
	{
		OnRequestReward(error, Data.MissionInfo.data.total_reward_list);
		_onReceivceAchievementSuccess.Call();
	}

	private void OnRequestReward(NetworkTask.ResultCode error, List<ReceivedReward> rewards)
	{
		base.transform.parent.gameObject.AddMissingComponent<ReceiveReward>().ShowReadDialog(rewards, MailReceive, base.gameObject, _resourceHandler);
		MyPageMenu.Instance.UpdateMissionCount();
	}

	private void SetAchievementCommon(UserAchievement achi)
	{
		bool num = achi.reward_type == 4;
		strAchievementData = achi.achievement_name;
		SystemText systemText = Data.SystemText;
		labelAchievementTitle.text = systemText.Get("Mission_0023") + strAchievementData;
		labelAchievementTitle.rightAnchor.target = _StarsWidget.transform;
		labelAchievementTitle.rightAnchor.relative = 0f;
		if (num)
		{
			ReceiveReward.SetTicket(achi.RewardUserGoodsId, achi.reward_number, achievementIconTexture, labelAchievementData, _resourceHandler);
		}
		else
		{
			ReceiveReward.SetTexture((UserGoods.Type)achi.reward_type, achievementIconTexture, _resourceHandler);
			labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)achi.reward_type, achi.RewardUserGoodsId, achi.reward_number);
		}
		GaugeUI.gameObject.SetActive(value: true);
		int num2 = ((achi.total_count > achi.require_number) ? achi.require_number : achi.total_count);
		int require_number = achi.require_number;
		labelAchievementCount.gameObject.SetActive(value: false);
		GaugeLabel.text = num2 + "/" + require_number;
		if (num2 != 0 && require_number != 0)
		{
			float value = (float)num2 / (float)require_number;
			GaugeUI.Value = value;
		}
		else
		{
			GaugeUI.Value = 0f;
		}
		goButtonReward.GetComponent<UIButton>().GetComponentInChildren<UILabel>().text = systemText.Get("Mail_0023");
	}

	private void SetRunning(UserAchievement achi)
	{
		SetType(AchievementType.Nonattainment);
		SetAchievementCommon(achi);
		SetAchievementStars(achi, cleared: false);
	}

	private void SetAchievementStars(UserAchievement achi, bool cleared)
	{
		int num = achi._maxLevel;
		int num2 = achi.level;
		if (achi._maxLevel > 5)
		{
			num = 5;
			num2 = ((achi.level == achi._maxLevel) ? 5 : ((achi.level <= 0 || achi.level % 5 != 0) ? (achi.level % 5) : 5));
		}
		for (int i = 0; i < num; i++)
		{
			UISprite uISprite = UnityEngine.Object.Instantiate(StarOriginal, StarOriginal.transform.localPosition, StarOriginal.transform.localRotation);
			uISprite.transform.parent = StarTable.transform;
			uISprite.transform.localPosition = Vector3.zero;
			uISprite.transform.localScale = Vector3.one;
			if ((num2 == i + 1 && cleared) || num2 > i + 1)
			{
				uISprite.spriteName = "achievement_star_02";
			}
			else
			{
				uISprite.spriteName = "achievement_star_01";
			}
			uISprite.gameObject.SetActive(value: true);
		}
		StarTable.repositionNow = true;
	}

	private void SetCanReceive(UserAchievement achi)
	{
		SetType(AchievementType.Reward);
		SetAchievementCommon(achi);
		SetAchievementStars(achi, cleared: false);
		UIButton component = goButtonReward.GetComponent<UIButton>();
		component.onClick.Clear();
		component.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			OnRewardClick();
		}));
	}

	private void SetAlreadyReceived(UserAchievement achi)
	{
		SetType(AchievementType.AlreadyReceived);
		SetAchievementCommon(achi);
		SetAchievementStars(achi, cleared: true);
	}

	public void SetAchievement(UserAchievement achi, ResourceHandler resourceHandler, Action onReceivceAchievementSuccess)
	{
		_resourceHandler = resourceHandler;
		_onReceivceAchievementSuccess = onReceivceAchievementSuccess;
		switch (achi.achievement_status)
		{
		case 0:
			SetRunning(achi);
			break;
		case 1:
			SetCanReceive(achi);
			break;
		case 2:
			SetAlreadyReceived(achi);
			break;
		default:
			UnityEngine.Debug.LogError("unkown achievement status");
			break;
		}
	}

	public void SetCrossoverReward(CrossoverRewardInfo reward, AchievementType type, ResourceHandler resourceHandler, Action onReceiveReward)
	{
		_crossoverRewardInfo = reward;
		_resourceHandler = resourceHandler;
		SetType(type);
		string texName = UserGoods.GetUserGoodsImageName((UserGoods.Type)reward.RewardType, reward.RewardDetailId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			if (reward.RewardDetailId == _crossoverRewardInfo.RewardDetailId)
			{
				string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
				achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
			}
		});
		RankInfo rankInfo = Data.Load.data.GetRankInfo(Format.Crossover, reward.Rank);
		labelAchievementTitle.text = Data.SystemText.Get("Profile_0042", Data.SystemText.Get(rankInfo.rank_name));
		labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)reward.RewardType, reward.RewardDetailId, reward.RewardCount);
		GaugeUI.gameObject.SetActive(value: false);
		UIButton component = goButtonReward.GetComponent<UIButton>();
		component.GetComponentInChildren<UILabel>().text = Data.SystemText.Get("Mail_0023");
		goButtonReward.gameObject.SetActive(type != AchievementType.PointReceived);
		UIManager.SetObjectToGrey(goButtonReward, type != AchievementType.PointClear);
		component.onClick.Clear();
		component.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			ReceiveCrossoverReward(reward.RewardId, onReceiveReward);
		}));
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
	}

	private void ReceiveCrossoverReward(int rewardId, Action onReceiveReward)
	{
		CrossoverReceiveRankRewardTask task = new CrossoverReceiveRankRewardTask();
		task.SetParameter(rewardId);
		StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			onReceiveReward.Call();
			DialogCreator.CreateRewardReceiveDialog(task.ReceivedRewardList);
		}));
	}

	public void SetQuestPoint(QuestRewardInfo reward, AchievementType type, ResourceHandler resourceHandler, Action onRequestRewardPointCallBack)
	{
		_questRewardInfo = reward;
		strAchievementData = reward.Point.ToString();
		labelAchievementTitle.text = Data.SystemText.Get("Quest_0019", strAchievementData);
		_resourceHandler = resourceHandler;
		SetType(type);
		string texName = UserGoods.GetUserGoodsImageName((UserGoods.Type)reward.RewardType, reward.RewardDetailId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			if (reward.RewardDetailId == _questRewardInfo.RewardDetailId)
			{
				string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(texName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
				achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
			}
		});
		labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)reward.RewardType, reward.RewardDetailId, reward.RewardCount);
		GaugeUI.gameObject.SetActive(value: false);
		UIButton component = goButtonReward.GetComponent<UIButton>();
		component.GetComponentInChildren<UILabel>().text = Data.SystemText.Get("Mail_0023");
		goButtonReward.gameObject.SetActive(type != AchievementType.PointReceived);
		UIManager.SetObjectToGrey(goButtonReward, type != AchievementType.PointClear);
		component.onClick.Clear();
		component.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			OnQuestPointReceive(reward.Id, onRequestRewardPointCallBack);
		}));
		GetComponent<UISprite>().spriteName = string.Empty;
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
	}

	public void SetMission(UserMission mission, ResourceHandler resourceHandler, bool canChangeMissions, bool enableSeparator, bool displayChange, Action onChangeMissionSuccess = null)
	{
		_resourceHandler = resourceHandler;
		_Separator.gameObject.SetActive(enableSeparator);
		if (mission.mission_status == 0 && SetMissionWait(mission))
		{
			return;
		}
		SystemText systemText = Data.SystemText;
		if (mission.reward_type == 4)
		{
			ReceiveReward.SetTicket(mission.RewardUserGoodsId, mission.reward_number, achievementIconTexture, labelAchievementData, _resourceHandler);
		}
		else
		{
			ReceiveReward.SetTexture((UserGoods.Type)mission.reward_type, mission.RewardUserGoodsId, achievementIconTexture, _resourceHandler);
			labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)mission.reward_type, mission.RewardUserGoodsId, mission.reward_number);
		}
		labelAchievementTitle.text = mission.mission_name;
		int require_number = mission.require_number;
		bool flag = require_number > 0;
		GaugeUI.gameObject.SetActive(flag);
		if (flag)
		{
			int num = ((mission.total_count > mission.require_number) ? mission.require_number : mission.total_count);
			GaugeLabel.text = num + "/" + require_number;
			if (num != 0)
			{
				float value = (float)num / (float)require_number;
				GaugeUI.Value = value;
			}
			else
			{
				GaugeUI.Value = 0f;
			}
		}
		UIButton component = goButtonReward.GetComponent<UIButton>();
		component.normalSprite = "btn_common_02_s_off";
		component.pressedSprite = "btn_common_02_s_on";
		component.GetComponentInChildren<UILabel>().text = systemText.Get("Mission_0029");
		component.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			ChangeMission(mission.id, mission.mission_name, onChangeMissionSuccess);
		}));
		goButtonReward.SetActive(displayChange && !mission.default_flag);
		UIManager.SetObjectToGrey(goButtonReward, !canChangeMissions);
		labelAchievementCount.gameObject.SetActive(value: false);
		SetMissionPeriodLabel(mission);
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
	}

	public void SetBttlePassMonthlyMission(BattlePassMonthlyMission.MissionDetail mission, ResourceHandler resourceHandler)
	{
		_Separator.gameObject.SetActive(value: false);
		_labelMissionPeriod.gameObject.SetActive(value: false);
		labelAchievementCount.gameObject.SetActive(value: false);
		goButtonReward.gameObject.SetActive(value: false);
		_resourceHandler = resourceHandler;
		labelAchievementTitle.text = mission.Name;
		alreadyReceived.gameObject.SetActive(mission.IsCleared);
		BattlePassMonthlyMission.MissionDetail.RewardInfo reward = mission.Reward;
		if (reward == null)
		{
			_resourceHandler.Add(Toolbox.ResourcesManager.GetAssetTypePath("thumbnail_battle_pass_point", ResourcesManager.AssetLoadPathType.BattlePass), delegate
			{
				string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("thumbnail_battle_pass_point", ResourcesManager.AssetLoadPathType.BattlePass, isfetch: true);
				achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath);
			});
			labelAchievementData.text = string.Empty;
		}
		else if (reward.UserGoods.GoodsType == UserGoods.Type.Item)
		{
			ReceiveReward.SetTicket(reward.UserGoods.Id, reward.Number, achievementIconTexture, labelAchievementData, _resourceHandler);
		}
		else
		{
			ReceiveReward.SetTexture(reward.UserGoods.GoodsType, achievementIconTexture, _resourceHandler);
			labelAchievementData.text = ReceiveReward.getTitle(reward.UserGoods.GoodsType, reward.UserGoods.Id, reward.Number);
		}
		SetViewBattlePassPointText(mission.BattlePassPoint);
		int requireNumber = mission.RequireNumber;
		bool flag = requireNumber > 0;
		GaugeUI.gameObject.SetActive(flag);
		if (flag)
		{
			int num = ((mission.DoneNumber > mission.RequireNumber) ? mission.RequireNumber : mission.DoneNumber);
			GaugeLabel.text = num + "/" + requireNumber;
			if (num != 0)
			{
				float value = (float)num / (float)requireNumber;
				GaugeUI.Value = value;
			}
			else
			{
				GaugeUI.Value = 0f;
			}
		}
	}

	private void SetViewBattlePassPointText(int point)
	{
		string text = "  ";
		if (labelAchievementData.text == string.Empty)
		{
			labelAchievementData.text = Data.SystemText.Get("BattlePass_0010", point.ToString());
		}
		else
		{
			UILabel uILabel = labelAchievementData;
			uILabel.text = uILabel.text + text + Data.SystemText.Get("BattlePass_0010", point.ToString());
		}
	}

	private bool SetMissionWait(UserMission mission)
	{
		MissionInfoTask missionInfoTask = GameMgr.GetIns().GetMissionInfoTask();
		long num = (long)Time.realtimeSinceStartup - missionInfoTask.RequestTime;
		long num2 = missionInfoTask.ServerTime + num;
		TimeSpan timeSpan = TimeSpan.FromSeconds(mission.start_time - num2).Add(new TimeSpan(0, 1, 0));
		int num3 = timeSpan.Hours;
		int num4 = timeSpan.Minutes;
		if (timeSpan.TotalHours >= 24.0)
		{
			num3 = 24;
			num4 = 0;
		}
		else if (num3 <= 0 && num4 <= 0)
		{
			return false;
		}
		if (mission.IsGemMission())
		{
			_missionWaitLabel.text = Data.SystemText.Get("Mission_0073", num3.ToString("00"), num4.ToString("00"));
			_labelMissionNotice.gameObject.SetActive(value: true);
			_labelMissionNotice.text = Data.SystemText.Get("Mission_0074");
		}
		else
		{
			_missionWaitLabel.text = Data.SystemText.Get("Mission_0041", num3.ToString("00"), num4.ToString("00"));
		}
		labelAchievementTitle.gameObject.SetActive(value: false);
		labelAchievementCount.gameObject.SetActive(value: false);
		labelAchievementData.gameObject.SetActive(value: false);
		labelAchievementData.gameObject.SetActive(value: false);
		goButtonReward.gameObject.SetActive(value: false);
		GaugeUI.gameObject.SetActive(value: false);
		_titleLine.gameObject.SetActive(value: false);
		_missionWaitLabel.gameObject.SetActive(value: true);
		return true;
	}

	private void SetMissionPeriodLabel(UserMission mission)
	{
		if (mission.end_time <= 0 || mission.IsGemMission())
		{
			_labelMissionPeriod.gameObject.SetActive(value: false);
			return;
		}
		long nowUnixTime = GameMgr.GetIns().GetMissionInfoTask().NowUnixTime();
		string remainingTime = ConvertTime.GetRemainingTime(TimeSpan.FromSeconds(mission.GetMissionPeriodSec(nowUnixTime)));
		goButtonReward.gameObject.SetActive(value: false);
		_labelMissionPeriod.gameObject.SetActive(value: true);
		_labelMissionPeriod.text = remainingTime;
	}

	private void ChangeMission(int id, string content, Action onChangeMissionSuccess)
	{
		SystemText systemText = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Mission_0033"));
		dialogBase.SetText(systemText.Get("Mission_0030", content));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.DecisionBtn);
		dialogBase.onPushButton1 = delegate
		{
			MissionRetireTask missionRetireTask = new MissionRetireTask();
			missionRetireTask.SetParameter(id);
			StartCoroutine(Toolbox.NetworkManager.Connect(missionRetireTask, delegate
			{
				onChangeMissionSuccess.Call();
			}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
		};
	}

	private void OnQuestPointReceive(int rewardId, Action onRequestRewardPointCallBack)
	{
		QuestRewardReceiveTask task = new QuestRewardReceiveTask();
		task.SetParameter(rewardId);
		StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			onRequestRewardPointCallBack.Call();
			DialogCreator.CreateRewardReceiveDialog(task.ReceiveRewardList);
		}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
	}

	public void SetHistoryItem(ItemAcquireHistory item, bool enableSeparator, ResourceHandler resourceHandler)
	{
		_resourceHandler = resourceHandler;
		SystemText systemText = Data.SystemText;
		if (item.RewardType == 4)
		{
			ReceiveReward.SetTicket(item.RewardUserGoodsId, item.RewardCount, achievementIconTexture, labelAchievementTitle, _resourceHandler);
		}
		else
		{
			ReceiveReward.SetTexture((UserGoods.Type)item.RewardType, achievementIconTexture, _resourceHandler);
			labelAchievementTitle.text = ReceiveReward.getTitle((UserGoods.Type)item.RewardType, item.RewardUserGoodsId, item.RewardCount);
		}
		labelAchievementData.text = item.Message;
		labelAchievementCount.text = systemText.Get("Mail_0043", ConvertTime.ToLocal(item.AcquireTime));
		GaugeUI.gameObject.SetActive(value: false);
		goButtonReward.SetActive(value: false);
		_Separator.gameObject.SetActive(enableSeparator);
	}

	public void SetMail(MailData mail, Action<int, int> OnReadMail, ResourceHandler handler)
	{
		_resourceHandler = handler;
		_viewMailId = mail.mail_id;
		SetCommonMail(mail);
		TimeLeftUpdate timeLeftUpdate = base.gameObject.AddMissingComponent<TimeLeftUpdate>();
		timeLeftUpdate.mailData = mail;
		_labelTopRight.gameObject.SetActive(value: true);
		timeLeftUpdate.timeLeft = _labelTopRight;
		timeLeftUpdate.UpdateTime();
		SystemText systemText = Data.SystemText;
		labelAchievementCount.text = systemText.Get("Mail_0043", mail.create_time);
		goButtonReward.SetActive(value: true);
		goButtonReward.transform.Find("RewardLabel").GetComponent<UILabel>().text = systemText.Get("Mail_0023");
		UIButton component = goButtonReward.GetComponent<UIButton>();
		component.normalSprite = "btn_common_02_s_off";
		component.hoverSprite = "btn_common_02_s_off";
		component.pressedSprite = "btn_common_02_s_on";
		UIEventListener.Get(goButtonReward).onClick = delegate
		{
			OnReadMail(mail.mail_id, mail.mail_id);
		};
	}

	public void SetHistoryMail(MailData mail, ResourceHandler handler)
	{
		_resourceHandler = handler;
		_viewMailId = mail.mail_id;
		SetCommonMail(mail);
		TimeLeftUpdate component = base.gameObject.GetComponent<TimeLeftUpdate>();
		if ((bool)component)
		{
			component.mailData = null;
		}
		_labelTopRight.gameObject.SetActive(value: false);
		labelAchievementCount.text = Data.SystemText.Get("Mail_0044", mail.create_time);
		goButtonReward.SetActive(value: false);
	}

	private void SetCommonMail(MailData mailData)
	{
		GaugeUI.gameObject.SetActive(value: false);
		labelAchievementData.text = mailData.message;
		labelAchievementTitle.text = ReceiveReward.getTitle(mailData);
		string textureName = ReceiveReward.GetThumbnailName((UserGoods.Type)mailData.reward_type, mailData.RewardUserGoodsId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			if (mailData.mail_id == _viewMailId)
			{
				string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
				achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
			}
		});
	}

	private void CopyAnchor(UIRect.AnchorPoint original, UIRect.AnchorPoint destination)
	{
		destination.target = original.target;
		destination.relative = original.relative;
		destination.absolute = original.absolute;
	}

	public void SetGetButtonToGreyOut()
	{
		UIManager.SetObjectToGrey(goButtonReward, b: true);
	}

	public void SetLottery(LotteryMissionData lotteryData, bool needCeparator)
	{
		string userGoodsImageName = UserGoods.GetUserGoodsImageName(lotteryData.UserGoodsType, lotteryData.ItemId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(userGoodsImageName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
		base.gameObject.GetComponent<UISprite>().width = 800;
		achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath);
		_Separator.gameObject.SetActive(needCeparator);
		labelAchievementTitle.text = lotteryData.MissionTitle;
		if (lotteryData.UserGoodsType == UserGoods.Type.Item)
		{
			labelAchievementData.text = ReceiveReward.SetTicketTitle(lotteryData.ItemId, lotteryData.ItemCount);
		}
		else
		{
			labelAchievementData.text = ReceiveReward.getTitle(lotteryData.UserGoodsType, lotteryData.ItemId, lotteryData.ItemCount);
		}
		goButtonReward.SetActive(value: false);
		if (lotteryData.StartTime.Second > 0)
		{
			_missionStartTime.text = Data.SystemText.Get("Mission_0077", lotteryData.StartTime.LocalTime);
			_missionStartTime.gameObject.SetActive(value: true);
		}
		else
		{
			_labelMissionPeriod.text = lotteryData.EndTime.GetShowText("Mission_0062", "Mission_0060", "Mission_0061");
			_labelMissionPeriod.gameObject.SetActive(value: true);
		}
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
		_applyFinish.gameObject.SetActive(lotteryData.IsCleared);
		_labelMissionPeriod.gameObject.SetActive(!lotteryData.IsCleared && !lotteryData.IsTimeOver);
		_missionTimeOver.gameObject.SetActive(lotteryData.IsTimeOver);
		GaugeLabel.text = lotteryData.MissionCurrent + "/" + lotteryData.MissionMax;
		GaugeUI.Value = lotteryData.MissionRatio;
		bool active = true;
		if (lotteryData.IsCleared || lotteryData.MissionMax == 0)
		{
			active = false;
		}
		GaugeUI.gameObject.SetActive(active);
	}

	public void SetBingoMission(BingoInfoTask.BingoMissionData missionData, bool needCeparator, ResourceHandler handler)
	{
		_resourceHandler = handler;
		base.gameObject.GetComponent<UISprite>().width = 752;
		base.gameObject.GetComponent<UISprite>().enabled = false;
		alreadyReceived.gameObject.SetActive(missionData.IsCleared);
		labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)missionData.Reward.reward_type, missionData.Reward.rewardUserGoodsId, missionData.Reward.reward_count);
		string textureName = UserGoods.GetUserGoodsImageName((UserGoods.Type)missionData.Reward.reward_type, missionData.Reward.rewardUserGoodsId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
			achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
		});
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
		_titleLine.SetAnchor((GameObject)null);
		_titleLine.spriteName = "quest_line_05";
		_titleLine.SetDimensions(610, 2);
		_Separator.spriteName = "quest_line_02";
		_Separator.gameObject.SetActive(needCeparator);
		goButtonReward.SetActive(value: false);
		GaugeLabel.text = missionData.MissionCurrent + "/" + missionData.MissionMax;
		GaugeUI.Value = missionData.MissionRatio;
		labelAchievementTitle.text = missionData.MissionTitle;
	}

	public void SetBingoRewardDetails(ReceivedReward reward, bool needCeparator, ResourceHandler handler)
	{
		_resourceHandler = handler;
		base.gameObject.GetComponent<UISprite>().width = 752;
		base.gameObject.GetComponent<UISprite>().enabled = false;
		goButtonReward.SetActive(value: false);
		_titleLine.SetAnchor((GameObject)null);
		_titleLine.spriteName = "quest_line_05";
		_titleLine.SetDimensions(610, 2);
		_Separator.spriteName = "quest_line_02";
		_Separator.gameObject.SetActive(needCeparator);
		labelAchievementTitle.text = string.Format(Data.SystemText.Get("Bingo_0004", reward.lineNum.ToString()));
		labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)reward.reward_type, reward.rewardUserGoodsId, reward.reward_count);
		GaugeUI.gameObject.SetActive(value: false);
		string textureName = UserGoods.GetUserGoodsImageName((UserGoods.Type)reward.reward_type, reward.rewardUserGoodsId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
			achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
		});
	}

	public void SetBingoSideBarRewards(string lineNum, ReceivedReward reward, bool isCleared, bool needCeparator, ResourceHandler handler)
	{
		_resourceHandler = handler;
		_Separator.gameObject.SetActive(needCeparator);
		goButtonReward.SetActive(value: false);
		labelAchievementTitle.text = string.Format(Data.SystemText.Get("Bingo_0004", lineNum));
		labelAchievementData.text = ReceiveReward.getTitle((UserGoods.Type)reward.reward_type, reward.rewardUserGoodsId, reward.reward_count);
		alreadyReceived.gameObject.SetActive(isCleared);
		string textureName = UserGoods.GetUserGoodsImageName((UserGoods.Type)reward.reward_type, reward.rewardUserGoodsId);
		string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item);
		_resourceHandler.Add(assetTypePath, delegate
		{
			string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(textureName, ResourcesManager.AssetLoadPathType.Item, isfetch: true);
			achievementIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(assetTypePath2);
		});
	}

	public void SetPracticePuzzleMission(PracticePuzzleMissionData mission, ResourceHandler resourceHandler, bool canChangeMissions, bool enableSeparator, bool displayChange, Action onChangeMissionSuccess = null)
	{
		_resourceHandler = resourceHandler;
		_Separator.gameObject.SetActive(enableSeparator);
		goButtonReward.SetActive(value: false);
		_ = Data.SystemText;
		if (mission.UserGoodsType == UserGoods.Type.Item)
		{
			ReceiveReward.SetTicket(mission.ItemId, mission.ItemCount, achievementIconTexture, labelAchievementData, _resourceHandler);
		}
		else
		{
			ReceiveReward.SetTexture(mission.UserGoodsType, mission.ItemId, achievementIconTexture, _resourceHandler);
			labelAchievementData.text = ReceiveReward.getTitle(mission.UserGoodsType, mission.ItemId, mission.ItemCount);
		}
		labelAchievementTitle.text = mission.Name;
		int totalMissionCount = mission.TotalMissionCount;
		bool flag = totalMissionCount > 0;
		GaugeUI.gameObject.SetActive(flag);
		if (flag)
		{
			int num = ((mission.TotalMissionCount > mission.CurrentClearCount) ? mission.CurrentClearCount : mission.TotalMissionCount);
			GaugeLabel.text = num + "/" + totalMissionCount;
			if (num != 0)
			{
				float value = (float)num / (float)totalMissionCount;
				GaugeUI.Value = value;
			}
			else
			{
				GaugeUI.Value = 0f;
			}
		}
		alreadyReceived.gameObject.SetActive(mission.IsCleared);
		labelAchievementCount.gameObject.SetActive(value: false);
		CopyAnchor(_labelTopRight.rightAnchor, labelAchievementTitle.rightAnchor);
	}

	public void SetRedEtherMission(RedEtherCampaignRewardData rewardData, ResourceHandler resourceHandler)
	{
		_resourceHandler = resourceHandler;
		goButtonReward.SetActive(value: false);
		ReceiveReward.SetTexture(rewardData.UserGoodsType, 0L, achievementIconTexture, _resourceHandler);
		labelAchievementData.text = ReceiveReward.getTitle(rewardData.UserGoodsType, 0L, rewardData.ItemCount);
		labelAchievementTitle.text = rewardData.MissionText;
		alreadyReceived.gameObject.SetActive(rewardData.IsCleared);
		GaugeUI.gameObject.SetActive(value: false);
	}
}
