Product_Mgr.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. using wf;
  7. public class Product_Mgr : PartsMgrBase
  8. {
  9. protected override void Start()
  10. {
  11. base.Start();
  12. switch (RhythmAction_Mgr.NowDance)
  13. {
  14. case RhythmAction_Mgr.DanceType.Free:
  15. case RhythmAction_Mgr.DanceType.View:
  16. this.m_nAudience = DanceSetting.Settings.Audience;
  17. this.m_nProduct = DanceSetting.Settings.Product;
  18. break;
  19. case RhythmAction_Mgr.DanceType.Challenge:
  20. this.m_nAudience = Product_Mgr.AudienceState.Few;
  21. this.m_nProduct = Product_Mgr.ProductRank.Normal;
  22. break;
  23. case RhythmAction_Mgr.DanceType.VS:
  24. this.m_nAudience = Product_Mgr.AudienceState.Normal;
  25. this.m_nProduct = Product_Mgr.ProductRank.Normal;
  26. break;
  27. case RhythmAction_Mgr.DanceType.Encore:
  28. this.m_nAudience = Product_Mgr.AudienceState.Many;
  29. this.m_nProduct = Product_Mgr.ProductRank.Special;
  30. break;
  31. case RhythmAction_Mgr.DanceType.BenchMark:
  32. this.m_nAudience = Product_Mgr.AudienceState.Normal;
  33. this.m_nProduct = Product_Mgr.ProductRank.Special;
  34. break;
  35. }
  36. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Encore)
  37. {
  38. this.m_nAudience = Product_Mgr.AudienceState.Many;
  39. this.m_nProduct = Product_Mgr.ProductRank.Special;
  40. }
  41. this.CheckProductAndAudience();
  42. int voltage = this.m_AllAudience.Single((Product_Mgr.Audience e) => e.State == this.m_nAudience).Voltage;
  43. foreach (Product_Mgr.Audience audience in this.m_AllAudience)
  44. {
  45. bool active = audience.Voltage <= voltage;
  46. foreach (GameObject gameObject in audience.AudienceObj)
  47. {
  48. gameObject.SetActive(active);
  49. }
  50. }
  51. foreach (GameObject gameObject2 in this.m_SpecialProduct)
  52. {
  53. this.CheckSpecialObj(gameObject2.transform);
  54. }
  55. if (this.m_SpecialEffect)
  56. {
  57. this.m_SpecialEffect.gameObject.SetActive(this.m_nProduct == Product_Mgr.ProductRank.Special);
  58. if (this.m_SpecialEffect.gameObject.activeSelf || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS)
  59. {
  60. IEnumerator enumerator3 = this.m_SpecialEffect.GetEnumerator();
  61. try
  62. {
  63. while (enumerator3.MoveNext())
  64. {
  65. object obj = enumerator3.Current;
  66. Transform transform = (Transform)obj;
  67. ParticleSystem component = transform.GetComponent<ParticleSystem>();
  68. ParticleSystem particleSystem = null;
  69. if (transform.childCount > 0)
  70. {
  71. particleSystem = transform.GetChild(0).GetComponent<ParticleSystem>();
  72. }
  73. if (component)
  74. {
  75. RhythmAction_Mgr.Instance.AddParticleSystem(component);
  76. }
  77. if (particleSystem)
  78. {
  79. RhythmAction_Mgr.Instance.AddParticleSystem(particleSystem);
  80. }
  81. }
  82. }
  83. finally
  84. {
  85. IDisposable disposable;
  86. if ((disposable = (enumerator3 as IDisposable)) != null)
  87. {
  88. disposable.Dispose();
  89. }
  90. }
  91. }
  92. }
  93. if (!base.IsActive)
  94. {
  95. base.gameObject.SetActive(false);
  96. return;
  97. }
  98. this.ReadTimeData();
  99. }
  100. private void CheckProductAndAudience()
  101. {
  102. if (this.m_SpecialProduct.Count == 0)
  103. {
  104. this.m_SpecialProduct.Add(GameObject.Find("LiveStage_Laser_use_dance"));
  105. this.m_SpecialProduct.Add(GameObject.Find("MovingLight"));
  106. this.m_SpecialProduct.Add(GameObject.Find("SpotLightL"));
  107. this.m_SpecialProduct.Add(GameObject.Find("SpotLightL"));
  108. this.m_SpecialProduct.Add(GameObject.Find("SpotFloorLight"));
  109. if (this.m_SpecialProduct.Contains(null))
  110. {
  111. this.m_SpecialProduct.Clear();
  112. return;
  113. }
  114. }
  115. for (int i = 0; i < this.m_AllAudience.Length; i++)
  116. {
  117. Product_Mgr.Audience audience = this.m_AllAudience[i];
  118. if (audience.AudienceObj.Count == 0)
  119. {
  120. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_A00{0}_alpha", i + 1)));
  121. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_B00{0}_alpha", i + 1)));
  122. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_C00{0}_alpha", i + 1)));
  123. }
  124. }
  125. }
  126. private void CheckSpecialObj(Transform parent)
  127. {
  128. if (parent.childCount > 0)
  129. {
  130. IEnumerator enumerator = parent.GetEnumerator();
  131. try
  132. {
  133. while (enumerator.MoveNext())
  134. {
  135. object obj = enumerator.Current;
  136. Transform parent2 = (Transform)obj;
  137. this.CheckSpecialObj(parent2);
  138. }
  139. }
  140. finally
  141. {
  142. IDisposable disposable;
  143. if ((disposable = (enumerator as IDisposable)) != null)
  144. {
  145. disposable.Dispose();
  146. }
  147. }
  148. }
  149. else
  150. {
  151. Animator component = parent.GetComponent<Animator>();
  152. MeshRenderer component2 = parent.GetComponent<MeshRenderer>();
  153. bool flag = this.m_nProduct == Product_Mgr.ProductRank.Special || this.m_nProduct == Product_Mgr.ProductRank.Normal;
  154. bool flag2 = RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS;
  155. if (!component || !flag2)
  156. {
  157. if (!this.m_ProductSpecialObj.Contains(parent.gameObject) && flag2)
  158. {
  159. this.m_ProductSpecialObj.Add(parent.gameObject);
  160. }
  161. parent.gameObject.SetActive(flag);
  162. }
  163. else if (component2 && !this.m_ProductSpecialRender.Contains(component2))
  164. {
  165. this.m_ProductSpecialRender.Add(component2);
  166. component2.enabled = flag;
  167. }
  168. }
  169. }
  170. private void ReadTimeData()
  171. {
  172. string text = RhythmAction_Mgr.Instance.MusicCSV_Path + "time_data.nei";
  173. if (!GameUty.FileSystem.IsExistentFile(text))
  174. {
  175. NDebug.Assert("表がありません。" + text, false);
  176. }
  177. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  178. {
  179. using (CsvParser csvParser = new CsvParser())
  180. {
  181. bool condition = csvParser.Open(afileBase);
  182. NDebug.Assert(condition, text + "\nopen failed.");
  183. for (int i = 1; i < csvParser.max_cell_y; i++)
  184. {
  185. if (csvParser.IsCellToExistData(0, i))
  186. {
  187. this.m_All_BranchPoint.Add(csvParser.GetCellAsReal(1, i));
  188. }
  189. }
  190. }
  191. }
  192. }
  193. private Product_Mgr.AudienceState GetNowAudience()
  194. {
  195. Product_Mgr.AudienceState result = Product_Mgr.AudienceState.Few;
  196. foreach (Product_Mgr.Audience audience in this.m_AllAudience)
  197. {
  198. if (audience.Voltage > Voltage_Mgr.Instance.VoltageStage)
  199. {
  200. break;
  201. }
  202. result = audience.State;
  203. }
  204. return result;
  205. }
  206. private IEnumerator ProductCheck()
  207. {
  208. float timer = 0f;
  209. for (;;)
  210. {
  211. if (!RhythmAction_Mgr.Instance.IsPause)
  212. {
  213. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  214. this.m_ProgressGauge.transform.localPosition = Vector3.right * timer / RhythmAction_Mgr.Instance.TakeTime * (float)this.m_ProgressGauge.width;
  215. if (timer / 60f < 10f)
  216. {
  217. this.m_MinuteTimeText.text = "0" + Mathf.FloorToInt(timer / 60f).ToString();
  218. }
  219. else
  220. {
  221. this.m_MinuteTimeText.text = Mathf.FloorToInt(timer / 60f).ToString();
  222. }
  223. if ((int)timer % 60 < 10)
  224. {
  225. this.m_SecondsTimeText.text = "0" + ((int)timer % 60).ToString();
  226. }
  227. else
  228. {
  229. this.m_SecondsTimeText.text = ((int)timer % 60).ToString();
  230. }
  231. if (this.m_All_BranchPoint.Count > 0 && timer >= this.m_All_BranchPoint.First<float>())
  232. {
  233. base.StartCoroutine(this.GaugeFlash());
  234. Voltage_Mgr.Instance.DecideVoltageValue();
  235. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
  236. {
  237. Product_Mgr.AudienceState nAudience = this.m_nAudience;
  238. this.m_nAudience = this.GetNowAudience();
  239. if (nAudience != this.m_nAudience)
  240. {
  241. foreach (Product_Mgr.Audience audience in this.m_AllAudience)
  242. {
  243. bool active = audience.Voltage <= Voltage_Mgr.Instance.VoltageStage;
  244. foreach (GameObject gameObject in audience.AudienceObj)
  245. {
  246. gameObject.SetActive(active);
  247. }
  248. }
  249. }
  250. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS)
  251. {
  252. Product_Mgr.ProductRank nProduct = this.m_nProduct;
  253. if (DanceBattle_Mgr.Instance.IsEven())
  254. {
  255. this.m_nProduct = Product_Mgr.ProductRank.Normal;
  256. }
  257. else if (DanceBattle_Mgr.Instance.IsWin())
  258. {
  259. this.m_nProduct = Product_Mgr.ProductRank.Special;
  260. }
  261. else
  262. {
  263. this.m_nProduct = Product_Mgr.ProductRank.Low;
  264. }
  265. if (nProduct != this.m_nProduct)
  266. {
  267. bool flag = this.m_nProduct == Product_Mgr.ProductRank.Special || this.m_nProduct == Product_Mgr.ProductRank.Normal;
  268. foreach (MeshRenderer meshRenderer in this.m_ProductSpecialRender)
  269. {
  270. meshRenderer.enabled = flag;
  271. }
  272. foreach (GameObject gameObject2 in this.m_ProductSpecialObj)
  273. {
  274. gameObject2.SetActive(flag);
  275. }
  276. if (this.m_SpecialEffect)
  277. {
  278. this.m_SpecialEffect.gameObject.SetActive(this.m_nProduct == Product_Mgr.ProductRank.Special);
  279. }
  280. }
  281. }
  282. }
  283. this.m_All_BranchPoint.RemoveAt(0);
  284. }
  285. }
  286. yield return null;
  287. }
  288. yield break;
  289. }
  290. private IEnumerator GaugeFlash()
  291. {
  292. this.m_FlashGauge.gameObject.SetActive(true);
  293. Color col = this.m_FlashGauge.color;
  294. float timer = 0f;
  295. for (;;)
  296. {
  297. if (!RhythmAction_Mgr.Instance.IsPause)
  298. {
  299. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  300. float alpha = this.m_MaxFlashAlpha * Mathf.Sin(Mathf.Clamp01(timer / this.m_MaxFlashAlpha) * 180f * 0.0174532924f);
  301. this.m_FlashGauge.alpha = alpha;
  302. if (timer > this.m_MaxFlashAlpha)
  303. {
  304. break;
  305. }
  306. }
  307. yield return null;
  308. }
  309. this.m_FlashGauge.gameObject.SetActive(false);
  310. yield break;
  311. yield break;
  312. }
  313. public override void StartAction()
  314. {
  315. foreach (float num in this.m_All_BranchPoint)
  316. {
  317. GameObject gameObject = Utility.CreatePrefab(this.m_MarkParent, "SceneDance/Rhythm_Action/Prefab/" + this.m_ProgressMarkName, true);
  318. float d = Mathf.Clamp01(num / RhythmAction_Mgr.Instance.TakeTime) * (float)this.m_ProgressGauge.width;
  319. gameObject.transform.localPosition = Vector3.right * d;
  320. UISprite component = gameObject.GetComponent<UISprite>();
  321. this.m_ProgressMarkList.Add(component);
  322. }
  323. base.StartCoroutine(this.ProductCheck());
  324. }
  325. private Product_Mgr.AudienceState m_nAudience;
  326. [SerializeField]
  327. [Header("通過マークオブジェクト名")]
  328. private string m_ProgressMarkName = "ProgressMark";
  329. private List<UISprite> m_ProgressMarkList = new List<UISprite>();
  330. [SerializeField]
  331. [Header("通過マークの親")]
  332. private GameObject m_MarkParent;
  333. [SerializeField]
  334. [Header("プログレスゲージ")]
  335. private UISprite m_ProgressGauge;
  336. [SerializeField]
  337. [Header("経過時間UI(1分以上)")]
  338. private UILabel m_MinuteTimeText;
  339. [SerializeField]
  340. [Header("経過時間UI(1分以下)")]
  341. private UILabel m_SecondsTimeText;
  342. [SerializeField]
  343. [Header("通常・上位演出用のオブジェクトグループ")]
  344. private List<GameObject> m_SpecialProduct = new List<GameObject>();
  345. [SerializeField]
  346. private Product_Mgr.Audience[] m_AllAudience = new Product_Mgr.Audience[]
  347. {
  348. new Product_Mgr.Audience(Product_Mgr.AudienceState.Few, 1),
  349. new Product_Mgr.Audience(Product_Mgr.AudienceState.Normal, 3),
  350. new Product_Mgr.Audience(Product_Mgr.AudienceState.Many, 5)
  351. };
  352. [SerializeField]
  353. [Header("上位演出エフェクト")]
  354. private Transform m_SpecialEffect;
  355. [SerializeField]
  356. [Header("ゲージ光らせる時間")]
  357. private float m_GaugeFlashTime;
  358. [SerializeField]
  359. [Range(0f, 1f)]
  360. private float m_MaxFlashAlpha = 1f;
  361. [SerializeField]
  362. private UISprite m_FlashGauge;
  363. private Product_Mgr.ProductRank m_nProduct;
  364. private List<float> m_All_BranchPoint = new List<float>();
  365. private List<MeshRenderer> m_ProductSpecialRender = new List<MeshRenderer>();
  366. private List<GameObject> m_ProductSpecialObj = new List<GameObject>();
  367. public enum ProductRank
  368. {
  369. Low,
  370. Special,
  371. Normal
  372. }
  373. public enum AudienceState
  374. {
  375. Few,
  376. Normal,
  377. Many
  378. }
  379. [Serializable]
  380. private class Audience
  381. {
  382. public Audience(Product_Mgr.AudienceState state, int voltage)
  383. {
  384. this.State = state;
  385. this.Voltage = voltage;
  386. }
  387. [Header("表示する時の客数状態")]
  388. public Product_Mgr.AudienceState State;
  389. [Header("このボルテージ以上の時表示")]
  390. public int Voltage;
  391. [Header("客オブジェクト")]
  392. public List<GameObject> AudienceObj = new List<GameObject>();
  393. }
  394. }