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

public class MyPageItemBattle : MyPageItem
{
	private enum RankMatchLayoutType
	{
		Default,
		DefaultWithReward,
		DefaultWithRewardAndSpeicalReward,
		Crossover,
		CrossoverWithReward,
		CrossoverWithRewardAndSpeicalReward
	}

	private struct FormatSelectLayout
	{
		public int GridY { get; private set; }

		public int Interval { get; private set; }

		public bool IsEnableRewardButton { get; private set; }

		public bool IsEnableSpecialRewardButton { get; private set; }

		public bool IsEnableCrossOver { get; private set; }

		public Vector3 RewardPosition { get; private set; }

		public Vector3 SpecialWinRewardPosition { get; private set; }

		public FormatSelectLayout(int gridY, int interval, bool enableRewardButton, bool enableSpecialRewardButton, bool enableCrossOver, Vector3 rewardPosition, Vector3 specialWinRewardPosition)
		{
			GridY = gridY;
			Interval = interval;
			IsEnableRewardButton = enableRewardButton;
			IsEnableCrossOver = enableCrossOver;
			IsEnableSpecialRewardButton = enableSpecialRewardButton;
			RewardPosition = rewardPosition;
			SpecialWinRewardPosition = specialWinRewardPosition;
		}
	}

	[Serializable]
	private class RankMatchLayout
	{
		public UIButton RotationButton;

		public UILabel RotationLabel;

		public UITexture RotationRankTexture;

		public UIButton UnlimitedButton;

		public UILabel UnlimitedLabel;

		public UITexture UnlimitedRankTexture;

		public UIButton CrossoverButton;

		public UILabel CrossoverLabel;

		public UITexture CrossoverRankTexture;

		public UIButton WinRewardButton;

		public UIButton SpecialWinRewardButton;

		public GameObject SpecialWinRewardIcon;

		public void ClearButtonOnClickEvent()
		{
			ClearButtonOnClickEventCore(RotationButton);
			ClearButtonOnClickEventCore(UnlimitedButton);
			ClearButtonOnClickEventCore(CrossoverButton);
			ClearButtonOnClickEventCore(WinRewardButton);
			ClearButtonOnClickEventCore(SpecialWinRewardButton);
			static void ClearButtonOnClickEventCore(UIButton button)
			{
				if (!(button == null))
				{
					button.onClick.Clear();
				}
			}
		}

		public void SetButtonOnClickEvent(UIButton button, Action onClick)
		{
			if (!(button == null))
			{
				button.onClick.Add(new EventDelegate(delegate
				{
					onClick();
				}));
			}
		}
	}

	private const int FREE_MATCH_TOP_BUTTON_Y_NORMAL = 57;

	private const int FREE_MATCH_TOP_BUTTON_Y_PRE_ROTATION = 163;

	private readonly Vector3 RANK_ROTATION_POSITION_WITH_REWARD = new Vector3(215f, 106f, 0f);

	private readonly Vector3 RANK_UNLIMITED_POSITION_WITH_REWARD = new Vector3(215f, -44f, 0f);

	private const int CARD_INDEX_FREE_MATCH = 0;

	private const int CARD_INDEX_RANK_MATCH = 1;

	private const int CARD_INDEX_ROOM_MATCH = 2;

	[SerializeField]
	private UIButton _freeMatchButton;

	[SerializeField]
	private UIButton _rankMatchButton;

	[SerializeField]
	private MyPageCardPanel _freeMatchCardPanel;

	[SerializeField]
	private MyPageCardPanel _rankMatchCardPanel;

	[SerializeField]
	private MyPageBattleCampaign _battleCampaignClass;

	[SerializeField]
	private MyPageCardPanel _roomMatchCardPanel;

	[SerializeField]
	private UIButton _roomMatchButton;

	[SerializeField]
	private UITexture _rankIcon;

	[SerializeField]
	private GameObject _inviteIconCardPanel;

	[SerializeField]
	private UIButton _roomCreateButton;

	[SerializeField]
	private UIButton _roomJoinButton;

	[SerializeField]
	private UIButton _roomWatchButton;

	[SerializeField]
	private GameObject _roomInviteIconOnJoinButton;

	[SerializeField]
	private UILabel _roomWatchLabel;

	[SerializeField]
	private UIButton _roomCreateNormalBattleButton;

	[SerializeField]
	private UIButton _roomCreate2PickBattleButton;

	[SerializeField]
	private UILabel _roomCreateNormalLabel;

	[SerializeField]
	private GameObject _roomActionRoot;

	[SerializeField]
	private GameObject _roomCreateTypeRoot;

	[SerializeField]
	private GameObject _cardPanelRoomMatch;

	[SerializeField]
	private GameObject _roomInviteMenuRoot;

	[SerializeField]
	private UIButton _roomIdInputButtonInInvite;

	[SerializeField]
	private UIButton _roomInviteReceiveButton;

	[SerializeField]
	private GameObject _inviteReceveDialog;

	[SerializeField]
	private GameObject _formatSelectRootRankMatch;

	[SerializeField]
	private RankMatchLayout _rankMatchLayouts = new RankMatchLayout();

	[SerializeField]
	private UIGrid _rankMatchGrid;

	[SerializeField]
	private GameObject _winRewardDialogBoxPrefab;

	[SerializeField]
	private GameObject _specialWinRewardDialogBoxPrefab;

	[SerializeField]
	private GameObject _formatSelectRootFreeMatch;

	[SerializeField]
	private UIButton _rotationButtonFreeMatch;

	[SerializeField]
	private UILabel _rotationButtonFreeMatchLabel;

	[SerializeField]
	private UIButton _unlimitedButtonFreeMatch;

	[SerializeField]
	private UILabel _unlimitedButtonFreeMatchLabel;

	[SerializeField]
	private GameObject _roomCampaignRoot;

	[SerializeField]
	private GameObject _roomCampaignTimeRoot;

	[SerializeField]
	private UILabel _roomCampaignEndTime;

	[SerializeField]
	private GameObject _freeMatchPreReleaseApeal;

	[SerializeField]
	private UIButton _preReleaseFreeMatchButton;

	[SerializeField]
	private UILabel _preReleaseFreeMatchLabel;

	[SerializeField]
	private UIButton _crossoverFreeMatchButton;

	[SerializeField]
	private UILabel _crossoverFreeMatchLabel;

