using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cute;
using UnityEngine;

namespace Wizard.Bingo;

public class BingoPage : UIBase
{
	public struct BallPosData
	{
		public Vector3 Line1LeftPos { get; private set; }

		public Vector3 Line2LeftPos { get; private set; }

		public Vector3 Line3LeftPos { get; private set; }

		public int Line1Num { get; private set; }

		public int Line2Num { get; private set; }

		public int Line3Num { get; private set; }

		public float Line1Space { get; private set; }

		public float Line2Space { get; private set; }

		public float Line3Space { get; private set; }

		public BallPosData(Vector3 line1LeftPos, Vector3 line2LeftPos, Vector3 line3LeftPos, int line1Num, int line2Num, int line3Num, float line1Space, float line2Space, float line3Space)
		{
			Line1LeftPos = line1LeftPos;
			Line2LeftPos = line2LeftPos;
			Line3LeftPos = line3LeftPos;
			Line1Num = line1Num;
			Line2Num = line2Num;
			Line3Num = line3Num;
			Line1Space = line1Space;
			Line2Space = line2Space;
			Line3Space = line3Space;
		}
	}

	public const float EFFECT_DURATION_TOTAL = 1f;

	public const float BALL_FALL_TIME = 0.7f;

	private const int MAX_BINGO_GACHA_NUM = 10;

	private const float BLOCK_LIGHT_DELAY = 0.06f;

	private const float THREE_ROWS_SIZE = 90f;

	private const float FIVE_ROWS_SIZE = 54f;

	public const string BALL_FALL_EFFECT = "cmn_bingo_ball_1";

	public const string BALL_LIGHT_EFFECT = "cmn_bingo_ball_2";

	public const string BINGO_EFFECT = "cmn_bingo_cmp_1";

	private const string TREASUREBOX_SPRITE_NAME = "box_2pick_0{0}_close";

	private const string TREASUREBOX_SE_NAME = "se_bng_box_open_0{0}";

	private const string TREASUREBOX_EFFECT_NAME = "cmn_arena_treasure_gp_{0}";

	private const string BINGO_LINES_TEXUTRE_NAME = "bingo_lines";

	private const string BINGO_STAMP_TEXUTRE_NAME = "bingo_square_stamp";

	private const string BINGO_SHEET_NAME = "bingosheet";

	private const int BINGO_CHARA_STANDING_PIC_CHARA_ID = 3304;

	private float _fiveFiveBlockScale = 0.6f;

	private float _bingoBlockGridSizeCoef = 1.0889f;

	private const float LOGIN_ANIMATION_WAIT_TIME = 1.25f;

	private const int DIALOG_RIBBON_ANCHOR_BOTTOM = -5;

	private const int DIALOG_RIBBON_ANCHOR_TOP = 15;

	[SerializeField]
	private UIGrid _gridBingBlockGrid;

	[SerializeField]
	private GameObject _originBingoSheetBlock;

	[SerializeField]
	private GachaLayoutPurchaseButton _bingoTicketAreaLayout;

	[SerializeField]
	private BingoSelectBuyNumPopup _prefabDialogSelectBuyNumber;

	[SerializeField]
	private UIButton _questMissionButton;

	[SerializeField]
	private UIButton _rewardsButton;

	[SerializeField]
	private UIButton _detailsButton;

	[SerializeField]
	private GameObject _missionDialogPrefab;

	[SerializeField]
	private GameObject _allRewardsDialogPrefab;

	[SerializeField]
	private TweenAlpha _fadeDarkBgTweenAlpha;

	[SerializeField]
	private BoxCollider _notTouchMypageCollider;

	[SerializeField]
	private UIGrid _bingoRewardsGrid;

	[SerializeField]
	private UIScrollView _bingoRewardsScrollPanel;

	[SerializeField]
	private GameObject _bingoMissionItemPrefab;

	[SerializeField]
	private BingoBall _originBingoBall;

	[SerializeField]
	private UILabel _labelPeriod;

	[SerializeField]
	private UILabel _labelSheetNum;

	[SerializeField]
	private GameObject _bingoBalls;

	[SerializeField]
	private RewardBase _rewardBase;

	[SerializeField]
	private TweenAnimationGroup _bingoAnimation;

	[SerializeField]
	private TweenAnimationGroup _bingoLineAnimation;

	[SerializeField]
	private UISpriteAtlasOverwriter _spriteAtlasOverwriter;

	[SerializeField]
	private UITexture _bgCharaTexture;

	[SerializeField]
	private UITexture _animationLinesTexture;

	[SerializeField]
	private UIButton _skipButton;

	[SerializeField]
	private UIButton _hiddenFullScreenButton;

	[SerializeField]
	private GameObject _dustEffectContainer;

	[SerializeField]
	private GameObject _bingoTicketButtonEffect;

	[SerializeField]
	private UITexture _bingoSheet;

	[SerializeField]
	private GameObject _bingoAnimationFadeDarkBg;

	[SerializeField]
	private TweenAlpha _bingoAnimationFadeDarkTweenAlpha;

	[SerializeField]
	private SpineDisplay _spineDisplayLogin;

	[SerializeField]
	private SpineDisplay _spineDisplayPurchase;

	[SerializeField]
	private UITexture _spineTexture;

	[SerializeField]
	private Camera _uiSpineCamera;

	private List<BingoSheetBlock> _bingoSheetBlockList;

	private BingoInfoTask.BingoInfoData _bingoInfoData;

	private BingoDrawTask.BingoDrawTaskData _bingoLoginDrawData;

	private BingoDrawTask.BingoDrawTaskData _bingoDrawTaskData;

	private ResourceHandler _resourceHandler;

	private GameObject _boxOpenEffectObj;

	private GameObject _treasureEffectObj;

	private bool _isPlayBoxOpenEffect;

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

	private List<Coroutine> _inProcessCoroutines = new List<Coroutine>();

	private List<TweenAnimationGroup> _inProcessTweenAnimationGroup = new List<TweenAnimationGroup>();

	private const string BINGO_LOGIN_ANIMATION = "spine_bingo_01";

	private const string BINGO_PURCHASE_ANIMATION = "spine_bingo_02";

	private static readonly KeyValuePair<string, int> FirstTipsSaveKey = PlayerPrefsWrapper.FIRST_TIPS_BINGO_ID;

