StaffRollScroll.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class StaffRollScroll : MonoBehaviour
  6. {
  7. public bool Finish
  8. {
  9. get
  10. {
  11. return this.finish;
  12. }
  13. }
  14. private void Awake()
  15. {
  16. this.ReadCSVFile_Data();
  17. this.ReadCSVFile_StaffName();
  18. }
  19. private void Start()
  20. {
  21. this.CreateLabels();
  22. this.mode = StaffRollScroll.Mode.Scroll;
  23. GameMain.Instance.SoundMgr.PlayBGM(this.soundFileName + ".ogg", 0f, false);
  24. }
  25. private void Update()
  26. {
  27. StaffRollScroll.Mode mode = this.mode;
  28. if (mode != StaffRollScroll.Mode.Scroll)
  29. {
  30. if (mode == StaffRollScroll.Mode.EndReady)
  31. {
  32. this.imgCtrl.Finish();
  33. this.mode = StaffRollScroll.Mode.End;
  34. base.StartCoroutine(this.End());
  35. }
  36. }
  37. else
  38. {
  39. this.Scroll();
  40. }
  41. }
  42. private IEnumerator End()
  43. {
  44. yield return new WaitForSeconds(9f);
  45. this.finish = true;
  46. yield break;
  47. }
  48. private void Scroll()
  49. {
  50. float num = this.progressTime / this.scrollTime;
  51. float y = Mathf.Lerp(0f, Mathf.Abs(this.endPosY), num);
  52. Vector3 localPosition = base.gameObject.transform.localPosition;
  53. localPosition.y = y;
  54. base.gameObject.transform.localPosition = localPosition;
  55. float deltaTime = Time.deltaTime;
  56. this.progressTime += deltaTime;
  57. this.imgCtrl.CheckChange(num);
  58. if (num >= 1f)
  59. {
  60. this.mode = StaffRollScroll.Mode.EndReady;
  61. }
  62. }
  63. private void ReadCSVFile_Data()
  64. {
  65. NDebug.Assert(GameUty.FileSystem.IsExistentFile("staffroll_data.nei"), "staffroll_data.nei\nopen failed.");
  66. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("staffroll_data.nei"))
  67. {
  68. using (CsvParser csvParser = new CsvParser())
  69. {
  70. bool condition = csvParser.Open(afileBase);
  71. NDebug.Assert(condition, "staffroll_data.nei\nopen failed.");
  72. this.soundFileName = csvParser.GetCellAsString(1, 1);
  73. this.scrollTime = (float)csvParser.GetCellAsInteger(1, 2);
  74. }
  75. }
  76. }
  77. private void ReadCSVFile_StaffName()
  78. {
  79. if (StaffRollScroll.dataList != null)
  80. {
  81. return;
  82. }
  83. StaffRollScroll.dataList = new List<StaffRollScroll.Data>();
  84. NDebug.Assert(GameUty.FileSystem.IsExistentFile("staffroll_stafflist.nei"), "staffroll_stafflist.nei\nopen failed.");
  85. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("staffroll_stafflist.nei"))
  86. {
  87. using (CsvParser csvParser = new CsvParser())
  88. {
  89. bool condition = csvParser.Open(afileBase);
  90. NDebug.Assert(condition, "staffroll_stafflist.nei\nopen failed.");
  91. for (int i = 1; i < csvParser.max_cell_y; i++)
  92. {
  93. StaffRollScroll.Data data = new StaffRollScroll.Data();
  94. data.name = csvParser.GetCellAsString(1, i);
  95. string cellAsString = csvParser.GetCellAsString(0, i);
  96. string[] array = cellAsString.Split(new char[]
  97. {
  98. ','
  99. });
  100. bool flag = true;
  101. foreach (string a in array)
  102. {
  103. if (a == "読み込み終了")
  104. {
  105. return;
  106. }
  107. if (a == "停止位置")
  108. {
  109. data.stopPoint = true;
  110. }
  111. else if (a == "文字_小")
  112. {
  113. data.type = StaffRollScroll.Data.Type.Small1;
  114. }
  115. else if (a == "文字_小2")
  116. {
  117. data.type = StaffRollScroll.Data.Type.Small2;
  118. }
  119. else if (a == "ご主人様")
  120. {
  121. data.userName = true;
  122. }
  123. else if (a == "コピーライト")
  124. {
  125. data.name = "©" + data.name;
  126. }
  127. else if (a == "ロゴ")
  128. {
  129. data.type = StaffRollScroll.Data.Type.Logo;
  130. }
  131. }
  132. if (flag)
  133. {
  134. StaffRollScroll.dataList.Add(data);
  135. }
  136. }
  137. }
  138. }
  139. }
  140. private void CreateLabels()
  141. {
  142. GameObject gameObject = null;
  143. for (int i = 0; i < StaffRollScroll.dataList.Count; i++)
  144. {
  145. StaffRollScroll.Data data = StaffRollScroll.dataList[i];
  146. if (!GameMain.Instance.CharacterMgr.status.lockUserDraftMaid || !data.userName)
  147. {
  148. GameObject original;
  149. if (data.type == StaffRollScroll.Data.Type.Logo)
  150. {
  151. original = this.prefabLabelLogo;
  152. }
  153. else if (data.name == string.Empty || data.type == StaffRollScroll.Data.Type.Small1)
  154. {
  155. original = this.prefabLabelSmall1;
  156. }
  157. else if (data.type == StaffRollScroll.Data.Type.Small2)
  158. {
  159. original = this.prefabLabelSmall2;
  160. }
  161. else
  162. {
  163. original = this.prefabLabel;
  164. }
  165. GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(original);
  166. gameObject2.transform.parent = base.gameObject.transform;
  167. gameObject2.transform.localScale = new Vector3(1f, 1f, 1f);
  168. if (data.type != StaffRollScroll.Data.Type.Logo)
  169. {
  170. UILabel component = gameObject2.GetComponent<UILabel>();
  171. component.text = data.name;
  172. }
  173. gameObject2.SetActive(true);
  174. if (data.stopPoint)
  175. {
  176. gameObject = gameObject2;
  177. }
  178. if (i >= StaffRollScroll.dataList.Count - 1 && gameObject == null)
  179. {
  180. gameObject = gameObject2;
  181. }
  182. }
  183. }
  184. this.prefabLabel.SetActive(false);
  185. this.prefabLabelSmall1.SetActive(false);
  186. this.prefabLabelSmall2.SetActive(false);
  187. this.prefabLabelLogo.SetActive(false);
  188. this.table.Reposition();
  189. if (gameObject != null)
  190. {
  191. this.endPosY = (float)((int)gameObject.transform.localPosition.y);
  192. }
  193. }
  194. [SerializeField]
  195. private StaffRollImageCtrl imgCtrl;
  196. [SerializeField]
  197. private GameObject prefabLabel;
  198. [SerializeField]
  199. private GameObject prefabLabelSmall1;
  200. [SerializeField]
  201. private GameObject prefabLabelSmall2;
  202. [SerializeField]
  203. private GameObject prefabLabelLogo;
  204. [SerializeField]
  205. private UITable table;
  206. [SerializeField]
  207. private float scrollTime = 15f;
  208. private float progressTime;
  209. private float endPosY;
  210. private StaffRollScroll.Mode mode;
  211. private string soundFileName;
  212. private bool finish;
  213. private static List<StaffRollScroll.Data> dataList;
  214. public enum Mode
  215. {
  216. Wait,
  217. Scroll,
  218. EndReady,
  219. End
  220. }
  221. public class Data
  222. {
  223. public string name;
  224. public StaffRollScroll.Data.Type type;
  225. public bool userName;
  226. public bool stopPoint;
  227. public enum Type
  228. {
  229. Normal,
  230. Small1,
  231. Small2,
  232. Logo
  233. }
  234. }
  235. }