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

namespace Kasizuki
{
	public class MaidLikabilityCtrl : NGUIWindow, IStatusCtrl<Maid>
	{
		protected override void Awake()
		{
			base.Awake();
			this.m_ListViewer = base.GetComponent<uGUIListViewer>();
			this.m_IsAwaked = true;
		}

		public void SetData(Maid maid)
		{
			if (maid == null)
			{
				NDebug.Warning("情報を表示するメイドにnullが指定されました。");
				return;
			}
			this.m_TargetMaid = maid;
			this.UpdateNGUILabel();
		}

		public void UpdateMaidInfo()
		{
			if (this.m_TargetMaid == null)
			{
				NDebug.Warning("情報を表示するメイドがnullでした。SetMaid( Maid )関数で、情報を表示するメイドを指定してください。");
				return;
			}
			this.UpdateNGUILabel();
		}

		private void UpdateNGUILabel()
		{
			if (!this.m_IsAwaked)
			{
				base.gameObject.SetActive(true);
			}
			KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
			Maid maid = this.m_TargetMaid;
			List<ManData.Data> manList = ManData.GetAllDatas(true, true);
			this.m_ListViewer.Show<Transform>(manList.Count, delegate(int index, Transform item)
			{
				ManData.Data data = manList[index];
				UILabel component2 = UTY.GetChildObject(item.gameObject, "Name", false).GetComponent<UILabel>();
				UILabel component3 = UTY.GetChildObject(item.gameObject, "Value", false).GetComponent<UILabel>();
				UISprite component4 = UTY.GetChildObject(item.gameObject, "Gauge/Gauge", false).GetComponent<UISprite>();
				int num = 0;
				ManDataType manType = data.manType;
				if (manType != ManDataType.主人公)
				{
					if (manType != ManDataType.傅き男１)
					{
						if (manType != ManDataType.傅き男２)
						{
							if (manType != ManDataType.傅き男３)
							{
								if (manType != ManDataType.傅き男４)
								{
									if (manType == ManDataType.傅き男５)
									{
										num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男５, false);
									}
								}
								else
								{
									num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男４, false);
								}
							}
							else
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男３, false);
							}
						}
						else
						{
							num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男２, false);
						}
					}
					else
					{
						num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男１, false);
					}
				}
				else
				{
					num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F本編, false);
				}
				num = Mathf.Clamp(num, 0, 100);
				component2.text = data.drawName;
				component3.text = num.ToString();
				component4.fillAmount = (float)num / 100f;
			});
			UIGrid component = this.m_ListViewer.parentItemArea.GetComponent<UIGrid>();
			component.enabled = true;
			component.Reposition();
			UIScrollView componentInChildren = base.GetComponentInChildren<UIScrollView>();
			componentInChildren.ResetPosition();
		}

		private uGUIListViewer m_ListViewer;

		private Maid m_TargetMaid;

		private bool m_IsAwaked;
	}
}
