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

public class EmpireLifeModeFacilityUI : MonoBehaviour
{
	public void ShowFacilityList()
	{
		int facilityCountMax = GameMain.Instance.FacilityMgr.FacilityCountMax;
		this.m_FacilityListViewer.CreateFacilityDetailsList<EmpireLifeModeFacilityUI.FacilityLifeModeViewer>(facilityCountMax, delegate(int index, EmpireLifeModeFacilityUI.FacilityLifeModeViewer info)
		{
			info.SetFacilityInfoOfIndex(index);
		});
	}

	public List<EmpireLifeModeFacilityUI.FacilityLifeModeViewer> GetAllItem()
	{
		return this.m_FacilityListViewer.GetAllItem<EmpireLifeModeFacilityUI.FacilityLifeModeViewer>();
	}

	[SerializeField]
	private FacilityDetailsListViewer m_FacilityListViewer;

	public class FacilityLifeModeViewer : FacilityDetailsListViewer.FacilityDetailsUI
	{
		private GameObject changeImage
		{
			get
			{
				GameObject result;
				if ((result = this.m_ChangeImage) == null)
				{
					result = (this.m_ChangeImage = base.transform.Find("Image Change").gameObject);
				}
				return result;
			}
		}

		private GameObject deleteImage
		{
			get
			{
				GameObject result;
				if ((result = this.m_DeleteImage) == null)
				{
					result = (this.m_DeleteImage = base.transform.Find("Image Delete").gameObject);
				}
				return result;
			}
		}

		public uGUIListViewer listViewerParentMaidIcon
		{
			get
			{
				uGUIListViewer result;
				if ((result = this.m_ListViewerParentMaidIcon) == null)
				{
					result = (this.m_ListViewerParentMaidIcon = base.transform.Find("parent window").GetComponent<uGUIListViewer>());
				}
				return result;
			}
		}

		private void Start()
		{
			NDebug.Assert(base.facilityInfoUI != null, "[FacilityDetailsListViewer.cs]\n施設の詳細表示UIクラスで、コンポーネント「FacilityInfoUI」の取得に失敗しました");
			NDebug.Assert(this.changeImage != null, "[FacilityDetailsListViewer.cs]\n施設の詳細表示UIクラスで、UI「Image Change」の取得に失敗しました");
			NDebug.Assert(this.deleteImage != null, "[FacilityDetailsListViewer.cs]\n施設の詳細表示UIクラスで、UI「Image Delete」の取得に失敗しました");
		}

		public Facility GetNowShowingFacility()
		{
			return this.m_NowShowingFacility;
		}

		private void SetFacilityInfo(Facility nowFacility, Facility nextDayFacility, bool isExistNextDayData)
		{
			if (isExistNextDayData)
			{
				if (nextDayFacility == null)
				{
					this.m_NowShowingFacility = nowFacility;
					base.facilityInfoUI.SetFacilityInfo(nowFacility, true);
					this.changeImage.SetActive(false);
					this.deleteImage.SetActive(false);
					this.SetInfoImageVisible(nowFacility != null);
				}
				else
				{
					this.m_NowShowingFacility = nowFacility;
					base.facilityInfoUI.SetFacilityInfo(nowFacility, true);
					this.changeImage.SetActive(false);
					this.deleteImage.SetActive(false);
					this.SetInfoImageVisible(nowFacility != null);
				}
			}
			else
			{
				this.m_NowShowingFacility = nowFacility;
				base.facilityInfoUI.SetFacilityInfo(nowFacility, true);
				this.changeImage.SetActive(false);
				this.deleteImage.SetActive(false);
				this.SetInfoImageVisible(nowFacility != null);
			}
		}

		public void SetFacilityInfoOfIndex(int index)
		{
			FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
			Facility facility = facilityMgr.GetFacility(index);
			Facility nextDayFacility = null;
			bool nextDayFacilityExist;
			if (nextDayFacilityExist = facilityMgr.GetNextDayFacilityExist(index))
			{
				nextDayFacility = facilityMgr.GetNextDayFacility(index);
			}
			this.SetFacilityInfo(facility, nextDayFacility, nextDayFacilityExist);
		}

		private void SetInfoImageVisible(bool isViewImage)
		{
			if (!isViewImage)
			{
				base.facilityInfoUI.imageFacilityThumbnail.color = new Color(0f, 0f, 0f, 0.25f);
			}
			else
			{
				base.facilityInfoUI.imageFacilityThumbnail.color = new Color(1f, 1f, 1f, 1f);
			}
		}

		private GameObject m_ChangeImage;

		private GameObject m_DeleteImage;

		private uGUIListViewer m_ListViewerParentMaidIcon;

		private Facility m_NowShowingFacility;
	}
}
