Product_Mgr.cs 11 KB

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