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

public class MyPageSubBanner : MyPageBannerBase
{
	private const int BANNER_VERTICAL_SPACING = 73;

	[SerializeField]
	private GameObject _bannerRoot;

	[SerializeField]
	private GameObject _roomCampaignBadge;

	public void HideAndRepositionBanner(string click)
	{
		if (_bannerList == null || _bannerList.Count <= 0)
		{
			return;
		}
		foreach (BannerInfo banner in _bannerList)
		{
			if (banner.Click == click)
			{
				banner.BannerGameObject.SetActive(value: false);
			}
		}
		RepositionBannerObject();
	}

	protected override IEnumerator CreateBannerImage()
	{
		_roomCampaignBadge.SetActive(value: false);
		if (Data.MyPage.data._subBannerInfoList != null)
		{
			_bannerList = new List<BannerInfo>(Data.MyPage.data._subBannerInfoList);
		}
		if (_bannerList == null || _bannerList.Count <= 0)
		{
			base.gameObject.SetActive(value: false);
			yield break;
		}
		yield return LoadBannerImage();
		while (!base.gameObject.activeInHierarchy)
		{
			yield return null;
		}
		for (int i = 0; i < _bannerList.Count; i++)
		{
			GameObject gameObject = NGUITools.AddChild(_bannerRoot, _bannerImagePrefab);
			InitializeEventHandler(gameObject, _bannerList[i]);
			if (_bannerList[i].NeedBadge)
			{
				GameObject obj = NGUITools.AddChild(gameObject, _roomCampaignBadge);
				obj.transform.localPosition = _roomCampaignBadge.transform.localPosition;
				obj.SetActive(value: true);
			}
			_bannerList[i].BannerGameObject = gameObject;
		}
		RepositionBannerObject();
	}

	private void RepositionBannerObject()
	{
		int num = 0;
		foreach (BannerInfo banner in _bannerList)
		{
			GameObject bannerGameObject = banner.BannerGameObject;
			if (bannerGameObject.activeSelf)
			{
				Vector3 zero = Vector3.zero;
				zero += Vector3.down * num * 73f;
				bannerGameObject.transform.localPosition = zero;
				num++;
			}
		}
	}
}
