123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class StaffRollScroll : MonoBehaviour
- {
- public bool Finish
- {
- get
- {
- return this.finish;
- }
- }
- private void Awake()
- {
- if (Product.type == Product.Type.JpAdult)
- {
- GameObject childObject = UTY.GetChildObject(this.prefabLabelLogoScort, "Sprite_public", false);
- if (childObject != null)
- {
- childObject.SetActive(false);
- }
- }
- this.ReadCSVFile_Data();
- this.ReadCSVFile_StaffName();
- }
- private void Start()
- {
- this.CreateLabels();
- this.mode = StaffRollScroll.Mode.Scroll;
- GameMain.Instance.SoundMgr.PlayBGM(this.soundFileName + ".ogg", 0f, false);
- }
- private void Update()
- {
- StaffRollScroll.Mode mode = this.mode;
- if (mode != StaffRollScroll.Mode.Scroll)
- {
- if (mode == StaffRollScroll.Mode.EndReady)
- {
- this.imgCtrl.Finish();
- this.mode = StaffRollScroll.Mode.End;
- base.StartCoroutine(this.End());
- }
- }
- else
- {
- this.Scroll();
- }
- }
- private IEnumerator End()
- {
- yield return new WaitForSeconds(9f);
- this.finish = true;
- yield break;
- }
- private void Scroll()
- {
- float num = this.progressTime / this.scrollTime;
- float y = Mathf.Lerp(0f, Mathf.Abs(this.endPosY), num);
- Vector3 localPosition = base.gameObject.transform.localPosition;
- localPosition.y = y;
- base.gameObject.transform.localPosition = localPosition;
- float deltaTime = Time.deltaTime;
- this.progressTime += deltaTime;
- this.imgCtrl.CheckChange(num);
- if (num >= 1f)
- {
- this.mode = StaffRollScroll.Mode.EndReady;
- }
- }
- private void ReadCSVFile_Data()
- {
- NDebug.Assert(GameUty.FileSystem.IsExistentFile("staffroll_data.nei"), "staffroll_data.nei\nopen failed.");
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen("staffroll_data.nei"))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, "staffroll_data.nei\nopen failed.");
- this.soundFileName = csvParser.GetCellAsString(1, 1);
- this.scrollTime = (float)csvParser.GetCellAsInteger(1, 2);
- }
- }
- }
- private void ReadCSVFile_StaffName()
- {
- if (StaffRollScroll.dataList != null)
- {
- return;
- }
- StaffRollScroll.dataList = new List<StaffRollScroll.Data>();
- string text = "staffroll_stafflist";
- if (!string.IsNullOrEmpty(Product.gameDataPath) && GameUty.FileSystem.IsExistentFile(text + Product.gameDataPath + ".nei"))
- {
- text += Product.gameDataPath;
- }
- text += ".nei";
- NDebug.Assert(GameUty.FileSystem.IsExistentFile(text), text + "\nopen failed.");
- 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++)
- {
- StaffRollScroll.Data data = new StaffRollScroll.Data();
- data.name = csvParser.GetCellAsString(1, i);
- string cellAsString = csvParser.GetCellAsString(0, i);
- string[] array = cellAsString.Split(new char[]
- {
- ','
- });
- bool flag = true;
- foreach (string a in array)
- {
- if (a == "読み込み終了")
- {
- return;
- }
- if (a == "停止位置")
- {
- data.stopPoint = true;
- }
- else if (a == "文字_小")
- {
- data.type = StaffRollScroll.Data.Type.Small1;
- }
- else if (a == "文字_小2")
- {
- data.type = StaffRollScroll.Data.Type.Small2;
- }
- else if (a == "ご主人様")
- {
- data.userName = true;
- }
- else if (a == "コピーライト")
- {
- data.name = "©" + data.name;
- }
- else if (a == "ロゴ")
- {
- data.type = StaffRollScroll.Data.Type.Logo;
- }
- else if (a == "ロゴエスコート")
- {
- data.type = StaffRollScroll.Data.Type.LogoScort;
- }
- }
- if (flag)
- {
- StaffRollScroll.dataList.Add(data);
- }
- }
- }
- }
- }
- private void CreateLabels()
- {
- GameObject gameObject = null;
- for (int i = 0; i < StaffRollScroll.dataList.Count; i++)
- {
- StaffRollScroll.Data data = StaffRollScroll.dataList[i];
- if (!GameMain.Instance.CharacterMgr.status.lockUserDraftMaid || !data.userName)
- {
- GameObject original;
- if (data.type == StaffRollScroll.Data.Type.Logo)
- {
- original = this.prefabLabelLogo;
- }
- else if (data.type == StaffRollScroll.Data.Type.LogoScort)
- {
- original = this.prefabLabelLogoScort;
- }
- else if (data.name == string.Empty || data.type == StaffRollScroll.Data.Type.Small1)
- {
- original = this.prefabLabelSmall1;
- }
- else if (data.type == StaffRollScroll.Data.Type.Small2)
- {
- original = this.prefabLabelSmall2;
- }
- else
- {
- original = this.prefabLabel;
- }
- GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(original);
- gameObject2.transform.parent = base.gameObject.transform;
- gameObject2.transform.localScale = new Vector3(1f, 1f, 1f);
- if (data.type != StaffRollScroll.Data.Type.Logo && data.type != StaffRollScroll.Data.Type.LogoScort)
- {
- UILabel component = gameObject2.GetComponent<UILabel>();
- component.text = data.name;
- }
- gameObject2.SetActive(true);
- if (data.stopPoint)
- {
- gameObject = gameObject2;
- }
- if (i >= StaffRollScroll.dataList.Count - 1 && gameObject == null)
- {
- gameObject = gameObject2;
- }
- }
- }
- this.prefabLabel.SetActive(false);
- this.prefabLabelSmall1.SetActive(false);
- this.prefabLabelSmall2.SetActive(false);
- this.prefabLabelLogo.SetActive(false);
- this.prefabLabelLogoScort.SetActive(false);
- this.table.Reposition();
- if (gameObject != null)
- {
- this.endPosY = (float)((int)gameObject.transform.localPosition.y);
- }
- }
- [SerializeField]
- private StaffRollImageCtrl imgCtrl;
- [SerializeField]
- private GameObject prefabLabel;
- [SerializeField]
- private GameObject prefabLabelSmall1;
- [SerializeField]
- private GameObject prefabLabelSmall2;
- [SerializeField]
- private GameObject prefabLabelLogo;
- [SerializeField]
- private GameObject prefabLabelLogoScort;
- [SerializeField]
- private UITable table;
- [SerializeField]
- private float scrollTime = 15f;
- private float progressTime;
- private float endPosY;
- private StaffRollScroll.Mode mode;
- private string soundFileName;
- private bool finish;
- private static List<StaffRollScroll.Data> dataList;
- public enum Mode
- {
- Wait,
- Scroll,
- EndReady,
- End
- }
- public class Data
- {
- public string name;
- public StaffRollScroll.Data.Type type;
- public bool userName;
- public bool stopPoint;
- public enum Type
- {
- Normal,
- Small1,
- Small2,
- Logo,
- LogoScort
- }
- }
- }
|