using System.Collections;
using System.Collections.Generic;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.QuestSpecialResult;

public class QuestSpecialBattleResult : MonoBehaviour
{
	private const float CARD_SCALE = 0.86f;

	private const int CARD_DEPTH = 50;

	private const string BOSS_RUSH_EFFECT = "cmn_result_bossrush_1";

	[SerializeField]
	private BattleResultUIController _battleResultNewControl;

	[Header("クエスト情報")]
	[SerializeField]
	public GameObject _questPointInfo;

	[SerializeField]
	private UIGauge _questPointGaugeBar;

	[SerializeField]
	public ParticleSystem QuestPointGaugeEffect;

	[SerializeField]
	private UILabel _questPointLabel;

	[SerializeField]
	public UILabel _questPointAddLabel;

	[SerializeField]
	public UILabel _questBonusPointAddLabel;

	[SerializeField]
	public UILabel _questBonusTitleLabel;

	[SerializeField]
	public UILabel _questBonusInfoLabel;

	[SerializeField]
	public UILabel _questPointRestLabel;

	[SerializeField]
	public List<UILabel> _questClearMissionTitleLabelList;

	[SerializeField]
	public List<UILabel> _questClearMissionPointLabelList;

	[SerializeField]
	private UISprite _bossrushFinishTitle;

	[SerializeField]
	private CardImageHelpder _bossRushCardLoader;

	[SerializeField]
	private GameObject _bossRushCardRoot;

	[SerializeField]
	private UISprite _bossRushBG;

	[SerializeField]
	private UIGrid _bossRushCardGrid;

	[SerializeField]
	private GameObject _bossRushEmptyFrameOriginal;

	[SerializeField]
	private UILabel _bossRushWinCountLabel;

	[SerializeField]
	private GameObject _bossRushWinCountObj;

	[SerializeField]
	private UIButton _bossRushTouchCollider;

	[SerializeField]
	private GameObject _bossRushCardOriginal;

	private List<string> _loadFileList = new List<string>();

	private bool _isNeedBossRushAtlasRemove;

	private const float QUEST_RESULT_LABEL_DURATION = 0.5f;

	private const float QUEST_RESULT_LABEL_DELAY = 0.1f;

	private const float QUEST_RESULT_LABEL_MOVE_DISTANCE = 50f;

	[SerializeField]
	private QuestAllConfirmDialog _questAllConfirmDialogOriginal;

	[SerializeField]
	private GameObject _winBonusRoot;

	[SerializeField]
	private UILabel _winBonusLabel;

	[SerializeField]
	private UILabel _winBonusTitleLabel;

	[SerializeField]
	private UILabel _winBonusPointLabel;

	[SerializeField]
	private UILabel _bossRushClearLife;

	[SerializeField]
	private UILabel _bossRushClearLifeMax;

	[SerializeField]
	private FlexibleGrid _bossRushClearLifeGrid;

	[SerializeField]
	private UILabel _bossRushClearTurn;

	[SerializeField]
	private UILabel _bossRushClearWinCount;

	[SerializeField]
	private UILabel _bossRushShortestClearTurn;

	[SerializeField]
	private UILabel _bossRushClearNewRecordLabel;

	[SerializeField]
	private GameObject _bossRushAnimationRoot;

	[SerializeField]
	private Camera _myPageCamera;

	private int _questLvPrev;

	private QuestAssetManager _assetManager;

	public bool IsBossRushTotalResultFinish { get; private set; }

	public Camera MyPageCamera => _myPageCamera;

	public void Init()
	{
		_assetManager = new QuestAssetManager();
		_battleResultNewControl.DefaultPosDict["QuestPointInfo"] = _questPointInfo.transform.localPosition;
		_bossRushEmptyFrameOriginal.SetActive(value: false);
		GameMgr.GetIns().GetDataMgr();
		_bossRushCardRoot.SetActive(value: false);
		_bossRushCardOriginal.SetActive(value: false);
		_myPageCamera.gameObject.SetActive(value: false);
	}

