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

public class ScheduleRoomCtrl : MonoBehaviour
{
	public void Init(ScheduleMgr scheduleMgr, ScheduleCtrl scheduleCtrl, GameObject goPanel)
	{
		this.m_scheduleMgr = scheduleMgr;
		this.m_scheduleCtrl = scheduleCtrl;
		this.m_goPanel = goPanel;
		this.m_MaidViewer = UTY.GetChildObject(goPanel, "SelectedMaidViewer", false);
	}

	public void ClickRoomScheduleClose()
	{
		this.m_scheduleCtrl.SetViewerActive(ScheduleCtrl.ExclusiveViewer.Task);
		this.m_MaidViewer.SetActive(true);
	}

	public void CreateTaskViewer()
	{
		if (!this.m_bInit)
		{
			this.CreateRoomListInfo();
			this.m_bInit = true;
		}
		this.m_scheduleCtrl.SetViewerActive(ScheduleCtrl.ExclusiveViewer.Room);
		this.m_MaidViewer.SetActive(false);
		if (this.content_parent_grid_ == null)
		{
			this.content_parent_grid_ = UTY.GetChildObject(this.viewer, "Content/Parent", false).GetComponent<UIGrid>();
		}
		this.content_parent_grid_.repositionNow = true;
		this.m_goPanel.SetActive(true);
		this.SetSecelctRoomIndex(0);
	}

	private void CreateRoomListInfo()
	{
		this.content_parent_grid_ = UTY.GetChildObject(this.viewer, "Content/Parent", false).GetComponent<UIGrid>();
		this.m_listBg = ScheduleRoomCtrl.CreateBGList(true);
		int num = 0;
		foreach (ScheduleRoomCtrl.PVBInfo pvbinfo in this.m_listBg)
		{
			GameObject gameObject = Utility.CreatePrefab(this.content_parent_grid_.gameObject, "SceneDaily/Schedule/Prefab/RoomInfo", true);
			ScheduleRoomInfo component = gameObject.GetComponent<ScheduleRoomInfo>();
			component.SetData(this, num, (ScheduleRoomCtrl.BGInfo)pvbinfo);
			this.roomInfoList.Add(component);
			num++;
			if (num >= 12)
			{
				break;
			}
		}
		UIButton component2 = UTY.GetChildObject(this.viewer, "Panel/RoomSettingEnd", false).GetComponent<UIButton>();
		EventDelegate.Add(component2.onClick, new EventDelegate.Callback(this.ClickRoomScheduleClose));
	}

	public void CloseTask()
	{
		this.m_goPanel.SetActive(false);
	}

	public void DeleteRoomList()
	{
		if (this.roomInfoList == null)
		{
			return;
		}
		foreach (ScheduleRoomInfo scheduleRoomInfo in this.roomInfoList)
		{
			if (scheduleRoomInfo.gameObject != null)
			{
				UnityEngine.Object.Destroy(scheduleRoomInfo.gameObject);
			}
		}
		this.roomInfoList.Clear();
	}

	public void SetSecelctRoomIndex(int index)
	{
		this.selectRoomIndex = index;
		foreach (ScheduleRoomInfo scheduleRoomInfo in this.roomInfoList)
		{
			if (scheduleRoomInfo.RoomIndex == this.selectRoomIndex)
			{
				scheduleRoomInfo.SetActiveCheckMark(true);
			}
			else
			{
				scheduleRoomInfo.SetActiveCheckMark(false);
			}
		}
	}

	public static List<ScheduleRoomCtrl.PVBInfo> CreateBGList(bool is_level_check)
	{
		return new List<ScheduleRoomCtrl.PVBInfo>();
	}

	private ScheduleMgr m_scheduleMgr;

	private ScheduleCtrl m_scheduleCtrl;

	private GameObject viewer;

	private GameObject m_goPanel;

	private GameObject m_MaidViewer;

	private List<ScheduleRoomInfo> roomInfoList = new List<ScheduleRoomInfo>();

	private bool m_bInit;

	public List<ScheduleRoomCtrl.PVBInfo> m_listBg = new List<ScheduleRoomCtrl.PVBInfo>();

	private UIGrid content_parent_grid_;

	private int selectRoomIndex;

	public class BGInfo : ScheduleRoomCtrl.PVBInfo
	{
		public string strBGFileName;

		public Vector3 vPos;

		public float fRot;

		public string stageName;
	}

	public class PVBInfo
	{
		public string strIconName;

		public Texture2D texIcon;
	}
}
