StaffRollScroll.cs 6.6 KB

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