using System;
using System.Collections.Generic;
using I2.Loc;
using MaidStatus;
using UnityEngine;
using wf;

public class MaidPlate : MonoBehaviour
{
	public void Awake()
	{
		this.back_plate_ = UTY.GetChildObject(base.gameObject, "Black", false).GetComponent<UISprite>();
		this.left_plate_.main = UTY.GetChildObject(base.gameObject, "LeftPlate", false);
		this.left_plate_.crown_sprite = new UISprite[3];
		for (int i = 0; i < 3; i++)
		{
			this.left_plate_.crown_sprite[i] = UTY.GetChildObject(this.left_plate_.main, "FrameRankingData/Rank" + (i + 1), false).GetComponent<UISprite>();
			this.left_plate_.crown_sprite[i].gameObject.SetActive(false);
		}
		List<UISprite> list = new List<UISprite>();
		int num = 0;
		for (;;)
		{
			GameObject childObject = UTY.GetChildObject(this.left_plate_.main, "FrameThumbnail/Select" + (num + 1), true);
			if (childObject == null)
			{
				break;
			}
			UISprite component = childObject.GetComponent<UISprite>();
			component.gameObject.SetActive(false);
			list.Add(component);
			num++;
		}
		this.left_plate_.select_no = list.ToArray();
		this.left_plate_.rank_label = UTY.GetChildObject(this.left_plate_.main, "FrameRankingData/RankLabel", false).GetComponent<UILabel>();
		this.left_plate_.thumbnail_sprite = UTY.GetChildObject(this.left_plate_.main, "FrameThumbnail/Thum", false).GetComponent<UI2DSprite>();
		this.left_plate_.engage_heart = UTY.GetChildObject(this.left_plate_.main, "FrameBaseData/Engage", false).GetComponent<UILabel>();
		this.left_plate_.leader_plate_sprite = UTY.GetChildObject(this.left_plate_.main, "FrameBaseData/LeaderPlate", false).GetComponent<UISprite>();
		this.left_plate_.last_name_label = UTY.GetChildObject(this.left_plate_.main, "FrameBaseData/TextLastName", false).GetComponent<UILabel>();
		this.left_plate_.first_name_label = UTY.GetChildObject(this.left_plate_.main, "FrameBaseData/TextFirstName", false).GetComponent<UILabel>();
		this.left_plate_.contract_type_label = UTY.GetChildObject(this.left_plate_.main, "FrameBaseData/TextTypeName", false).GetComponent<UILabel>();
		this.right_plate_.main = UTY.GetChildObject(base.gameObject, "RightPlate", false);
		this.right_plate_.evaluation_label = UTY.GetChildObject(this.right_plate_.main, "RankingBGFrame/TextEvaluation", false).GetComponent<UILabel>();
		this.right_plate_.total_evaluation_label = UTY.GetChildObject(this.right_plate_.main, "RankingBGFrame/Frame0/TextTotalEvaluation", false).GetComponent<UILabel>();
		this.right_plate_.sales_label = UTY.GetChildObject(this.right_plate_.main, "RankingBGFrame/TextSales", false).GetComponent<UILabel>();
		this.right_plate_.total_sales_label = UTY.GetChildObject(this.right_plate_.main, "RankingBGFrame/Frame0/TextTotalSales", false).GetComponent<UILabel>();
		this.SetMaidData(GameMain.Instance.CharacterMgr.GetMaid(0));
		this.SetRightPlateVisible(false);
	}

	public void SetRightPlateVisible(bool is_visible)
	{
		if (this.miniMode)
		{
			return;
		}
		BoxCollider component = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<BoxCollider>();
		UIWidget component2 = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIWidget>();
		UIPlayAnimation component3 = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIPlayAnimation>();
		Vector3 zero = Vector3.zero;
		Vector3 zero2 = Vector3.zero;
		Vector2 zero3 = Vector2.zero;
		Vector3 zero4 = Vector3.zero;
		zero2.y = 111f;
		zero3.y = 111f;
		if (!is_visible)
		{
			zero.x = -140f;
			zero2.x = 419f;
			zero3.x = 419f;
			component3.target = UTY.GetChildObject(base.gameObject, "LeftPlate", false).GetComponent<Animation>();
			UTY.GetChildObject(base.gameObject, "RightPlate", false).SetActive(false);
		}
		else
		{
			zero2.x = 700f;
			zero3.x = 700f;
			zero4.x = 140f;
			component3.target = base.gameObject.GetComponent<Animation>();
			UTY.GetChildObject(base.gameObject, "RightPlate", false).SetActive(true);
		}
		component.center = zero;
		if (component.size != Vector3.zero)
		{
			component.size = zero2;
		}
		component2.width = (int)zero2.x;
		component2.height = (int)zero2.y;
		this.back_plate_.width = (int)zero3.x;
		this.back_plate_.height = (int)zero3.y;
		this.back_plate_.transform.localPosition = zero4;
	}

