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

public class ScheduleTaskCtrl : BaseCreateViewerCtrl
{
	public ScheduleScene ScheduleApi
	{
		get
		{
			return this.m_scheduleApi;
		}
	}

	public ScheduleMgr ScheduleMgr
	{
		get
		{
			return this.m_scheduleMgr;
		}
	}

	public ScheduleCtrl ScheduleCtrl
	{
		get
		{
			return this.m_scheduleCtrl;
		}
	}

	public ScheduleTaskViewer TaskViewer
	{
		get
		{
			return this.m_taskViewer;
		}
	}

	public List<ScheduleBase> GetWorksData(ScheduleTaskCtrl.TaskType type)
	{
		return this.m_listWorksData[type];
	}

	public int CurrentActiveSlotNo
	{
		get
		{
			return this.m_currentActiveSlotNo;
		}
	}

	public void Init(ScheduleMgr scheduleMgr, ScheduleCtrl scheduleCtrl, GameObject goPanel)
	{
		this.m_scheduleMgr = scheduleMgr;
		this.m_scheduleCtrl = scheduleCtrl;
		this.m_goScheduleTaskViewer = UTY.GetChildObject(goPanel, "ScheduleTaskViewer", false);
		this.m_taskViewer = UTY.GetChildObject(goPanel, "ScheduleTaskViewer", false).GetComponent<ScheduleTaskViewer>();
		this.m_taskViewer.taskCtrl = this;
	}

	private void InitViewer()
	{
		this.m_unitPrefabPath = "SceneDaily/Schedule/Prefab/NightTaskUnit";
		GameObject childObject = UTY.GetChildObject(this.m_goScheduleTaskViewer, "TaskViewer", false);
		this.m_goUnitParent = UTY.GetChildObject(childObject, "Contents/TaskUnitParent", false);
		this.m_content = UTY.GetChildObject(childObject, "Contents", false);
		this.m_contentPosY = this.m_content.transform.localPosition.y;
		this.m_taskScrollView = UTY.GetChildObject(childObject, "Contents", false).GetComponent<UIScrollView>();
		GameObject childObject2 = UTY.GetChildObject(this.m_goScheduleTaskViewer, "DescScheduleYotogi", false);
		this.m_lDescription = UTY.GetChildObject(childObject2, "Description/Message", false).GetComponent<UILabel>();
		this.m_goConditionParent = UTY.GetChildObject(childObject2, "Condition/ConditionParent", false);
		this.m_goTitleOfConditiont = UTY.GetChildObject(childObject2, "Condition/Title", false);
		this.m_goConditionUnit = (Resources.Load("SceneDaily/Schedule/Prefab/ConditionUnit") as GameObject);
		this.m_taskScrollBar = UTY.GetChildObject(childObject, "Scroll Bar", false).GetComponent<UIScrollBar>();
		this.m_spBGOfDescriptionViewer = UTY.GetChildObject(childObject2, "BG", false).GetComponent<UISprite>();
		this.m_heightOfconditionTitle = this.m_goTitleOfConditiont.GetComponent<UISprite>().height;
		childObject2.SetActive(false);
		childObject.SetActive(false);
	}

	public void CreateTaskViewer(string buttonName)
	{
		this.CreateTaskViewer(buttonName, ScheduleTaskViewer.ScheduleTime);
	}