	[SerializeField]
	private UIButton _myrotaionFreeMatchButton;

	[SerializeField]
	private UILabel _myRotationFreeMatchLabel;

	[SerializeField]
	private UIButton _avatarBattleFreeMatchButton;

	[SerializeField]
	private UILabel _avatarBattleFreeMatchLabel;

	[SerializeField]
	private CardDetailUI _cardDetailPrefab;

	[SerializeField]
	private GameObject _rewardDetailCamera;

	private CardDetailUI _cardDetail;

	private CardPanelMaintenancePlate _roomWatchMaintenancePlate;

	private CardPanelMaintenancePlate _roomCreateMaintenancePlate;

	private CardPanelMaintenancePlate _roomJoinMaintenancePlate;

	private CardPanelMaintenancePlate _roomCreateNormalMaintenancePlate;

	private CardPanelMaintenancePlate _roomCreate2PickMaintenancePlate;

	private CardPanelMaintenancePlate _freeRotationMaintenancePlate;

	private CardPanelMaintenancePlate _freeUnlimitedMaintenancePlate;

	private CardPanelMaintenancePlate _freePreReleaseMaintenancePlate;

	private CardPanelMaintenancePlate _rankRotationMaintenancePlate;

	private CardPanelMaintenancePlate _rankUnlimitedMaintenancePlate;

	private CardPanelMaintenancePlate _freeCrossoverMaintenancePlate;

	private CardPanelMaintenancePlate _rankCrossoverMaintenancePlate;

	private CardPanelMaintenancePlate _freeMyRotationReleaseMaintenancePlate;

	private CardPanelMaintenancePlate _freeAvatarReleaseMaintenancePlate;

	private RoomRuleSetting _roomCreateSetting;

	private RoomRuleSetting _roomCreateSetting2Pick;

	private IDInput _roomInput;

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

	private bool _isStopSendMyPageRefreshTask;

	private static readonly Dictionary<RankMatchLayoutType, FormatSelectLayout> RANK_FORMAT_SELECT_LAYOUT = new Dictionary<RankMatchLayoutType, FormatSelectLayout>
	{
		{
			RankMatchLayoutType.Default,
			new FormatSelectLayout(57, 150, enableRewardButton: false, enableSpecialRewardButton: false, enableCrossOver: false, Vector3.zero, Vector3.zero)
		},
		{
			RankMatchLayoutType.DefaultWithReward,
			new FormatSelectLayout(106, 150, enableRewardButton: true, enableSpecialRewardButton: false, enableCrossOver: false, new Vector3(381f, -141f, 0f), Vector3.zero)
		},
		{
			RankMatchLayoutType.DefaultWithRewardAndSpeicalReward,
			new FormatSelectLayout(106, 150, enableRewardButton: true, enableSpecialRewardButton: true, enableCrossOver: false, new Vector3(381f, -141f, 0f), new Vector3(175f, -141f, 0f))
		},
		{
			RankMatchLayoutType.Crossover,
			new FormatSelectLayout(163, 146, enableRewardButton: false, enableSpecialRewardButton: false, enableCrossOver: true, Vector3.zero, Vector3.zero)
		},
		{
			RankMatchLayoutType.CrossoverWithReward,
			new FormatSelectLayout(162, 131, enableRewardButton: true, enableSpecialRewardButton: true, enableCrossOver: false, new Vector3(381f, -190f, 0f), Vector3.zero)
		},
		{
			RankMatchLayoutType.CrossoverWithRewardAndSpeicalReward,
			new FormatSelectLayout(162, 131, enableRewardButton: true, enableSpecialRewardButton: true, enableCrossOver: true, new Vector3(381f, -190f, 0f), new Vector3(175f, -190f, 0f))
		}
	};

	public RoomConnectController RoomConnectControllerInstance { get; private set; }

	public override void OnMyPageInfoReceive()
	{
		base.OnMyPageInfoReceive();
		Format inFormat = ((PlayerStaticData.UserRank(Format.Rotation) <= PlayerStaticData.UserRank(Format.Unlimited)) ? Format.Unlimited : Format.Rotation);
		PlayerStaticData.LoadUserRankTexture(inFormat);
		PlayerStaticData.AttachUserRankTexture(_rankIcon, PlayerStaticData.RankTexSize.L);
		InitializeRankIcon();
		_inviteIconCardPanel.SetActive(base.Parent.IsEnableRoomInvite);
	}

	public override void Initialize(MyPageMenu parent)
	{
		base.Initialize(parent);
		GameObject[] array = new GameObject[10] { _roomCreateButton.gameObject, _roomJoinButton.gameObject, _roomWatchButton.gameObject, _roomCreateNormalBattleButton.gameObject, _roomCreate2PickBattleButton.gameObject, _roomCreateTypeRoot, _roomInviteMenuRoot, _formatSelectRootRankMatch, _formatSelectRootFreeMatch, _roomActionRoot };
		foreach (GameObject obj in array)
		{
			SaveDefaultPosition(obj);
		}
		InitializeCardDetail();
	}

	private void InitializeCardDetail()
	{
		_rewardDetailCamera.SetActive(value: false);
		if (!(_cardDetail != null))
		{
			int detailLayer = LayerMask.NameToLayer("Detail");
			_cardDetail = UnityEngine.Object.Instantiate(_cardDetailPrefab);
			_cardDetail.transform.parent = base.transform;
			_cardDetail.transform.localPosition = Vector3.zero;
			_cardDetail.transform.localScale = Vector3.one;
			_cardDetail.gameObject.SetActive(value: false);
			_cardDetail.Initialize(detailLayer, CardMaster.CardMasterId.Default);
			_cardDetail.IsShowFlavorTextButton = false;
			_cardDetail.IsShowVoiceButton = false;
			_cardDetail.IsShowEvolutionButton = false;
		}
	}

