PrivateEventSelectPanel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using PrivateMaidMode;
  4. using UnityEngine;
  5. public class PrivateEventSelectPanel : MonoBehaviour
  6. {
  7. private bool isNoon
  8. {
  9. get
  10. {
  11. return GameMain.Instance.CharacterMgr.status.isDaytime;
  12. }
  13. }
  14. private Maid maid
  15. {
  16. get
  17. {
  18. return (!(PrivateModeMgr.Instance.PrivateMaid != null)) ? GameMain.Instance.CharacterMgr.GetMaid(0) : PrivateModeMgr.Instance.PrivateMaid;
  19. }
  20. }
  21. public void Setup(Maid overRideMaid = null, DataBase.BG overRideBg = null)
  22. {
  23. foreach (GameObject obj in this.unitList)
  24. {
  25. UnityEngine.Object.Destroy(obj);
  26. }
  27. this.unitList.Clear();
  28. this.conditionParent.gameObject.SetActive(false);
  29. DataBase.BG bg = (overRideBg != null) ? overRideBg : PrivateModeMgr.Instance.SelectBG;
  30. Maid maid = (!(overRideMaid == null)) ? overRideMaid : this.maid;
  31. if (bg == null || maid == null)
  32. {
  33. return;
  34. }
  35. DataBase.BG.Event @event = bg.GetEvent(this.isNoon);
  36. foreach (DataBase.BG.Event.PointData pointData in @event.eventPointList)
  37. {
  38. bool flag = pointData.IsExec(maid) && @event.isNoon == GameMain.Instance.CharacterMgr.status.isDaytime;
  39. int nextScenarioIndex = @event.GetNextScenarioIndex(maid, pointData);
  40. int no = pointData.no;
  41. for (int j = 0; j < pointData.information.Count; j++)
  42. {
  43. bool isAlreadyReaded = @event.IsFinishedReadingFile(maid, pointData, j);
  44. DataBase.BG.Event.PointData.Information information = pointData.information[j];
  45. if (information.iconType != DataBase.BG.Event.PointData.Information.IconType.NTR || !GameMain.Instance.CharacterMgr.status.lockNTRPlay)
  46. {
  47. bool isExec = flag && nextScenarioIndex == j;
  48. PrivateEventListUnit privateEventListUnit = this.InstantiateUnitOBject(information, no, isExec, isAlreadyReaded);
  49. this.unitGrid.AddChild(privateEventListUnit.transform);
  50. this.unitGrid.repositionNow = true;
  51. this.unitList.Add(privateEventListUnit.gameObject);
  52. }
  53. }
  54. }
  55. if (this.unitList.Count <= 0)
  56. {
  57. PrivateEventListUnit privateEventListUnit2 = this.InstantiateEmptyUnitOBject();
  58. this.unitGrid.AddChild(privateEventListUnit2.transform);
  59. this.unitGrid.repositionNow = true;
  60. this.unitList.Add(privateEventListUnit2.gameObject);
  61. }
  62. }
  63. private PrivateEventListUnit InstantiateUnitOBject(DataBase.BG.Event.PointData.Information info, int eventNo, bool isExec, bool isAlreadyReaded)
  64. {
  65. Maid maid = this.maid;
  66. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.eventUnit.gameObject, this.eventUnit.transform);
  67. gameObject.SetActive(true);
  68. gameObject.name = info.title;
  69. PrivateEventListUnit component = gameObject.GetComponent<PrivateEventListUnit>();
  70. component.SetInformation(info, this.conditionParent, this.conditionList);
  71. component.isViewMode = this.isViewMode;
  72. component.isEnabled = isExec;
  73. component.isAlreadyReaded = isAlreadyReaded;
  74. if (component.isEnabled && !component.isViewMode)
  75. {
  76. PrivateEventListUnit privateEventListUnit = component;
  77. privateEventListUnit.onClickEvent = (Action)Delegate.Combine(privateEventListUnit.onClickEvent, new Action(delegate()
  78. {
  79. PrivateModeMgr instance = PrivateModeMgr.Instance;
  80. if (instance == null)
  81. {
  82. return;
  83. }
  84. if (maid == null)
  85. {
  86. return;
  87. }
  88. DataBase.BG.Event @event = instance.SelectBG.GetEvent(this.isNoon);
  89. @event.LoadScript(maid, eventNo);
  90. }));
  91. }
  92. return component;
  93. }
  94. private PrivateEventListUnit InstantiateEmptyUnitOBject()
  95. {
  96. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.eventUnit.gameObject, this.eventUnit.transform);
  97. gameObject.SetActive(true);
  98. PrivateEventListUnit component = gameObject.GetComponent<PrivateEventListUnit>();
  99. component.SetEmptyInformation("イベントはありません");
  100. component.isViewMode = true;
  101. component.isEnabled = false;
  102. component.isAlreadyReaded = true;
  103. return component;
  104. }
  105. [SerializeField]
  106. private PrivateEventListUnit eventUnit;
  107. [SerializeField]
  108. private UIGrid unitGrid;
  109. [SerializeField]
  110. private Transform conditionParent;
  111. [SerializeField]
  112. private UIWFConditionList conditionList;
  113. [SerializeField]
  114. private bool isViewMode;
  115. private readonly List<GameObject> unitList = new List<GameObject>();
  116. }