using System; using System.Collections; using System.Collections.Generic; using MaidStatus; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class VRVIPMenu : MonoBehaviour { private void Update() { for (int i = 0; i < this.m_VIPElementDataArray.Count; i++) { VRVIPMenu.ElementData elementData = this.m_VIPElementDataArray[i]; if (elementData.isEnable) { MaskableGraphic[] componentsInChildren = elementData.Element.GetComponentsInChildren(); Color color = Color.white; if (elementData.isPointerDown) { color *= 0.78f; color.a = 1f; for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].CrossFadeColor(color, 0.1f, false, true); } return; } if (elementData.isPointerStay) { for (int k = 0; k < componentsInChildren.Length; k++) { componentsInChildren[k].CrossFadeColor(color, 0.1f, false, true); } } else { color *= 0.75f; color.a = 1f; for (int l = 0; l < componentsInChildren.Length; l++) { componentsInChildren[l].CrossFadeColor(color, 0.1f, false, true); } } } } } private void UpdateVIPUI() { this.m_PrefabElement.SetActive(false); string text = "vrcom_vip.nei"; if (!GameUty.FileSystem.IsExistentFile(text)) { NDebug.Assert("表がありません。" + text, false); } using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text)) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, text + "\nopen failed."); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { int num = 0; int cellAsInteger = csvParser.GetCellAsInteger(num++, i); string cellAsString = csvParser.GetCellAsString(num++, i); string cellAsString2 = csvParser.GetCellAsString(num++, i); string cellAsString3 = csvParser.GetCellAsString(num++, i); string cellAsString4 = csvParser.GetCellAsString(num++, i); string cellAsString5 = csvParser.GetCellAsString(num++, i); string cellAsString6 = csvParser.GetCellAsString(num++, i); string cellAsString7 = csvParser.GetCellAsString(num++, i); string cellAsString8 = csvParser.GetCellAsString(num++, i); string cellAsString9 = csvParser.GetCellAsString(num++, i); string scriptName = csvParser.GetCellAsString(num++, i); string cellAsString10 = csvParser.GetCellAsString(num++, i); string cellAsString11 = csvParser.GetCellAsString(num++, i); string cellAsString12 = csvParser.GetCellAsString(num++, i); string cellAsString13 = csvParser.GetCellAsString(num++, i); string cellAsString14 = csvParser.GetCellAsString(num++, i); if (string.IsNullOrEmpty(cellAsString10) || GameMain.Instance.CharacterMgr.status.GetFlag(cellAsString10) > 0) { VRVIPMenu.ElementData data = this.CreateElement(); data.TextName.text = cellAsString; data.TextFlag1.text = cellAsString3; data.TextFlag2.text = cellAsString4; data.TextFlag3.text = cellAsString5; data.TextFlag4.text = cellAsString6; data.TextHowToVIP.text = cellAsString9; data.TextFlag1.gameObject.SetActive(!string.IsNullOrEmpty(cellAsString3)); data.TextFlag2.gameObject.SetActive(!string.IsNullOrEmpty(cellAsString4)); data.TextFlag3.gameObject.SetActive(!string.IsNullOrEmpty(cellAsString5)); data.TextFlag4.gameObject.SetActive(!string.IsNullOrEmpty(cellAsString6)); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); bool flag = true; if (maid) { if (!string.IsNullOrEmpty(cellAsString7)) { flag &= (GameMain.Instance.CharacterMgr.status.GetFlag(cellAsString7) > 0); } if (!string.IsNullOrEmpty(cellAsString8)) { flag &= (maid.status.GetFlag(cellAsString8) > 0); } if (cellAsString11.Equals("×")) { flag &= (maid.status.seikeiken != Seikeiken.No_No); } if (cellAsString12.Equals("×")) { flag &= (maid.status.seikeiken != Seikeiken.Yes_No); } if (cellAsString13.Equals("×")) { flag &= (maid.status.seikeiken != Seikeiken.No_Yes); } if (cellAsString14.Equals("×")) { flag &= (maid.status.seikeiken != Seikeiken.Yes_Yes); } } else { flag = false; } data.isEnable = flag; if (flag) { VRVIPMenuElement component = data.Element.GetComponent(); VRVIPMenuElement vrvipmenuElement = component; vrvipmenuElement.m_CallbackPointerClick = (UnityAction)Delegate.Combine(vrvipmenuElement.m_CallbackPointerClick, new UnityAction(delegate { this.EventElementClick(data, scriptName); GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click); })); VRVIPMenuElement vrvipmenuElement2 = component; vrvipmenuElement2.m_CallbackPointerDown = (UnityAction)Delegate.Combine(vrvipmenuElement2.m_CallbackPointerDown, new UnityAction(delegate { data.isPointerDown = true; })); VRVIPMenuElement vrvipmenuElement3 = component; vrvipmenuElement3.m_CallbackPointerUp = (UnityAction)Delegate.Combine(vrvipmenuElement3.m_CallbackPointerUp, new UnityAction(delegate { data.isPointerDown = false; })); VRVIPMenuElement vrvipmenuElement4 = component; vrvipmenuElement4.m_CallbackPointerEnter = (UnityAction)Delegate.Combine(vrvipmenuElement4.m_CallbackPointerEnter, new UnityAction(delegate { data.isPointerStay = true; GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover); })); VRVIPMenuElement vrvipmenuElement5 = component; vrvipmenuElement5.m_CallbackPointerExit = (UnityAction)Delegate.Combine(vrvipmenuElement5.m_CallbackPointerExit, new UnityAction(delegate { data.isPointerStay = false; data.isPointerDown = false; })); } else { MaskableGraphic[] componentsInChildren = data.Element.GetComponentsInChildren(); Color color = Color.white; color *= 0.66f; color.a = 0.75f; for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].CrossFadeColor(color, 0f, false, true); } } string path = this.m_uGUIAtlasPath + cellAsString2; base.StartCoroutine(this.Coroutine_Load(path, delegate(ResourceRequest req) { data.ImageThumbnail.sprite = (req.asset as Sprite); })); this.m_VIPElementDataArray.Add(data); } } } } } } private VRVIPMenu.ElementData CreateElement() { GameObject gameObject = UnityEngine.Object.Instantiate(this.m_PrefabElement); gameObject.SetActive(true); gameObject.transform.SetParent(this.m_Content, false); return new VRVIPMenu.ElementData { Element = gameObject.GetComponent(), TextName = gameObject.transform.Find("Text VIP Name").GetComponent(), ImageThumbnail = gameObject.transform.Find("Image VIP thumnail").GetComponent(), TextFlag1 = gameObject.transform.Find("Text VIP Flag 1").GetComponent(), TextFlag2 = gameObject.transform.Find("Text VIP Flag 2").GetComponent(), TextFlag3 = gameObject.transform.Find("Text VIP Flag 3").GetComponent(), TextFlag4 = gameObject.transform.Find("Text VIP Flag 4").GetComponent(), TextHowToVIP = gameObject.transform.Find("Text VIP Comment").GetComponent() }; } private void EventElementClick(VRVIPMenu.ElementData element, string scriptName) { Debug.Log("項目がクリックされた。\n" + element.Element.name); VRDialogMenu dialog = VRDialogMenu.CreateDialog(); VRDialogMenu.TYPE_STYLE style = (VRDialogMenu.TYPE_STYLE)12; dialog.OpenDialog("「" + element.TextName.text + "」を\n行います。", style, delegate(VRDialogMenu.TYPE_STYLE type) { dialog.CloseDialog(); if (type == VRDialogMenu.TYPE_STYLE.OK) { VRCanvasManager.Instance.ClearCanvasStack(); VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); GameMain.Instance.ScriptMgr.LoadAdvScenarioScript(scriptName + ".ks", string.Empty); GameMain.Instance.ScriptMgr.adv_kag.Exec(); } else { VRCanvasManager.Instance.ClearCanvasStack(); VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.VIP); } }); } private void OnEnable() { this.UpdateVIPUI(); } private void OnDisable() { if (base.gameObject == null) { return; } if (this.m_Content == null) { return; } if (this.m_PrefabElement == null) { return; } this.m_VIPElementDataArray.Clear(); for (int i = 0; i < this.m_Content.childCount; i++) { GameObject gameObject = this.m_Content.GetChild(i).gameObject; if (!(gameObject == this.m_PrefabElement)) { UnityEngine.Object.Destroy(gameObject); } } } public void ButtonEvent_Close() { SceneVRCommunication sceneVRCom = SceneVRCommunication.Instance; if (sceneVRCom == null) { return; } VRSelectorMenu selector = VRSelectorMenu.CreateSelector(); selector.SetSelectType(VRChoices.SelectPair.Type.Text); List list = new List(); list.Add(new VRChoices.SelectPair("VIPを続ける", "0", 0, VRChoices.SelectPair.Type.Text, 0, -1f)); list.Add(new VRChoices.SelectPair("翌日ヘ進む", "1", 0, VRChoices.SelectPair.Type.Text, 0, -1f)); selector.SelectStart(list, delegate(VRChoices.SelectPair choice) { selector.SelectFinalize(null); if (choice.strLabel == "0") { VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.VIP); } else { VRCanvasManager.Instance.OpenVRCanvas(VRCanvasManager.VRCanvasType.MainMenu); sceneVRCom.KagDoNextTime(); } }); } private IEnumerator Coroutine_Load(string path, UnityAction callback) where T : UnityEngine.Object { ResourceRequest res = Resources.LoadAsync(path); while (!res.isDone) { yield return null; } callback(res); yield break; } [SerializeField] [Tooltip("VIPの概要を表示する要素(プレハブ)")] private GameObject m_PrefabElement; [SerializeField] [Tooltip("説明する要素を並べるUI")] private RectTransform m_Content; private string m_uGUIAtlasPath = "SceneVRCommunication\\Tablet\\Sprite\\"; private List m_VIPElementDataArray = new List(); private class ElementData { public ElementData() { this.Element = null; this.TextName = null; this.ImageThumbnail = null; this.TextFlag1 = null; this.TextFlag2 = null; this.TextFlag3 = null; this.TextFlag4 = null; this.TextHowToVIP = null; this.isPointerStay = false; this.isPointerDown = false; this.isEnable = false; } public RectTransform Element; public Text TextName; public Image ImageThumbnail; public Text TextFlag1; public Text TextFlag2; public Text TextFlag3; public Text TextFlag4; public Text TextHowToVIP; public bool isPointerStay; public bool isPointerDown; public bool isEnable; } }