	public void CreateTaskViewer(string buttonName, ScheduleMgr.ScheduleTime scheduleTime)
	{
		if (!this.m_bInit)
		{
			this.InitViewer();
			this.m_bInit = true;
		}
		ScheduleTaskViewer.ScheduleTime = scheduleTime;
		this.m_scheduleCtrl.SetMaidIdByButtonName(buttonName);
		this.m_scheduleCtrl.SetViewerActive(ScheduleCtrl.ExclusiveViewer.Task);
		this.m_scheduleCtrl.SetSelectedRowActive(buttonName);
		this.m_currentActiveSlotNo = ScheduleCtrl.GetSlotNoByButtonName(buttonName);
		this.m_listTaskButton = new Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskCtrl.TaskButton>>();
		this.m_listWorksData = new Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleBase>>();
		if (!DailyMgr.IsLegacy)
		{
			GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
		}
		this.m_scheduleMgr.GetScheduleApi().Update(this.CurrentActiveSlotNo);
		List<ScheduleTaskCtrl.TaskButton> list = this.LoadYotogiData(this.m_currentActiveSlotNo);
		this.m_listTaskButton.Add(ScheduleTaskCtrl.TaskType.Yotogi, list);
		List<ScheduleTaskViewer.ViewData> list2 = new List<ScheduleTaskViewer.ViewData>();
		for (int i = 0; i < list.Count; i++)
		{
			ScheduleTaskViewer.ViewData item = default(ScheduleTaskViewer.ViewData);
			ScheduleTaskCtrl.YotogiTaskButton yotogiTaskButton = (ScheduleTaskCtrl.YotogiTaskButton)list[i];
			item.taskButton = yotogiTaskButton;
			item.schedule = ScheduleCSVData.AllData[yotogiTaskButton.data.id];
			item.is_enabled = list[i].enableTask;
			if (!GameMain.Instance.CharacterMgr.status.lockNTRPlay || !ScheduleCSVData.NetorareFlag.Contains(item.schedule.id))
			{
				list2.Add(item);
			}
		}
		List<ScheduleTaskCtrl.TaskButton> list3 = this.LoadTrainingData(this.m_currentActiveSlotNo);
		this.m_listTaskButton.Add(ScheduleTaskCtrl.TaskType.Training, list3);
		List<ScheduleTaskViewer.ViewData> list4 = new List<ScheduleTaskViewer.ViewData>();
		for (int j = 0; j < list3.Count; j++)
		{
			ScheduleTaskViewer.ViewData item2 = default(ScheduleTaskViewer.ViewData);
			ScheduleTaskCtrl.TrainingTaskButton trainingTaskButton = (ScheduleTaskCtrl.TrainingTaskButton)list3[j];
			item2.taskButton = trainingTaskButton;
			item2.schedule = ScheduleCSVData.AllData[int.Parse(trainingTaskButton.id)];
			item2.is_enabled = list3[j].enableTask;
			list4.Add(item2);
		}
		List<ScheduleTaskCtrl.TaskButton> list5 = this.LoadWorkData(this.m_currentActiveSlotNo);
		this.m_listTaskButton.Add(ScheduleTaskCtrl.TaskType.Work, list5);
		List<ScheduleTaskViewer.ViewData> list6 = new List<ScheduleTaskViewer.ViewData>();
		for (int k = 0; k < list5.Count; k++)
		{
			ScheduleTaskViewer.ViewData item3 = default(ScheduleTaskViewer.ViewData);
			ScheduleTaskCtrl.WorkTaskButton workTaskButton = (ScheduleTaskCtrl.WorkTaskButton)list5[k];
			item3.taskButton = workTaskButton;
			item3.schedule = ScheduleCSVData.AllData[int.Parse(workTaskButton.id)];
			item3.is_enabled = list5[k].enableTask;
			list6.Add(item3);
		}
		Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskViewer.ViewData>> dictionary = new Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskViewer.ViewData>>();
		dictionary.Add(ScheduleTaskCtrl.TaskType.Yotogi, list2);
		dictionary.Add(ScheduleTaskCtrl.TaskType.Training, list4);
		dictionary.Add(ScheduleTaskCtrl.TaskType.Work, list6);
		Dictionary<ScheduleMgr.ScheduleTime, ScheduleCSVData.ScheduleBase> dictionary2 = new Dictionary<ScheduleMgr.ScheduleTime, ScheduleCSVData.ScheduleBase>();
		dictionary2.Add(ScheduleMgr.ScheduleTime.Night, ScheduleCSVData.AllData[int.Parse(this.GetTaskId(ScheduleMgr.ScheduleTime.Night))]);
		dictionary2.Add(ScheduleMgr.ScheduleTime.DayTime, ScheduleCSVData.AllData[int.Parse(this.GetTaskId(ScheduleMgr.ScheduleTime.DayTime))]);
		this.m_taskViewer.Call(this.m_scheduleCtrl.SelectedMaid, scheduleTime, dictionary, dictionary2);
		Action<ScheduleCSVData.ScheduleBase> onClickWorkUnitEvent = delegate(ScheduleCSVData.ScheduleBase click_unit)
		{
			this.SetWorkId(ScheduleTaskViewer.ScheduleTime, click_unit.id);
			string currentActiveButton = this.m_scheduleMgr.CurrentActiveButton;
			this.m_scheduleMgr.UpdateMaidStatus();
			this.m_scheduleCtrl.SetViewerActive(ScheduleCtrl.ExclusiveViewer.Task);
			this.m_scheduleCtrl.SetMaidIdByButtonName(currentActiveButton);
			this.m_scheduleCtrl.SetSelectedRowActive(currentActiveButton);
			this.m_scheduleMgr.CurrentActiveButton = currentActiveButton;
		};
		this.m_taskViewer.onClickWorkUnitEvent = onClickWorkUnitEvent;
	}

