Product_Mgr.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. for (int i = 0; i < this.m_AllAudience.Length; i++)
  103. {
  104. Product_Mgr.Audience audience = this.m_AllAudience[i];
  105. if (audience.AudienceObj.Contains(null))
  106. {
  107. audience.AudienceObj.Clear();
  108. }
  109. else if (audience.AudienceObj.Count == 0)
  110. {
  111. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_A00{0}_alpha", i + 1)));
  112. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_B00{0}_alpha", i + 1)));
  113. audience.AudienceObj.Add(GameObject.Find(string.Format("psyllium_C00{0}_alpha", i + 1)));
  114. if (audience.AudienceObj.Contains(null))
  115. {
  116. audience.AudienceObj.Clear();
  117. }
  118. }
  119. }
  120. if (this.m_SpecialProduct.Contains(null))
  121. {
  122. this.m_SpecialProduct.Clear();
  123. }
  124. else if (this.m_SpecialProduct.Count == 0)
  125. {
  126. this.m_SpecialProduct.Add(GameObject.Find("LiveStage_Laser_use_dance"));
  127. this.m_SpecialProduct.Add(GameObject.Find("MovingLight"));
  128. this.m_SpecialProduct.Add(GameObject.Find("SpotLightL"));
  129. this.m_SpecialProduct.Add(GameObject.Find("SpotLightL"));
  130. this.m_SpecialProduct.Add(GameObject.Find("SpotFloorLight"));
  131. if (this.m_SpecialProduct.Contains(null))
  132. {
  133. this.m_SpecialProduct.Clear();
  134. }
  135. }
  136. }
  137. private void CheckSpecialObj(Transform parent)
  138. {
  139. if (parent.childCount > 0)
  140. {
  141. IEnumerator enumerator = parent.GetEnumerator();
  142. try
  143. {
  144. while (enumerator.MoveNext())
  145. {
  146. object obj = enumerator.Current;
  147. Transform parent2 = (Transform)obj;
  148. this.CheckSpecialObj(parent2);
  149. }
  150. }
  151. finally
  152. {
  153. IDisposable disposable;
  154. if ((disposable = (enumerator as IDisposable)) != null)
  155. {
  156. disposable.Dispose();
  157. }
  158. }
  159. }
  160. else
  161. {
  162. Animator component = parent.GetComponent<Animator>();
  163. MeshRenderer component2 = parent.GetComponent<MeshRenderer>();
  164. bool flag = this.m_nProduct == Product_Mgr.ProductRank.Special || this.m_nProduct == Product_Mgr.ProductRank.Normal;
  165. bool flag2 = RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS;
  166. if (!component || !flag2)
  167. {
  168. if (!this.m_ProductSpecialObj.Contains(parent.gameObject) && flag2)
  169. {
  170. this.m_ProductSpecialObj.Add(parent.gameObject);
  171. }
  172. parent.gameObject.SetActive(flag);
  173. }
  174. else if (component2 && !this.m_ProductSpecialRender.Contains(component2))
  175. {
  176. this.m_ProductSpecialRender.Add(component2);
  177. component2.enabled = flag;
  178. }
  179. }
  180. }
  181. private void ReadTimeData()
  182. {
  183. string text = RhythmAction_Mgr.Instance.MusicCSV_Path + "time_data.nei";
  184. if (!GameUty.FileSystem.IsExistentFile(text))
  185. {
  186. NDebug.Assert("表がありません。" + text, false);
  187. }
  188. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  189. {
  190. using (CsvParser csvParser = new CsvParser())
  191. {
  192. bool condition = csvParser.Open(afileBase);
  193. NDebug.Assert(condition, text + "\nopen failed.");
  194. for (int i = 1; i < csvParser.max_cell_y; i++)
  195. {
  196. if (csvParser.IsCellToExistData(0, i))
  197. {
  198. this.m_All_BranchPoint.Add(csvParser.GetCellAsReal(1, i));
  199. }
  200. }
  201. }
  202. }
  203. }
  204. private Product_Mgr.AudienceState GetNowAudience()
  205. {
  206. Product_Mgr.AudienceState result = Product_Mgr.AudienceState.Few;
  207. foreach (Product_Mgr.Audience audience in this.m_AllAudience)
  208. {
  209. if (audience.Voltage > Voltage_Mgr.Instance.VoltageStage)
  210. {
  211. break;
  212. }
  213. result = audience.State;
  214. }
  215. return result;
  216. }
  217. private IEnumerator ProductCheck()
  218. {
  219. float timer = 0f;
  220. for (;;)
  221. {
  222. if (!RhythmAction_Mgr.Instance.IsPause)
  223. {
  224. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  225. this.m_ProgressGauge.transform.localPosition = Vector3.right * timer / RhythmAction_Mgr.Instance.TakeTime * (float)this.m_ProgressGauge.width;
  226. if (timer / 60f < 10f)
  227. {
  228. this.m_MinuteTimeText.text = "0" + Mathf.FloorToInt(timer / 60f).ToString();
  229. }
  230. else
  231. {
  232. this.m_MinuteTimeText.text = Mathf.FloorToInt(timer / 60f).ToString();
  233. }
  234. if ((int)timer % 60 < 10)
  235. {
  236. this.m_SecondsTimeText.text = "0" + ((int)timer % 60).ToString();
  237. }
  238. else
  239. {
  240. this.m_SecondsTimeText.text = ((int)timer % 60).ToString();
  241. }
  242. if (this.m_All_BranchPoint.Count > 0 && timer >= this.m_All_BranchPoint.First<float>())
  243. {
  244. base.StartCoroutine(this.GaugeFlash());
  245. Voltage_Mgr.Instance.DecideVoltageValue();
  246. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS || RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.BenchMark)
  247. {
  248. Product_Mgr.AudienceState nAudience = this.m_nAudience;
  249. this.m_nAudience = this.GetNowAudience();
  250. if (nAudience != this.m_nAudience)
  251. {
  252. foreach (Product_Mgr.Audience audience in this.m_AllAudience)
  253. {
  254. bool active = audience.Voltage <= Voltage_Mgr.Instance.VoltageStage;
  255. foreach (GameObject gameObject in audience.AudienceObj)
  256. {
  257. gameObject.SetActive(active);
  258. }
  259. }
  260. }
  261. if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.VS)
  262. {
  263. Product_Mgr.ProductRank nProduct = this.m_nProduct;
  264. if (DanceBattle_Mgr.Instance.IsEven())
  265. {
  266. this.m_nProduct = Product_Mgr.ProductRank.Normal;
  267. }
  268. else if (DanceBattle_Mgr.Instance.IsWin())
  269. {
  270. this.m_nProduct = Product_Mgr.ProductRank.Special;
  271. }
  272. else
  273. {
  274. this.m_nProduct = Product_Mgr.ProductRank.Low;
  275. }
  276. if (nProduct != this.m_nProduct)
  277. {
  278. bool flag = this.m_nProduct == Product_Mgr.ProductRank.Special || this.m_nProduct == Product_Mgr.ProductRank.Normal;
  279. foreach (MeshRenderer meshRenderer in this.m_ProductSpecialRender)
  280. {
  281. meshRenderer.enabled = flag;
  282. }
  283. foreach (GameObject gameObject2 in this.m_ProductSpecialObj)
  284. {
  285. gameObject2.SetActive(flag);
  286. }
  287. if (this.m_SpecialEffect)
  288. {
  289. this.m_SpecialEffect.gameObject.SetActive(this.m_nProduct == Product_Mgr.ProductRank.Special);
  290. }
  291. }
  292. }
  293. }
  294. this.m_All_BranchPoint.RemoveAt(0);
  295. }
  296. }
  297. yield return null;
  298. }
  299. yield break;
  300. }
  301. private IEnumerator GaugeFlash()
  302. {
  303. this.m_FlashGauge.gameObject.SetActive(true);
  304. Color col = this.m_FlashGauge.color;
  305. float timer = 0f;
  306. for (;;)
  307. {
  308. if (!RhythmAction_Mgr.Instance.IsPause)
  309. {
  310. timer += RhythmAction_Mgr.Instance.DanceDeltaTime;
  311. float alpha = this.m_MaxFlashAlpha * Mathf.Sin(Mathf.Clamp01(timer / this.m_MaxFlashAlpha) * 180f * 0.017453292f);
  312. this.m_FlashGauge.alpha = alpha;
  313. if (timer > this.m_MaxFlashAlpha)
  314. {
  315. break;
  316. }
  317. }
  318. yield return null;
  319. }
  320. this.m_FlashGauge.gameObject.SetActive(false);
  321. yield break;
  322. yield break;
  323. }
  324. public override void StartAction()
  325. {
  326. foreach (float num in this.m_All_BranchPoint)
  327. {
  328. GameObject gameObject = Utility.CreatePrefab(this.m_MarkParent, "SceneDance/Rhythm_Action/Prefab/" + this.m_ProgressMarkName, true);
  329. float d = Mathf.Clamp01(num / RhythmAction_Mgr.Instance.TakeTime) * (float)this.m_ProgressGauge.width;
  330. gameObject.transform.localPosition = Vector3.right * d;
  331. UISprite component = gameObject.GetComponent<UISprite>();
  332. this.m_ProgressMarkList.Add(component);
  333. }
  334. base.StartCoroutine(this.ProductCheck());
  335. }
  336. private Product_Mgr.AudienceState m_nAudience;
  337. [SerializeField]
  338. [Header("通過マークオブジェクト名")]
  339. private string m_ProgressMarkName = "ProgressMark";
  340. private List<UISprite> m_ProgressMarkList = new List<UISprite>();
  341. [SerializeField]
  342. [Header("通過マークの親")]
  343. private GameObject m_MarkParent;
  344. [SerializeField]
  345. [Header("プログレスゲージ")]
  346. private UISprite m_ProgressGauge;
  347. [SerializeField]
  348. [Header("経過時間UI(1分以上)")]
  349. private UILabel m_MinuteTimeText;
  350. [SerializeField]
  351. [Header("経過時間UI(1分以下)")]
  352. private UILabel m_SecondsTimeText;
  353. [SerializeField]
  354. [Header("通常・上位演出用のオブジェクトグループ")]
  355. private List<GameObject> m_SpecialProduct = new List<GameObject>();
  356. [SerializeField]
  357. private Product_Mgr.Audience[] m_AllAudience = new Product_Mgr.Audience[]
  358. {
  359. new Product_Mgr.Audience(Product_Mgr.AudienceState.Few, 1),
  360. new Product_Mgr.Audience(Product_Mgr.AudienceState.Normal, 3),
  361. new Product_Mgr.Audience(Product_Mgr.AudienceState.Many, 5)
  362. };
  363. [SerializeField]
  364. [Header("上位演出エフェクト")]
  365. private Transform m_SpecialEffect;
  366. [SerializeField]
  367. [Header("ゲージ光らせる時間")]
  368. private float m_GaugeFlashTime;
  369. [SerializeField]
  370. [Range(0f, 1f)]
  371. private float m_MaxFlashAlpha = 1f;
  372. [SerializeField]
  373. private UISprite m_FlashGauge;
  374. private Product_Mgr.ProductRank m_nProduct;
  375. private List<float> m_All_BranchPoint = new List<float>();
  376. private List<MeshRenderer> m_ProductSpecialRender = new List<MeshRenderer>();
  377. private List<GameObject> m_ProductSpecialObj = new List<GameObject>();
  378. public enum ProductRank
  379. {
  380. Low,
  381. Special,
  382. Normal
  383. }
  384. public enum AudienceState
  385. {
  386. Few,
  387. Normal,
  388. Many
  389. }
  390. [Serializable]
  391. private class Audience
  392. {
  393. public Audience(Product_Mgr.AudienceState state, int voltage)
  394. {
  395. this.State = state;
  396. this.Voltage = voltage;
  397. }
  398. [Header("表示する時の客数状態")]
  399. public Product_Mgr.AudienceState State;
  400. [Header("このボルテージ以上の時表示")]
  401. public int Voltage;
  402. [Header("客オブジェクト")]
  403. public List<GameObject> AudienceObj = new List<GameObject>();
  404. }
  405. }