	private List<string> _bingoSeList = new List<string>
	{
		"se_sys_bng_ballfall_01", "se_sys_bng_number_open_01", "se_sys_bng_stamp_01", "se_sys_bng_line_01", "se_sys_bng_line_02", "se_sys_bng_line_03", "se_sys_bng_line_04", "se_sys_bng_line_05", "se_sys_bng_line_06", "se_sys_bng_line_07",
		"se_sys_bng_line_08", "se_sys_bng_line_09", "se_sys_bng_line_10", "se_sys_bng_line_11", "se_sys_bng_line_12", "se_sys_bng_bingo_01", "se_sys_bng_number_open_pre_01", "se_bng_appear_01", "se_bng_lottery_01", "se_bng_lottery_voice_01",
		"se_bng_box_open_01", "se_bng_box_open_05", "se_bng_box_open_06"
	};

	private const float BALL_SPACE = 40f;

	private Dictionary<int, BallPosData> _ballPosDataDic;

	private List<BingoBall> _bingoBallList;

	private List<BingoInfoTask.SquareData> GetOpenedBingoBlock => _bingoInfoData.SquareDataList.Where((BingoInfoTask.SquareData squareData) => squareData.IsOpen).ToList();

	private int GetDisplayIdBySquareId(int squareId)
	{
		return _bingoInfoData.SquareDataList.Where((BingoInfoTask.SquareData squareData) => squareData.SquareId == squareId).FirstOrDefault().DisplayId;
	}

	private bool IsGetSomeRewards()
	{
		if (_bingoDrawTaskData == null || (_bingoDrawTaskData.LineRewardData.Count <= 0 && _bingoDrawTaskData.TreasureBoxReawrdList.Count <= 0))
		{
			if (_bingoLoginDrawData != null)
			{
				if (_bingoLoginDrawData.LineRewardData.Count <= 0)
				{
					return _bingoLoginDrawData.TreasureBoxReawrdList.Count > 0;
				}
				return true;
			}
			return false;
		}
		return true;
	}