	private void ResetPosition()
	{
		this.m_taskScrollView.ResetPosition();
		this.m_content.transform.localPosition = new Vector2(this.m_content.transform.localPosition.x, this.m_contentPosY);
	}

	protected override void SetDataForViewer()
	{
		this.m_dicTask = new Dictionary<ScheduleTaskCtrl.TaskType, Dictionary<string, ScheduleTaskCtrl.TaskButton>>();
		this.m_dicTask.Add(ScheduleTaskCtrl.TaskType.Yotogi, this.AddYotogiTaskButton(ScheduleTaskCtrl.TaskType.Yotogi));
		this.m_dicTask.Add(ScheduleTaskCtrl.TaskType.Training, this.AddTrainingTaskButton(ScheduleTaskCtrl.TaskType.Training));
	}

	private Dictionary<string, ScheduleTaskCtrl.TaskButton> AddTrainingTaskButton(ScheduleTaskCtrl.TaskType taskType)
	{
		Dictionary<string, ScheduleTaskCtrl.TaskButton> dictionary = new Dictionary<string, ScheduleTaskCtrl.TaskButton>();
		int num = 0;
		foreach (ScheduleTaskCtrl.TaskButton taskButton in this.m_listTaskButton[taskType])
		{
			ScheduleTaskCtrl.TrainingTaskButton trainingTaskButton = (ScheduleTaskCtrl.TrainingTaskButton)taskButton;
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
			gameObject.name = trainingTaskButton.id;
			GameObject childObject = UTY.GetChildObject(gameObject, "Main", false);
			childObject.name = trainingTaskButton.id;
			base.SetTransformInfo(gameObject);
			UILabel component = UTY.GetChildObject(gameObject, "Title", false).GetComponent<UILabel>();
			component.text = trainingTaskButton.name;
			UITexture component2 = childObject.GetComponent<UITexture>();
			component2.mainTexture = trainingTaskButton.txtTaskIcon;
			this.SetDaytimeTaskRank(gameObject, trainingTaskButton.rank);
			this.SetExpRatio(gameObject, trainingTaskButton.expRatio);
			if (trainingTaskButton.type == ScheduleCSVData.TrainingType.Travel)
			{
				UTY.GetChildObject(gameObject, "Stars", false).SetActive(false);
				UTY.GetChildObject(gameObject, "ExpRatio", false).SetActive(false);
				Transform transform = UTY.GetChildObject(gameObject, "Title", false).transform;
				Vector3 localPosition = transform.localPosition;
				localPosition.y = -55f;
				transform.localPosition = localPosition;
			}
			GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
			childObject2.SetActive(false);
			trainingTaskButton.selectCursor = childObject2;
			trainingTaskButton.order = num;
			UIButton component3 = childObject.GetComponent<UIButton>();
			trainingTaskButton.btnTask = component3;
			EventDelegate eventDelegate = new EventDelegate(this.m_scheduleMgr, "ClickTask");
			eventDelegate.parameters[0].value = ScheduleMgr.ScheduleTime.DayTime;
			EventDelegate.Add(component3.onClick, eventDelegate);
			if (!trainingTaskButton.enableTask)
			{
				Debug.Log(string.Format("選択できないタスクです。タスクID={0}, タスク名={1}", trainingTaskButton.id, trainingTaskButton.name));
			}
			dictionary.Add(trainingTaskButton.id, trainingTaskButton);
			num++;
		}
		return dictionary;
	}

	private void SetDaytimeTaskRank(GameObject go, int rank)
	{
		List<GameObject> list = new List<GameObject>();
		GameObject childObject = UTY.GetChildObject(go, "Stars/Icon", false);
		IEnumerator enumerator = childObject.transform.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform transform = (Transform)obj;
				list.Add(transform.gameObject);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		int count = list.Count;
		for (int i = 0; i < count; i++)
		{
			if (rank > i)
			{
				list[i].SetActive(true);
			}
			else
			{
				list[i].SetActive(false);
			}
		}
	}

