StaffRollScroll.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. string text = "staffroll_stafflist";
  85. if (!string.IsNullOrEmpty(Product.gameDataPath) && GameUty.FileSystem.IsExistentFile(text + Product.gameDataPath + ".nei"))
  86. {
  87. text += Product.gameDataPath;
  88. }
  89. text += ".nei";
  90. NDebug.Assert(GameUty.FileSystem.IsExistentFile(text), text + "\nopen failed.");
  91. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  92. {
  93. using (CsvParser csvParser = new CsvParser())
  94. {
  95. bool condition = csvParser.Open(afileBase);
  96. NDebug.Assert(condition, text + "\nopen failed.");
  97. for (int i = 1; i < csvParser.max_cell_y; i++)
  98. {
  99. StaffRollScroll.Data data = new StaffRollScroll.Data();
  100. data.name = csvParser.GetCellAsString(1, i);
  101. string cellAsString = csvParser.GetCellAsString(0, i);
  102. string[] array = cellAsString.Split(new char[]
  103. {
  104. ','
  105. });
  106. bool flag = true;
  107. foreach (string a in array)
  108. {
  109. if (a == "読み込み終了")
  110. {
  111. return;
  112. }
  113. if (a == "停止位置")
  114. {
  115. data.stopPoint = true;
  116. }
  117. else if (a == "文字_小")
  118. {
  119. data.type = StaffRollScroll.Data.Type.Small1;
  120. }
  121. else if (a == "文字_小2")
  122. {
  123. data.type = StaffRollScroll.Data.Type.Small2;
  124. }
  125. else if (a == "ご主人様")
  126. {
  127. data.userName = true;
  128. }
  129. else if (a == "コピーライト")
  130. {
  131. data.name = "©" + data.name;
  132. }
  133. else if (a == "ロゴ")
  134. {
  135. data.type = StaffRollScroll.Data.Type.Logo;
  136. }
  137. }
  138. if (flag)
  139. {
  140. StaffRollScroll.dataList.Add(data);
  141. }
  142. }
  143. }
  144. }
  145. }
  146. private void CreateLabels()
  147. {
  148. GameObject gameObject = null;
  149. for (int i = 0; i < StaffRollScroll.dataList.Count; i++)
  150. {
  151. StaffRollScroll.Data data = StaffRollScroll.dataList[i];
  152. if (!GameMain.Instance.CharacterMgr.status.lockUserDraftMaid || !data.userName)
  153. {
  154. GameObject original;
  155. if (data.type == StaffRollScroll.Data.Type.Logo)
  156. {
  157. original = this.prefabLabelLogo;
  158. }
  159. else if (data.name == string.Empty || data.type == StaffRollScroll.Data.Type.Small1)
  160. {
  161. original = this.prefabLabelSmall1;
  162. }
  163. else if (data.type == StaffRollScroll.Data.Type.Small2)
  164. {
  165. original = this.prefabLabelSmall2;
  166. }
  167. else
  168. {
  169. original = this.prefabLabel;
  170. }
  171. GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(original);
  172. gameObject2.transform.parent = base.gameObject.transform;
  173. gameObject2.transform.localScale = new Vector3(1f, 1f, 1f);
  174. if (data.type != StaffRollScroll.Data.Type.Logo)
  175. {
  176. UILabel component = gameObject2.GetComponent<UILabel>();
  177. component.text = data.name;
  178. }
  179. gameObject2.SetActive(true);
  180. if (data.stopPoint)
  181. {
  182. gameObject = gameObject2;
  183. }
  184. if (i >= StaffRollScroll.dataList.Count - 1 && gameObject == null)
  185. {
  186. gameObject = gameObject2;
  187. }
  188. }
  189. }
  190. this.prefabLabel.SetActive(false);
  191. this.prefabLabelSmall1.SetActive(false);
  192. this.prefabLabelSmall2.SetActive(false);
  193. this.prefabLabelLogo.SetActive(false);
  194. this.table.Reposition();
  195. if (gameObject != null)
  196. {
  197. this.endPosY = (float)((int)gameObject.transform.localPosition.y);
  198. }
  199. }
  200. [SerializeField]
  201. private StaffRollImageCtrl imgCtrl;
  202. [SerializeField]
  203. private GameObject prefabLabel;
  204. [SerializeField]
  205. private GameObject prefabLabelSmall1;
  206. [SerializeField]
  207. private GameObject prefabLabelSmall2;
  208. [SerializeField]
  209. private GameObject prefabLabelLogo;
  210. [SerializeField]
  211. private UITable table;
  212. [SerializeField]
  213. private float scrollTime = 15f;
  214. private float progressTime;
  215. private float endPosY;
  216. private StaffRollScroll.Mode mode;
  217. private string soundFileName;
  218. private bool finish;
  219. private static List<StaffRollScroll.Data> dataList;
  220. public enum Mode
  221. {
  222. Wait,
  223. Scroll,
  224. EndReady,
  225. End
  226. }
  227. public class Data
  228. {
  229. public string name;
  230. public StaffRollScroll.Data.Type type;
  231. public bool userName;
  232. public bool stopPoint;
  233. public enum Type
  234. {
  235. Normal,
  236. Small1,
  237. Small2,
  238. Logo
  239. }
  240. }
  241. }