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

namespace Kasizuki
{
	public class KasizukiMainMenu : WfScreenChildren
	{
		public override void Awake()
		{
			base.Awake();
			GameObject gameObject = base.transform.parent.parent.gameObject;
			this.m_SwitchingWindowDic = new Dictionary<string, NGUIWindow>();
			this.m_SwitchingWindowDic.Add("部屋選択", UTY.GetChildObject(gameObject, "Window Select Club", false).GetComponent<NGUIWindow>());
			this.m_SwitchingWindowDic.Add("メインメニュー", base.root_obj.GetComponent<NGUIWindow>());
			this.m_SwitchingWindowDic.Add("メイド情報", UTY.GetChildObject(gameObject, "MaidMiniManagement", false).AddComponent<NGUIWindow>());
			this.m_SwitchingWindowDic.Add("セーブロード", UTY.GetChildObject(gameObject, "SaveAndLoadPanel", false).GetComponent<NGUIWindow>());
			this.m_SwitchingWindowDic.Add("男選択", UTY.GetChildObject(gameObject, "Window Select Man", false).GetComponent<NGUIWindow>());
			this.m_SwitchingWindowDic.Add("施設情報", UTY.GetChildObject(gameObject, "Window Play Info", false).GetComponent<NGUIWindow>());
			this.SetUpMainMenu();
			this.SetUpSelectRoom();
			this.SetUpSaveLoad();
			this.SetUpManSelect();
			this.SetUpPlayInfo();
		}