	public static void ChangeSceneBingoPage()
	{
		UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Bingo);
	}

	public override void onFirstStart()
	{
		base.IsShowFooterMenu = true;
		_resourceHandler = base.gameObject.AddMissingComponent<ResourceHandler>();
		base.onFirstStart();
	}

	protected override void onOpen()
	{
		base.onOpen();
		CreateTopBar();
		InitFooter();
		InitSpriteAtlasOverwriter();
		AddSeCueSheet();
		BingoInfoTask task = new BingoInfoTask();
		task.SetParameter(isDisplayUpdate: false);
		StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			_bingoInfoData = task.Result;
			_bingoLoginDrawData = task.BingoLoginDrawResult;
			Init();
		}));
	}

	protected override void onClose()
	{
		base.onClose();
		UnloadResources();
		_notTouchMypageCollider.enabled = false;
		UIManager.GetInstance()._Footer.CancelOverwriteLabelColors();
		UnityEngine.Object.Destroy(_fadeDarkBgTweenAlpha.transform.parent.gameObject);
	}

	private void CreateBallPosDataDic()
	{
		float num = 0f - _originBingoBall.GetBallMovement().x;
		float num2 = 0f - _originBingoBall.GetBallMovement().y;
		_ballPosDataDic = new Dictionary<int, BallPosData>
		{
			{
				1,
				new BallPosData(new Vector3(num, num2, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 1, 0, 0, 0f, 0f, 0f)
			},
			{
				2,
				new BallPosData(new Vector3(num - 80f, num2, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 2, 0, 0, 160f, 0f, 0f)
			},
			{
				3,
				new BallPosData(new Vector3(num - 160f, num2, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 3, 0, 0, 160f, 0f, 0f)
			},
			{
				4,
				new BallPosData(new Vector3(num - 240f, num2, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 4, 0, 0, 160f, 0f, 0f)
			},
			{
				5,
				new BallPosData(new Vector3(num - 320f, num2, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), 5, 0, 0, 160f, 0f, 0f)
			},
			{
				6,
				new BallPosData(new Vector3(num - 160f, num2 + 80f, 0f), new Vector3(num - 160f, num2 - 80f, 0f), new Vector3(0f, 0f, 0f), 3, 3, 0, 160f, 160f, 0f)
			},
			{
				7,
				new BallPosData(new Vector3(num - 80f, num2 + 160f, 0f), new Vector3(num - 160f, num2, 0f), new Vector3(num - 80f, num2 - 160f, 0f), 2, 3, 2, 160f, 160f, 160f)
			},
			{
				8,
				new BallPosData(new Vector3(num - 160f, num2 + 160f, 0f), new Vector3(num - 80f, num2, 0f), new Vector3(num - 160f, num2 - 160f, 0f), 3, 2, 3, 160f, 160f, 160f)
			},
			{
				9,
				new BallPosData(new Vector3(num - 160f, num2 + 160f, 0f), new Vector3(num - 160f, num2, 0f), new Vector3(num - 160f, num2 - 160f, 0f), 3, 3, 3, 160f, 160f, 160f)
			},
			{
				10,
				new BallPosData(new Vector3(num - 160f, num2 + 160f, 0f), new Vector3(num - 240f, num2, 0f), new Vector3(num - 160f, num2 - 160f, 0f), 3, 4, 3, 160f, 160f, 160f)
			}
		};
	}

	private void Init()
	{
		if (_bingoInfoData == null)
		{
			return;
		}
		CreateBallPosDataDic();
		_fadeDarkBgTweenAlpha.gameObject.transform.parent.transform.parent = UIManager.GetInstance().transform;
		_fadeDarkBgTweenAlpha.gameObject.transform.parent.gameObject.SetLayer(LayerMask.NameToLayer("MyPage"), isSetChildren: true);
		_fadeDarkBgTweenAlpha.gameObject.transform.parent.gameObject.GetComponent<UIPanel>().depth = 31;
		_notTouchMypageCollider.enabled = false;
		_skipButton.GetComponent<UIAnchor>().uiCamera = UIManager.GetInstance().MyPageUICameraObj.GetComponent<Camera>();
		UpdatePeriodInfo();
		_bingoSheetBlockList = new List<BingoSheetBlock>();
		_bingoBallList = new List<BingoBall>();
		StartCoroutine(LoadResources(delegate
		{
			SetTextures();
			UpdateBingoSheet();
			UpdatePurchaseArea();
			UpdateSideBarRewards(isFirstOpen: true);
			UpdateBingoSheetNum();
			UpdateBuyButton();
			_spineDisplayPurchase.Initialize("spine_bingo_02", _spineTexture, _uiSpineCamera);
			_spineDisplayLogin.Initialize("spine_bingo_01", _spineTexture, _uiSpineCamera);
			_spineDisplayPurchase.gameObject.SetActive(value: false);
			_spineDisplayLogin.gameObject.SetActive(value: false);
			_spineTexture.gameObject.SetActive(value: false);
			UIManager.GetInstance().OnReadyViewScene(isFadein: true, delegate
			{
				if (_bingoLoginDrawData != null)
				{
					BingoLoginBonusStart();
				}
				else
				{
					DisplayFirstTips(_bingoInfoData.CampaignId, _bingoInfoData.IsMissionActivePeriod);
				}
			});
		}));
		CreateButtons();
	}

	private void CreateTopBar()
	{
		string titleMsg = Data.SystemText.Get("Bingo_0023");
		TopBar topBar = UIManager.GetInstance().CreateTopBar(base.gameObject, titleMsg, UIManager.ViewScene.MyPage, MoneyDraw: false);
		topBar.gameObject.layer = LayerMask.NameToLayer("MyPage");
		topBar.OverwriteBackLabelColors(eColorCodeId.QuestBackButtonGradientTop, eColorCodeId.QuestBackButtonGradientBottom);
	}

	private void InitFooter()
	{
		UIManager.GetInstance()._Footer.OverwriteLabelColors(eColorCodeId.QuestFooterGradientTop, eColorCodeId.QuestFooterGradientBottom, eColorCodeId.QuestFooterOutline);
		UIManager.GetInstance()._Footer.UpdateCurrentIndex(0);
	}

	private void InitSpriteAtlasOverwriter()
	{
		UIAtlas component = Toolbox.ResourcesManager.LoadObject<GameObject>(Toolbox.ResourcesManager.GetAssetTypePath("dummy", ResourcesManager.AssetLoadPathType.QuestAtlas, isfetch: true)).GetComponent<UIAtlas>();
		UISpriteAtlasOverwriter.TargetObject[] targetObjects = new UISpriteAtlasOverwriter.TargetObject[2]
		{
			new UISpriteAtlasOverwriter.TargetObject(UIManager.GetInstance().UIManagerRoot.gameObject, includeChildren: true),
			new UISpriteAtlasOverwriter.TargetObject(UIManager.GetInstance().UIRootSystem.gameObject, includeChildren: true)
		};
		_spriteAtlasOverwriter.Init(component, targetObjects);
	}

	private void AddSeCueSheet()
	{
		foreach (string bingoSe in _bingoSeList)
		{
			Toolbox.AudioManager.AddCueSheet(bingoSe, bingoSe + ".acb", "s/");
		}
	}

	private void CreateButtons()
	{
		_questMissionButton.onClick.Clear();
		_questMissionButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			if (_bingoInfoData.IsMissionActivePeriod)
			{
				BingoMissionDialog.Create(_missionDialogPrefab, _bingoInfoData);
			}
			else
			{
				SystemText systemText = Data.SystemText;
				DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
				dialogBase.SetSize(DialogBase.Size.S);
				dialogBase.SetTitleLabel(systemText.Get("Bingo_0005"));
				dialogBase.SetText(systemText.Get("Bingo_0033"));
				dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
			}
		}));
		_detailsButton.onClick.Clear();
		_detailsButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			OnClickDetailsButton();
		}));
		_rewardsButton.onClick.Clear();
		_rewardsButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			BingoRewardsDialog.Create(_allRewardsDialogPrefab, _bingoInfoData);
		}));
		_skipButton.onClick.Clear();
		_skipButton.gameObject.SetActive(value: false);
		_skipButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			SkipBingoAnimationsAndEffects();
			_skipButton.gameObject.SetActive(value: false);
		}));
		_hiddenFullScreenButton.onClick.Clear();
		_hiddenFullScreenButton.gameObject.SetActive(value: false);
	}

	private void OnClickDetailsButton()
	{
		if (_bingoInfoData.NotificationId == "")
		{
			SystemText systemText = Data.SystemText;
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetSize(DialogBase.Size.M);
			dialogBase.SetTitleLabel(systemText.Get("Bingo_0007"));
			dialogBase.SetText(systemText.Get("Quest_0034"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
			SetExceptionDialog(dialogBase);
		}
		else
		{
			UIManager.GetInstance().WebViewHelper.OpenAnnounceWebView(_bingoInfoData.NotificationId, delegate(DialogBase dialog)
			{
				SetExceptionDialog(dialog);
			});
		}
	}

	private void SetExceptionDialog(DialogBase dialog)
	{
		List<UISpriteAtlasOverwriter.TargetObject> exceptionObjects = new List<UISpriteAtlasOverwriter.TargetObject>
		{
			new UISpriteAtlasOverwriter.TargetObject(dialog.gameObject, includeChildren: true)
		};
		_spriteAtlasOverwriter.AddExceptionObjects(exceptionObjects);
	}

	private void UpdateBingoSheet()
	{
		_gridBingBlockGrid.transform.DestroyChildren();
		_bingoSheetBlockList.Clear();
		_originBingoSheetBlock.SetActive(value: false);
		List<BingoInfoTask.SquareData> squareDataList = _bingoInfoData.SquareDataList;
		int num = (int)Mathf.Sqrt(_bingoInfoData.MaxSquareNum);
		float blockScale = ((num == 5) ? _fiveFiveBlockScale : 1f);
		int num2 = ((num == 3) ? 90 : 54);
		for (int i = 0; i < _bingoInfoData.MaxSquareNum; i++)
		{
			BingoSheetBlock component = NGUITools.AddChild(_gridBingBlockGrid.gameObject, _originBingoSheetBlock).GetComponent<BingoSheetBlock>();
			component.gameObject.SetActive(value: true);
			component.SetNumLabel(squareDataList[i].DisplayId, num);
			component.SetBlockScale(blockScale);
			component.SetPartsVisible(blockVisible: true, squareDataList[i].TreasureBoxGradeId, squareDataList[i].IsOpen);
			_bingoSheetBlockList.Add(component);
		}
		_originBingoSheetBlock.gameObject.SetActive(value: false);
		_gridBingBlockGrid.maxPerLine = num;
		_gridBingBlockGrid.cellHeight = (float)num2 * _bingoBlockGridSizeCoef;
		_gridBingBlockGrid.cellWidth = (float)num2 * _bingoBlockGridSizeCoef;
		_gridBingBlockGrid.repositionNow = true;
	}

	private void UpdateBingoSheetNum()
	{
		_labelSheetNum.text = Data.SystemText.Get("Bingo_0002", _bingoInfoData.SheetNum.ToString(), _bingoInfoData.MaxSheetNum.ToString(), GetOpenedBingoBlock.Count.ToString(), _bingoInfoData.MaxSquareNum.ToString());
	}

	private void UpdatePurchaseArea(int preCalculatedNum = -1)
	{
		if (preCalculatedNum >= 0)
		{
			_bingoTicketAreaLayout.SetHaveItemLabel(preCalculatedNum);
		}
		else
		{
			_bingoTicketAreaLayout.SetHaveItemLabel(_bingoInfoData.BingoTicketNum);
		}
		_bingoTicketAreaLayout.SetOnClickPurchaseButton(OnClickPurchaseButton);
	}

	private void UpdateSideBarRewards(bool isFirstOpen = false)
	{
		List<BingoInfoTask.CurrentLineRewardInfo> currentLineRewardList = _bingoInfoData.CurrentLineRewardList;
		_bingoRewardsGrid.transform.DestroyChildren();
		for (int i = 0; i < currentLineRewardList.Count; i++)
		{
			bool flag = i + 1 == currentLineRewardList.Count;
			AchievementWindowBase component = NGUITools.AddChild(_bingoRewardsGrid.gameObject, _bingoMissionItemPrefab).GetComponent<AchievementWindowBase>();
			component.gameObject.SetActive(value: true);
			component.SetBingoSideBarRewards(currentLineRewardList[i].LineNum, currentLineRewardList[i].Reward, currentLineRewardList[i].IsCleared, !flag, _resourceHandler);
		}
		_bingoRewardsGrid.Reposition();
		if (GetOpenedBingoBlock.Count == 0 || isFirstOpen)
		{
			_bingoRewardsScrollPanel.ResetPosition();
		}
	}

	private void SkipBingoAnimationsAndEffects()
	{
		if (_inProcessCoroutines.Count > 0)
		{
			foreach (Coroutine inProcessCoroutine in _inProcessCoroutines)
			{
				if (inProcessCoroutine != null)
				{
					UIManager.GetInstance().StopCoroutine(inProcessCoroutine);
				}
			}
		}
		foreach (BingoBall bingoBall in _bingoBallList)
		{
			bingoBall.StopCoroutine();
		}
		_spineTexture.gameObject.SetActive(value: false);
		_spineDisplayPurchase.StartMotion("NONE");
		_spineDisplayLogin.StartMotion("NONE");
		_spineDisplayPurchase.gameObject.SetActive(value: false);
		_spineDisplayLogin.gameObject.SetActive(value: false);
		iTween.Stop(base.gameObject, includechildren: true);
		_bingoBalls.transform.DestroyChildren();
		_dustEffectContainer.transform.DestroyChildren();
		TweenAlpha.Begin(_fadeDarkBgTweenAlpha.gameObject, 0f, 0f);
		_notTouchMypageCollider.enabled = false;
		if (_inProcessTweenAnimationGroup.Count > 0)
		{
			foreach (TweenAnimationGroup item in _inProcessTweenAnimationGroup)
			{
				item.StopAllCoroutines();
				UnityEngine.Object.Destroy(item.gameObject);
			}
			_inProcessTweenAnimationGroup.Clear();
		}
		foreach (BingoSheetBlock bingoSheetBlock in _bingoSheetBlockList)
		{
			bingoSheetBlock.CancelAnimations();
		}
		_hiddenFullScreenButton.onClick.Clear();
		_hiddenFullScreenButton.gameObject.SetActive(value: false);
		_bingoAnimationFadeDarkBg.SetActive(value: false);
		if (_boxOpenEffectObj != null)
		{
			UnityEngine.Object.Destroy(_boxOpenEffectObj);
		}
		if (_treasureEffectObj != null)
		{
			UnityEngine.Object.Destroy(_treasureEffectObj);
		}
		_isPlayBoxOpenEffect = false;
		if (IsGetSomeRewards())
		{
			ShowAllRewardsDialog();
			return;
		}
		BingoInfoUpdate(delegate
		{
			EnableTouchAndBackKey();
			DisplayFirstTips(_bingoInfoData.CampaignId, _bingoInfoData.IsMissionActivePeriod);
		});
	}

	private IEnumerator LoadResources(Action callBack)
	{
		List<string> loadList = new List<string>();
		string[] array = new string[3] { "cmn_bingo_ball_1", "cmn_bingo_ball_2", "cmn_bingo_cmp_1" };
		foreach (string path in array)
		{
			loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.Effect2D));
		}
		loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(3304.ToString("00"), ResourcesManager.AssetLoadPathType.ClassCharaBase));
		array = new string[3] { "bingo_lines", "bingo_square_stamp", "bingosheet" };
		foreach (string path2 in array)
		{
			loadList.Add(Toolbox.ResourcesManager.GetAssetTypePath(path2, ResourcesManager.AssetLoadPathType.Bingo));
		}
		loadList.AddRange(_spineDisplayPurchase.GetLoadPath("spine_bingo_02", fetch: false));
		loadList.AddRange(_spineDisplayLogin.GetLoadPath("spine_bingo_01", fetch: false));
		yield return StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(loadList, null));
		_loadedResourceList.AddRange(loadList);
		callBack.Call();
	}

	private void UnloadResources()
	{
		_resourceHandler.UnloadAll();
		if (_loadedResourceList.Count > 0)
		{
			Toolbox.ResourcesManager.RemoveAssetGroup(_loadedResourceList);
			_loadedResourceList.Clear();
		}
	}

	private void OnClickPurchaseButton()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
		CreateSelectBuyNumDialog();
	}

	private void CreateSelectBuyNumDialog()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(Data.SystemText.Get("Bingo_0014"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.NONE);
		dialogBase.SetReturnMsg(null, "");
		dialogBase.SetPanelDepth(100);
		int ablePackNumByGachaInfo = GetAblePackNumByGachaInfo();
		BingoSelectBuyNumPopup bingoSelectBuyNumPopup = UnityEngine.Object.Instantiate(_prefabDialogSelectBuyNumber);
		bingoSelectBuyNumPopup.gameObject.SetActive(value: true);
		dialogBase.SetObj(bingoSelectBuyNumPopup.gameObject);
		bingoSelectBuyNumPopup.Init(dialogBase, ablePackNumByGachaInfo, GetOpenedBingoBlock.Count, _bingoInfoData, BingoPurchase);
	}

	private static void DisplayFirstTips(int id, bool isMissionActivePeriod)
	{
		if (isMissionActivePeriod && PlayerPrefsWrapper.GetValue(FirstTipsSaveKey) != id)
		{
			UIManager.GetInstance().StartFirstTips(FirstTips.TipsType.Bingo, delegate
			{
				PlayerPrefsWrapper.SetValue(FirstTipsSaveKey, id);
			});
		}
	}

	private int GetAblePackNumByGachaInfo()
	{
		int count = GetOpenedBingoBlock.Count;
		return Mathf.Clamp(_bingoInfoData.BingoTicketNum / _bingoInfoData.BingoDrawCost, 0, Mathf.Min(10, _bingoInfoData.MaxSquareNum - count));
	}

	private void BingoPurchase(int buyNum)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
		BingoDrawTask task = new BingoDrawTask();
		task.SetParameter(buyNum, Certification.ViewerId);
		StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			_bingoDrawTaskData = task.Result;
			FadeInDark(task.Result);
		}));
	}

	private void BingoLoginBonusStart()
	{
		FadeInDark(_bingoLoginDrawData);
	}

	private void FadeInDark(BingoDrawTask.BingoDrawTaskData result)
	{
		UIManager.GetInstance().OpenNotTouch();
		GameMgr.GetIns().GetInputMgr().isBackKeyEnable = false;
		_notTouchMypageCollider.enabled = true;
		if (!result.IsBingoLoginBonus)
		{
			UpdatePurchaseArea(_bingoInfoData.BingoTicketNum - result.HitSquareIdList.Count);
		}
		_fadeDarkBgTweenAlpha.from = 0f;
		_fadeDarkBgTweenAlpha.SetOnFinished(delegate
		{
			_skipButton.gameObject.SetActive(value: true);
			_skipButton.gameObject.SetLayer(LayerMask.NameToLayer("SystemUI"), isSetChildren: true);
			if (result.IsBingoLoginBonus)
			{
				_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(PlayBingoLoginBonusAnimation(result)));
			}
			else
			{
				_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(PlayPurchaseAnimation(result)));
			}
		});
		TweenAlpha.Begin(_fadeDarkBgTweenAlpha.gameObject, 0.6f, 1f);
	}

	private IEnumerator PlayPurchaseAnimation(BingoDrawTask.BingoDrawTaskData result)
	{
		_spineDisplayPurchase.gameObject.SetActive(value: true);
		_spineDisplayPurchase.StartMotion(ClassCharaPrm.MotionType.extra.ToString());
		yield return null;
		_spineTexture.gameObject.SetActive(value: true);
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_bng_lottery_01", "se_bng_lottery_01", 0f, 0L);
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_bng_lottery_voice_01", "se_bng_lottery_voice_01", 0f, 0L);
		while (_spineDisplayPurchase.IsPlaying())
		{
			yield return null;
		}
		_spineDisplayPurchase.gameObject.SetActive(value: false);
		_spineTexture.gameObject.SetActive(value: false);
		BingoMovement(result, delegate
		{
			EnableTouchAndBackKey();
			DisplayFirstTips(_bingoInfoData.CampaignId, _bingoInfoData.IsMissionActivePeriod);
		});
	}

	private IEnumerator PlayBingoLoginBonusAnimation(BingoDrawTask.BingoDrawTaskData result)
	{
		_spineDisplayLogin.gameObject.SetActive(value: true);
		_spineDisplayLogin.StartMotion("anime");
		yield return null;
		_spineTexture.gameObject.SetActive(value: true);
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_bng_appear_01", "se_bng_appear_01", 0f, 0L);
		yield return new WaitForSeconds(1.25f);
		_spineDisplayLogin.gameObject.SetActive(value: false);
		_spineTexture.gameObject.SetActive(value: false);
		_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(FadeOutDark(0.3f, result, delegate
		{
			EnableTouchAndBackKey();
			DisplayFirstTips(_bingoInfoData.CampaignId, _bingoInfoData.IsMissionActivePeriod);
		})));
	}

	private void EnableTouchAndBackKey()
	{
		UIManager.GetInstance().offNotTouch();
		_notTouchMypageCollider.enabled = false;
		_inProcessCoroutines.Clear();
		GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true;
	}

	private IEnumerator FadeOutDark(float delay, BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		yield return new WaitForSeconds(delay);
		_bingoBalls.transform.DestroyChildren();
		_fadeDarkBgTweenAlpha.from = 1f;
		_fadeDarkBgTweenAlpha.SetOnFinished(delegate
		{
			_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(PlayStamp(result, onBingoFinish)));
		});
		TweenAlpha.Begin(_fadeDarkBgTweenAlpha.gameObject, 0.6f, 0f);
	}

	private void BingoMovement(BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		_bingoBallList.Clear();
		int count = result.HitSquareIdList.Count;
		_bingoBalls.transform.DestroyChildren();
		_ballPosDataDic.TryGetValue(count, out var value);
		for (int i = 0; i < value.Line1Num; i++)
		{
			BingoBall component = NGUITools.AddChild(_bingoBalls, _originBingoBall.gameObject).GetComponent<BingoBall>();
			component.gameObject.transform.localPosition = new Vector3(value.Line1LeftPos.x + (float)i * value.Line1Space, value.Line1LeftPos.y, 0f);
			component.SetBallSprite(isFront: false);
			_bingoBallList.Add(component);
		}
		for (int j = 0; j < value.Line2Num; j++)
		{
			BingoBall component2 = NGUITools.AddChild(_bingoBalls, _originBingoBall.gameObject).GetComponent<BingoBall>();
			component2.gameObject.transform.localPosition = new Vector3(value.Line2LeftPos.x + (float)j * value.Line2Space, value.Line2LeftPos.y, 0f);
			component2.SetBallSprite(isFront: false);
			_bingoBallList.Add(component2);
		}
		for (int k = 0; k < value.Line3Num; k++)
		{
			BingoBall component3 = NGUITools.AddChild(_bingoBalls, _originBingoBall.gameObject).GetComponent<BingoBall>();
			component3.gameObject.transform.localPosition = new Vector3(value.Line3LeftPos.x + (float)k * value.Line3Space, value.Line3LeftPos.y, 0f);
			component3.SetBallSprite(isFront: false);
			_bingoBallList.Add(component3);
		}
		for (int l = 0; l < _bingoBallList.Count; l++)
		{
			_bingoBallList[l].SetBallNum(GetDisplayIdBySquareId(result.HitSquareIdList[l]));
			float num = 0f - _originBingoBall.GetBallMovement().y;
			float y = _bingoBallList[l].transform.parent.transform.TransformPoint(new Vector3(_bingoBallList[l].transform.localPosition.x, _bingoBallList[l].transform.localPosition.y - num, 0f)).y;
			float num2 = 1f / (float)_bingoBallList.Count * (float)l;
			_bingoBallList[l].PlayTweenAnimation(_bingoBallList[l].transform.localPosition, num2);
			_loadedResourceList.AddRange(_bingoBallList[l].PlayDustEffect("cmn_bingo_ball_1", _dustEffectContainer, 0.7f, y, num2));
		}
		_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(PlayBallEffect(_bingoBallList, 1.7f, result, onBingoFinish)));
	}

	private IEnumerator PlayBallEffect(List<BingoBall> bingoBalls, float delay, BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		yield return new WaitForSeconds(delay - 0.4f);
		foreach (BingoBall bingoBall in bingoBalls)
		{
			_loadedResourceList.AddRange(bingoBall.PlayEffect("cmn_bingo_ball_2", isOnBottom: false));
		}
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_sys_bng_number_open_pre_01", "se_sys_bng_number_open_pre_01", 0f, 0L);
		yield return new WaitForSeconds(0.4f);
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_sys_bng_number_open_01", "se_sys_bng_number_open_01", 0f, 0L);
		foreach (BingoBall bingoBall2 in bingoBalls)
		{
			bingoBall2.SetBallSprite(isFront: true);
			bingoBall2.SetNumSprite();
		}
		_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(FadeOutDark(3f, result, onBingoFinish)));
	}

	private IEnumerator PlayStamp(BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		float num = 0.05f;
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_sys_bng_stamp_01", "se_sys_bng_stamp_01", 0f, 0L);
		for (int i = 0; i < result.HitSquareIdList.Count; i++)
		{
			int index = result.HitSquareIdList[i] - 1;
			BingoSheetBlock bingoSheetBlock = _bingoSheetBlockList[index];
			bingoSheetBlock.ResetStampTexture();
			bingoSheetBlock.SetStampVisible(visible: true);
			bingoSheetBlock.StampDown(num);
			num += 0.03f;
		}
		float num2 = num;
		int num3 = (((int)Mathf.Sqrt(_bingoInfoData.MaxSquareNum) == 3) ? 10 : 8);
		for (int j = 0; j < result.CompletedLineConditionList.Count; j++)
		{
			List<int> list = result.CompletedLineConditionList[j].OrderBy((int a) => a).ToList();
			num2 += (float)(list.Count + num3) * 0.06f;
			for (int num4 = 0; num4 < list.Count; num4++)
			{
				if (num4 == 0)
				{
					_bingoSheetBlockList[list[num4] - 1].PlaySe(j, num2 - (float)(list.Count - num4) * 0.06f);
				}
				_bingoSheetBlockList[list[num4] - 1].LightOn(num2 - (float)(list.Count - num4) * 0.06f);
			}
		}
		yield return new WaitForSeconds(Mathf.Max(num2, num) + 0.15f);
		_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(ShowBingoAnimationAndEffects(result, onBingoFinish)));
	}

	private IEnumerator ShowBingoAnimationAndEffects(BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		if (result.CompletedLineConditionList.Count <= 0)
		{
			ShowLineRewardsDialog(result, onBingoFinish);
			yield break;
		}
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr("se_sys_bng_bingo_01", "se_sys_bng_bingo_01", 0f, 0L);
		TweenAnimationGroup component = NGUITools.AddChild(_bingoAnimationFadeDarkBg, _bingoAnimation.gameObject).GetComponent<TweenAnimationGroup>();
		UIManager.GetInstance().AttachAtlas(component.gameObject);
		component.Play(null);
		_inProcessTweenAnimationGroup.Add(component);
		GameObject bingoEffectObj = UnityEngine.Object.Instantiate(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("cmn_bingo_cmp_1", ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject);
		bingoEffectObj.transform.parent = component.gameObject.transform;
		bingoEffectObj.transform.localPosition = Vector3.zero;
		_loadedResourceList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(bingoEffectObj, delegate
		{
			bingoEffectObj.SetActive(value: true);
		}));
		_bingoAnimationFadeDarkTweenAlpha.ResetToBeginning();
		_bingoAnimationFadeDarkBg.SetActive(value: true);
		_bingoAnimationFadeDarkTweenAlpha.PlayForward();
		yield return new WaitForSeconds(0.32f);
		if (result.CompletedLineConditionList.Count > 1)
		{
			TweenAnimationGroup component2 = NGUITools.AddChild(_bingoAnimationFadeDarkBg, _bingoLineAnimation.gameObject).GetComponent<TweenAnimationGroup>();
			component2.gameObject.SetActive(value: true);
			UIManager.GetInstance().AttachAtlas(component2.gameObject);
			component2.GetChildObject(0).GetComponentInChildren<UISprite>().spriteName = $"bingo_lines_{result.CompletedLineConditionList.Count.ToString()}";
			component2.Play(null);
			_inProcessTweenAnimationGroup.Add(component2);
		}
		yield return new WaitForSeconds(2f);
		_hiddenFullScreenButton.onClick.Clear();
		_hiddenFullScreenButton.onClick.Add(new EventDelegate(delegate
		{
			foreach (TweenAnimationGroup item in _inProcessTweenAnimationGroup)
			{
				UnityEngine.Object.Destroy(item.gameObject);
			}
			_inProcessTweenAnimationGroup.Clear();
			ShowLineRewardsDialog(result, onBingoFinish);
			_hiddenFullScreenButton.gameObject.SetActive(value: false);
			_bingoAnimationFadeDarkBg.SetActive(value: false);
		}));
		_hiddenFullScreenButton.gameObject.SetActive(value: true);
	}

	public void ShowLineRewardsDialog(BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		if (result.LineRewardData.Count > 0)
		{
			UIManager.GetInstance().createInSceneCenterLoading();
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetSize(DialogBase.Size.M);
			dialogBase.ResetBackViewAlpha();
			dialogBase.SetLayer("MyPage");
			dialogBase.SetPanelDepth(34, isSetBackViewDepthImmediately: true);
			dialogBase.SetTitleLabel(Data.SystemText.Get("Bingo_0022"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
			_skipButton.gameObject.SetActive(value: false);
			dialogBase.OnClose = delegate
			{
				_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(RunOpenBoxEffect(Data.SystemText.Get("Bingo_0020"), result, delegate
				{
					ShowTreatureBoxRewardsDialog(result, onBingoFinish);
				})));
			};
			RewardBase component = NGUITools.AddChild(dialogBase.gameObject, _rewardBase.gameObject).GetComponent<RewardBase>();
			for (int num = 0; num < result.LineRewardData.Count; num++)
			{
				component.AddReward(result.LineRewardData[num]);
			}
			component.EndCreate();
		}
		else
		{
			_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(RunOpenBoxEffect(Data.SystemText.Get("Bingo_0020"), result, delegate
			{
				ShowTreatureBoxRewardsDialog(result, onBingoFinish);
			})));
		}
	}

	public void ShowTreatureBoxRewardsDialog(BingoDrawTask.BingoDrawTaskData result, Action onBingoFinish)
	{
		HideBoxEffect();
		if (result.TreasureBoxReawrdList.Count > 0)
		{
			_skipButton.gameObject.SetActive(value: true);
			UIManager.GetInstance().createInSceneCenterLoading();
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetSize(DialogBase.Size.M);
			dialogBase.SetLayer("MyPage");
			dialogBase.SetPanelDepth(34);
			dialogBase.SetTitleLabel(Data.SystemText.Get("Bingo_0021"));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
			_skipButton.gameObject.SetActive(value: false);
			dialogBase.OnClose = delegate
			{
				BingoInfoUpdate(onBingoFinish);
			};
			RewardBase component = NGUITools.AddChild(dialogBase.gameObject, _rewardBase.gameObject).GetComponent<RewardBase>();
			for (int num = 0; num < result.TreasureBoxReawrdList.Count; num++)
			{
				component.AddReward(result.TreasureBoxReawrdList[num]);
			}
			component.EndCreate();
		}
		else
		{
			BingoInfoUpdate(onBingoFinish);
		}
	}

	private void BingoInfoUpdate(Action onBingoFinish)
	{
		_skipButton.gameObject.SetActive(value: false);
		BingoInfoTask task = new BingoInfoTask();
		task.SetParameter(isDisplayUpdate: true);
		StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
		{
			if (task.CanGiveDailyLoginBonus)
			{
				CreateLoginBonusDialog();
			}
			else
			{
				_bingoInfoData = task.Result;
				UpdateBingoSheet();
				UpdatePurchaseArea();
				UpdateSideBarRewards();
				UpdateBingoSheetNum();
				UpdateBuyButton();
				onBingoFinish.Call();
				_bingoDrawTaskData = null;
				_bingoLoginDrawData = null;
			}
		}));
	}

	private void CreateLoginBonusDialog()
	{
		SystemText systemText = Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Dia_LoginBonus_001_Title"));
		dialogBase.SetText(systemText.Get("Dia_LoginBonus_001_Body"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BackToTitleBtn);
		dialogBase.SetPanelDepth(10);
		dialogBase.SetFadeButtonEnabled(flag: false);
	}

	private void UpdateBuyButton()
	{
		bool flag = false;
		flag |= _bingoInfoData.MaxSheetNum == _bingoInfoData.SheetNum && _bingoInfoData.SquareDataList.Where((BingoInfoTask.SquareData b) => !b.IsOpen).ToList().Count == 0;
		flag |= _bingoInfoData.BingoTicketNum == 0;
		_bingoTicketAreaLayout.SetToGrayPurchaseButton(flag);
		_bingoTicketButtonEffect.SetActive(!flag);
	}

	private void UpdatePeriodInfo()
	{
		string text = "";
		if (_bingoInfoData.IsMissionActivePeriod)
		{
			text = ConvertTime.ToLocal(_bingoInfoData.StartTime, _bingoInfoData.MissionEndTime);
			_labelPeriod.text = Data.SystemText.Get("Bingo_0001", text);
		}
		else
		{
			text = ConvertTime.ToLocal(_bingoInfoData.StartTime, _bingoInfoData.EndTime);
			_labelPeriod.text = Data.SystemText.Get("Bingo_0032", text);
		}
	}

	private void SetTextures()
	{
		_bgCharaTexture.mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(3304.ToString("00"), ResourcesManager.AssetLoadPathType.ClassCharaBase, isfetch: true)) as Texture;
		_animationLinesTexture.mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("bingo_lines", ResourcesManager.AssetLoadPathType.Bingo, isfetch: true)) as Texture;
		_originBingoSheetBlock.GetComponent<BingoSheetBlock>().SetStampTexture(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("bingo_square_stamp", ResourcesManager.AssetLoadPathType.Bingo, isfetch: true)) as Texture);
		_bingoSheet.mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath("bingosheet", ResourcesManager.AssetLoadPathType.Bingo, isfetch: true)) as Texture;
	}

	private IEnumerator RunOpenBoxEffect(string message, BingoDrawTask.BingoDrawTaskData result, Action endAction)
	{
		if (result.TreasureBoxReawrdList.Count <= 0)
		{
			endAction.Call();
			yield break;
		}
		_isPlayBoxOpenEffect = true;
		int maxGrade = result.TreasureBoxReawrdList.Max((ReceivedReward d) => d._gradeId).Value;
		UIManager.GetInstance().OpenNotTouch();
		_notTouchMypageCollider.enabled = true;
		_boxOpenEffectObj = NGUITools.AddChild(base.gameObject, Resources.Load("UI/layoutParts/RankWinnerRewardResultPanel") as GameObject);
		NguiObjs component = _boxOpenEffectObj.GetComponent<NguiObjs>();
		UISprite bg = component.sprites[0];
		UISprite window = component.sprites[1];
		UISprite box = component.sprites[2];
		box.atlas = UIManager.GetInstance().GetAtlasList().FirstOrDefault((UIAtlas s) => s.name == "Bingo");
		UILabel label = component.labels[0];
		label.text = message;
		UIPanel panel = _boxOpenEffectObj.GetComponent<UIPanel>();
		panel.alpha = 0f;
		box.spriteName = $"box_2pick_0{maxGrade - 1}_close";
		string loadEffectName = $"cmn_arena_treasure_gp_{maxGrade}";
		List<string> loadList = new List<string> { Toolbox.ResourcesManager.GetAssetTypePath(loadEffectName, ResourcesManager.AssetLoadPathType.Effect2D) };
		yield return UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(loadList, null));
		_loadedResourceList.AddRange(loadList);
		_treasureEffectObj = UnityEngine.Object.Instantiate(Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(loadEffectName, ResourcesManager.AssetLoadPathType.Effect2D, isfetch: true)) as GameObject);
		_treasureEffectObj.transform.parent = _boxOpenEffectObj.transform;
		_loadedResourceList.AddRange(GameMgr.GetIns().GetEffectMgr().SetUIParticleShader(_treasureEffectObj, null));
		_boxOpenEffectObj.SetLayer(LayerMask.NameToLayer("MyPage"), isSetChildren: true);
		bg.alpha = 0f;
		box.alpha = 0f;
		label.alpha = 0f;
		panel.alpha = 1f;
		TweenAlpha.Begin(bg.gameObject, 0.5f, 0.65f);
		TweenAlpha.Begin(label.gameObject, 0.5f, 1f);
		TweenAlpha.Begin(box.gameObject, 0.5f, 1f);
		label.transform.localPosition = new Vector3(100f, 0f, 0f);
		window.transform.localScale = new Vector3(1f, 0.01f, 1f);
		box.transform.localPosition = new Vector3(180f, 0f, 0f);
		iTween.MoveTo(label.gameObject, iTween.Hash("x", 20f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.ScaleTo(window.gameObject, iTween.Hash("y", 1f, "time", 0.5f, "easetype", iTween.EaseType.easeInOutExpo));
		iTween.MoveTo(box.gameObject, iTween.Hash("y", 20f, "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		yield return new WaitForSeconds(0.8f);
		TweenAlpha.Begin(label.gameObject, 0.5f, 0f);
		iTween.MoveTo(box.gameObject, iTween.Hash("x", 0f, "time", 0.7f, "islocal", true, "easetype", iTween.EaseType.easeInOutExpo));
		string text = $"se_bng_box_open_0{maxGrade}";
		GameMgr.GetIns().GetSoundMgr().PlaySeByStr(text, text, 0f, 0L);
		yield return new WaitForSeconds(1f);
		_treasureEffectObj.transform.localPosition = box.transform.localPosition;
		_treasureEffectObj.transform.localScale = Vector3.one * 320f * 1.75f;
		_treasureEffectObj.SetActive(value: true);
		box.gameObject.SetActive(value: false);
		yield return new WaitForSeconds(1.2f);
		endAction.Call();
		UIManager.GetInstance().offNotTouch();
		_notTouchMypageCollider.enabled = false;
	}

	private void HideBoxEffect()
	{
		if (_isPlayBoxOpenEffect)
		{
			_inProcessCoroutines.Add(UIManager.GetInstance().StartCoroutine(RunHideBoxEffect()));
		}
	}

	private IEnumerator RunHideBoxEffect()
	{
		NguiObjs component = _boxOpenEffectObj.GetComponent<NguiObjs>();
		UISprite uISprite = component.sprites[0];
		UISprite obj = component.sprites[1];
		TweenAlpha.Begin(uISprite.gameObject, 0.3f, 0f);
		TweenAlpha.Begin(obj.gameObject, 0.3f, 0f);
		_treasureEffectObj.SetActive(value: false);
		yield return new WaitForSeconds(0.3f);
		_boxOpenEffectObj.SetActive(value: false);
		UnityEngine.Object.Destroy(_boxOpenEffectObj);
		_isPlayBoxOpenEffect = false;
	}

	private void ShowAllRewardsDialog()
	{
		UIManager.GetInstance().createInSceneCenterLoading();
		BingoDrawTask.BingoDrawTaskData bingoDrawTaskData = ((_bingoDrawTaskData == null) ? _bingoLoginDrawData : _bingoDrawTaskData);
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetLayer("MyPage");
		dialogBase.SetPanelDepth(34);
		dialogBase.SetTitleLabel(Data.SystemText.Get("Bingo_0024"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.OnClose = delegate
		{
			BingoInfoUpdate(delegate
			{
				EnableTouchAndBackKey();
				DisplayFirstTips(_bingoInfoData.CampaignId, _bingoInfoData.IsMissionActivePeriod);
			});
		};
		RewardBase component = NGUITools.AddChild(dialogBase.gameObject, _rewardBase.gameObject).GetComponent<RewardBase>();
		for (int num = 0; num < bingoDrawTaskData.LineRewardData.Count; num++)
		{
			component.AddReward(bingoDrawTaskData.LineRewardData[num]);
		}
		for (int num2 = 0; num2 < bingoDrawTaskData.TreasureBoxReawrdList.Count; num2++)
		{
			component.AddReward(bingoDrawTaskData.TreasureBoxReawrdList[num2]);
		}
		component.EndCreate();
	}

	private List<int> GetBingoLineBlocks(int beginSquareId, int endSquareID, int squareNum)
	{
		List<int> list = new List<int>();
		Vector2 vector = new Vector2(beginSquareId / squareNum, beginSquareId % squareNum);
		Vector2 vector2 = new Vector2(endSquareID / squareNum, endSquareID % squareNum);
		if (vector.x == vector2.x)
		{
			for (int i = (int)vector.y; i <= endSquareID; i++)
			{
				list.Add(i);
			}
			return list;
		}
		if (vector.y == vector2.y)
		{
			for (int j = (int)vector.y; j <= endSquareID; j += squareNum)
			{
				list.Add(j);
			}
			return list;
		}
		if (vector.x == 0f)
		{
			for (int k = 0; k < squareNum * squareNum; k += squareNum + 1)
			{
				list.Add(k);
			}
		}
		else
		{
			for (int l = squareNum - 1; l < squareNum * squareNum; l += squareNum - 1)
			{
				list.Add(l);
			}
		}
		return list;
	}

	public void LateUpdate()
	{
		AllLabelColorChanger.ChangeAllLabel(base.gameObject);
		FixDialogRibbon();
	}

	public static void FixDialogRibbon()
	{
		DialogBase nowOpenDialog = UIManager.GetInstance().NowOpenDialog;
		if (!(nowOpenDialog != null))
		{
			return;
		}
		Transform transform = nowOpenDialog.transform.Find("Anchor/WindowBase/WindowTop");
		if (transform != null)
		{
			UISprite component = transform.GetComponent<UISprite>();
			if (component != null && component.atlas.name == "Quest")
			{
				component.bottomAnchor.absolute = -5;
				component.topAnchor.absolute = 15;
			}
		}
		Transform transform2 = nowOpenDialog.transform.Find("StoryRewardPanel(Clone)/CardDetailRoot/CardDetail(Clone)/DialogParts/Frame/Top");
		if (transform2 != null)
		{
			UISprite component2 = transform2.GetComponent<UISprite>();
			if (component2 != null && component2.atlas.name == "Quest")
			{
				component2.bottomAnchor.absolute = -5;
				component2.topAnchor.absolute = 15;
			}
		}
	}
}
