VRNeiLetterMenu.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. public class VRNeiLetterMenu : MonoBehaviour
  7. {
  8. private void OnEnable()
  9. {
  10. string text = "vrcom_nei_letter.nei";
  11. if (!GameUty.FileSystem.IsExistentFile(text))
  12. {
  13. NDebug.Assert("表がありません。" + text, false);
  14. }
  15. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  16. {
  17. using (CsvParser csvParser = new CsvParser())
  18. {
  19. bool condition = csvParser.Open(afileBase);
  20. NDebug.Assert(condition, text + "\nopen failed.");
  21. for (int i = 1; i < csvParser.max_cell_y; i++)
  22. {
  23. int num = 0;
  24. string cellAsString = csvParser.GetCellAsString(num++, i);
  25. string imageName = csvParser.GetCellAsString(num++, i);
  26. string cellAsString2 = csvParser.GetCellAsString(num++, i);
  27. char[] array = csvParser.GetCellAsString(num++, i).ToCharArray();
  28. string cellAsString3 = csvParser.GetCellAsString(num++, i);
  29. bool flag = false;
  30. for (int j = 0; j < array.Length; j++)
  31. {
  32. if (array[j] == ((int)GameMain.Instance.VRDeviceTypeID).ToString().ToCharArray()[0])
  33. {
  34. flag = true;
  35. }
  36. }
  37. if (GameMain.Instance.CharacterMgr.GetMaid(0) != null)
  38. {
  39. flag = (flag && GameMain.Instance.CharacterMgr.GetMaid(0).status.GetFlag(cellAsString2) == 1);
  40. }
  41. string itemFlag1 = csvParser.GetCellAsString(num++, i);
  42. string itemFlag2 = csvParser.GetCellAsString(num++, i);
  43. string itemFlag3 = csvParser.GetCellAsString(num++, i);
  44. string itemFlag4 = csvParser.GetCellAsString(num++, i);
  45. string itemFlag5 = csvParser.GetCellAsString(num++, i);
  46. string itemFlag6 = csvParser.GetCellAsString(num++, i);
  47. if (flag)
  48. {
  49. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_PrefabButton);
  50. gameObject.gameObject.SetActive(true);
  51. gameObject.transform.SetParent(this.m_ScrollArea, false);
  52. gameObject.GetComponentInChildren<Text>().text = cellAsString3;
  53. gameObject.GetComponent<Button>().onClick.AddListener(delegate
  54. {
  55. string path = this.m_uGUIAtlasPath + imageName;
  56. this.StartCoroutine(this.Coroutine_Load<Sprite>(path, delegate(ResourceRequest req)
  57. {
  58. this.m_ImageManual.sprite = (req.asset as Sprite);
  59. }));
  60. this.ButtonClickEvent(new string[]
  61. {
  62. itemFlag1,
  63. itemFlag2,
  64. itemFlag3,
  65. itemFlag4,
  66. itemFlag5,
  67. itemFlag6
  68. });
  69. });
  70. if (i == 1)
  71. {
  72. gameObject.GetComponent<Button>().onClick.Invoke();
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. private void ButtonClickEvent(params string[] strArray)
  80. {
  81. for (int i = 0; i < this.m_ImageItemGetIcons.Length; i++)
  82. {
  83. this.m_ImageItemGetIcons[i].SetActive(false);
  84. }
  85. for (int j = 0; j < strArray.Length; j++)
  86. {
  87. string text = strArray[j];
  88. if (!string.IsNullOrEmpty(text))
  89. {
  90. string compareItemName = this.GetCompareItemName(text);
  91. if (!string.IsNullOrEmpty(compareItemName))
  92. {
  93. string[] array = compareItemName.Split(new char[]
  94. {
  95. ','
  96. });
  97. bool active = false;
  98. for (int k = 0; k < array.Length; k++)
  99. {
  100. if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(array[k] + ".menu"))
  101. {
  102. active = true;
  103. }
  104. }
  105. this.m_ImageItemGetIcons[j].SetActive(active);
  106. }
  107. }
  108. }
  109. }
  110. private string GetCompareItemName(string ID)
  111. {
  112. string text = "vrcom_mini_game.nei";
  113. if (!GameUty.FileSystem.IsExistentFile(text))
  114. {
  115. NDebug.Assert("表がありません。" + text, false);
  116. }
  117. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  118. {
  119. using (CsvParser csvParser = new CsvParser())
  120. {
  121. bool condition = csvParser.Open(afileBase);
  122. NDebug.Assert(condition, text + "\nopen failed.");
  123. for (int i = 1; i < csvParser.max_cell_y; i++)
  124. {
  125. string cellAsString = csvParser.GetCellAsString(1, i);
  126. if (cellAsString == ID)
  127. {
  128. return csvParser.GetCellAsString(3, i);
  129. }
  130. }
  131. }
  132. }
  133. return null;
  134. }
  135. private void OnDisable()
  136. {
  137. for (int i = 0; i < this.m_ScrollArea.childCount; i++)
  138. {
  139. GameObject gameObject = this.m_ScrollArea.GetChild(i).gameObject;
  140. if (!(gameObject == this.m_PrefabButton))
  141. {
  142. UnityEngine.Object.Destroy(gameObject);
  143. }
  144. }
  145. }
  146. private IEnumerator Coroutine_Load<T>(string path, UnityAction<ResourceRequest> callback) where T : UnityEngine.Object
  147. {
  148. ResourceRequest res = Resources.LoadAsync<T>(path);
  149. while (!res.isDone)
  150. {
  151. yield return null;
  152. }
  153. callback(res);
  154. yield break;
  155. }
  156. [SerializeField]
  157. private int m_ManualIndex;
  158. [SerializeField]
  159. private int m_PageIndex;
  160. [SerializeField]
  161. private Image m_ImageManual;
  162. [SerializeField]
  163. private Text m_TextPageNumber;
  164. [SerializeField]
  165. private RectTransform m_ScrollArea;
  166. [SerializeField]
  167. private GameObject m_PrefabButton;
  168. [Space(16f)]
  169. [SerializeField]
  170. [Tooltip("所持しているアイテムに付く赤丸アイコン")]
  171. private GameObject[] m_ImageItemGetIcons;
  172. private string m_uGUIAtlasPath = "SceneVRCommunication\\Tablet\\Sprite\\";
  173. }