		protected override void OnCall()
		{
			this.m_SwitchingWindowDic["部屋選択"].GetCache<UIButton>("OK").isEnabled = (KasizukiMainMenu.m_NowSelectingRoom != null);
			this.m_SwitchingWindowDic["メイド情報"].OnOpen = delegate()
			{
				MaidMiniManagementCtrl component = base.parent_mgr.children_dic["MaidInfo"].GetComponent<MaidMiniManagementCtrl>();
				component.buttonDic["エディット"].gameObject.SetActive(component.selectMaid != null);
			};
			if ((base.parent_mgr as SceneKasizukiMainMenu).isReturnEdit)
			{
				MaidMiniManagementCtrl maidMiniManagementCtrl = base.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
				if (KasizukiMainMenu.m_NowSelectingRoom != null)
				{
					KasizukiCharacterSelectCtrl charaSelect = maidMiniManagementCtrl.charaSelectMgr;
					maidMiniManagementCtrl.selectMaid = null;
					charaSelect.callbackGetMaidList = delegate()
					{
						ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType();
						List<PlayData.Data> playDatas = KasizukiMainMenu.m_NowSelectingRoom.GetPlayDatas();
						List<PlayData.Data> list = new List<PlayData.Data>();
						foreach (PlayData.Data data in playDatas)
						{
							if (data.enableManTypeDic[nowManType])
							{
								list.Add(data);
							}
						}
						HashSet<Maid> hashSet = new HashSet<Maid>();
						foreach (PlayData.Data data2 in list)
						{
							List<Maid> filteringPlayDataMaidArray = data2.GetFilteringPlayDataMaidArray(nowManType);
							foreach (Maid item in filteringPlayDataMaidArray)
							{
								hashSet.Add(item);
							}
						}
						charaSelect.callbackGetMaidList = null;
						return new List<Maid>(hashSet);
					};
				}
				this.OpenSwitchingWindow("メイド情報", true);
				this.SetMaidInfoWindowParameter(KasizukiMainMenu.m_BackUpBeforeMaidInfoParameter);
			}
			else
			{
				this.OpenSwitchingWindow("メインメニュー", true);
			}
			if ((base.parent_mgr as SceneKasizukiMainMenu).isUpdateMaidStatus)
			{
				CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
				Maid maid = characterMgr.GetMaid(0);
				if (maid != null)
				{
					Debug.Log("メイドの仕事回数、好感度を更新");
					KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
					bool systemData = kasizukiMgr.GetSystemData<bool>(SystemDataType.仕事回数ロック);
					int num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.仕事回数, false);
					if (!systemData)
					{
						kasizukiMgr.SetMaidData<int>(maid, MaidDataType.仕事回数, num + 1, false);
					}
					if (!kasizukiMgr.GetSystemData<bool>(SystemDataType.好感度ロック))
					{
						if (kasizukiMgr.GetNowManType() != 10)
						{
							if (kasizukiMgr.GetNowManType() == 20)
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男１, false);
								num += 4;
								kasizukiMgr.SetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男１, num, false);
							}
							else if (kasizukiMgr.GetNowManType() == 30)
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男２, false);
								num += 4;
								kasizukiMgr.SetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男２, num, false);
							}
							else if (kasizukiMgr.GetNowManType() == 40)
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男３, false);
								num += 4;
								kasizukiMgr.SetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男３, num, false);
							}
							else if (kasizukiMgr.GetNowManType() == 50)
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男４, false);
								num += 4;
								kasizukiMgr.SetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男４, num, false);
							}
							else if (kasizukiMgr.GetNowManType() == 60)
							{
								num = kasizukiMgr.GetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男５, false);
								num += 4;
								kasizukiMgr.SetMaidData<int>(maid, MaidDataType.好感度\uFF3F傅き男５, num, false);
							}
						}
					}
					Debug.Log("プレイ回数を更新");
					num = kasizukiMgr.GetSystemData<int>(SystemDataType.プレイ回数);
					num++;
					kasizukiMgr.SetSystemData<int>(SystemDataType.プレイ回数, num, false);
				}
			}
		}

		private void SetUpMainMenu()
		{
			NGUIWindow nguiwindow = this.m_SwitchingWindowDic["メインメニュー"];
			foreach (UIButton uibutton in new List<UIButton>
			{
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/男選択", "男選択"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/クラブ", "クラブ"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/セーブ", "セーブ"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/ロード", "ロード"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/ヒロイン", "ヒロイン"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/フリー", "フリー"),
				nguiwindow.CacheChildObject<UIButton>("parent button/Grid/タイトルに戻る", "タイトルに戻る")
			})
			{
				EventDelegate.Add(uibutton.onClick, new EventDelegate.Callback(this.OnClickButton));
			}
		}

		private void SetUpSelectRoom()
		{
			NGUIWindow nguiwindow = this.m_SwitchingWindowDic["部屋選択"];
			nguiwindow.CacheChildObject<UIButton>("OK", "OK");
			nguiwindow.CacheChildObject<UIButton>("Cancel", "Cancel");
			EventDelegate.Add(nguiwindow.GetCache<UIButton>("OK").onClick, delegate()
			{
				this.OnOKRoom();
			});
			EventDelegate.Add(nguiwindow.GetCache<UIButton>("Cancel").onClick, delegate()
			{
				this.OpenSwitchingWindow("メインメニュー", false);
			});
			nguiwindow.GetComponent<ClubRoomSelectCtrl>().SetCallbackOnClick(new Action<RoomData.Data>(this.OnSelectRoom));
		}

		private void SetUpSaveLoad()
		{
			NGUIWindow nguiwindow = this.m_SwitchingWindowDic["セーブロード"];
			KasizukiSaveAndLoadCtrl component = nguiwindow.GetComponent<KasizukiSaveAndLoadCtrl>();
			NDebug.Assert(component != null, "セーブロードUIが取得できない");
			KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl = component;
			kasizukiSaveAndLoadCtrl.onClickCancel = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl.onClickCancel, new Action(delegate()
			{
				this.OpenSwitchingWindow("メインメニュー", false);
			}));
			KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl2 = component;
			kasizukiSaveAndLoadCtrl2.onClickNewGame = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl2.onClickNewGame, new Action(delegate()
			{
				SceneKasizukiMainMenu mgr = base.parent_mgr as SceneKasizukiMainMenu;
				mgr.CameraFadeOut(delegate
				{
					mgr.UpdateMan(delegate
					{
						mgr.CameraFadeIn(null);
						this.OpenSwitchingWindow("メインメニュー", true);
					});
				}, 0.5f);
			}));
			KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl3 = component;
			kasizukiSaveAndLoadCtrl3.onLoad = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl3.onLoad, new Action(delegate()
			{
				SceneKasizukiMainMenu mgr = base.parent_mgr as SceneKasizukiMainMenu;
				mgr.CameraFadeOut(delegate
				{
					mgr.UpdateMan(delegate
					{
						mgr.CameraFadeIn(null);
						this.OpenSwitchingWindow("メインメニュー", true);
					});
				}, 0.5f);
			}));
			KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl4 = component;
			kasizukiSaveAndLoadCtrl4.onSave = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl4.onSave, new Action(delegate()
			{
				int nowOriginSaveDataNumber = GameMain.Instance.KasizukiMgr.NowOriginSaveDataNumber;
				if (GameMain.Instance.GetSaveDataHeader(nowOriginSaveDataNumber) == null)
				{
					NDebug.Assert("本編セーブデータ" + nowOriginSaveDataNumber + "番の取得に失敗しました", false);
					return;
				}
				GameMain.Instance.SerializeKasizukiOnly(nowOriginSaveDataNumber);
			}));
			KasizukiSaveAndLoadCtrl kasizukiSaveAndLoadCtrl5 = component;
			kasizukiSaveAndLoadCtrl5.onDelete = (Action)Delegate.Combine(kasizukiSaveAndLoadCtrl5.onDelete, new Action(delegate()
			{
				int nowOriginSaveDataNumber = GameMain.Instance.KasizukiMgr.NowOriginSaveDataNumber;
				if (GameMain.Instance.GetSaveDataHeader(nowOriginSaveDataNumber) == null)
				{
					NDebug.Assert("本編セーブデータ" + nowOriginSaveDataNumber + "番の取得に失敗しました", false);
					return;
				}
				GameMain.Instance.SerializeKasizukiOnly(nowOriginSaveDataNumber);
			}));
		}

		private void SetUpManSelect()
		{
			NGUIWindow nguiwindow = this.m_SwitchingWindowDic["男選択"];
			nguiwindow.CacheChildObject<UIButton>("OK", "OK");
			nguiwindow.CacheChildObject<UIButton>("Cancel", "Cancel");
			EventDelegate.Add(nguiwindow.GetCache<UIButton>("OK").onClick, delegate()
			{
				this.OpenSwitchingWindow("メインメニュー", false);
			});
			EventDelegate.Add(nguiwindow.GetCache<UIButton>("Cancel").onClick, delegate()
			{
				this.OpenSwitchingWindow("メインメニュー", false);
			});
			KasizukiManSelectCtrl compManSelect = nguiwindow.GetComponent<KasizukiManSelectCtrl>();
			if (compManSelect)
			{
				NGUIWindow nguiwindow2 = nguiwindow;
				nguiwindow2.OnOpen = (Action)Delegate.Combine(nguiwindow2.OnOpen, new Action(delegate()
				{
					int nowManType = GameMain.Instance.KasizukiMgr.GetNowManType();
					compManSelect.OnClickManListButton(nowManType);
				}));
				KasizukiManSelectCtrl compManSelect2 = compManSelect;
				compManSelect2.OnClickManTypeButton = (Action<int>)Delegate.Combine(compManSelect2.OnClickManTypeButton, new Action<int>(delegate(int manTypeID)
				{
					KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
					kasizukiMgr.SetNowManType(manTypeID);
					SceneKasizukiMainMenu sceneMgr = this.parent_mgr as SceneKasizukiMainMenu;
					sceneMgr.UpdateMan(delegate
					{
						sceneMgr.CameraFadeIn(null);
					});
				}));
			}
		}

		private void SetUpPlayInfo()
		{
			NGUIWindow window = this.m_SwitchingWindowDic["施設情報"];
			window.CacheChildObject<UIButton>("OK", "OK");
			window.CacheChildObject<UIButton>("Cancel", "Cancel");
			KasizukiPlayInfoCtrl comp = window.GetComponent<KasizukiPlayInfoCtrl>();
			RoomData.Data selectingRoomData = null;
			ManData.Data selectingManData = null;
			PlayData.Data selectingPlayData = null;
			EventDelegate.Add(window.GetCache<UIButton>("OK").onClick, delegate()
			{
				MaidMiniManagementCtrl maidMiniManagementCtrl = this.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
				this.StartFree(maidMiniManagementCtrl.selectMaid, selectingRoomData, selectingManData, selectingPlayData);
			});
			EventDelegate.Set(window.GetCache<UIButton>("Cancel").onClick, delegate()
			{
				this.OpenSwitchingWindow("メインメニュー", false);
			});
			Action actResetDescriptionWindow = delegate()
			{
				UILabel cache = comp.descriptionCache.GetCache<UILabel>("説明文");
				uGUIListViewer cache2 = comp.descriptionCache.GetCache<uGUIListViewer>("条件一覧");
				cache.text = string.Empty;
				cache2.ResetList();
			};
			Action<PlayData.Data> actSetDescriptionWindow = delegate(PlayData.Data playData)
			{
				UILabel cache = comp.descriptionCache.GetCache<UILabel>("説明文");
				cache.text = playData.strDescription;
				uGUIListViewer cache2 = comp.descriptionCache.GetCache<uGUIListViewer>("条件一覧");
				string[] strConditionArray = playData.strConditionArray;
				cache2.Show<Transform>(strConditionArray.Length, delegate(int index, Transform trans)
				{
					UILabel component = UTY.GetChildObject(trans.gameObject, "Value", false).GetComponent<UILabel>();
					UILabel component2 = UTY.GetChildObject(trans.gameObject, "Number", false).GetComponent<UILabel>();
					component.text = strConditionArray[index];
					component2.text = (index + 1).ToString();
				});
				cache2.GetComponent<UIGrid>().Reposition();
			};
			Action<RoomData.Data, ManData.Data, PlayData.Data> actSetOKButtonEnable = delegate(RoomData.Data roomData, ManData.Data manData, PlayData.Data playData)
			{
				UIButton cache = window.GetCache<UIButton>("OK");
				cache.isEnabled = (roomData != null && manData != null && playData != null);
			};
			NGUIWindow window2 = window;
			window2.OnOpen = (Action)Delegate.Combine(window2.OnOpen, new Action(delegate()
			{
				selectingManData = ManData.GetData(GameMain.Instance.KasizukiMgr.GetNowManType());
				List<RoomData.Data> datas;
				if (!GameMain.Instance.CharacterMgr.status.lockNTRPlay)
				{
					datas = RoomData.GetDatas(delegate(RoomData.Data data)
					{
						if (!data.isExistUpwardRoom)
						{
							return false;
						}
						if (data.isOnlyNTR)
						{
							return false;
						}
						MaidMiniManagementCtrl maidMiniManagementCtrl = this.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
						foreach (PlayData.Data data2 in data.GetPlayDatas())
						{
							if (data2.IsCorrectPersonal(maidMiniManagementCtrl.selectMaid))
							{
								return true;
							}
						}
						return false;
					});
				}
				else
				{
					datas = RoomData.GetDatas(delegate(RoomData.Data data)
					{
						RoomData.Data subordinateRoomData = data.GetSubordinateRoomData();
						if (subordinateRoomData != null)
						{
							return false;
						}
						if (!data.enableManTypeDic[ManDataType.主人公])
						{
							return false;
						}
						if (!data.isEnableNTR && !data.isOnlyNTR)
						{
							return false;
						}
						List<PlayData.Data> playDatas = data.GetPlayDatas();
						for (int i = 0; i < playDatas.Count; i++)
						{
							if (playDatas[i].enableManTypeDic[ManDataType.主人公])
							{
								return true;
							}
						}
						return false;
					});
				}
				comp.OpenRoomList(datas, selectingRoomData);
				if (selectingRoomData != null)
				{
					comp.onClickRoom(selectingRoomData);
				}
				actResetDescriptionWindow();
				actSetOKButtonEnable(selectingRoomData, selectingManData, selectingPlayData);
			}));
			KasizukiPlayInfoCtrl comp6 = comp;
			comp6.onClickRoom = (Action<RoomData.Data>)Delegate.Combine(comp6.onClickRoom, new Action<RoomData.Data>(delegate(RoomData.Data roomData)
			{
				selectingRoomData = roomData;
				comp.OpenManList(ManData.GetAllDatas(true, true), selectingManData, delegate(UIWFTabButton item, ManData.Data data)
				{
					bool flag = false;
					MaidMiniManagementCtrl maidMiniManagementCtrl = this.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
					foreach (PlayData.Data data2 in selectingRoomData.GetPlayDatas())
					{
						if (data2.enableManTypeDic[data.manType] && data2.IsCorrectPersonal(maidMiniManagementCtrl.selectMaid))
						{
							flag = true;
							break;
						}
					}
					if (!flag && item.isSelected)
					{
						item.SetSelect(false);
					}
					item.gameObject.SetActive(flag);
				});
				List<PlayData.Data> datas = PlayData.GetDatas(delegate(PlayData.Data data)
				{
					if (data.roomID != selectingRoomData.ID)
					{
						return false;
					}
					if (!data.enableManTypeDic[selectingManData.manType])
					{
						return false;
					}
					MaidMiniManagementCtrl maidMiniManagementCtrl = this.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
					return data.IsCorrectPersonal(maidMiniManagementCtrl.selectMaid);
				});
				comp.OpenPlayList(datas, null);
				actResetDescriptionWindow();
				selectingPlayData = null;
				actSetOKButtonEnable(selectingRoomData, selectingManData, selectingPlayData);
			}));
			KasizukiPlayInfoCtrl comp2 = comp;
			comp2.onClickMan = (Action<ManData.Data>)Delegate.Combine(comp2.onClickMan, new Action<ManData.Data>(delegate(ManData.Data manData)
			{
				selectingManData = manData;
				List<PlayData.Data> datas = PlayData.GetDatas((PlayData.Data data) => data.roomID == selectingRoomData.ID && data.enableManTypeDic[selectingManData.manType]);
				comp.OpenPlayList(datas, null);
				actResetDescriptionWindow();
				selectingPlayData = null;
				actSetOKButtonEnable(selectingRoomData, selectingManData, selectingPlayData);
			}));
			KasizukiPlayInfoCtrl comp3 = comp;
			comp3.onClickPlay = (Action<PlayData.Data>)Delegate.Combine(comp3.onClickPlay, new Action<PlayData.Data>(delegate(PlayData.Data playData)
			{
				selectingPlayData = playData;
				actSetDescriptionWindow(selectingPlayData);
				actSetOKButtonEnable(selectingRoomData, selectingManData, selectingPlayData);
			}));
			KasizukiPlayInfoCtrl comp4 = comp;
			comp4.onHoverPlay = (Action<PlayData.Data>)Delegate.Combine(comp4.onHoverPlay, new Action<PlayData.Data>(delegate(PlayData.Data playData)
			{
				actSetDescriptionWindow(playData);
			}));
			KasizukiPlayInfoCtrl comp5 = comp;
			comp5.onOutPlay = (Action<PlayData.Data>)Delegate.Combine(comp5.onOutPlay, new Action<PlayData.Data>(delegate(PlayData.Data playData)
			{
				if (selectingPlayData == null)
				{
					actResetDescriptionWindow();
				}
				else
				{
					actSetDescriptionWindow(selectingPlayData);
				}
			}));
		}

		protected void OnClickButton()
		{
			NGUIWindow nguiwindow = this.m_SwitchingWindowDic["メインメニュー"];
			List<UnityEngine.Object> values = nguiwindow.cachedObjectDic.Values;
			if (!values.Contains(UIButton.current))
			{
				NDebug.Warning(string.Format("クリックされたボタン名に対応するボタンがありません\n{0}", UIButton.current.name));
			}
			string name = UIButton.current.name;
			if (name == "男選択")
			{
				this.OpenSwitchingWindow("男選択", false);
			}
			else if (name == "クラブ")
			{
				if (!this.CheckPlayableRoom())
				{
					GameMain.Instance.SysDlg.Show("利用可能な施設がありません。", SystemDialog.TYPE.OK, null, null);
					return;
				}
				if (!this.CheckPlayableMaid())
				{
					GameMain.Instance.SysDlg.Show("プレイ可能なメイドがいません。", SystemDialog.TYPE.OK, null, null);
					return;
				}
				this.OnSelectRoom(null);
				this.OpenSwitchingWindow("部屋選択", false);
				(this.m_SwitchingWindowDic["部屋選択"] as ClubRoomSelectCtrl).SetData();
			}
			else if (name == "セーブ")
			{
				this.OpenSwitchingWindow("セーブロード", false);
				KasizukiSaveAndLoadCtrl component = this.m_SwitchingWindowDic["セーブロード"].GetComponent<KasizukiSaveAndLoadCtrl>();
				component.Open(SaveAndLoadMgr.ViewType.Save, true);
			}
			else if (name == "ロード")
			{
				this.OpenSwitchingWindow("セーブロード", false);
				KasizukiSaveAndLoadCtrl component2 = this.m_SwitchingWindowDic["セーブロード"].GetComponent<KasizukiSaveAndLoadCtrl>();
				component2.Open(SaveAndLoadMgr.ViewType.Load, true);
			}
			else if (name == "ヒロイン")
			{
				this.OpenSwitchingWindow("メイド情報", false);
				this.SetMaidInfoWindowParameter("ヒロイン情報");
			}
			else if (name == "フリー")
			{
				this.OpenSwitchingWindow("メイド情報", false);
				this.SetMaidInfoWindowParameter("フリーモード");
			}
			else if (name == "タイトルに戻る")
			{
				GameMain.Instance.SysDlg.Show("保存されていない情報は失われます。\nタイトルに戻りますか？", SystemDialog.TYPE.YES_NO, delegate
				{
					GameMain.Instance.SysDlg.Close();
					GameMain.Instance.LoadScene("SceneToTitle");
					GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
				}, delegate
				{
					GameMain.Instance.SysDlg.Close();
				});
			}
		}

		public void OpenSwitchingWindow(string name, bool isImmediate = false)
		{
			Dictionary<string, NGUIWindow> switchingWindowDic = this.m_SwitchingWindowDic;
			if (switchingWindowDic == null)
			{
				NDebug.Assert("ウィンドウの配列にnullが指定されました", false);
			}
			if (!switchingWindowDic.ContainsKey(name))
			{
				NDebug.Assert(string.Format("ウィンドウの配列には「{0}」のキーが存在しません", name), false);
			}
			if (name == "メインメニュー")
			{
				MaidMiniManagementCtrl maidMiniManagementCtrl = base.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
				maidMiniManagementCtrl.selectMaid = null;
			}
			foreach (KeyValuePair<string, NGUIWindow> keyValuePair in switchingWindowDic)
			{
				if (keyValuePair.Key == name)
				{
					if (isImmediate)
					{
						keyValuePair.Value.Open(0.01f, null);
					}
					else
					{
						keyValuePair.Value.Open(0.25f, null);
					}
				}
				else if (isImmediate)
				{
					keyValuePair.Value.Close(0.01f, null);
				}
				else
				{
					keyValuePair.Value.Close(0.25f, null);
				}
			}
		}

		public void CloseSwitchingWindowAll(bool isImmediate = false)
		{
			Dictionary<string, NGUIWindow> switchingWindowDic = this.m_SwitchingWindowDic;
			if (switchingWindowDic == null)
			{
				NDebug.Assert("ウィンドウの配列にnullが指定されました", false);
			}
			foreach (KeyValuePair<string, NGUIWindow> keyValuePair in switchingWindowDic)
			{
				if (isImmediate)
				{
					keyValuePair.Value.Close(0.01f, null);
				}
				else
				{
					keyValuePair.Value.Close(0.25f, null);
				}
			}
		}

		private bool CheckPlayableRoom()
		{
			ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType();
			foreach (RoomData.Data data in RoomData.GetAllDatas(true))
			{
				if (data.enableManTypeDic[nowManType])
				{
					if (data.IsExistFacility())
					{
						return true;
					}
				}
			}
			return false;
		}

		private bool CheckPlayableMaid()
		{
			ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType();
			foreach (RoomData.Data data in RoomData.GetAllDatas(true))
			{
				if (data.enableManTypeDic[nowManType])
				{
					if (data.IsExistFacility())
					{
						foreach (PlayData.Data data2 in data.GetPlayDatas())
						{
							if (data2.enableManTypeDic[nowManType])
							{
								List<Maid> filteringPlayDataMaidArray = data2.GetFilteringPlayDataMaidArray(nowManType);
								if (filteringPlayDataMaidArray != null && filteringPlayDataMaidArray.Count > 0)
								{
									return true;
								}
							}
						}
					}
				}
			}
			return false;
		}

		private void OnSelectRoom(RoomData.Data roomData)
		{
			KasizukiMainMenu.m_NowSelectingRoom = roomData;
			this.m_SwitchingWindowDic["部屋選択"].GetCache<UIButton>("OK").isEnabled = (KasizukiMainMenu.m_NowSelectingRoom != null);
		}

		private void OnOKRoom()
		{
			if (KasizukiMainMenu.m_NowSelectingRoom == null)
			{
				NDebug.Warning("現在選択している部屋の情報がnullでした");
				return;
			}
			MaidMiniManagementCtrl maidMiniManagementCtrl = base.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
			KasizukiCharacterSelectCtrl charaSelect = maidMiniManagementCtrl.charaSelectMgr;
			maidMiniManagementCtrl.selectMaid = null;
			charaSelect.callbackGetMaidList = delegate()
			{
				ManDataType nowManType = (ManDataType)GameMain.Instance.KasizukiMgr.GetNowManType();
				List<PlayData.Data> playDatas = KasizukiMainMenu.m_NowSelectingRoom.GetPlayDatas();
				List<PlayData.Data> list = new List<PlayData.Data>();
				foreach (PlayData.Data data in playDatas)
				{
					if (data.enableManTypeDic[nowManType])
					{
						list.Add(data);
					}
				}
				HashSet<Maid> hashSet = new HashSet<Maid>();
				foreach (PlayData.Data data2 in list)
				{
					List<Maid> filteringPlayDataMaidArray = data2.GetFilteringPlayDataMaidArray(nowManType);
					foreach (Maid item in filteringPlayDataMaidArray)
					{
						hashSet.Add(item);
					}
				}
				charaSelect.callbackGetMaidList = null;
				return new List<Maid>(hashSet);
			};
			GameMain.Instance.KasizukiMgr.SetSystemData<int>(SystemDataType.選択部屋, KasizukiMainMenu.m_NowSelectingRoom.ID, true);
			this.OpenSwitchingWindow("メイド情報", false);
			this.SetMaidInfoWindowParameter("ヒロイン選択");
		}

		private void SetMaidInfoWindowParameter(string openType)
		{
			MaidMiniManagementCtrl window = base.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
			window.Open();
			window.Call();
			if (openType == "ヒロイン情報")
			{
				window.onClickOK = delegate()
				{
					this.OpenSwitchingWindow("メインメニュー", false);
				};
				window.buttonDic["OK"].isEnabled = true;
				window.buttonDic["Cancel"].gameObject.SetActive(false);
				if (window.selectMaid == null)
				{
					window.CloseSwitchingWindowAll(true);
				}
				window.UpdateMaidInfoButtonEnable(window.selectMaid != null, true);
				MaidMiniStatusCtrl window4 = window.GetWindow<MaidMiniStatusCtrl>("ステータス");
				Collider component = window4.GetCache<UIInput>("FreeComment").GetComponent<Collider>();
				component.enabled = true;
				window4.GetCache<MaidAppealComment>("Appeal").SetEnableEditing(true);
				window.GetWindow<NGUIWindow>("パラメータロック").transform.localScale = Vector3.one;
			}
			else if (openType == "ヒロイン選択")
			{
				window.onClickOK = delegate()
				{
					this.StartSenario(window.selectMaid, KasizukiMainMenu.m_NowSelectingRoom);
				};
				window.onClickCancel = delegate()
				{
					this.OpenSwitchingWindow("部屋選択", false);
					this.OnSelectRoom(null);
					(this.m_SwitchingWindowDic["部屋選択"] as ClubRoomSelectCtrl).SetData();
				};
				window.buttonDic["OK"].isEnabled = (window.selectMaid != null);
				window.buttonDic["Cancel"].gameObject.SetActive(true);
				if (window.selectMaid == null)
				{
					window.CloseSwitchingWindowAll(true);
				}
				window.UpdateMaidInfoButtonEnable(window.selectMaid != null, true);
				MaidMiniStatusCtrl window2 = window.GetWindow<MaidMiniStatusCtrl>("ステータス");
				Collider component2 = window2.GetCache<UIInput>("FreeComment").GetComponent<Collider>();
				component2.enabled = false;
				window2.GetCache<MaidAppealComment>("Appeal").SetEnableEditing(false);
				window.GetWindow<NGUIWindow>("パラメータロック").transform.localScale = Vector3.one;
			}
			else if (openType == "フリーモード")
			{
				window.onClickOK = delegate()
				{
					this.OpenSwitchingWindow("施設情報", false);
					UIButton cache = this.m_SwitchingWindowDic["施設情報"].GetCache<UIButton>("Cancel");
					EventDelegate.Set(cache.onClick, delegate()
					{
						this.OpenSwitchingWindow("メイド情報", false);
						this.SetMaidInfoWindowParameter("フリーモード");
					});
				};
				window.onClickCancel = delegate()
				{
					this.OpenSwitchingWindow("メインメニュー", false);
				};
				window.buttonDic["OK"].isEnabled = (window.selectMaid != null);
				window.buttonDic["Cancel"].gameObject.SetActive(true);
				if (window.selectMaid == null)
				{
					window.CloseSwitchingWindowAll(true);
				}
				window.UpdateMaidInfoButtonEnable(window.selectMaid != null, true);
				MaidMiniStatusCtrl window3 = window.GetWindow<MaidMiniStatusCtrl>("ステータス");
				Collider component3 = window3.GetCache<UIInput>("FreeComment").GetComponent<Collider>();
				component3.enabled = false;
				window3.GetCache<MaidAppealComment>("Appeal").SetEnableEditing(false);
				window.GetWindow<NGUIWindow>("パラメータロック").transform.localScale = Vector3.zero;
			}
			else
			{
				NDebug.Warning(string.Format("メイド情報ウィンドウのレイアウト設定の文字列が対応していません\n渡された文字列：{0}", openType));
			}
			KasizukiMainMenu.m_BackUpBeforeMaidInfoParameter = openType;
		}

		private void StartSenario(Maid targetMaid, RoomData.Data targetRoom)
		{
			ManData.Data data = ManData.GetData(GameMain.Instance.KasizukiMgr.GetNowManType());
			Debug.LogFormat("傅きモードのシナリオを開始します\r\n選択状態↓\r\nメイド：{0}\r\n選択した部屋：{1}\r\n選択した男：{2}\r\n", new object[]
			{
				targetMaid.status.fullNameJpStyle,
				targetRoom.drawName,
				data.drawName
			});
			PlayData.Data optimalConditionData = PlayData.GetOptimalConditionData(targetMaid, targetRoom, data.manType);
			string scenarioFileNameReplace = optimalConditionData.GetScenarioFileNameReplace(targetMaid);
			Debug.LogFormat("呼び出すシナリオは「{0}」になりました", new object[]
			{
				scenarioFileNameReplace
			});
			if (!GameUty.FileSystem.IsExistentFile(scenarioFileNameReplace + ".ks"))
			{
				NDebug.Warning(string.Format("シナリオファイル「{0}」が見つかりません。\nシナリオ呼び出しは行いません。", scenarioFileNameReplace + ".ks"));
				return;
			}
			SceneKasizukiMainMenu sceneKasizukiMainMenu = base.parent_mgr as SceneKasizukiMainMenu;
			if (!sceneKasizukiMainMenu.moveScreen.IsExistNextLabel())
			{
				sceneKasizukiMainMenu.moveScreen.SetNextLabel(sceneKasizukiMainMenu.strScriptReturnLabel);
			}
			this.Finish();
		}

		private void StartFree(Maid targetMaid, RoomData.Data targetRoom, ManData.Data targetMan, PlayData.Data targetPlay)
		{
			if (!this.CheckCorrectPlayData(targetMaid, targetMan, targetPlay))
			{
				return;
			}
			Debug.LogFormat("傅きモードの回想を開始します\r\n選択状態↓\r\nメイド：{0}\r\n選択した部屋：{1}\r\n選択した男：{2}\r\n選択したプレイ情報：{3}\r\n", new object[]
			{
				targetMaid.status.fullNameJpStyle,
				targetRoom.drawName,
				targetMan.drawName,
				targetPlay.drawName
			});
			string scenarioFileNameReplace = targetPlay.GetScenarioFileNameReplace(targetMaid);
			Debug.LogFormat("呼び出すシナリオは「{0}」になりました", new object[]
			{
				scenarioFileNameReplace
			});
			if (!GameUty.FileSystem.IsExistentFile(scenarioFileNameReplace + ".ks"))
			{
				NDebug.Warning(string.Format("シナリオファイル「{0}」が見つかりません。\nシナリオ呼び出しは行いません。", scenarioFileNameReplace + ".ks"));
				return;
			}
			Debug.Log("システムデータのフラグを一時的に書き換え");
			KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
			kasizukiMgr.SetSystemData<int>(SystemDataType.選択部屋, targetRoom.ID, false);
			kasizukiMgr.SetNowManType(targetMan.ID);
			GameMain.Instance.ScriptMgr.EvalScript("tf['傅き再生_ファイル名'] = '" + scenarioFileNameReplace + "';");
			SceneKasizukiMainMenu sceneKasizukiMainMenu = base.parent_mgr as SceneKasizukiMainMenu;
			if (!sceneKasizukiMainMenu.moveScreen.IsExistNextLabel())
			{
				sceneKasizukiMainMenu.moveScreen.SetNextLabel(sceneKasizukiMainMenu.strScriptReturnLabelFree);
			}
			this.Finish();
		}

		private bool CheckCorrectPlayData(Maid targetMaid, ManData.Data targetMan, PlayData.Data targetPlay)
		{
			NDebug.AssertNull(targetMaid != null);
			NDebug.AssertNull(targetMan != null);
			NDebug.AssertNull(targetPlay != null);
			if (!targetPlay.IsCorrectPersonal(targetMaid))
			{
				GameMain.Instance.SysDlg.Show("メイドの性格が対応していません。", SystemDialog.TYPE.OK, null, null);
				return false;
			}
			return true;
		}

		protected override void OnFinish()
		{
			this.CloseSwitchingWindowAll(true);
			KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
			Maid man = kasizukiMgr.GetMan();
			kasizukiMgr.SetManModel(man, (ManDataType)kasizukiMgr.GetNowManType());
			kasizukiMgr.UpdateManModel(man, null);
			man.Visible = false;
			CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
			MaidMiniManagementCtrl maidMiniManagementCtrl = base.parent_mgr.children_dic["MaidInfo"] as MaidMiniManagementCtrl;
			characterMgr.SetActiveMaid(maidMiniManagementCtrl.selectMaid, 0);
			maidMiniManagementCtrl.selectMaid.Visible = true;
			maidMiniManagementCtrl.selectMaid.AllProcPropSeqStart();
			base.StartCoroutine(this.CoroutineWaitPropSeq(maidMiniManagementCtrl.selectMaid, delegate
			{
				SceneKasizukiMainMenu sceneKasizukiMainMenu = base.parent_mgr as SceneKasizukiMainMenu;
				if (!string.IsNullOrEmpty(sceneKasizukiMainMenu.moveScreen.next_label))
				{
					sceneKasizukiMainMenu.CallScreen("Move");
				}
			}));
		}

		private IEnumerator CoroutineWaitPropSeq(Maid target, Action callback)
		{
			while (target.IsBusy)
			{
				yield return null;
			}
			if (callback != null)
			{
				callback();
			}
			yield break;
		}

		private static string m_BackUpBeforeMaidInfoParameter = string.Empty;

		private const string STR_MESSAGE_NOTHING_ROOM = "利用可能な施設がありません。";

		private const string STR_MESSAGE_NOTHING_MAID = "プレイ可能なメイドがいません。";

		private const string STR_MESSAGE_END = "保存されていない情報は失われます。\nタイトルに戻りますか？";

		private const string STR_MESSAGE_INCORRECT_PERSONAL = "メイドの性格が対応していません。";

		private static RoomData.Data m_NowSelectingRoom;

		private Dictionary<string, NGUIWindow> m_SwitchingWindowDic;
	}
}
