PrivateEventSelectPanel.cs 3.1 KB

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