	public void ResultSetupEnd(Format format)
	{
		_questPointInfo.transform.localPosition = _battleResultNewControl.DefaultPosDict["QuestPointInfo"] + Vector3.left * 2000f;
		_questPointInfo.gameObject.SetActive(value: true);
		_questPointAddLabel.alpha = 0f;
		_questBonusPointAddLabel.alpha = 0f;
		_questBonusTitleLabel.alpha = 0f;
		_questBonusInfoLabel.alpha = 0f;
		for (int i = 0; i < _questClearMissionTitleLabelList.Count; i++)
		{
			_questClearMissionTitleLabelList[i].alpha = 0f;
		}
		for (int j = 0; j < _questClearMissionPointLabelList.Count; j++)
		{
			_questClearMissionPointLabelList[j].alpha = 0f;
		}
		_winBonusTitleLabel.alpha = 0f;
		_winBonusPointLabel.alpha = 0f;
	}

	public void GetServerData(IBattleResultReporter resultReporter)
	{
		SetQuestPoint(0, isLvUpCheck: false);
		QuestFinishDetail data = Data.QuestFinish.data;
		if (data.WinBonusPointStatus == QuestFinishDetail.WinBonusStatus.AlreadyAchieved || data.WinCountForWinBonusPoint == 0)
		{
			_winBonusRoot.SetActive(value: false);
			return;
		}
		_winBonusRoot.SetActive(value: true);
		if (data.WinBonusPointStatus == QuestFinishDetail.WinBonusStatus.NotAchieved)
		{
			_winBonusLabel.text = string.Format(Data.SystemText.Get("Quest_0039"), data.WinCountForWinBonusPoint - data.WinCount);
		}
		else if (data.WinBonusPointStatus == QuestFinishDetail.WinBonusStatus.NowAchieved)
		{
			_winBonusLabel.text = Data.SystemText.Get("Quest_0041");
		}
	}