	private void SetExpRatio(GameObject go, int expRatio)
	{
		List<GameObject> list = new List<GameObject>();
		GameObject childObject = UTY.GetChildObject(go, "ExpRatio/ValueGroup", false);
		IEnumerator enumerator = childObject.transform.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				object obj = enumerator.Current;
				Transform transform = (Transform)obj;
				list.Add(transform.gameObject);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		int count = list.Count;
		for (int i = 0; i < count; i++)
		{
			if (expRatio > i)
			{
				list[i].SetActive(true);
			}
			else
			{
				list[i].SetActive(false);
			}
		}
	}

	private Dictionary<string, ScheduleTaskCtrl.TaskButton> AddYotogiTaskButton(ScheduleTaskCtrl.TaskType taskType)
	{
		Dictionary<string, ScheduleTaskCtrl.TaskButton> dictionary = new Dictionary<string, ScheduleTaskCtrl.TaskButton>();
		int num = 0;
		foreach (ScheduleTaskCtrl.TaskButton taskButton in this.m_listTaskButton[taskType])
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
			gameObject.name = taskButton.id;
			GameObject childObject = UTY.GetChildObject(gameObject, "Main", false);
			childObject.name = taskButton.id;
			base.SetTransformInfo(gameObject);
			UILabel component = UTY.GetChildObject(gameObject, "Title", false).GetComponent<UILabel>();
			component.text = taskButton.name;
			UITexture component2 = childObject.GetComponent<UITexture>();
			component2.mainTexture = taskButton.txtTaskIcon;
			GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
			childObject2.SetActive(false);
			taskButton.selectCursor = childObject2;
			taskButton.order = num;
			UIButton component3 = childObject.GetComponent<UIButton>();
			taskButton.btnTask = component3;
			EventDelegate eventDelegate = new EventDelegate(this.m_scheduleMgr, "ClickTask");
			eventDelegate.parameters[0].value = ScheduleMgr.ScheduleTime.Night;
			EventDelegate.Add(component3.onClick, eventDelegate);
			if (!taskButton.enableTask)
			{
				Debug.Log(string.Format("選択できないタスクです。タスクID={0}, タスク名={1}", taskButton.id, taskButton.name));
			}
			dictionary.Add(taskButton.id, taskButton);
			num++;
		}
		return dictionary;
	}

	public void UpdateTaskViewer(string taskId)
	{
		this.LoadYotogiTaskData(taskId);
		this.SetTaskButtonActive(ScheduleTaskCtrl.TaskType.Yotogi, taskId);
	}

	private string GetTaskId(ScheduleMgr.ScheduleTime workTime)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
		Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTask = this.m_scheduleCtrl.GetDicMaidStatusAndTask();
		if (dicMaidStatusAndTask.TryGetValue(this.m_scheduleCtrl.GetActiveSlotNo(), out maidStatusAndTaskUnit))
		{
			if (workTime == ScheduleMgr.ScheduleTime.Night)
			{
				return maidStatusAndTaskUnit.nightTaskId;
			}
			if (workTime == ScheduleMgr.ScheduleTime.DayTime)
			{
				return maidStatusAndTaskUnit.daytimeTaskId;
			}
		}
		return null;
	}

	private void LoadYotogiTaskData(string taskId)
	{
		int num = int.Parse(taskId);
		this.m_listCondition = new List<ScheduleCtrl.VariableItem>();
		foreach (ScheduleBase scheduleBase in this.m_listWorksData[ScheduleTaskCtrl.TaskType.Yotogi])
		{
			if (scheduleBase.id == num)
			{
				ScheduleYotogi scheduleYotogi = (ScheduleYotogi)scheduleBase;
				this.m_lDescription.text = scheduleYotogi.info;
				base.DelChildGameObject(this.m_goConditionParent);
				int num2 = 1;
				if (scheduleYotogi.condInfo != null && scheduleYotogi.condInfo.Count > 0)
				{
					foreach (string text in scheduleYotogi.condInfo)
					{
						GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goConditionUnit);
						gameObject.name = "condition_" + num2;
						base.SetTransformInfo(this.m_goConditionParent, gameObject);
						UILabel component = UTY.GetChildObject(gameObject, "No", false).GetComponent<UILabel>();
						component.text = num2.ToString();
						UILabel component2 = UTY.GetChildObject(gameObject, "Message", false).GetComponent<UILabel>();
						component2.text = text;
						ScheduleCtrl.VariableItem item = new ScheduleCtrl.VariableItem(gameObject, component2);
						this.m_listCondition.Add(item);
						num2++;
					}
				}
			}
		}
		this.ExamineDisplayItem();
	}

	private void ExamineDisplayItem()
	{
		int num = ScheduleCtrl.SetActiveExceptForNothing(this.m_listCondition, this.NOTHING);
		bool active = num > 0;
		this.m_goTitleOfConditiont.SetActive(active);
		BaseCreateViewerCtrl.Reposition(this.m_goConditionParent);
		this.AdjustConditon(num);
	}

	private void AdjustConditon(int displayConditionCount)
	{
		float num = 260f;
		float num2 = 10f;
		float num3 = 25f;
		float num4 = 4f;
		float num5 = 0f;
		if (displayConditionCount > 0)
		{
			num5 += (float)this.m_heightOfconditionTitle + num2;
			float y = this.m_goConditionParent.GetComponent<UITable>().padding.y;
			IEnumerator enumerator = this.m_goConditionParent.transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					object obj = enumerator.Current;
					Transform transform = (Transform)obj;
					if (transform.gameObject.activeSelf)
					{
						UILabel component = transform.Find("Message").GetComponent<UILabel>();
						num5 += (float)component.height + y * 2f + num4;
					}
				}
			}
			finally
			{
				IDisposable disposable;
				if ((disposable = (enumerator as IDisposable)) != null)
				{
					disposable.Dispose();
				}
			}
			num5 += num3;
		}
		this.m_spBGOfDescriptionViewer.height = (int)(num + num5);
	}

	public void SetTaskButtonActive(ScheduleTaskCtrl.TaskType type, string taskId)
	{
		foreach (KeyValuePair<string, ScheduleTaskCtrl.TaskButton> keyValuePair in this.m_dicTask[type])
		{
			string key = keyValuePair.Key;
			ScheduleTaskCtrl.TaskButton value = keyValuePair.Value;
			if (key == taskId)
			{
				if (value.enableTask)
				{
					value.btnTask.defaultColor = this.m_scheduleCtrl.GetActiveColor();
				}
				else
				{
					value.btnTask.defaultColor = this.m_scheduleCtrl.GetDisableColor();
				}
				value.selectCursor.SetActive(true);
			}
			else
			{
				value.selectCursor.SetActive(false);
				value.btnTask.defaultColor = this.m_scheduleCtrl.GetInActiveColor();
			}
		}
	}

	public void UpdateSelectedMaidTask(string taskId)
	{
		this.SetWorkId(ScheduleTaskViewer.ScheduleTime, int.Parse(taskId));
		string currentActiveButton = this.m_scheduleMgr.CurrentActiveButton;
		this.m_scheduleMgr.UpdateMaidStatus();
		this.CreateTaskViewer(currentActiveButton);
		this.m_scheduleMgr.CurrentActiveButton = currentActiveButton;
	}

	public void SetCommu(ScheduleMgr.ScheduleTime workTime, string guid, bool value)
	{
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
		{
			Maid stockMaid = characterMgr.GetStockMaid(i);
			bool flag = false;
			if (stockMaid.status.guid == guid)
			{
				flag = value;
			}
			if (stockMaid.status.guid == guid || flag)
			{
				if (workTime == ScheduleMgr.ScheduleTime.DayTime)
				{
					stockMaid.status.noonCommu = flag;
				}
				else if (workTime == ScheduleMgr.ScheduleTime.Night)
				{
					stockMaid.status.nightCommu = flag;
				}
			}
		}
	}

	private void SetWorkId(ScheduleMgr.ScheduleTime workTime, int taskId)
	{
		if (ScheduleCSVData.AllData.ContainsKey(taskId))
		{
			ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[taskId];
			int slotId = 0;
			for (int i = 0; i < 40; i++)
			{
				Maid scheduleSlot = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(i);
				if (scheduleSlot != null && scheduleSlot == this.m_scheduleCtrl.SelectedMaid)
				{
					slotId = i;
				}
			}
			ScheduleTaskCtrl.TaskType type = scheduleBase.type;
			if (type != ScheduleTaskCtrl.TaskType.Training && type != ScheduleTaskCtrl.TaskType.Work)
			{
				if (type == ScheduleTaskCtrl.TaskType.Yotogi)
				{
					this.m_scheduleApi.SetNightWorkSlot_Safe(workTime, slotId, taskId);
				}
			}
			else
			{
				this.m_scheduleApi.SetNoonWorkSlot_Safe(workTime, slotId, taskId);
			}
		}
		if (!DailyMgr.IsLegacy)
		{
			GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
		}
		ScheduleAPI.MaidWorkIdErrorCheck(true);
	}

	private List<ScheduleTaskCtrl.TaskButton> LoadYotogiData(int slotNo)
	{
		this.m_scheduleApi = this.m_scheduleMgr.GetScheduleApi();
		List<ScheduleBase> scheduleData = this.m_scheduleApi.slot[slotNo].scheduleData;
		List<ScheduleBase> list = new List<ScheduleBase>();
		this.m_listWorksData.Add(ScheduleTaskCtrl.TaskType.Yotogi, list);
		List<ScheduleTaskCtrl.TaskButton> list2 = new List<ScheduleTaskCtrl.TaskButton>();
		foreach (ScheduleBase scheduleBase in scheduleData)
		{
			list.Add(scheduleBase);
			if (scheduleBase.workType == ScheduleType.Yotogi)
			{
				ScheduleYotogi scheduleYotogi = (ScheduleYotogi)scheduleBase;
				if (scheduleYotogi.visible)
				{
					list2.Add(new ScheduleTaskCtrl.YotogiTaskButton
					{
						id = scheduleYotogi.id.ToString(),
						name = scheduleYotogi.name,
						txtTaskIcon = scheduleYotogi.icon,
						enableTask = scheduleYotogi.enabled,
						data = scheduleYotogi
					});
				}
			}
		}
		return list2;
	}

	private List<ScheduleTaskCtrl.TaskButton> LoadTrainingData(int slotNo)
	{
		this.m_scheduleApi = this.m_scheduleMgr.GetScheduleApi();
		List<ScheduleBase> scheduleData = this.m_scheduleApi.slot[slotNo].scheduleData;
		List<ScheduleBase> list = new List<ScheduleBase>();
		this.m_listWorksData.Add(ScheduleTaskCtrl.TaskType.Training, list);
		this.m_currentSlotInfo = this.m_scheduleApi.slot[slotNo];
		List<ScheduleTaskCtrl.TaskButton> list2 = new List<ScheduleTaskCtrl.TaskButton>();
		foreach (ScheduleBase scheduleBase in scheduleData)
		{
			list.Add(scheduleBase);
			if (scheduleBase.workType == ScheduleType.Training)
			{
				ScheduleTraining scheduleTraining = (ScheduleTraining)scheduleBase;
				if (scheduleTraining.visible)
				{
					list2.Add(new ScheduleTaskCtrl.TrainingTaskButton
					{
						id = scheduleTraining.id.ToString(),
						name = scheduleTraining.name,
						rank = scheduleTraining.lv,
						expRatio = scheduleTraining.expRatioFrom0To10,
						txtTaskIcon = scheduleTraining.icon,
						enableTask = scheduleTraining.enabled,
						type = scheduleTraining.type
					});
				}
			}
		}
		return list2;
	}

	private List<ScheduleTaskCtrl.TaskButton> LoadWorkData(int slotNo)
	{
		this.m_scheduleApi = this.m_scheduleMgr.GetScheduleApi();
		List<ScheduleBase> scheduleData = this.m_scheduleApi.slot[slotNo].scheduleData;
		List<ScheduleBase> list = new List<ScheduleBase>();
		this.m_listWorksData.Add(ScheduleTaskCtrl.TaskType.Work, list);
		this.m_currentSlotInfo = this.m_scheduleApi.slot[slotNo];
		List<ScheduleTaskCtrl.TaskButton> list2 = new List<ScheduleTaskCtrl.TaskButton>();
		foreach (ScheduleBase scheduleBase in scheduleData)
		{
			list.Add(scheduleBase);
			if (scheduleBase.workType == ScheduleType.Work)
			{
				ScheduleWork scheduleWork = (ScheduleWork)scheduleBase;
				if (scheduleWork.visible)
				{
					list2.Add(new ScheduleTaskCtrl.WorkTaskButton
					{
						id = scheduleWork.id.ToString(),
						name = scheduleWork.name,
						rank = scheduleWork.lv,
						expRatio = scheduleWork.expRatioFrom0To10,
						txtTaskIcon = scheduleWork.icon,
						enableTask = scheduleWork.enabled,
						type = scheduleWork.type
					});
				}
			}
		}
		return list2;
	}

	private string Sign(int input, string format = null)
	{
		if (input <= 0)
		{
			return input.ToString();
		}
		if (format != null)
		{
			return "+" + input.ToString(format);
		}
		return "+" + input.ToString();
	}

	public bool CanSetTask(ScheduleTaskCtrl.TaskType type, int taskId)
	{
		foreach (ScheduleBase scheduleBase in this.m_listWorksData[type])
		{
			if (scheduleBase.id == taskId)
			{
				return scheduleBase.enabled;
			}
		}
		return false;
	}

	private ScheduleMgr m_scheduleMgr;

	private ScheduleCtrl m_scheduleCtrl;

	private ScheduleScene m_scheduleApi;

	private ScheduleTaskViewer m_taskViewer;

	private ScheduleRoomCtrl m_roomViewer;

	private Dictionary<ScheduleTaskCtrl.TaskType, Dictionary<string, ScheduleTaskCtrl.TaskButton>> m_dicTask;

	private Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleTaskCtrl.TaskButton>> m_listTaskButton;

	private Dictionary<ScheduleTaskCtrl.TaskType, List<ScheduleBase>> m_listWorksData;

	private List<ScheduleCtrl.VariableItem> m_listCondition;

	private GameObject m_goScheduleTaskViewer;

	private GameObject m_goTitleOfConditiont;

	private GameObject m_goConditionParent;

	private GameObject m_goConditionUnit;

	private GameObject m_content;

	private UISprite m_spBGOfParameterViewer;

	private UILabel m_lStudyRate;

	private UILabel m_lReception;

	private UILabel m_lCare;

	private UILabel m_lLovely;

	private UILabel m_lElegance;

	private UILabel m_lCharm;

	private UILabel m_lTeachRate;

	private UILabel m_lMaidClassExp;

	private UILabel m_lCleanliness;

	private UILabel m_lBrilliant;

	private UILabel m_lIncome;

	private UILabel m_lCurrentStudyRate;

	private UILabel m_lCurrentReception;

	private UILabel m_lCurrentCare;

	private UILabel m_lCurrentLovely;

	private UILabel m_lCurrentElegance;

	private UILabel m_lCurrentCharm;

	private UILabel m_lCurrentTeachRate;

	private UILabel m_lCurrentMaidClassExp;

	private UILabel m_lRoomName;

	private Slot m_currentSlotInfo;

	private UIScrollView m_taskScrollView;

	private UIScrollBar m_taskScrollBar;

	private UISprite m_spBGOfDescriptionViewer;

	private UILabel m_lDescription;

	private bool m_bInit;

	private float m_contentPosY;

	private string NOTHING = string.Empty;

	private int m_heightOfconditionTitle;

	[SerializeField]
	private int m_currentActiveSlotNo;

	private const string NIGHT_TASK_UNIT_PATH = "SceneDaily/Schedule/Prefab/NightTaskUnit";

	private const string CONDITION_UNIT_PATH = "SceneDaily/Schedule/Prefab/ConditionUnit";

	private const string PREFIX_BUTTON_NAME = "NightTask";

	private const int MAX_CONDITION_COUNT = 9;

	public class TaskButton
	{
		public ScheduleBase data;

		public string id;

		public string name;

		public int order;

		public bool enableTask;

		public UIButton btnTask;

		public Texture2D txtTaskIcon;

		public GameObject selectCursor;
	}

	public class YotogiTaskButton : ScheduleTaskCtrl.TaskButton
	{
	}

	public class TrainingTaskButton : ScheduleTaskCtrl.TaskButton
	{
		public int rank;

		public int expRatio;

		public List<GameObject> listRank;

		public ScheduleCSVData.TrainingType type;
	}

	public class WorkTaskButton : ScheduleTaskCtrl.TrainingTaskButton
	{
	}

	public enum TaskType
	{
		Yotogi,
		Training,
		Work,
		Max
	}
}
