using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; using UnityEngine.UI; using wf; namespace PrivateMaidMode { public class PrivateCharaSelectMain : WfScreenChildren { public override void Awake() { base.Awake(); this.charaContent = UTY.GetChildObject(base.root_obj, "CharacterSelect/uGUI Scroll View/Viewport/Content", false); this.charaSelectMgr = UTY.GetChildObject(base.root_obj, "CharacterSelect/uGUI Scroll View/Viewport", false).GetComponent(); this.eventListVisibleCheckBox.onClick.Add(delegate(WFCheckBox checkBox) { this.SetEventListVisible(checkBox.check); }); this.dayTalkToggle.onValueChanged.AddListener(delegate(bool call) { this.SetDayTalkToggle(call); }); this.nightTalkToggle.onValueChanged.AddListener(delegate(bool call) { this.SetNightTalkToggle(call); }); this.hEventToggle.onValueChanged.AddListener(delegate(bool call) { this.SetHEventToggle(call); }); } protected override void OnCall() { GameMain.Instance.MainLight.Reset(); GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true); GameMain.Instance.SoundMgr.VoiceStopAll(); this.m_selectMaid = null; this.m_selectBG = null; this.m_selectLocation = null; this.charaMgr = GameMain.Instance.CharacterMgr; this.isDaily = this.charaMgr.status.isDaytime; this.dayTalkToggle.isOn = GameMain.Instance.CMSystem.SConfig.PrivateModeSettingDayTalkEnabled; this.nightTalkToggle.isOn = GameMain.Instance.CMSystem.SConfig.PrivateModeSettingNightTalkEnabled; this.hEventToggle.isOn = GameMain.Instance.CMSystem.SConfig.PrivateModeSettingHEventEnabled; this.charaSelectMgr.SetCallBackOnSelect(new uGUICharacterSelectManager.CallBackOnSelect(this.SelectCharacter)); uGUICharacterSelectManager uGUICharacterSelectManager = this.charaSelectMgr; if (PrivateCharaSelectMain.<>f__mg$cache0 == null) { PrivateCharaSelectMain.<>f__mg$cache0 = new uGUICharacterSelectManager.CallBackMaidList(uGUICharacterSelectManager.PrivateMaidList); } uGUICharacterSelectManager.SetCallBackMaidList(PrivateCharaSelectMain.<>f__mg$cache0); this.charaSelectMgr.Create(uGUICharacterSelectManager.Type.Private); this.buttonList = this.charaSelectMgr.GetButtonList(); this.maidList = this.charaSelectMgr.GetMaidList(); this.buttonList[0].onSelectEvent.Add(new EventDelegate(new EventDelegate.Callback(this.OnSelectNoSelect))); if (this.maidList.Count > 0) { this.CreateRandomButton(this.buttonList[1], PrivateCharaSelectMain.SelectType.Maid); for (int i = 2; i < this.buttonList.Count; i++) { this.buttonList[i].onSelectEvent.Add(new EventDelegate(new EventDelegate.Callback(this.OnClickSelectChara))); } if (PrivateModeMgr.Instance.isRandomMaid) { this.charaContent.GetComponent().Select(this.buttonList[1]); } } this.CreateBGPanel(); this.CreateBGPosPanel(); GameMain.Instance.CharacterMgr.DeactivateCharaAll(); GameMain.Instance.CharacterMgr.DeactivateMaid(0); if (PrivateModeMgr.Instance.LoadPrivateMaid(this.isDaily)) { this.m_selectMaid = PrivateModeMgr.Instance.PrivateMaid; this.m_selectBG = PrivateModeMgr.Instance.SelectBG; this.m_selectLocation = PrivateModeMgr.Instance.SelectLocation; this.SetSelectAll(); this.SetEventListVisible(GameMain.Instance.CMSystem.SConfig.PrivateModeSettingEventListVisible); this.eventSelectPanel.Setup(null, null); } else { uGUITabPanel component = this.charaContent.GetComponent(); component.Select(this.buttonList[0]); } uGUITutorialPanel.OpenTutorial("ScenePrivate", null, false); } public void SetPrivateSettingManager(PrivateSettingManager mgr) { this.privateManager = mgr; } private void CreateBGPanel() { GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BG); this.ResetChildren(parentPanel.transform); this.bgList = new List(); using (List.Enumerator enumerator = DataBase.GetAllDatas(true).GetEnumerator()) { while (enumerator.MoveNext()) { DataBase.Data data = enumerator.Current; if (!this.bgList.Exists((DataBase.BG bgElm) => bgElm.uniqueName == data.bgData.uniqueName)) { this.bgList.Add(data.bgData); } } } this.enabledBGList = new List(); for (int i = 0; i < this.bgList.Count; i++) { GameObject f_goParent = Utility.CreatePrefab(parentPanel, "ScenePrivate/SelectButton", true); uGUITabButton component = UTY.GetChildObject(f_goParent, "Plate", false).GetComponent(); component.onSelectEvent.Add(new EventDelegate(new EventDelegate.Callback(this.OnSelectBG))); if (!this.bgList[i].enabled) { component.interactable = false; } else { this.enabledBGList.Add(this.bgList[i]); } Text component2 = UTY.GetChildObject(f_goParent, "Text", false).GetComponent(); component2.text = this.bgList[i].drawName; } GameObject f_goParent2 = Utility.CreatePrefab(parentPanel, "ScenePrivate/RandomButton", true); uGUITabButton component3 = UTY.GetChildObject(f_goParent2, "Plate", false).GetComponent(); this.CreateRandomButton(component3, PrivateCharaSelectMain.SelectType.BG); parentPanel.GetComponent().UpdateChildren(); if (PrivateModeMgr.Instance.isRandomBG) { parentPanel.GetComponent().Select(component3); } else { DataBase.BG bgdata = DataBase.GetBGData("執務室"); int index = this.bgList.IndexOf(bgdata); uGUITabButton component4 = UTY.GetChildObject(parentPanel.transform.GetChild(index).gameObject, "Plate", false).GetComponent(); parentPanel.GetComponent().Select(component4); } } private void CreateBGPosPanel() { GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos); this.ResetChildren(parentPanel.transform); for (int i = 0; i < this.m_selectBG.locations.Length; i++) { GameObject f_goParent = Utility.CreatePrefab(parentPanel, "ScenePrivate/SelectButton", true); uGUITabButton component = UTY.GetChildObject(f_goParent, "Plate", false).GetComponent(); component.onSelectEvent.Add(new EventDelegate(new EventDelegate.Callback(this.OnSelectBGPos))); Text component2 = UTY.GetChildObject(f_goParent, "Text", false).GetComponent(); component2.text = this.m_selectBG.locations[i].drawName; } GameObject f_goParent2 = Utility.CreatePrefab(parentPanel, "ScenePrivate/RandomButton", true); uGUITabButton component3 = UTY.GetChildObject(f_goParent2, "Plate", false).GetComponent(); this.CreateRandomButton(component3, PrivateCharaSelectMain.SelectType.BGPos); parentPanel.GetComponent().UpdateChildren(); bool flag = false; if (PrivateModeMgr.Instance.isRandomBG) { parentPanel.GetComponent().Select(component3); this.SetCanSelectButton(parentPanel.GetComponent(), false); flag = true; } else if (PrivateModeMgr.Instance.isRandomLocation) { parentPanel.GetComponent().Select(component3); flag = true; } else if (this.m_selectLocation != null) { foreach (DataBase.BG.Location location in this.m_selectBG.locations) { if (location == this.m_selectLocation) { this.SetSelect(PrivateCharaSelectMain.SelectType.BGPos); flag = true; break; } } } if (!flag) { uGUITabButton component4 = UTY.GetChildObject(parentPanel.transform.GetChild(0).gameObject, "Plate", false).GetComponent(); parentPanel.GetComponent().Select(component4); } } private void CreateRandomButton(uGUITabButton button, PrivateCharaSelectMain.SelectType type) { EventDelegate eventDelegate = new EventDelegate(this, "OnSelectRandom"); if (type != PrivateCharaSelectMain.SelectType.BG) { if (type != PrivateCharaSelectMain.SelectType.BGPos) { if (type == PrivateCharaSelectMain.SelectType.Maid) { eventDelegate.parameters[0].value = PrivateCharaSelectMain.SelectType.Maid; } } else { eventDelegate.parameters[0].value = PrivateCharaSelectMain.SelectType.BGPos; } } else { eventDelegate.parameters[0].value = PrivateCharaSelectMain.SelectType.BG; } button.onSelectEvent.Add(eventDelegate); } private void ResetChildren(Transform parentTrans) { for (int i = 0; i < parentTrans.childCount; i++) { UnityEngine.Object.Destroy(parentTrans.GetChild(i).gameObject); } parentTrans.DetachChildren(); } private void ResetSetting() { GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BG); DataBase.BG bgdata = DataBase.GetBGData("執務室"); int index = this.bgList.IndexOf(bgdata); uGUITabButton component = UTY.GetChildObject(parentPanel.transform.GetChild(index).gameObject, "Plate", false).GetComponent(); parentPanel.GetComponent().Select(component); parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos); uGUITabButton component2 = UTY.GetChildObject(parentPanel.transform.GetChild(0).gameObject, "Plate", false).GetComponent(); parentPanel.GetComponent().Select(component2); this.ResetCamera(); } private void OnSelectNoSelect() { this.charaMgr.DeactivateMaidAll(); this.m_selectMaid = null; PrivateModeMgr.Instance.isRandomMaid = false; this.bgPanel.SetActive(false); this.bgPositionPanel.SetActive(false); this.ResetSetting(); this.SetEventListVisible(false); this.eventListVisibleCheckBox.gameObject.SetActive(false); } private void OnClickSelectChara() { PrivateModeMgr.Instance.isRandomMaid = false; } private void SelectCharacter(Maid select_maid) { this.bgPanel.SetActive(true); this.bgPositionPanel.SetActive(true); if (select_maid != null && this.m_selectMaid != select_maid) { GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color)); this.m_selectMaid = select_maid; this.charaMgr.SetActiveMaid(this.m_selectMaid, 0); this.m_selectMaid.Visible = true; base.StartCoroutine(this.WaitCharaLoad()); this.SetEventListVisible(true); this.eventListVisibleCheckBox.gameObject.SetActive(true); this.eventSelectPanel.Setup(this.m_selectMaid, this.m_selectBG); } } private IEnumerator WaitCharaLoad() { while (this.charaMgr.IsBusy()) { yield return null; } yield return null; yield return null; this.m_selectBG.Apply(this.isDaily); GameMain.Instance.ScriptMgr.is_motion_blend = false; this.m_selectLocation.LoadScript(); GameMain.Instance.ScriptMgr.is_motion_blend = true; GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color)); yield break; } private void OnSelectBG() { uGUITabButton selectButton = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BG).GetComponent().GetSelectButton(); DataBase.BG bg = this.bgList[selectButton.transform.parent.GetSiblingIndex()]; if (bg != null && this.m_selectBG != bg) { this.SelectBG(bg); } PrivateModeMgr.Instance.isRandomBG = false; GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos); this.SetCanSelectButton(parentPanel.GetComponent(), true); } private void SelectBG(DataBase.BG bg) { if (bg == null) { return; } GameMain.Instance.MainCamera.FadeOut(0.5f, false, null, true, default(Color)); this.m_selectBG = bg; this.m_selectBG.Apply(this.isDaily); this.CreateBGPosPanel(); this.eventSelectPanel.Setup(this.m_selectMaid, this.m_selectBG); GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color)); } private void OnSelectBGPos() { uGUITabButton selectButton = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos).GetComponent().GetSelectButton(); DataBase.BG.Location location = this.m_selectBG.locations[selectButton.transform.parent.GetSiblingIndex()]; if (location != null) { this.SelectBGPos(location); } PrivateModeMgr.Instance.isRandomLocation = false; } private void SelectBGPos(DataBase.BG.Location select_location) { GameMain.Instance.MainCamera.FadeOut(0.5f, false, null, true, default(Color)); this.m_selectLocation = select_location; if (this.m_selectMaid != null) { GameMain.Instance.ScriptMgr.is_motion_blend = false; this.m_selectLocation.LoadScript(); GameMain.Instance.ScriptMgr.is_motion_blend = true; } GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, true, true, default(Color)); } private void SetSelectAll() { this.SetSelect(PrivateCharaSelectMain.SelectType.Maid); this.SetSelect(PrivateCharaSelectMain.SelectType.BG); this.SetSelect(PrivateCharaSelectMain.SelectType.BGPos); } private void SetSelect(PrivateCharaSelectMain.SelectType type) { if (type != PrivateCharaSelectMain.SelectType.Maid) { if (type != PrivateCharaSelectMain.SelectType.BG) { if (type == PrivateCharaSelectMain.SelectType.BGPos) { if (this.m_selectLocation == null) { return; } if (PrivateModeMgr.Instance.isRandomLocation) { return; } GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos); this.Select(type, parentPanel); } } else { if (this.m_selectBG == null) { return; } if (PrivateModeMgr.Instance.isRandomBG) { this.CreateBGPosPanel(); return; } GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BG); this.Select(type, parentPanel); this.CreateBGPosPanel(); } } else { if (PrivateModeMgr.Instance.isRandomMaid) { return; } this.charaSelectMgr.SelectMaid(this.m_selectMaid); } } private void Select(PrivateCharaSelectMain.SelectType type, GameObject parentObj) { string a = null; if (type != PrivateCharaSelectMain.SelectType.BG) { if (type == PrivateCharaSelectMain.SelectType.BGPos) { a = this.m_selectLocation.drawName; } } else { a = this.m_selectBG.drawName; } uGUITabPanel component = parentObj.GetComponent(); Transform transform = parentObj.transform; for (int i = 0; i < transform.childCount; i++) { string text = UTY.GetChildObject(transform.GetChild(i).gameObject, "Text", false).GetComponent().text; if (a == text) { uGUITabButton component2 = UTY.GetChildObject(transform.GetChild(i).gameObject, "Plate", false).GetComponent(); component.Select(component2); return; } } } private void OnSelectRandom(PrivateCharaSelectMain.SelectType type) { if (type == PrivateCharaSelectMain.SelectType.Maid && this.maidList != null) { int index = UnityEngine.Random.Range(0, this.maidList.Count); this.SelectCharacter(this.maidList[index]); PrivateModeMgr.Instance.isRandomMaid = true; this.SetButtonTouch(this.GetParentPanel(PrivateCharaSelectMain.SelectType.Maid).GetComponent().GetSelectButton(), true); } if (type == PrivateCharaSelectMain.SelectType.BG && this.enabledBGList != null) { int index2 = UnityEngine.Random.Range(0, this.enabledBGList.Count); this.SelectBG(this.enabledBGList[index2]); PrivateModeMgr.Instance.isRandomBG = true; PrivateModeMgr.Instance.isRandomLocation = true; this.SetButtonTouch(this.GetParentPanel(PrivateCharaSelectMain.SelectType.BG).GetComponent().GetSelectButton(), true); GameObject parentPanel = this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos); uGUITabButton component = UTY.GetChildObject(parentPanel.transform.GetChild(parentPanel.transform.childCount - 1).gameObject, "Plate", false).GetComponent(); parentPanel.GetComponent().Select(component); } if (type == PrivateCharaSelectMain.SelectType.BGPos && this.m_selectBG != null) { int num = UnityEngine.Random.Range(0, this.m_selectBG.locations.Length); this.SelectBGPos(this.m_selectBG.locations[num]); PrivateModeMgr.Instance.isRandomLocation = true; if (PrivateModeMgr.Instance.isRandomBG) { this.SetCanSelectButton(this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos).GetComponent(), false); } this.SetButtonTouch(this.GetParentPanel(PrivateCharaSelectMain.SelectType.BGPos).GetComponent().GetSelectButton(), true); } } private void ResetCamera() { GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true); GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true); GameMain.Instance.MainCamera.SetDistance(1.6f, true); GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true); GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false); } private GameObject GetParentPanel(PrivateCharaSelectMain.SelectType type) { if (type == PrivateCharaSelectMain.SelectType.Maid) { if (this.charaContent != null) { this.charaContent = UTY.GetChildObject(base.root_obj, "CharacterSelect/uGUI Scroll View/Viewport/Content", false); } return this.charaContent; } if (type == PrivateCharaSelectMain.SelectType.BG) { return UTY.GetChildObject(this.bgPanel, "uGUI Scroll View/Viewport/Content", false); } if (type != PrivateCharaSelectMain.SelectType.BGPos) { return null; } return UTY.GetChildObject(this.bgPositionPanel, "uGUI Scroll View/Viewport/Content", false); } private void SetButtonTouch(uGUITabButton button, bool isActive) { button.GetComponent().enabled = isActive; button.maskObj.SetActive(!isActive); } private void SetCanSelectButton(uGUITabPanel parent, bool select) { for (int i = 0; i < parent.transform.childCount; i++) { uGUITabButton component = UTY.GetChildObject(parent.transform.GetChild(i).gameObject, "Plate", false).GetComponent(); if (component.maskObj != null) { component.maskObj.SetActive(!select); } } } private void SetEventListVisible(bool visible) { this.eventListVisibleCheckBox.check = visible; this.eventSelectPanel.gameObject.SetActive(visible); GameMain.Instance.CMSystem.SConfig.PrivateModeSettingEventListVisible = visible; } private void SetDayTalkToggle(bool value) { this.dayTalkToggle.isOn = value; this.SetToggleColor(this.dayTalkToggle, value); GameMain.Instance.CMSystem.SConfig.PrivateModeSettingDayTalkEnabled = value; } private void SetNightTalkToggle(bool value) { this.nightTalkToggle.isOn = value; this.SetToggleColor(this.nightTalkToggle, value); GameMain.Instance.CMSystem.SConfig.PrivateModeSettingNightTalkEnabled = value; } private void SetHEventToggle(bool value) { this.hEventToggle.isOn = value; this.SetToggleColor(this.hEventToggle, value); GameMain.Instance.CMSystem.SConfig.PrivateModeSettingHEventEnabled = value; } private void SetToggleColor(Toggle toggle, bool value) { ColorBlock colors = toggle.colors; if (value) { colors.normalColor = Color.white; colors.highlightedColor = Color.white; } else { colors.normalColor = Color.gray; colors.highlightedColor = Color.gray; } toggle.colors = colors; } public void OnClickOKButton() { PrivateModeMgr.Instance.SetPrivateMaid(this.m_selectMaid); PrivateModeMgr.Instance.SetPrivateBG(this.m_selectBG); PrivateModeMgr.Instance.SetPrivateLocation(this.m_selectLocation); this.Finish(); } protected override void OnFinish() { if (this.privateManager.MoveScreen.IsExistNextFile()) { this.privateManager.CallScreen("Move"); } } [SerializeField] private PrivateEventSelectPanel eventSelectPanel; [SerializeField] private WFCheckBox eventListVisibleCheckBox; [SerializeField] private Toggle dayTalkToggle; [SerializeField] private Toggle nightTalkToggle; [SerializeField] private Toggle hEventToggle; private Maid m_selectMaid; private DataBase.BG m_selectBG; private DataBase.BG.Location m_selectLocation; private PrivateSettingManager privateManager; private CharacterMgr charaMgr; private uGUICharacterSelectManager charaSelectMgr; private List buttonList; private List maidList; private List bgList; private List enabledBGList; private bool isDaily; private GameObject charaContent; [SerializeField] private GameObject bgPanel; [SerializeField] private GameObject bgPositionPanel; [CompilerGenerated] private static uGUICharacterSelectManager.CallBackMaidList <>f__mg$cache0; public enum SelectType { Maid, BG, BGPos } } }