	private void InitializeRankIcon()
	{
		List<string> list = new List<string>();
		list.Add(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Rotation).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L));
		list.Add(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Unlimited).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L));
		list.Add(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Crossover).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L));
		if (LoadCheckRankIcon(list))
		{
			List<string> oldFilePath = _rankIconPathList;
			_rankIconPathList = list;
			Toolbox.ResourcesManager.StartCoroutine_LoadAssetGroupSync(_rankIconPathList, delegate
			{
				UpdateRankIcon();
				if (oldFilePath.Count > 0)
				{
					Toolbox.ResourcesManager.RemoveAssetGroup(oldFilePath);
				}
			});
		}
		else
		{
			UpdateRankIcon();
		}
	}

	private void UpdateRankIcon()
	{
		Texture mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Rotation).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L, isfetch: true)) as Texture;
		Texture mainTexture2 = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Unlimited).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L, isfetch: true)) as Texture;
		Texture mainTexture3 = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(PlayerStaticData.UserRank(Format.Crossover).ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_L, isfetch: true)) as Texture;
		RankMatchLayout rankMatchLayouts = _rankMatchLayouts;
		if (rankMatchLayouts.RotationRankTexture != null)
		{
			rankMatchLayouts.RotationRankTexture.mainTexture = mainTexture;
		}
		if (rankMatchLayouts.UnlimitedRankTexture != null)
		{
			rankMatchLayouts.UnlimitedRankTexture.mainTexture = mainTexture2;
		}
		if (rankMatchLayouts.CrossoverRankTexture != null)
		{
			rankMatchLayouts.CrossoverRankTexture.mainTexture = mainTexture3;
		}
	}

	public override void OnClose()
	{
		base.OnClose();
		Toolbox.ResourcesManager.RemoveAssetGroup(_rankIconPathList);
		_rankIconPathList.Clear();
	}

	private bool LoadCheckRankIcon(List<string> newList)
	{
		if (_rankIconPathList.Count != newList.Count)
		{
			return true;
		}
		for (int i = 0; i < newList.Count; i++)
		{
			if (_rankIconPathList[i] != newList[i])
			{
				return true;
			}
		}
		return false;
	}

	public override void Show(bool skipCardAnimation = false)
	{
		RestoreCardPanelPosition();
		RestoreDefaultPosition(_roomCreateNormalBattleButton.gameObject);
		RestoreDefaultPosition(_roomCreate2PickBattleButton.gameObject);
		RestoreDefaultPosition(_roomCreateTypeRoot);
		UpdateCampaignInfo();
		base.Show(skipCardAnimation);
		if (FirstTips.IsFirstTipsOpen(FirstTips.TipsType.Battle))
		{
			UIManager.GetInstance().CheckFirstTips(FirstTips.TipsType.Battle);
			FirstTips.SaveFinishFirstTips(FirstTips.TipsType.BattleBeforeFormatUser);
		}
		else if (FirstTips.IsFirstTipsOpen(FirstTips.TipsType.BattleBeforeFormatUser))
		{
			UIManager.GetInstance().CheckFirstTips(FirstTips.TipsType.BattleBeforeFormatUser);
		}
		_freeMatchPreReleaseApeal.SetActive(Prerelease.Instance.IsEnableFreeMatch);
		_preReleaseFreeMatchButton.gameObject.SetActive(Prerelease.Instance.IsEnableFreeMatch);
		_crossoverFreeMatchButton.gameObject.SetActive(Data.Crossover.IsWithinFreeMatchPeriod);
		_myrotaionFreeMatchButton.gameObject.SetActive(Data.MyRotationAllInfo.IsWithinFreeMatchPeriod);
		_avatarBattleFreeMatchButton.gameObject.SetActive(Data.AvatarBattleAllInfo.IsWithinFreeMatchPeriod);
		int num = ((Data.MyRotationAllInfo.IsWithinFreeMatchPeriod || Prerelease.Instance.IsEnableFreeMatch || Data.Crossover.IsWithinFreeMatchPeriod || Data.AvatarBattleAllInfo.IsWithinFreeMatchPeriod) ? 163 : 57);
		UIUtil.SetLocalPositionY(_rotationButtonFreeMatch.transform, num);
		ShowCardPanelMenu(skipCardAnimation);
	}

	private void UpdateCampaignInfo()
	{
		_roomCampaignTimeRoot.SetActive(value: true);
		if (Data.MyPageNotifications.data.RoomRule.NormalRuleFormatList.Contains(Format.Hof))
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPageNotifications.data.RoomRule.NormalRuleFormatEndTime[Format.Hof]);
		}
		else if (Data.MyPageNotifications.data.RoomRule.NormalRuleFormatList.Contains(Format.Windfall))
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPageNotifications.data.RoomRule.NormalRuleFormatEndTime[Format.Windfall]);
		}
		else if (Data.MyPageNotifications.data.RoomRule.SpecialTwoPickRuleFormatList.Contains(TwoPickFormat.Cube))
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPageNotifications.data.RoomRule.TwoPickRuleFormatEndTime[TwoPickFormat.Cube]);
		}
		else if (Data.MyPageNotifications.data.RoomRule.SpecialTwoPickRuleFormatList.Contains(TwoPickFormat.Chaos))
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPageNotifications.data.RoomRule.TwoPickRuleFormatEndTime[TwoPickFormat.Chaos]);
		}
		else if (Data.MyPageNotifications.data.RoomRule.NormalRuleFormatList.Contains(Format.Avatar))
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPageNotifications.data.RoomRule.NormalRuleFormatEndTime[Format.Avatar]);
		}
		else if (Data.MyPage.data.IsRoomNonPossessionCardCampaign())
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignEndTime.text = Data.SystemText.Get("MyPage_0048", Data.MyPage.data.RoomNonPossessionCardCampaign.EndLocalTimeString);
		}
		else if (Data.MyPage.data._lotteryData.IsCampaignTimeNow())
		{
			_roomCampaignRoot.gameObject.SetActive(value: true);
			_roomCampaignTimeRoot.SetActive(value: false);
		}
		else
		{
			_roomCampaignRoot.gameObject.SetActive(value: false);
		}
	}

	private void ShowCardPanelMenu(bool skipCardAnimation = false)
	{
		if (!skipCardAnimation)
		{
			StartCardPanelAppearAnimation();
		}
		SetNotRoomCardPanelVisible(visible: true);
		_roomActionRoot.SetActive(value: false);
		_roomCreateTypeRoot.SetActive(value: false);
		_roomInviteMenuRoot.SetActive(value: false);
		_formatSelectRootRankMatch.SetActive(value: false);
		_formatSelectRootFreeMatch.SetActive(value: false);
		_freeMatchButton.onClick.Clear();
		_freeMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnPushFreeMatch();
		}));
		_rankMatchButton.onClick.Clear();
		_rankMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnPushRankMatch();
		}));
		_roomMatchButton.onClick.Clear();
		_roomMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnPushRoomMatch();
		}));
		_inviteIconCardPanel.SetActive(base.Parent.IsEnableRoomInvite);
		StartCoroutine(_battleCampaignClass.Init());
	}

	private void OnPushFreeMatch()
	{
		if (!base.IsCardMoving)
		{
			ShowFreeMatchFormatSelect(isPlaySe: true);
		}
	}

	public void ShowFreeMatchFormatSelect(bool isPlaySe)
	{
		if (Data.AvatarBattleAllInfo.IsWithinFreeMatchPeriod)
		{
			UIManager.GetInstance().CheckFirstTips(FirstTips.TipsType.HeroesFreeMatch);
		}
		FormatSelectCommon(Data.SystemText.Get("MyPage_0010"), 0, _freeMatchButton, _formatSelectRootFreeMatch, isPlaySe);
		SetupFreeMatch();
		MoveCardPanelLeftPosition(_freeMatchCardPanel.gameObject);
		FadeOutCardPanelAndNonActive(_roomMatchCardPanel);
		FadeOutCardPanelAndNonActive(_rankMatchCardPanel);
	}

	private void OnClickFormatFreeMatch(Format type)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		ShowMatchDeckSelect(type, DataMgr.BattleType.FreeBattle);
	}

	private void OnPushRankMatch()
	{
		if (!base.IsCardMoving)
		{
			ShowRankMatchFormatSelect(isPlaySe: true);
		}
	}

	public void ShowRankMatchFormatSelect(bool isPlaySe)
	{
		FormatSelectCommon(Data.SystemText.Get("MyPage_0011"), 1, _rankMatchButton, _formatSelectRootRankMatch, isPlaySe);
		SetupRankMatch();
		MoveCardPanelLeftPosition(_rankMatchCardPanel.gameObject);
		FadeOutCardPanelAndNonActive(_freeMatchCardPanel);
		FadeOutCardPanelAndNonActive(_roomMatchCardPanel);
	}

	private RankMatchLayoutType GetRankMatchLayoutType()
	{
		CampaignBattleWin campaignBattleWin = Data.MyPageNotifications.data.CampaignBattleWin;
		if (Data.Crossover.IsWithinRankMatchPeriod)
		{
			if (!campaignBattleWin.IsInSessionCampaign || !campaignBattleWin.IsHaveSpecialWinReward)
			{
				if (!campaignBattleWin.IsInSessionCampaign)
				{
					return RankMatchLayoutType.Crossover;
				}
				return RankMatchLayoutType.CrossoverWithReward;
			}
			return RankMatchLayoutType.CrossoverWithRewardAndSpeicalReward;
		}
		if (!campaignBattleWin.IsInSessionCampaign || !campaignBattleWin.IsHaveSpecialWinReward)
		{
			if (!campaignBattleWin.IsInSessionCampaign)
			{
				return RankMatchLayoutType.Default;
			}
			return RankMatchLayoutType.DefaultWithReward;
		}
		return RankMatchLayoutType.DefaultWithRewardAndSpeicalReward;
	}

	private void FormatSelectCommon(string topBarTitle, int cardIndex, UIButton cardButton, GameObject formatSelectRoot, bool isPlaySe)
	{
		base.CardAnimation.OnClicked(cardIndex, isPlaySe);
		formatSelectRoot.SetActive(value: true);
		RestoreDefaultPosition(formatSelectRoot);
		AppearAnimationFromRight(formatSelectRoot);
		cardButton.onClick.Clear();
		base.Parent.SetBackButtonEnable();
		base.Parent.SetDefaultBackButtonHandler();
		base.IsEnableFooterCurrentMenu = true;
		base.TopBar.SetTitleLabel(topBarTitle);
	}

	private void SetupFreeMatch()
	{
		bool isMaintenance = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_ROTATION);
		bool isMaintenance2 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_UNLIMITED);
		bool isMaintenance3 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_PREROTATION);
		bool isMaintenance4 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_CROSSOVER);
		bool isMaintenance5 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_MYROTATION);
		bool isMaintenance6 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.FREEBATTLE_AVATAR);
		_freeRotationMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance, _rotationButtonFreeMatch, _freeRotationMaintenancePlate, _rotationButtonFreeMatchLabel.depth + 1);
		_freeUnlimitedMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance2, _unlimitedButtonFreeMatch, _freeUnlimitedMaintenancePlate, _unlimitedButtonFreeMatchLabel.depth + 1);
		_freePreReleaseMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance3, _preReleaseFreeMatchButton, _freePreReleaseMaintenancePlate, _preReleaseFreeMatchLabel.depth + 1);
		_freeCrossoverMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance4, _crossoverFreeMatchButton, _freeCrossoverMaintenancePlate, _crossoverFreeMatchLabel.depth + 1);
		_freeMyRotationReleaseMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance5, _myrotaionFreeMatchButton, _freeMyRotationReleaseMaintenancePlate, _myRotationFreeMatchLabel.depth + 1);
		_freeAvatarReleaseMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance6, _avatarBattleFreeMatchButton, _freeAvatarReleaseMaintenancePlate, _avatarBattleFreeMatchLabel.depth + 1);
		_rotationButtonFreeMatch.onClick.Clear();
		_unlimitedButtonFreeMatch.onClick.Clear();
		_preReleaseFreeMatchButton.onClick.Clear();
		_crossoverFreeMatchButton.onClick.Clear();
		_myrotaionFreeMatchButton.onClick.Clear();
		_avatarBattleFreeMatchButton.onClick.Clear();
		_rotationButtonFreeMatch.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.Rotation);
		}));
		_unlimitedButtonFreeMatch.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.Unlimited);
		}));
		_preReleaseFreeMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.PreRotation);
		}));
		_crossoverFreeMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.Crossover);
		}));
		_myrotaionFreeMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.MyRotation);
		}));
		_avatarBattleFreeMatchButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickFormatFreeMatch(Format.Avatar);
		}));
	}

	private void SetupRankMatch()
	{
		RankMatchLayoutType rankMatchLayoutType = GetRankMatchLayoutType();
		FormatSelectLayout formatSelectLayout = RANK_FORMAT_SELECT_LAYOUT[rankMatchLayoutType];
		bool isMaintenance = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.RANKBATTLE_ROTATION);
		bool isMaintenance2 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.RANKBATTLE_UNLIMITED);
		bool isMaintenance3 = Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.RANKBATTLE_CROSSOVER);
		_rankRotationMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance, _rankMatchLayouts.RotationButton, _rankRotationMaintenancePlate, _rankMatchLayouts.RotationLabel.depth + 1);
		_rankUnlimitedMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance2, _rankMatchLayouts.UnlimitedButton, _rankUnlimitedMaintenancePlate, _rankMatchLayouts.UnlimitedLabel.depth + 1);
		_rankCrossoverMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance3, _rankMatchLayouts.CrossoverButton, _rankCrossoverMaintenancePlate, _rankMatchLayouts.CrossoverLabel.depth + 1);
		_rankMatchLayouts.CrossoverButton.gameObject.SetActive(formatSelectLayout.IsEnableCrossOver);
		_rankMatchLayouts.WinRewardButton.gameObject.SetActive(formatSelectLayout.IsEnableRewardButton);
		_rankMatchLayouts.SpecialWinRewardButton.gameObject.SetActive(formatSelectLayout.IsEnableSpecialRewardButton);
		if (Data.MyPageNotifications.data.CampaignBattleWin.SpecialTreasureInfo != null)
		{
			_rankMatchLayouts.SpecialWinRewardIcon.SetActive(Data.MyPageNotifications.data.CampaignBattleWin.SpecialTreasureInfo.IsTreasureBoxReadyToOpen);
			UIManager.GetInstance()._Footer.InviteIconDisp(Data.MyPageNotifications.data.CampaignBattleWin.SpecialTreasureInfo.IsTreasureBoxReadyToOpen);
		}
		_rankMatchLayouts.WinRewardButton.transform.localPosition = formatSelectLayout.RewardPosition;
		_rankMatchLayouts.SpecialWinRewardButton.transform.localPosition = formatSelectLayout.SpecialWinRewardPosition;
		_rankMatchGrid.cellHeight = formatSelectLayout.Interval;
		_rankMatchGrid.transform.localPosition = new Vector3(_rankMatchGrid.transform.localPosition.x, formatSelectLayout.GridY, _rankMatchGrid.transform.localPosition.z);
		_rankMatchGrid.Reposition();
		_rankMatchLayouts.ClearButtonOnClickEvent();
		_rankMatchLayouts.SetButtonOnClickEvent(_rankMatchLayouts.RotationButton, delegate
		{
			OnClickFormatRankMatch(Format.Rotation);
		});
		_rankMatchLayouts.SetButtonOnClickEvent(_rankMatchLayouts.UnlimitedButton, delegate
		{
			OnClickFormatRankMatch(Format.Unlimited);
		});
		_rankMatchLayouts.SetButtonOnClickEvent(_rankMatchLayouts.CrossoverButton, delegate
		{
			OnClickFormatRankMatch(Format.Crossover);
		});
		_rankMatchLayouts.SetButtonOnClickEvent(_rankMatchLayouts.WinRewardButton, OnClickWinReward);
		_rankMatchLayouts.SetButtonOnClickEvent(_rankMatchLayouts.SpecialWinRewardButton, OnClickSpecialWinReward);
	}

	private void OnClickFormatRankMatch(Format format)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		ShowMatchDeckSelect(format, DataMgr.BattleType.RankBattle);
	}

	private static string GetRewardDialogName(CampaignRewardInfo info)
	{
		return info.Type switch
		{
			UserGoods.Type.Sleeve => Data.Master.SleeveMgr.Get(info.GoodsId).sleeve_name, 
			UserGoods.Type.Emblem => Data.Master.EmblemMgr.Get(info.GoodsId)._name, 
			_ => UserGoods.getUserGoodsName(info.Type, info.GoodsId), 
		};
	}

	private List<PurchaseRewardInfo> GetWinnarRewardDialogData()
	{
		List<PurchaseRewardInfo> list = new List<PurchaseRewardInfo>();
		for (int i = 0; i < base.Parent.WinnerRewardInfoCopy.Count; i++)
		{
			CampaignRewardInfo campaignRewardInfo = base.Parent.WinnerRewardInfoCopy[i];
			PurchaseRewardInfo purchaseRewardInfo = new PurchaseRewardInfo();
			purchaseRewardInfo.PurchaseNthText = GetRewardDialogName(campaignRewardInfo);
			purchaseRewardInfo.IsGet = campaignRewardInfo.IsReceived;
			ShopCommonRewardInfo shopCommonRewardInfo = new ShopCommonRewardInfo();
			shopCommonRewardInfo.Type = (int)campaignRewardInfo.Type;
			shopCommonRewardInfo.Num = campaignRewardInfo.GoodsCount;
			shopCommonRewardInfo.UserGoodsId = campaignRewardInfo.GoodsId;
			purchaseRewardInfo.RewardInfoList.Add(shopCommonRewardInfo);
			list.Add(purchaseRewardInfo);
		}
		return list;
	}

	private void OnClickWinReward()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		_rewardDetailCamera.SetActive(value: true);
		DialogBase obj = PurchaseRewardDialog.Create(GetWinnarRewardDialogData(), attachBottomObj: MyPageRewardDialogBoxCount.Create(_winRewardDialogBoxPrefab, Data.MyPageNotifications.data.CampaignBattleWin), cardDetail: _cardDetail, useLargeDetailDialog: true, layout: PurchaseRewardDialog.Layout.TITLE_BOTTOM, detailDialogTitleOverride: Data.SystemText.Get("Mission_0025"));
		obj.SetTitleLabel(Data.SystemText.Get("MyPage_0081"));
		obj.OnClose = delegate
		{
			_rewardDetailCamera.SetActive(value: false);
		};
		obj.SetLayer("Loading");
	}

	private void OnClickSpecialWinReward()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		_rewardDetailCamera.SetActive(value: true);
		GetWinnarRewardDialogData();
		GameObject obj = MyPageSpecialWinRewardDialog.Create(_specialWinRewardDialogBoxPrefab, base.Parent.GetNotTouchMypageCollider());
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(Data.SystemText.Get("MyPage_0108"));
		dialogBase.SetObj(obj);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
		dialogBase.OnClose = delegate
		{
			_rewardDetailCamera.SetActive(value: false);
		};
		dialogBase.SetLayer("MyPage");
		dialogBase.SetPanelDepth(100, isSetBackViewDepthImmediately: true);
	}

	public void ShowMatchDeckSelect(Format format, DataMgr.BattleType battleType)
	{
		Data.CurrentFormat = format;
		GameMgr.GetIns().GetDataMgr().m_BattleType = battleType;
		DeckInfoTask task = new DeckInfoTask();
		task.SetParameter(format);
		UIManager.GetInstance().StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			DeckSelectUIDialog.Create(DeckSelectUIDialog.GetTitleByBattleType(GameMgr.GetIns().GetDataMgr().m_BattleType), task.DeckGroupListData, format, DeckSelectUIDialog.eFormatChangeUIType.SingleFormat, isVisibleCreateNew: true, delegate(DialogBase dialog, DeckData deckData)
			{
				FreeAndRankMatchDeckSelectConfirmDialog.Create(dialog, deckData, isBattleEnd: false);
			});
		}));
	}

	private void OnPushRoomMatch()
	{
		if (!base.IsCardMoving)
		{
			base.Parent.SetBackButtonEnable();
			base.Parent.SetDefaultBackButtonHandler();
			base.CardAnimation.OnClicked(2);
			ShowRoomActionMenu(cutCardPanelAnimation: false);
			MoveCardPanelLeftPosition(_cardPanelRoomMatch);
		}
	}

	private void SetNotRoomCardPanelVisible(bool visible)
	{
		_freeMatchCardPanel.gameObject.SetActive(visible);
		_rankMatchCardPanel.gameObject.SetActive(visible);
	}

	private void FadeOutNotRoomCardPanel()
	{
		FadeOutCardPanelAndNonActive(_freeMatchCardPanel);
		FadeOutCardPanelAndNonActive(_rankMatchCardPanel);
	}

	private void SetRoomActionButtonEnable(bool isEnabled)
	{
		_roomCreateButton.isEnabled = isEnabled;
		_roomJoinButton.isEnabled = isEnabled;
		_roomWatchButton.isEnabled = isEnabled;
	}

	private void SetRoomActionButtonGameObjectActive(bool isActive)
	{
		_roomCreateButton.gameObject.SetActive(isActive);
		_roomJoinButton.gameObject.SetActive(isActive);
		_roomWatchButton.gameObject.SetActive(isActive);
	}

	private void ShowRoomActionMenu(bool cutCardPanelAnimation)
	{
		base.IsEnableFooterCurrentMenu = true;
		if (cutCardPanelAnimation)
		{
			SetNotRoomCardPanelVisible(visible: false);
		}
		else
		{
			FadeOutNotRoomCardPanel();
		}
		_roomMatchButton.onClick.Clear();
		_roomActionRoot.gameObject.SetActive(value: true);
		SetRoomActionButtonGameObjectActive(isActive: true);
		SetRoomActionButtonEnable(isEnabled: true);
		RestoreDefaultPosition(_roomCreateButton.gameObject);
		RestoreDefaultPosition(_roomJoinButton.gameObject);
		RestoreDefaultPosition(_roomWatchButton.gameObject);
		RestoreDefaultPosition(_roomActionRoot);
		ResetAlphaAndRemoveTween(_roomCreateButton.gameObject.GetComponent<UISprite>());
		ResetAlphaAndRemoveTween(_roomJoinButton.gameObject.GetComponent<UISprite>());
		ResetAlphaAndRemoveTween(_roomWatchButton.gameObject.GetComponent<UISprite>());
		_roomInviteIconOnJoinButton.gameObject.SetActive(base.Parent.IsEnableRoomInvite);
		_roomCreateButton.onClick.Clear();
		_roomCreateButton.onClick.Add(new EventDelegate(delegate
		{
			SetRoomActionButtonEnable(isEnabled: false);
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			OnPushRoomCreateButton(isFadeOut: true);
		}));
		_roomJoinButton.onClick.Clear();
		_roomJoinButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			if (base.Parent.IsEnableRoomInvite)
			{
				SetRoomActionButtonEnable(isEnabled: false);
				FadeOutRoomActionButton(isFadeOut: true);
				ShowRoomJoinMenuExistInvite();
			}
			else
			{
				StartRoomIDInput(isWatch: false);
			}
		}));
		_roomWatchButton.onClick.Clear();
		_roomWatchButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			StartRoomIDInput(isWatch: true);
		}));
		base.TopBar.SetTitleLabel(Data.SystemText.Get("RoomBattle_0001"));
		AppearAnimationFromRight(_roomActionRoot);
		RefreshRoomActionButtonMaintenancePlate();
	}

	private void OnPushRoomCreateButton(bool isFadeOut)
	{
		_roomCreateSetting = new RoomRuleSetting();
		_roomCreateSetting2Pick = new RoomRuleSetting();
		_roomCreateSetting2Pick.BattleParameterInstance.BattleType = NetworkDefine.ServerBattleType.RoomTwoPick;
		if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_ROTATION) && _roomCreateSetting.BattleParameterInstance.DeckFormat == Format.Rotation)
		{
			_roomCreateSetting.BattleParameterInstance.DeckFormat = Format.Unlimited;
		}
		RefreshRoomTypeSelectBattleButton();
		_roomCreateButton.isEnabled = false;
		_roomJoinButton.isEnabled = false;
		_roomWatchButton.isEnabled = false;
		FadeOutRoomActionButton(isFadeOut);
		RestoreDefaultPosition(_roomCreateTypeRoot);
		_roomCreateTypeRoot.SetActive(value: true);
		AppearAnimationFromRight(_roomCreateTypeRoot);
		_roomCreateNormalBattleButton.gameObject.SetActive(value: true);
		_roomCreate2PickBattleButton.gameObject.SetActive(value: true);
		List<EventDelegate> tempBackButtonEvent = new List<EventDelegate>(base.TopBar.BackButton.onClick);
		base.TopBar.SetBackButtonEvent(null, UIManager.ViewScene.None, new EventDelegate(delegate
		{
			RemoveITween(_roomCreateTypeRoot);
			BackOnRoomCreateMenu(tempBackButtonEvent);
		}));
	}

	private void FadeOutRoomActionButton(bool isFadeOut)
	{
		if (isFadeOut)
		{
			SetRoomActionButtonGameObjectActive(isActive: true);
			FadeUtility.FadeOutObjectAndNonActive(_roomCreateButton.gameObject);
			FadeUtility.FadeOutObjectAndNonActive(_roomJoinButton.gameObject);
			FadeUtility.FadeOutObjectAndNonActive(_roomWatchButton.gameObject);
		}
		else
		{
			SetRoomActionButtonGameObjectActive(isActive: false);
		}
	}

	private void BackOnRoomCreateMenu(List<EventDelegate> tempBackButtonEvent)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		_roomCreateButton.gameObject.SetActive(value: true);
		UISprite roomCreateButtonSprite = _roomCreateButton.GetComponent<UISprite>();
		ResetAlphaAndRemoveTween(roomCreateButtonSprite);
		_roomJoinButton.gameObject.SetActive(value: true);
		ResetAlphaAndRemoveTween(_roomJoinButton.GetComponent<UISprite>());
		ShowRoomActionMenu(cutCardPanelAnimation: true);
		_roomWatchButton.gameObject.SetActive(value: true);
		ResetAlphaAndRemoveTween(_roomWatchButton.GetComponent<UISprite>());
		RefreshRoomActionButtonMaintenancePlate();
		MyPageItem.FadeOutObject(_roomCreateNormalBattleButton.gameObject.AddMissingComponent<UITweenAlpha>(), delegate
		{
			_roomCreateNormalBattleButton.gameObject.SetActive(value: false);
			roomCreateButtonSprite.panel.Refresh();
		});
		MyPageItem.FadeOutObject(_roomCreate2PickBattleButton.gameObject.AddMissingComponent<UITweenAlpha>(), delegate
		{
			_roomCreate2PickBattleButton.gameObject.SetActive(value: false);
			roomCreateButtonSprite.panel.Refresh();
		});
		base.TopBar.BackButton.onClick = tempBackButtonEvent;
	}

	private void RefreshRoomActionButtonMaintenancePlate()
	{
		if (!Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_ALL_MAINTENANCE))
		{
			_roomCreateMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance: false, _roomCreateButton, _roomCreateMaintenancePlate, _roomWatchLabel.depth);
			_roomJoinMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance: false, _roomJoinButton, _roomJoinMaintenancePlate, _roomWatchLabel.depth);
			_roomCreateButton.isEnabled = true;
			_roomJoinButton.isEnabled = true;
			_roomWatchButton.isEnabled = true;
		}
		else
		{
			_roomCreateMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance: true, _roomCreateButton, _roomCreateMaintenancePlate, _roomWatchLabel.depth);
			_roomJoinMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance: true, _roomJoinButton, _roomJoinMaintenancePlate, _roomWatchLabel.depth);
		}
		bool isMaintenance = false;
		if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_WATCHING_MAINTENANCE) || Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_ALL_MAINTENANCE))
		{
			isMaintenance = true;
		}
		_roomWatchMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance, _roomWatchButton, _roomWatchMaintenancePlate, _roomWatchLabel.depth);
	}

	private void RefreshRoomTypeSelectBattleButton()
	{
		_roomCreateNormalBattleButton.gameObject.SetActive(value: true);
		ResetAlphaAndRemoveTween(_roomCreateNormalBattleButton.GetComponent<UISprite>());
		AppearAnimationFromRight(_roomCreateNormalBattleButton.gameObject);
		_roomCreateNormalBattleButton.onClick.Clear();
		_roomCreateNormalBattleButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			OnClickRoomCreateNormalRule();
		}));
		bool isMaintenance = false;
		if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_BATTLE_MAINTENANCE))
		{
			isMaintenance = true;
		}
		_roomCreateNormalMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance, _roomCreateNormalBattleButton, _roomCreateNormalMaintenancePlate, _roomCreateNormalLabel.depth + 1);
		_roomCreate2PickBattleButton.gameObject.SetActive(value: true);
		ResetAlphaAndRemoveTween(_roomCreate2PickBattleButton.GetComponent<UISprite>());
		_roomCreate2PickBattleButton.onClick.Clear();
		_roomCreate2PickBattleButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			OnClickRoomCreateTwoPick();
		}));
		bool isMaintenance2 = false;
		if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.ROOM_TWOPICK_MAINTENANCE))
		{
			isMaintenance2 = true;
		}
		_roomCreate2PickMaintenancePlate = MyPageItem.SetMaintenanceVisible(isMaintenance2, _roomCreate2PickBattleButton, _roomCreate2PickMaintenancePlate, _roomCreateNormalLabel.depth + 1);
	}

	private void OnClickRoomCreateNormalRule()
	{
		_roomCreateSetting.BattleParameterInstance.DeckFormat = (Format)PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.ROOM_MATCH_FORMAT);
		_roomCreateSetting.BattleParameterInstance.Rule = RoomRuleSelectDialog.GetLastRule(PlayerPrefsWrapper.LAST_ROOM_MATCH_RULE, _roomCreateSetting.BattleParameterInstance.Rule);
		RoomRuleSelectDialog.Create(_roomCreateSetting, out var _, isTwoPick: false);
		_roomCreateSetting.OnDecide = OnSelectRoomCreateNormalRule;
	}

	private void OnClickRoomCreateTwoPick()
	{
		_roomCreateSetting2Pick.BattleParameterInstance.Rule = RoomRuleSelectDialog.GetLastRule(PlayerPrefsWrapper.LAST_ROOM_MATCH_RULE_2PICK, _roomCreateSetting2Pick.BattleParameterInstance.Rule);
		_roomCreateSetting2Pick.BattleParameterInstance.TwoPickFormat = RoomRuleSelectDialog.GetLastTwoPickFormat(PlayerPrefsWrapper.LAST_ROOM_MATCH_FORMAT_2PICK, TwoPickFormat.Normal);
		RoomRuleSelectDialog.Create(_roomCreateSetting2Pick, out var _, isTwoPick: true);
		_roomCreateSetting2Pick.OnDecide = OnSelectRoomCreateRule2Pick;
	}

	private void OnSelectRoomCreateNormalRule()
	{
		RoomConnectController.InitializeParameter initializeParameter = new RoomConnectController.InitializeParameter(RoomConnectController.PositionMode.OWNER, _roomCreateSetting.BattleParameterInstance, "");
		initializeParameter.IsPermitFriendWatch = _roomCreateSetting.EnableFriendWatch;
		initializeParameter.IsPermitGuildWatch = _roomCreateSetting.EnableGuildWatch;
		StartCoroutine(JoinRoom(initializeParameter, isInvite: false));
	}

	private void OnSelectRoomCreateRule2Pick()
	{
		RoomConnectController.InitializeParameter initializeParameter = new RoomConnectController.InitializeParameter(RoomConnectController.PositionMode.OWNER, _roomCreateSetting2Pick.BattleParameterInstance, "");
		initializeParameter.IsPermitFriendWatch = _roomCreateSetting2Pick.EnableFriendWatch;
		initializeParameter.IsPermitGuildWatch = _roomCreateSetting2Pick.EnableGuildWatch;
		StartCoroutine(JoinRoom(initializeParameter, isInvite: false));
	}

	private void ShowRoomJoinMenuExistInvite()
	{
		RestoreDefaultPosition(_roomInviteMenuRoot);
		_roomInviteMenuRoot.gameObject.SetActive(value: true);
		AppearAnimationFromRight(_roomInviteMenuRoot);
		_roomIdInputButtonInInvite.onClick.Clear();
		_roomIdInputButtonInInvite.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			StartRoomIDInput(isWatch: false);
		}));
		_roomInviteReceiveButton.onClick.Clear();
		_roomInviteReceiveButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			InviteGetListTask inviteGetListTask = new InviteGetListTask();
			inviteGetListTask.SetParameter();
			inviteGetListTask.SkipAllCuteResultCodeCheckErrorPopup();
			StartCoroutine(Toolbox.NetworkManager.Connect(inviteGetListTask, CreateInviteFriendDialog));
		}));
	}

	protected void CreateInviteFriendDialog(NetworkTask.ResultCode inResultCode)
	{
		RoomInviteReceiveDialog component = UnityEngine.Object.Instantiate(_inviteReceveDialog).GetComponent<RoomInviteReceiveDialog>();
		component.MyPageClass = base.Parent;
		component.SetFriendList();
	}

	public void StartRoomIDInput(bool isWatch, ConventionInfo conventionInfo = null)
	{
		SystemText systemText = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetTitleLabel(systemText.Get("RoomBattle_0006"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.DecisionBtn);
		dialogBase.onPushButton1 = delegate
		{
			RoomConnectController.InitializeParameter initializeParameter = new RoomConnectController.InitializeParameter((!isWatch) ? RoomConnectController.PositionMode.VISITOR : RoomConnectController.PositionMode.WATCHER, new BattleParameter(NetworkDefine.ServerBattleType.Free, Format.Max, TwoPickFormat.None, RoomConnectController.BattleRule.None, isOpenDeckRoom: false), _roomInput.InputID);
			if (conventionInfo != null)
			{
				initializeParameter.IsEnableTurnSelect = conventionInfo.IsSelectableTurn;
				initializeParameter.ConventionInfo = conventionInfo;
			}
			base.Parent.StartCoroutine(JoinRoom(initializeParameter, isInvite: false));
		};
		_roomInput = IDInput.Create(dialogBase.gameObject);
		_roomInput.CurrentDialogBase = dialogBase;
		_roomInput.InitInputID(5);
	}

	public void SpecialWinRewardIconActive(bool active)
	{
		_rankMatchLayouts.SpecialWinRewardIcon.SetActive(active);
	}

	public void RedrawBattleCampaign()
	{
		_battleCampaignClass.RedrawAfterSpecialWinRewardOpened();
	}

	public IEnumerator JoinRoom(RoomConnectController.InitializeParameter param, bool isInvite)
	{
		bool oldBackKeyEnable = GameMgr.GetIns().GetInputMgr().isBackKeyEnable;
		base.TopBar.SetBackButtonEnable(enable: false);
		_isStopSendMyPageRefreshTask = true;
		yield return JoinRoomSub(param, isInvite);
		_isStopSendMyPageRefreshTask = false;
		base.TopBar.SetBackButtonEnable(oldBackKeyEnable);
	}

	private IEnumerator JoinRoomSub(RoomConnectController.InitializeParameter param, bool isInvite)
	{
		UIManager.GetInstance().createInSceneCenterLoading(notBlack: true);
		GameMgr.GetIns().GetDataMgr().m_BattleType = DataMgr.BattleType.RoomBattle;
		RoomConnectControllerInstance = new RoomConnectController(param);
		yield return UIManager.GetInstance().StartCoroutine(RoomConnectControllerInstance.StartConnect());
		if (RoomConnectControllerInstance.ConnectRoomResultType == RoomConnectController.ConnectRoomResult.SUCCESS)
		{
			UIManager.GetInstance()._Footer.InviteIconDisp(inDisp: false);
			UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Room);
		}
		else if (isInvite && Data.Load.data._receiveInviteCount <= 1 && !RoomConnectControllerInstance.IsEnterErrorDeckCount)
		{
			ClearInviteIcon();
			ShowRoomActionMenu(cutCardPanelAnimation: true);
			_roomInviteMenuRoot.gameObject.SetActive(value: false);
		}
		UIManager.GetInstance().closeInSceneCenterLoading();
	}

	private void ClearInviteIcon()
	{
		if (UIManager.GetInstance().GetCurrentScene() == UIManager.ViewScene.MyPage)
		{
			UIManager.GetInstance()._Footer.InviteIconDisp(inDisp: false);
			_inviteIconCardPanel.SetActive(value: false);
			_roomInviteIconOnJoinButton.SetActive(value: false);
			base.Parent.RoomInviteClear();
			Data.Load.data._receiveInviteCount = 0;
		}
	}

	public void GoToFreeMatch()
	{
		ShowCardPanelMenu();
		RestoreCardPanelPosition();
		MoveCardPanelLeftPosition(_freeMatchCardPanel.gameObject);
		ShowFreeMatchFormatSelect(isPlaySe: true);
		base.CardAnimation.SkipMoveAnimation();
	}

	public void GoToRoomMatch()
	{
		ShowCardPanelMenu();
		RestoreCardPanelPosition();
		MoveCardPanelLeftPosition(_cardPanelRoomMatch);
		ShowRoomActionMenu(cutCardPanelAnimation: true);
		base.CardAnimation.SkipMoveAnimation();
	}

	public bool IsStopSendMyPageRefreshTask()
	{
		if (!_isStopSendMyPageRefreshTask)
		{
			if (RoomConnectControllerInstance != null)
			{
				return RoomConnectControllerInstance.IsExistNodeErrorDialog();
			}
			return false;
		}
		return true;
	}
}