	public void SetSelectNoVisible(int no, bool is_visible)
	{
		this.left_plate_.select_no[no - 1].gameObject.SetActive(is_visible);
	}

	public void SetSelectNoVisibleAllOff()
	{
		foreach (UISprite uisprite in this.left_plate_.select_no)
		{
			uisprite.gameObject.SetActive(false);
		}
	}

	public void SetMaidData(Maid maid)
	{
		this.maid_ = maid;
		if (this.maid_ == null)
		{
			return;
		}
		Status status = this.maid_.status;
		for (int i = 0; i < this.left_plate_.crown_sprite.Length; i++)
		{
			this.left_plate_.crown_sprite[i].gameObject.SetActive(false);
		}
		if (1 <= status.popularRank && status.popularRank <= 3)
		{
			this.left_plate_.crown_sprite[status.popularRank - 1].gameObject.SetActive(true);
		}
		if (1 <= status.popularRank && status.popularRank <= 99)
		{
			this.left_plate_.rank_label.text = status.popularRank.ToString();
		}
		else
		{
			this.left_plate_.rank_label.text = "-";
		}
		if (status.OldStatus != null && (status.OldStatus.isMarriage || status.OldStatus.isNewWife))
		{
			this.left_plate_.engage_heart.enabled = true;
		}
		else
		{
			this.left_plate_.engage_heart.enabled = false;
		}
		this.left_plate_.leader_plate_sprite.gameObject.SetActive(status.leader);
		this.left_plate_.last_name_label.text = status.lastName;
		this.left_plate_.first_name_label.text = status.firstName;
		if (status.heroineType != HeroineType.Sub)
		{
			this.left_plate_.contract_type_label.text = EnumConvert.GetString(status.contract);
			Localize component = this.left_plate_.contract_type_label.GetComponent<Localize>();
			if (component != null)
			{
				component.SetTerm(EnumConvert.GetTerm(status.contract));
			}
		}
		else
		{
			this.left_plate_.contract_type_label.text = status.subCharaStatus.contractText;
		}
		this.right_plate_.evaluation_label.text = status.evaluation.ToString();
		this.right_plate_.total_evaluation_label.text = status.totalEvaluations.ToString();
		this.right_plate_.sales_label.text = Utility.ConvertMoneyText(status.sales);
		this.right_plate_.total_sales_label.text = Utility.ConvertMoneyText(status.totalSales);
		Texture2D thumIcon = this.maid_.GetThumIcon();
		if (thumIcon != null)
		{
			Sprite sprite2D = Sprite.Create(thumIcon, new Rect(0f, 0f, (float)thumIcon.width, (float)thumIcon.height), default(Vector2));
			this.left_plate_.thumbnail_sprite.sprite2D = sprite2D;
			if (this.miniMode)
			{
				this.left_plate_.thumbnail_sprite.SetDimensions(50, 50);
			}
			else
			{
				this.left_plate_.thumbnail_sprite.SetDimensions(thumIcon.width, thumIcon.height);
			}
		}
		else
		{
			this.left_plate_.thumbnail_sprite.sprite2D = null;
		}
	}

	public Maid maid
	{
		get
		{
			return this.maid_;
		}
	}

	[SerializeField]
	private bool miniMode;

	private Maid maid_;

	private UISprite back_plate_;

	private MaidPlate.LeftPlate left_plate_;

	private MaidPlate.RightPlate right_plate_;

	private struct LeftPlate
	{
		public GameObject main;

		public UISprite[] crown_sprite;

		public UISprite[] select_no;

		public UILabel rank_label;

		public UI2DSprite thumbnail_sprite;

		public UISprite leader_plate_sprite;

		public UILabel engage_heart;

		public UILabel last_name_label;

		public UILabel first_name_label;

		public UILabel contract_type_label;
	}

	private struct RightPlate
	{
		public GameObject main;

		public UILabel evaluation_label;

		public UILabel total_evaluation_label;

		public UILabel sales_label;

		public UILabel total_sales_label;
	}
}