	public void CreateQuestList()
	{
		_ = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(Data.SystemText.Get("Quest_0005"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
		QuestAllConfirmDialog questAllConfirmDialog = Object.Instantiate(_questAllConfirmDialogOriginal);
		questAllConfirmDialog.CreateQuestAllConfirmDialog();
		dialogBase.SetObj(questAllConfirmDialog.gameObject);
		_battleResultNewControl._missionDialog = dialogBase;
	}

	public void SettingAddQuestPointTextAnimation()
	{
		QuestFinishDetail data = Data.QuestFinish.data;
		iTween.ValueTo(base.gameObject, iTween.Hash("from", 0, "to", data.AddPoint, "time", 0.5f, "delay", 0.5f, "onstart", "StartAddQuestPoint", "onupdate", "UpdateQuestPoint", "oncomplete", "CompleteQuestPoint", "easetype", iTween.EaseType.easeOutQuad));
		bool flag = data.AddPoint >= 0;
		_questPointAddLabel.text = (flag ? "+" : string.Empty) + data.AddPoint;
		_questPointAddLabel.color = (flag ? BattleResultUIController.PLUS_START_COLOR : BattleResultUIController.MINUS_START_COLOR);
		TweenAlpha.Begin(_questPointAddLabel.gameObject, 0.3f, 1f);
		iTween.MoveFrom(_questPointAddLabel.gameObject, iTween.Hash("y", _questPointAddLabel.transform.localPosition.y - 10f, "time", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
	}

	public void AddWinBonusQuestPoint()
	{
		QuestFinishDetail data = Data.QuestFinish.data;
		iTween.ValueTo(base.gameObject, iTween.Hash("from", 0, "to", data.WinBonusPoint, "time", 0.5f, "delay", 0.5f, "onstart", "StartAddQuestPoint", "onupdate", "UpdateWinBonusQuestPoint", "oncomplete", "CompleteWinBonusQuestPoint", "easetype", iTween.EaseType.easeOutQuad));
		_winBonusPointLabel.text = "+" + data.WinBonusPoint;
		_winBonusPointLabel.color = BattleResultUIController.PLUS_END_COLOR;
		_winBonusTitleLabel.alpha = 1f;
		iTween.MoveFrom(_winBonusTitleLabel.gameObject, iTween.Hash("x", _winBonusTitleLabel.transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
	}

	public void SettingAddBounusQuestPointTextAnimation()
	{
		QuestFinishDetail data = Data.QuestFinish.data;
		iTween.ValueTo(base.gameObject, iTween.Hash("from", 0, "to", data.GetTotalBonusPoint(), "time", 0.5f, "delay", 0.5f, "onstart", "StartAddQuestPoint", "onupdate", "UpdateBonusQuestPoint", "oncomplete", "CompleteBonusQuestPoint", "easetype", iTween.EaseType.easeOutQuad));
		_questBonusPointAddLabel.text = ((data.GetTotalBonusPoint() >= 0) ? "+" : string.Empty) + data.GetTotalBonusPoint();
		_questBonusPointAddLabel.color = BattleResultUIController.PLUS_END_COLOR;
		_questBonusTitleLabel.alpha = 1f;
		iTween.MoveFrom(_questBonusTitleLabel.gameObject, iTween.Hash("x", _questBonusTitleLabel.transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		TweenAlpha.Begin(_questBonusInfoLabel.gameObject, 0.3f, 1f).delay = 0.1f;
		iTween.MoveFrom(_questBonusInfoLabel.gameObject, iTween.Hash("x", _questBonusInfoLabel.transform.localPosition.x - 50f, "time", 0.5f, "delay", 0.1f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
	}

	public void SettingAddCommonMissionQuestPointTextAnimation()
	{
		int totalCommonMissionClearPoint = Data.QuestFinish.data.GetTotalCommonMissionClearPoint();
		iTween.ValueTo(base.gameObject, iTween.Hash("from", 0, "to", totalCommonMissionClearPoint, "time", 0.5f, "delay", 0.5f, "onstart", "StartAddQuestPoint", "onupdate", "UpdateCommonMissionQuestPoint", "oncomplete", (Data.QuestFinish.data.CharacterMissionClearInfoList.Count > 0) ? "CompleteCommonMissionQuestPointDisappearLabel" : "CompleteCommonMissionQuestPoint", "easetype", iTween.EaseType.easeOutQuad));
		List<QuestFinishDetail.MissionClearInfo> commonMissionClearInfoList = Data.QuestFinish.data.CommonMissionClearInfoList;
		for (int i = 0; i < commonMissionClearInfoList.Count; i++)
		{
			_questClearMissionTitleLabelList[i].text = commonMissionClearInfoList[i].MissionText;
			_questClearMissionPointLabelList[i].text = "+" + commonMissionClearInfoList[i].MissionPoint;
			_questClearMissionTitleLabelList[i].alpha = 1f;
			iTween.MoveFrom(_questClearMissionTitleLabelList[i].gameObject, iTween.Hash("x", _questClearMissionTitleLabelList[i].transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
			_questClearMissionPointLabelList[i].alpha = 1f;
			iTween.MoveFrom(_questClearMissionPointLabelList[i].gameObject, iTween.Hash("x", _questClearMissionPointLabelList[i].transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		}
	}

	public void SettingAddCharacterMissionQuestPointTextAnimation()
	{
		int totalCharacterMissionClearPoint = Data.QuestFinish.data.GetTotalCharacterMissionClearPoint();
		iTween.ValueTo(base.gameObject, iTween.Hash("from", 0, "to", totalCharacterMissionClearPoint, "time", 0.5f, "delay", 0.5f, "onstart", "StartAddQuestPoint", "onupdate", "UpdateCharacterMissionQuestPoint", "oncomplete", "CompleteCharacterMissionQuestPoint", "easetype", iTween.EaseType.easeOutQuad));
		List<QuestFinishDetail.MissionClearInfo> characterMissionClearInfoList = Data.QuestFinish.data.CharacterMissionClearInfoList;
		for (int i = 0; i < characterMissionClearInfoList.Count; i++)
		{
			_questClearMissionTitleLabelList[i].text = characterMissionClearInfoList[i].MissionText;
			_questClearMissionPointLabelList[i].text = "+" + characterMissionClearInfoList[i].MissionPoint;
			_questClearMissionTitleLabelList[i].alpha = 1f;
			iTween.MoveFrom(_questClearMissionTitleLabelList[i].gameObject, iTween.Hash("x", _questClearMissionTitleLabelList[i].transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
			_questClearMissionPointLabelList[i].alpha = 1f;
			iTween.MoveFrom(_questClearMissionPointLabelList[i].gameObject, iTween.Hash("x", _questClearMissionPointLabelList[i].transform.localPosition.x - 50f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		}
	}

	private void StartAddQuestPoint()
	{
		QuestPointGaugeEffect.gameObject.SetActive(value: true);
		QuestPointGaugeEffect.Play();
	}

	private void SetQuestPoint(int diffPoint, bool isLvUpCheck)
	{
		if (GameMgr.GetIns().GetDataMgr().IsQuestBattleType())
		{
			QuestFinishDetail data = Data.QuestFinish.data;
			int initPoint = data.CurrentPoint - data.AddPoint - data.WinBonusPoint - data.GetTotalBonusPoint() - data.GetTotalCommonMissionClearPoint() - data.GetTotalCharacterMissionClearPoint() + diffPoint;
			int questLv = GetQuestLv(initPoint);
			int questPointNow = GetQuestPointNow(initPoint);
			int num = Mathf.Max(0, data.NecessaryPointList[questLv - 1] - questPointNow);
			_questPointLabel.text = initPoint.ToString();
			_questPointAddLabel.text = "+" + (data.AddPoint - diffPoint);
			_questPointRestLabel.text = num.ToString();
			_questPointGaugeBar.Value = (((float)data.NecessaryPointList[questLv - 1] > 0f) ? Mathf.Min((float)questPointNow / (float)data.NecessaryPointList[questLv - 1], 1f) : 1f);
			if (isLvUpCheck && questLv > _questLvPrev)
			{
				GameMgr ins = GameMgr.GetIns();
				ins.GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_LEVELUP);
				ins.GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_GAUGE_1, _questPointGaugeBar.GetTransformGaugeStartEdge().position);
				_questLvPrev = questLv;
			}
			else
			{
				_questLvPrev = GetQuestLv(initPoint);
			}
		}
	}

	private void SetWinBonusQuestPoint(int diffPoint)
	{
		if (GameMgr.GetIns().GetDataMgr().IsQuestBattleType())
		{
			QuestFinishDetail data = Data.QuestFinish.data;
			int initPoint = data.CurrentPoint - data.WinBonusPoint - data.GetTotalBonusPoint() - data.GetTotalCommonMissionClearPoint() - data.GetTotalCharacterMissionClearPoint() + diffPoint;
			int questLv = GetQuestLv(initPoint);
			int questPointNow = GetQuestPointNow(initPoint);
			int num = data.NecessaryPointList[questLv - 1];
			int num2 = Mathf.Max(0, num - questPointNow);
			_questPointLabel.text = initPoint.ToString();
			_winBonusPointLabel.text = "+" + (data.WinBonusPoint - diffPoint);
			_questPointRestLabel.text = num2.ToString();
			_questPointGaugeBar.Value = ((num > 0) ? Mathf.Min((float)questPointNow / (float)num, 1f) : 1f);
			if (questLv > _questLvPrev)
			{
				GameMgr ins = GameMgr.GetIns();
				ins.GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_LEVELUP);
				ins.GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_GAUGE_1, _questPointGaugeBar.GetTransformGaugeStartEdge().position);
				_questLvPrev = questLv;
			}
			else
			{
				_questLvPrev = GetQuestLv(initPoint);
			}
		}
	}

	private void SetBonusQuestPoint(int diffPoint)
	{
		if (GameMgr.GetIns().GetDataMgr().IsQuestBattleType())
		{
			QuestFinishDetail data = Data.QuestFinish.data;
			int initPoint = data.CurrentPoint - data.GetTotalBonusPoint() - data.GetTotalCommonMissionClearPoint() - data.GetTotalCharacterMissionClearPoint() + diffPoint;
			int questLv = GetQuestLv(initPoint);
			int questPointNow = GetQuestPointNow(initPoint);
			int num = Mathf.Max(0, data.NecessaryPointList[questLv - 1] - questPointNow);
			_questPointLabel.text = initPoint.ToString();
			_questBonusPointAddLabel.text = "+" + (data.GetTotalBonusPoint() - diffPoint);
			_questPointRestLabel.text = num.ToString();
			_questPointGaugeBar.Value = (((float)data.NecessaryPointList[questLv - 1] > 0f) ? Mathf.Min((float)questPointNow / (float)data.NecessaryPointList[questLv - 1], 1f) : 1f);
			if (questLv > _questLvPrev)
			{
				GameMgr ins = GameMgr.GetIns();
				ins.GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_LEVELUP);
				ins.GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_GAUGE_1, _questPointGaugeBar.GetTransformGaugeStartEdge().position);
				_questLvPrev = questLv;
			}
			else
			{
				_questLvPrev = GetQuestLv(initPoint);
			}
		}
	}

	private void SetCommonMissionQuestPoint(int diffPoint)
	{
		if (GameMgr.GetIns().GetDataMgr().IsQuestBattleType())
		{
			QuestFinishDetail data = Data.QuestFinish.data;
			int initPoint = data.CurrentPoint - data.GetTotalCommonMissionClearPoint() - data.GetTotalCharacterMissionClearPoint() + diffPoint;
			int questLv = GetQuestLv(initPoint);
			int questPointNow = GetQuestPointNow(initPoint);
			int num = Mathf.Max(0, data.NecessaryPointList[questLv - 1] - questPointNow);
			_questPointLabel.text = initPoint.ToString();
			_questPointRestLabel.text = num.ToString();
			_questPointGaugeBar.Value = (((float)data.NecessaryPointList[questLv - 1] > 0f) ? Mathf.Min((float)questPointNow / (float)data.NecessaryPointList[questLv - 1], 1f) : 1f);
			if (questLv > _questLvPrev)
			{
				GameMgr ins = GameMgr.GetIns();
				ins.GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_LEVELUP);
				ins.GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_GAUGE_1, _questPointGaugeBar.GetTransformGaugeStartEdge().position);
				_questLvPrev = questLv;
			}
			else
			{
				_questLvPrev = GetQuestLv(initPoint);
			}
		}
	}

	private void SetCharacterMissionQuestPoint(int diffPoint)
	{
		if (GameMgr.GetIns().GetDataMgr().IsQuestBattleType())
		{
			QuestFinishDetail data = Data.QuestFinish.data;
			int initPoint = data.CurrentPoint - data.GetTotalCharacterMissionClearPoint() + diffPoint;
			int questLv = GetQuestLv(initPoint);
			int questPointNow = GetQuestPointNow(initPoint);
			int num = Mathf.Max(0, data.NecessaryPointList[questLv - 1] - questPointNow);
			_questPointLabel.text = initPoint.ToString();
			_questPointRestLabel.text = num.ToString();
			_questPointGaugeBar.Value = (((float)data.NecessaryPointList[questLv - 1] > 0f) ? Mathf.Min((float)questPointNow / (float)data.NecessaryPointList[questLv - 1], 1f) : 1f);
			if (questLv > _questLvPrev)
			{
				GameMgr ins = GameMgr.GetIns();
				ins.GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_LEVELUP);
				ins.GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_GAUGE_1, _questPointGaugeBar.GetTransformGaugeStartEdge().position);
				_questLvPrev = questLv;
			}
			else
			{
				_questLvPrev = GetQuestLv(initPoint);
			}
		}
	}

	private void UpdateQuestPoint(int num)
	{
		SetQuestPoint(num, isLvUpCheck: true);
	}

	private void UpdateWinBonusQuestPoint(int num)
	{
		SetWinBonusQuestPoint(num);
	}

	private void UpdateBonusQuestPoint(int num)
	{
		SetBonusQuestPoint(num);
	}

	private void UpdateCommonMissionQuestPoint(int num)
	{
		SetCommonMissionQuestPoint(num);
	}

	private void UpdateCharacterMissionQuestPoint(int num)
	{
		SetCharacterMissionQuestPoint(num);
	}

	private void CompleteQuestPoint()
	{
		QuestPointGaugeEffect.Stop();
		TweenAlpha.Begin(_questPointAddLabel.gameObject, 0.5f, 0f);
	}

	private void CompleteWinBonusQuestPoint()
	{
		QuestPointGaugeEffect.Stop();
		TweenAlpha.Begin(_winBonusTitleLabel.gameObject, 0.5f, 0f);
		TweenAlpha.Begin(_winBonusPointLabel.gameObject, 0.5f, 0f);
	}

	private void CompleteBonusQuestPoint()
	{
		QuestPointGaugeEffect.Stop();
		TweenAlpha.Begin(_questBonusTitleLabel.gameObject, 0.5f, 0f);
		TweenAlpha.Begin(_questBonusPointAddLabel.gameObject, 0.5f, 0f);
	}

	private void CompleteCommonMissionQuestPointDisappearLabel()
	{
		CompleteCommonMissionQuestPoint();
		for (int i = 0; i < Data.QuestFinish.data.CommonMissionClearInfoList.Count; i++)
		{
			TweenAlpha.Begin(_questClearMissionTitleLabelList[i].gameObject, 0.5f, 0f);
			TweenAlpha.Begin(_questClearMissionPointLabelList[i].gameObject, 0.5f, 0f);
		}
	}

	private void CompleteCommonMissionQuestPoint()
	{
		QuestPointGaugeEffect.Stop();
	}

	private void CompleteCharacterMissionQuestPoint()
	{
		QuestPointGaugeEffect.Stop();
	}

	private int GetQuestLv(int initPoint)
	{
		int num = 1;
		int num2 = 0;
		List<int> necessaryPointList = Data.QuestFinish.data.NecessaryPointList;
		for (int i = 0; i < necessaryPointList.Count; i++)
		{
			num2 += necessaryPointList[i];
			if (initPoint < num2)
			{
				break;
			}
			num++;
		}
		return Mathf.Min(num, necessaryPointList.Count);
	}

	private int GetQuestPointNow(int initPoint)
	{
		int num = initPoint;
		List<int> necessaryPointList = Data.QuestFinish.data.NecessaryPointList;
		for (int i = 0; i < necessaryPointList.Count && num >= necessaryPointList[i]; i++)
		{
			num -= necessaryPointList[i];
		}
		return num;
	}

	public IEnumerator LoadCoroutine()
	{
		yield return _assetManager.LoadAllCoroutine();
	}

	public void Unload()
	{
		if (_isNeedBossRushAtlasRemove)
		{
			UIManager.GetInstance().RemoveResidentAtlas(UIAtlasManager.AssetBundleNames.BossRush);
		}
		Toolbox.ResourcesManager.RemoveAssetGroup(_loadFileList);
		_loadFileList.Clear();
		_assetManager.UnloadAll();
	}

	public IEnumerator PlayAnimationCoroutine()
	{
		while (!_assetManager.IsLoaded)
		{
			yield return null;
		}
	}

	private IEnumerator LoadBossRushResource()
	{
		List<int> cardIdList = new List<int>();
		BossRushBattleData bossRushBattleData = GameMgr.GetIns().GetDataMgr().BossRushBattleData;
		CardMaster instance = CardMaster.GetInstance(CardMaster.CardMasterId.Default);
		foreach (BossRushSpecialSkill playerSkill in bossRushBattleData.PlayerSkillList)
		{
			CardParameter cardParameterFromId = instance.GetCardParameterFromId(playerSkill.OriginalCardId);
			if (playerSkill.IsFoil)
			{
				cardIdList.Add(cardParameterFromId.FoilCardId);
			}
			else
			{
				cardIdList.Add(playerSkill.OriginalCardId);
			}
		}
		bool finish = false;
		_isNeedBossRushAtlasRemove = true;
		List<string> loadList = new List<string> { UIManager.GetInstance().GetSceneAssetPath(UIAtlasManager.AssetBundleNames.BossRush) };
		string[] array = new string[1] { "cmn_result_bossrush_1" };
		foreach (string path in array)
		{
			loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.Effect2D));
		}
		yield return StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(loadList, null));
		_loadFileList = loadList;
		UIManager.GetInstance().AddResidentAtlas(UIAtlasManager.AssetBundleNames.BossRush);
		_bossRushCardLoader.Load(cardIdList, 0.86f, 50, CardTemplateCustomize, delegate
		{
			finish = true;
		});
		while (!finish)
		{
			yield return null;
		}
	}

	private void CardTemplateCustomize(CardListTemplate template)
	{
		template.SetBossRushSkillFrame();
		template.HideNum();
		template.HideLabelsForBossRushSkill();
		template.SetBossRushCardTexture();
	}

	private void InitializeCard()
	{
		BossRushBattleData bossRushBattleData = GameMgr.GetIns().GetDataMgr().BossRushBattleData;
		for (int i = 0; i < bossRushBattleData.MaxBattleCount; i++)
		{
			if (i >= bossRushBattleData.PlayerSkillList.Count)
			{
				AddEmptyAbilityFrame();
			}
			else
			{
				AddAbilityCardObj(i);
			}
		}
		_bossRushCardGrid.Reposition();
	}

	private void AddEmptyAbilityFrame()
	{
		NGUITools.AddChild(_bossRushCardGrid.gameObject, _bossRushEmptyFrameOriginal).SetActive(value: true);
	}

	private void AddAbilityCardObj(int index)
	{
		GameObject gameObject = NGUITools.AddChild(_bossRushCardGrid.gameObject, _bossRushCardOriginal);
		gameObject.SetActive(value: true);
		GameObject cardObj = _bossRushCardLoader.GetCardObjData(index).CardObj;
		Vector3 localScale = cardObj.transform.localScale;
		cardObj.transform.parent = gameObject.transform;
		cardObj.transform.localPosition = Vector3.zero;
		cardObj.transform.localScale = localScale;
		BossRushBattleData bossRushBattleData = GameMgr.GetIns().GetDataMgr().BossRushBattleData;
		UILabel componentInChildren = gameObject.GetComponentInChildren<UILabel>();
		componentInChildren.text = bossRushBattleData.PlayerSkillList[index].Name;
		UIManager.GetInstance().getUIBase_CardManager().SetNameLabelStyle(componentInChildren, bossRushBattleData.PlayerSkillList[index].IsFoil);
	}

	private bool IsBossRushAllWin(bool isWin)
	{
		if (GameMgr.GetIns().GetDataMgr().m_BattleType == DataMgr.BattleType.BossRushQuest)
		{
			BossRushBattleData bossRushBattleData = GameMgr.GetIns().GetDataMgr().BossRushBattleData;
			if (isWin)
			{
				return bossRushBattleData.CurrentWinCount + 1 >= bossRushBattleData.MaxBattleCount;
			}
			return false;
		}
		return false;
	}

	public IEnumerator SettingBossRushFinishResultAnimation(bool isWin)
	{
		BossRushBattleData bossRushBattleData = GameMgr.GetIns().GetDataMgr().BossRushBattleData;
		Vector3 finishTitleDefaultPosition = _bossrushFinishTitle.transform.localPosition;
		Vector3 winObjDefaultPosition = _bossRushWinCountObj.transform.localPosition;
		Vector3 cardGridDefaultPosition = _bossRushCardGrid.transform.localPosition;
		_bossrushFinishTitle.gameObject.SetActive(value: false);
		_bossRushWinCountObj.gameObject.SetActive(value: false);
		_bossRushCardGrid.gameObject.SetActive(value: false);
		_bossRushBG.gameObject.SetActive(value: false);
		UIWidget[] allWinCountWidget = _bossRushAnimationRoot.GetComponentsInChildren<UIWidget>();
		UIWidget[] array = allWinCountWidget;
		for (int i = 0; i < array.Length; i++)
		{
			array[i].alpha = 0f;
		}
		_bossrushFinishTitle.transform.localPosition = finishTitleDefaultPosition + Vector3.up * 500f;
		_bossRushWinCountObj.transform.localPosition = winObjDefaultPosition + Vector3.down * 100f;
		_bossRushCardGrid.transform.localPosition = cardGridDefaultPosition + Vector3.down * 500f;
		new List<GameObject>();
		_ = GameMgr.GetIns().GetDataMgr().BossRushBattleData.PlayerSkillList;
		_bossRushCardRoot.SetActive(value: true);
		int num = (isWin ? (bossRushBattleData.CurrentWinCount + 1) : bossRushBattleData.CurrentWinCount);
		_bossRushWinCountLabel.text = num.ToString();
		_bossRushClearWinCount.text = num.ToString();
		_bossRushClearLife.text = Data.QuestFinish.data.CurrentLife.ToString();
		_bossRushClearLifeMax.text = "/" + Data.QuestFinish.data.MaxLife;
		_bossRushClearLife.ProcessText();
		_bossRushClearLifeMax.ProcessText();
		_bossRushClearLifeGrid.Reposition();
		if (Data.QuestFinish.data.IsEnableBossRushShortestTurn)
		{
			_bossRushShortestClearTurn.text = Data.QuestFinish.data.BossRushShortestTurn.ToString();
		}
		else
		{
			_bossRushShortestClearTurn.text = Data.SystemText.Get("BossRush_0040");
		}
		_bossRushClearTurn.text = Data.QuestFinish.data.BossRushTotalTurn.ToString();
		if (!isWin)
		{
			_bossRushClearTurn.text = Data.SystemText.Get("BossRush_0040");
		}
		_bossRushClearNewRecordLabel.gameObject.SetActive(Data.QuestFinish.data.IsBossRushNewRecord && isWin);
		yield return StartCoroutine(LoadBossRushResource());
		InitializeCard();
		_bossrushFinishTitle.spriteName = (isWin ? "result_text_clear" : "result_text_failed");
		_bossrushFinishTitle.alpha = 0f;
		_bossRushBG.alpha = 0f;
		_bossRushBG.gameObject.SetActive(value: true);
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BOSS_RUSH_RESULT_APPEAR);
		TweenAlpha.Begin(_battleResultNewControl.Bg.gameObject, 0.2f, 0.5f);
		TweenAlpha.Begin(_bossRushBG.gameObject, 0.2f, 1f);
		yield return new WaitForSeconds(0.2f);
		_bossrushFinishTitle.gameObject.SetActive(value: true);
		_bossRushWinCountObj.gameObject.SetActive(value: true);
		_bossRushCardGrid.gameObject.SetActive(value: true);
		UIManager.GetInstance().AttachAtlas(_bossrushFinishTitle.gameObject, isTargetChildren: false);
		TweenAlpha.Begin(_bossrushFinishTitle.gameObject, 0.2f, 1f);
		array = allWinCountWidget;
		for (int i = 0; i < array.Length; i++)
		{
			TweenAlpha.Begin(array[i].gameObject, 0.2f, 1f);
		}
		iTween.MoveTo(_bossrushFinishTitle.gameObject, iTween.Hash("position", finishTitleDefaultPosition, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(_bossRushWinCountObj.gameObject, iTween.Hash("position", winObjDefaultPosition, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(_bossRushCardGrid.gameObject, iTween.Hash("position", cardGridDefaultPosition, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		yield return new WaitForSeconds(0.5f);
		GameObject effectObject = null;
		if (IsBossRushAllWin(isWin))
		{
			effectObject = Object.Instantiate(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("cmn_result_bossrush_1", ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject);
			effectObject.transform.SetParent(_bossRushWinCountObj.transform);
			effectObject.transform.localPosition = Vector3.zero;
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BOSS_RUSH_RESULT_CLEAR);
			_loadFileList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(effectObject, null));
			effectObject.SetActive(value: true);
		}
		bool isTouchCollider = false;
		_bossRushTouchCollider.onClick.Add(new EventDelegate(delegate
		{
			isTouchCollider = true;
		}));
		while (!isTouchCollider)
		{
			yield return null;
		}
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BOSS_RUSH_RESULT_MOVE);
		if (effectObject != null)
		{
			Object.Destroy(effectObject);
		}
		iTween.MoveTo(_bossrushFinishTitle.gameObject, iTween.Hash("position", finishTitleDefaultPosition + Vector3.up * 500f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		TweenAlpha.Begin(_bossRushWinCountObj.gameObject, 0.5f, 0f);
		TweenAlpha.Begin(_bossRushBG.gameObject, 0.5f, 0f);
		array = allWinCountWidget;
		for (int i = 0; i < array.Length; i++)
		{
			TweenAlpha.Begin(array[i].gameObject, 0.5f, 0f);
		}
		iTween.MoveTo(_bossRushCardGrid.gameObject, iTween.Hash("position", cardGridDefaultPosition + Vector3.down * 500f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		yield return new WaitForSeconds(0.5f);
		_bossRushTouchCollider.gameObject.SetActive(value: false);
		IsBossRushTotalResultFinish = true;
	}
}
