using System;
using Cute;
using UnityEngine;
using Wizard;

public class PracticeNextSceneSelector : INextSceneSelector
{
	private BattleResultUIController m_battleResultNewControl;

	private bool _movingToMyPage;

	public PracticeNextSceneSelector(BattleResultUIController battleResultControl)
	{
		m_battleResultNewControl = battleResultControl;
		_movingToMyPage = false;
	}

	public void Setup(bool isWin, GameObject gameObject)
	{
		m_battleResultNewControl.MissionBtnObj.labels[0].text = Data.SystemText.Get("Battle_0200");
		m_battleResultNewControl.MissionBtnObj.buttons[0].onClick.Clear();
		m_battleResultNewControl.MissionBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			UIManager.GetInstance().createInSceneCenterLoading();
			MissionInfoTask missionInfoTask = GameMgr.GetIns().GetMissionInfoTask();
			missionInfoTask.SetParameter();
			m_battleResultNewControl.StartCoroutine(Toolbox.NetworkManager.Connect(missionInfoTask, delegate
			{
				m_battleResultNewControl.CreateMissionList();
			}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
		}));
		m_battleResultNewControl.HomeBtnObj.labels[0].text = Data.SystemText.Get("Battle_0202");
		m_battleResultNewControl.HomeBtnObj.buttons[0].onClick.Clear();
		m_battleResultNewControl.HomeBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
		{
			MoveToMyPage();
		}));
		m_battleResultNewControl.RetryBtnObj.labels[0].text = Data.SystemText.Get("Battle_0204");
		m_battleResultNewControl.RetryBtnObj.buttons[0].onClick.Clear();
		m_battleResultNewControl.RetryBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			PracticeDeckInfoTask task = new PracticeDeckInfoTask();
			UIManager.GetInstance().StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
			{
				Format value = (Format)PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.LAST_SELECT_DECK_FORMAT);
				Action<DeckUI> onUpdateDeckUICustomize = delegate(DeckUI deckUI)
				{
					if (deckUI.Deck.Format == GameMgr.GetIns().GetDataMgr().GetSelectDeckFormat() && deckUI.Deck.GetDeckID() == GameMgr.GetIns().GetDataMgr().GetSelectDeckId())
					{
						deckUI.SetTextAppealLabelLeft(Data.SystemText.Get("Card_0235"));
					}
					deckUI.SetSelectable(deckUI.Deck.IsUsable());
				};
				DeckSelectUIDialog.Create(Data.SystemText.Get("Story_0017"), task.DeckGroupListData, value, DeckSelectUIDialog.eFormatChangeUIType.UseOtherCategory, isVisibleCreateNew: false, delegate(DialogBase dialog, DeckData deck)
				{
					PracticeDeckSelectConfirmDialog.Create(dialog, deck, isBattleAgain: true);
				}, new DeckSelectUI.InitOptions
				{
					OnUpdateDeckUICustomize = onUpdateDeckUICustomize
				});
			}));
		}));
	}

	public void Show()
	{
		iTween.MoveTo(m_battleResultNewControl.ButtonGrid.gameObject, iTween.Hash("position", m_battleResultNewControl.DefaultPosDict["ButtonGrid"], "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
	}

	private void MoveToMyPage()
	{
		if (!_movingToMyPage)
		{
			_movingToMyPage = true;
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL_TRANS);
			GameMgr.GetIns().GetBattleCtrl().BattleEnd(UIManager.ViewScene.MyPage);
		}
	}
}
