123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System;
- using System.Collections;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class VRNeiLetterMenu : MonoBehaviour
- {
- private void OnEnable()
- {
- string text = "vrcom_nei_letter.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++)
- {
- int num = 0;
- string cellAsString = csvParser.GetCellAsString(num++, i);
- string imageName = csvParser.GetCellAsString(num++, i);
- string cellAsString2 = csvParser.GetCellAsString(num++, i);
- char[] array = csvParser.GetCellAsString(num++, i).ToCharArray();
- string cellAsString3 = csvParser.GetCellAsString(num++, i);
- bool flag = false;
- for (int j = 0; j < array.Length; j++)
- {
- if (array[j] == ((int)GameMain.Instance.VRDeviceTypeID).ToString().ToCharArray()[0])
- {
- flag = true;
- }
- }
- if (GameMain.Instance.CharacterMgr.GetMaid(0) != null)
- {
- flag = (flag && GameMain.Instance.CharacterMgr.GetMaid(0).status.GetFlag(cellAsString2) == 1);
- }
- string itemFlag1 = csvParser.GetCellAsString(num++, i);
- string itemFlag2 = csvParser.GetCellAsString(num++, i);
- string itemFlag3 = csvParser.GetCellAsString(num++, i);
- string itemFlag4 = csvParser.GetCellAsString(num++, i);
- string itemFlag5 = csvParser.GetCellAsString(num++, i);
- string itemFlag6 = csvParser.GetCellAsString(num++, i);
- if (flag)
- {
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_PrefabButton);
- gameObject.gameObject.SetActive(true);
- gameObject.transform.SetParent(this.m_ScrollArea, false);
- gameObject.GetComponentInChildren<Text>().text = cellAsString3;
- gameObject.GetComponent<Button>().onClick.AddListener(delegate
- {
- string path = this.m_uGUIAtlasPath + imageName;
- this.StartCoroutine(this.Coroutine_Load<Sprite>(path, delegate(ResourceRequest req)
- {
- this.m_ImageManual.sprite = (req.asset as Sprite);
- }));
- this.ButtonClickEvent(new string[]
- {
- itemFlag1,
- itemFlag2,
- itemFlag3,
- itemFlag4,
- itemFlag5,
- itemFlag6
- });
- });
- if (i == 1)
- {
- gameObject.GetComponent<Button>().onClick.Invoke();
- }
- }
- }
- }
- }
- }
- private void ButtonClickEvent(params string[] strArray)
- {
- for (int i = 0; i < this.m_ImageItemGetIcons.Length; i++)
- {
- this.m_ImageItemGetIcons[i].SetActive(false);
- }
- for (int j = 0; j < strArray.Length; j++)
- {
- string text = strArray[j];
- if (!string.IsNullOrEmpty(text))
- {
- string compareItemName = this.GetCompareItemName(text);
- if (!string.IsNullOrEmpty(compareItemName))
- {
- string[] array = compareItemName.Split(new char[]
- {
- ','
- });
- bool active = false;
- for (int k = 0; k < array.Length; k++)
- {
- if (GameMain.Instance.CharacterMgr.status.IsHavePartsItem(array[k] + ".menu"))
- {
- active = true;
- }
- }
- this.m_ImageItemGetIcons[j].SetActive(active);
- }
- }
- }
- }
- private string GetCompareItemName(string ID)
- {
- string text = "vrcom_mini_game.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++)
- {
- string cellAsString = csvParser.GetCellAsString(1, i);
- if (cellAsString == ID)
- {
- return csvParser.GetCellAsString(3, i);
- }
- }
- }
- }
- return null;
- }
- private void OnDisable()
- {
- for (int i = 0; i < this.m_ScrollArea.childCount; i++)
- {
- GameObject gameObject = this.m_ScrollArea.GetChild(i).gameObject;
- if (!(gameObject == this.m_PrefabButton))
- {
- UnityEngine.Object.Destroy(gameObject);
- }
- }
- }
- private IEnumerator Coroutine_Load<T>(string path, UnityAction<ResourceRequest> callback) where T : UnityEngine.Object
- {
- ResourceRequest res = Resources.LoadAsync<T>(path);
- while (!res.isDone)
- {
- yield return null;
- }
- callback(res);
- yield break;
- }
- [SerializeField]
- private int m_ManualIndex;
- [SerializeField]
- private int m_PageIndex;
- [SerializeField]
- private Image m_ImageManual;
- [SerializeField]
- private Text m_TextPageNumber;
- [SerializeField]
- private RectTransform m_ScrollArea;
- [SerializeField]
- private GameObject m_PrefabButton;
- [Space(16f)]
- [SerializeField]
- [Tooltip("所持しているアイテムに付く赤丸アイコン")]
- private GameObject[] m_ImageItemGetIcons;
- private string m_uGUIAtlasPath = "SceneVRCommunication\\Tablet\\Sprite\\";
- }
|