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

public class DescResultTraining : DescResulteBase
{
	public override void Init(ResultWorkMgr resultWorkMgr, ResultWorkCtrl ctrl, GameObject goPanel)
	{
		base.Init(resultWorkMgr, ctrl, goPanel);
		this.m_lMaidClassExp = new DescResulteBase.ParamSet(this.m_goMaidParameterParent, "MaidClassExp");
		this.m_lMaidClassLv = new DescResulteBase.ParamSet(this.m_goMaidParameterParent, "MaidClassLevel");
		this.m_listMaidItem.Add(this.m_lMaidClassExp.GetVariableItem());
		this.m_listMaidItem.Add(this.m_lMaidClassLv.GetVariableItem());
		this.m_listAnimationTarget.Add(this.m_lMaidClassExp.ValueObj);
		this.m_listAnimationTarget.Add(this.m_lMaidClassLv.ValueObj);
		this.SettingSalon();
		this.m_goCommuBonus = UTY.GetChildObject(this.m_goMaidStatus, "CommuBonus", false);
		this.m_commuBonusIcon = this.m_goCommuBonus.GetComponent<UITexture>();
		this.m_goCommuBonus.SetActive(false);
		this.m_goPerfectSuccess = UTY.GetChildObject(this.m_goMaidStatus, "PerfectSuccess", false);
		this.m_perfectSuccessIcon = this.m_goPerfectSuccess.GetComponent<UITexture>();
		this.m_goCommuBonus.SetActive(false);
		base.gameObject.SetActive(false);
	}

	private void SettingSalon()
	{
		this.m_goSalonStatus = UTY.GetChildObject(this.viewPanel, "SalonStatus", false);
		this.m_goSalonParameterParent = UTY.GetChildObject(this.m_goSalonStatus, "ParameterParent", false);
		this.m_lWorkingFunds = new DescResulteBase.ParamSet(this.m_goSalonParameterParent, "WorkingFunds");
		this.m_listSalonStatus = new List<ScheduleCtrl.VariableItem>
		{
			this.m_lWorkingFunds.GetVariableItem()
		};
		this.m_spBGOfSalonParameterViewer = UTY.GetChildObject(this.m_goSalonStatus, "BG", false).GetComponent<UISprite>();
		this.m_heightOfSalonParameterTitle = UTY.GetChildObject(this.m_goSalonStatus, "Title", false).GetComponent<UISprite>().height;
	}

	public override void UpdateView(string buttonName)
	{
		this.m_resultWorkCtrl.SetSelectedRowActive(buttonName);
		int slotNoByButtonName = ScheduleCtrl.GetSlotNoByButtonName(buttonName);
		ResultWorkCtrl.ResultWork resultWorkBySlotNo = this.m_resultWorkCtrl.GetResultWorkBySlotNo(slotNoByButtonName);
		if (resultWorkBySlotNo.hasResult)
		{
			this.SetAcquiredSalonStatusPoints(slotNoByButtonName);
			this.SetAcquiredMaidStatusPoints(slotNoByButtonName);
		}
		else
		{
			Debug.LogWarning(string.Format("スロットNo={0}には仕事の結果データが存在しません。", slotNoByButtonName));
		}
		base.ActivePanel(true);
		this.ExamineMaidStatusDisplayItem();
	}

	protected override void UpdateAddValue(ResultWorkCtrl.UpperMaidStatus maidStatus)
	{
		base.UpdateAddValue(maidStatus);
		this.m_lMaidClassExp.AddValueText = base.Sign(maidStatus.maidClassExp);
		this.m_lMaidClassLv.AddValueText = base.Sign(maidStatus.maidClassLevel);
	}

	public void SetAcquiredSalonStatusPoints(int slotNo)
	{
		ResultWorkCtrl.UpperMaidStatus maidStatusBySlotNo = base.GetMaidStatusBySlotNo(slotNo);
		if (maidStatusBySlotNo != null)
		{
			this.m_lWorkingFunds.AddValueText = base.Sign(maidStatusBySlotNo.workingFunds, "#,0");
			bool active = this.ExamineSalonStatusDisplayItem();
			this.m_goSalonStatus.SetActive(active);
		}
		else
		{
			this.m_goSalonStatus.SetActive(false);
		}
	}

