using System.Collections;
using UnityEngine;
using Wizard;

public class ArenaResultAnimationAgent : ResultAnimationAgent
{
	public override IEnumerator RunUI(BattleResultUIController battleResultControl, INextSceneSelector nextSceneSelector, bool isWin)
	{
		m_BattleCamera.m_CutInCamera.gameObject.SetActive(value: false);
		if (battleResultControl.IsDraw)
		{
			battleResultControl.TitleWin.gameObject.SetActive(value: false);
			battleResultControl.TitleLose.gameObject.SetActive(value: false);
			battleResultControl.TitleDraw.gameObject.SetActive(value: true);
			battleResultControl.TitleDraw.transform.localScale = Vector3.one * 10f;
			battleResultControl.TitleDraw.alpha = 0f;
			battleResultControl.Bg.color = new Color32(0, 48, 16, 0);
			battleResultControl.ResultTitle.spriteName = "result_top_lose";
		}
		else if (isWin)
		{
			battleResultControl.TitleWin.gameObject.SetActive(value: true);
			battleResultControl.TitleLose.gameObject.SetActive(value: false);
			battleResultControl.TitleDraw.gameObject.SetActive(value: false);
			battleResultControl.TitleWin.transform.localScale = Vector3.one * 10f;
			battleResultControl.TitleWin.alpha = 0f;
			battleResultControl.Bg.color = new Color32(32, 24, 0, 0);
			battleResultControl.ResultTitle.spriteName = "result_top_win";
		}
		else
		{
			battleResultControl.TitleWin.gameObject.SetActive(value: false);
			battleResultControl.TitleLose.gameObject.SetActive(value: true);
			battleResultControl.TitleDraw.gameObject.SetActive(value: false);
			battleResultControl.TitleLose.transform.localScale = Vector3.one * 10f;
			battleResultControl.TitleLose.alpha = 0f;
			battleResultControl.Bg.color = new Color32(0, 24, 48, 0);
			battleResultControl.ResultTitle.spriteName = "result_top_lose";
		}
		battleResultControl.MainPanel.alpha = 1f;
		yield return new WaitForSeconds(0.1f);
		if (battleResultControl.IsDraw)
		{
			TweenAlpha.Begin(battleResultControl.TitleDraw.gameObject, 0.2f, 1f);
			iTween.ScaleTo(battleResultControl.TitleDraw.gameObject, iTween.Hash("scale", Vector3.one, "time", 0.2f, "islocal", true, "easetype", iTween.EaseType.easeInQuad));
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_YOULOSE);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_JINGLE_LOSE);
		}
		else if (isWin)
		{
			TweenAlpha.Begin(battleResultControl.TitleWin.gameObject, 0.2f, 1f);
			iTween.ScaleTo(battleResultControl.TitleWin.gameObject, iTween.Hash("scale", Vector3.one, "time", 0.2f, "islocal", true, "easetype", iTween.EaseType.easeInQuad));
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_YOUWIN);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_JINGLE_WIN);
		}
		else
		{
			TweenAlpha.Begin(battleResultControl.TitleLose.gameObject, 0.2f, 1f);
			iTween.ScaleTo(battleResultControl.TitleLose.gameObject, iTween.Hash("scale", Vector3.one, "time", 0.2f, "islocal", true, "easetype", iTween.EaseType.easeInQuad));
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_YOULOSE);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_JINGLE_LOSE);
		}
		TweenAlpha.Begin(battleResultControl.Bg.gameObject, 0.5f, 0.75f);
		yield return new WaitForSeconds(0.2f);
		TweenAlpha.Begin(battleResultControl.ArcaneIn.gameObject, 0.5f, 1f);
		TweenAlpha.Begin(battleResultControl.ArcaneOut.gameObject, 0.5f, 1f);
		iTween.ScaleTo(battleResultControl.ArcaneIn.gameObject, iTween.Hash("scale", Vector3.one, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.ScaleTo(battleResultControl.ArcaneOut.gameObject, iTween.Hash("scale", Vector3.one, "time", 2f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		if (battleResultControl.IsDraw)
		{
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_TITLE_3, Vector3.zero);
			battleResultControl.TitleDraw.transform.localScale = Vector3.one;
			iTween.ScaleTo(battleResultControl.TitleDraw.gameObject, iTween.Hash("scale", Vector3.one * 1.1f, "time", 2f, "islocal", true, "easetype", iTween.EaseType.linear));
		}
		else if (isWin)
		{
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_TITLE_1, Vector3.zero);
			battleResultControl.TitleWin.transform.localScale = Vector3.one;
			iTween.ScaleTo(battleResultControl.TitleWin.gameObject, iTween.Hash("scale", Vector3.one * 1.1f, "time", 2f, "islocal", true, "easetype", iTween.EaseType.linear));
		}
		else
		{
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_TITLE_2, Vector3.zero);
			battleResultControl.TitleLose.transform.localScale = Vector3.one;
			iTween.ScaleTo(battleResultControl.TitleLose.gameObject, iTween.Hash("scale", Vector3.one * 1.1f, "time", 2f, "islocal", true, "easetype", iTween.EaseType.linear));
		}
		HideEmotionMessage();
		if (battleResultControl.ResultMsgWindowFlag)
		{
			StartCoroutine(battleResultControl.ShowSpecialResultInfo());
		}
		yield return new WaitForSeconds(2f);
		RankWinnerReward winnerReward = GameMgr.GetIns()._rankWinnerReward;
		if (winnerReward == null)
		{
			int value = PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_GRADE);
			string value2 = PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_STRING);
			if (value != 0 && value2 != "")
			{
				winnerReward = UIManager.GetInstance().createRankWinnerReward();
				GameMgr.GetIns()._rankWinnerReward = winnerReward;
				winnerReward.SetInfomation(value, value2);
				winnerReward.gameObject.SetActive(value: false);
			}
		}
		if (winnerReward != null && isWin)
		{
			float seconds = 3f;
			StartCoroutine(winnerReward.ResultWinnerReward());
			yield return new WaitForSeconds(seconds);
			StartCoroutine(winnerReward.HideRewardObject());
		}
		if (!battleResultControl.IsDraw && ShowRewardDialog(battleResultControl))
		{
			while (battleResultControl.IsRewardWait)
			{
				yield return null;
			}
		}
		if (Data.ArenaBattleFinish.data != null)
		{
			TreasureBoxCpResultInfo treasureBoxCpResultInfo = Data.ArenaBattleFinish.data.TreasureBoxCpResultInfo;
			if (treasureBoxCpResultInfo.IsPlayGradeUpAnimation())
			{
				yield return TreasureBoxCpOpenBoxAnimation(battleResultControl, treasureBoxCpResultInfo.AfterGrade);
			}
			if (treasureBoxCpResultInfo.IsBoxOpened())
			{
				yield return CreateTreasureBoxCpRewardDialog(treasureBoxCpResultInfo);
			}
		}
		if (battleResultControl.IsDraw)
		{
			TweenAlpha.Begin(battleResultControl.TitleDraw.gameObject, 0.2f, 0f);
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_BACK_3, battleResultControl.AnchorBottom.transform.position, battleResultControl.AnchorBottom.gameObject);
		}
		else if (isWin)
		{
			TweenAlpha.Begin(battleResultControl.TitleWin.gameObject, 0.2f, 0f);
			iTween.ScaleTo(battleResultControl.TitleWin.gameObject, iTween.Hash("scale", Vector3.one * 3f, "time", 0.2f, "islocal", true, "easetype", iTween.EaseType.easeInQuad));
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_BACK_1, battleResultControl.AnchorBottom.transform.position, battleResultControl.AnchorBottom.gameObject);
		}
		else
		{
			TweenAlpha.Begin(battleResultControl.TitleLose.gameObject, 0.2f, 0f);
			GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_RESULT_BACK_2, battleResultControl.AnchorBottom.transform.position, battleResultControl.AnchorBottom.gameObject);
		}
		yield return new WaitForSeconds(0.2f);
		if (isWin)
		{
			GameMgr.GetIns().GetSoundMgr().PlayBGM(Bgm.BGM_TYPE.SYS_WIN_LOOP);
		}
		else
		{
			GameMgr.GetIns().GetSoundMgr().PlayBGM(Bgm.BGM_TYPE.SYS_LOSE_LOOP);
		}
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_WINDOW_APPER);
		iTween.MoveTo(battleResultControl.ClassCharObj.gameObject, iTween.Hash("position", battleResultControl.DefaultPosDict["ClassCharObj"], "time", 0.5f, "delay", 0.1f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(battleResultControl.ResultTitle.gameObject, iTween.Hash("position", battleResultControl.DefaultPosDict["ResultTitle"], "time", 0.5f, "delay", 0f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(battleResultControl.ClassInfo.gameObject, iTween.Hash("position", battleResultControl.DefaultPosDict["ClassInfo"], "time", 0.5f, "delay", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		yield return new WaitForSeconds(1f);
		if (isWin)
		{
			PlayWinVoice();
		}
		if (battleResultControl.AddClassExp > 0)
		{
			battleResultControl.SettingAddClassExpTextAnimation();
			yield return new WaitForSeconds(0.5f);
			for (int i = 0; i < 10; i++)
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_RESULT_GAUGEUP);
				yield return new WaitForSeconds(0.05f);
			}
			yield return new WaitForSeconds(0.5f);
		}
		bool _isFinishBattlePass = false;
		battleResultControl.SetBattlePassGauge(delegate
		{
			_isFinishBattlePass = true;
		});
		while (!_isFinishBattlePass)
		{
			yield return null;
		}
		if (Data.RedEtherCampaignResultData != null)
		{
			bool isFinishRedEther = false;
			RedEtherCampaignPanel.Create(battleResultControl.gameObject, Data.RedEtherCampaignResultData, battleResultControl, delegate
			{
				isFinishRedEther = true;
			});
			while (!isFinishRedEther)
			{
				yield return null;
			}
			yield return ShowRewardDialog(Data.RedEtherCampaignResultData.RewardList);
		}
		battleResultControl.GreySpriteBGVisible = false;
		nextSceneSelector.Show();
		battleResultControl.PrepareAchievementLog();
		battleResultControl.FinishResult();
	}
}