	public void SetAcquiredMaidStatusPoints(int slotNo)
	{
		ResultWorkCtrl.UpperMaidStatus maidStatusBySlotNo = base.GetMaidStatusBySlotNo(slotNo);
		if (maidStatusBySlotNo != null)
		{
			this.SetMaidStatusValue(maidStatusBySlotNo);
			this.SetMaxMaidClassLevelIcon(slotNo, maidStatusBySlotNo.maidLvCompletion);
			this.m_goCommuBonus.SetActive(false);
			if (maidStatusBySlotNo.givenPerfectSucces)
			{
				this.m_goPerfectSuccess.SetActive(true);
				this.m_perfectSuccessIcon.mainTexture = maidStatusBySlotNo.perfectSuccessIcon;
			}
			else
			{
				this.m_goPerfectSuccess.SetActive(false);
				this.m_perfectSuccessIcon.mainTexture = null;
			}
			if (maidStatusBySlotNo.givenCommuBonus)
			{
				this.m_goCommuBonus.SetActive(true);
				this.m_commuBonusIcon.mainTexture = maidStatusBySlotNo.bonusIcon;
				base.TweenAnimation(this.m_playedAnimation);
			}
			else
			{
				this.m_commuBonusIcon.mainTexture = null;
				this.m_goCommuBonus.SetActive(false);
				base.TweenAnimation(false);
			}
			this.m_goMaidStatus.SetActive(true);
		}
		else
		{
			this.m_goMaidStatus.SetActive(false);
		}
	}

	private void SetMaxMaidClassLevelIcon(int slotNo, bool reachMaxLevel)
	{
		string key = slotNo.ToString();
		if (this.m_dicResultWork.ContainsKey(key))
		{
			ResultWorkCtrl.ResultWork resultWork = this.m_dicResultWork[key];
			resultWork.goIconMaidClassMax.SetActive(reachMaxLevel);
		}
		else
		{
			Debug.LogError(string.Format("不適切なスロットNoが選択されました。選択されたスロットNo=", slotNo + 1));
		}
	}

	private void SetMaidStatusValue(ResultWorkCtrl.UpperMaidStatus maidStatus)
	{
		this.UpdateAddValue(maidStatus);
	}

	private bool ExamineSalonStatusDisplayItem()
	{
		int num = ScheduleCtrl.SetActiveExceptForNothing(this.m_listSalonStatus, "0");
		if (num == 0)
		{
			return false;
		}
		BaseCreateViewerCtrl.Reposition(this.m_goSalonParameterParent);
		this.m_resultWorkCtrl.AdjustParameterViewer(this.m_goSalonParameterParent, num, this.m_heightOfSalonParameterTitle, this.m_spBGOfSalonParameterViewer);
		return true;
	}

	private void ExamineMaidStatusDisplayItem()
	{
		int num = ScheduleCtrl.SetActiveExceptForNothing(this.m_listMaidItem, "0");
		if (num == 0)
		{
			this.m_spBGOfMaidParameterViewer.height = 133;
			return;
		}
		BaseCreateViewerCtrl.Reposition(this.m_goMaidParameterParent);
		this.m_resultWorkCtrl.AdjustParameterViewer(this.m_goMaidParameterParent, num, this.m_heightOfMaidParameterTitle, this.m_spBGOfMaidParameterViewer);
	}

	private Dictionary<int, GameObject> m_dicMaxLevelMaidClassIcon;

	private List<ScheduleCtrl.VariableItem> m_listSalonStatus;

	private GameObject m_goSalonStatus;

	private GameObject m_goSalonParameterParent;

	private GameObject m_goCommuBonus;

	private GameObject m_goPerfectSuccess;

	private UITexture m_commuBonusIcon;

	private UITexture m_perfectSuccessIcon;

	private UISprite m_spBGOfSalonParameterViewer;

	private int m_heightOfSalonParameterTitle;

	private const int NO_PARAM_HEIGHT = 133;

	protected DescResulteBase.ParamSet m_lMaidClassLv;

	protected DescResulteBase.ParamSet m_lMaidClassExp;

	protected DescResulteBase.ParamSet m_lWorkingFunds;
}
