using System; using System.Collections.Generic; using PrivateMaidMode; using UnityEngine; public class PrivateEventSelectPanel : MonoBehaviour { private Maid maid { get { return (!(PrivateModeMgr.Instance.PrivateMaid != null)) ? GameMain.Instance.CharacterMgr.GetMaid(0) : PrivateModeMgr.Instance.PrivateMaid; } } public void Setup(Maid overRideMaid = null, DataBase.BG overRideBg = null) { foreach (GameObject obj in this.unitList) { UnityEngine.Object.Destroy(obj); } this.conditionParent.gameObject.SetActive(false); DataBase.BG bg = (overRideBg != null) ? overRideBg : PrivateModeMgr.Instance.SelectBG; Maid maid = (!(overRideMaid == null)) ? overRideMaid : this.maid; if (bg == null || maid == null) { return; } DataBase.BG.Event @event = bg.GetEvent(true); foreach (DataBase.BG.Event.PointData pointData in @event.eventPointList) { bool flag = pointData.IsExec(maid) && @event.isNoon == GameMain.Instance.CharacterMgr.status.isDaytime; int nextScenarioIndex = @event.GetNextScenarioIndex(maid, pointData); int no = pointData.no; for (int j = 0; j < pointData.information.Count; j++) { bool isAlreadyReaded = @event.IsFinishedReadingFile(maid, pointData, j); DataBase.BG.Event.PointData.Information info = pointData.information[j]; bool isExec = flag && nextScenarioIndex == j; PrivateEventListUnit privateEventListUnit = this.InstantiateUnitOBject(info, no, isExec, isAlreadyReaded); this.unitGrid.AddChild(privateEventListUnit.transform); this.unitGrid.repositionNow = true; this.unitList.Add(privateEventListUnit.gameObject); } } } private PrivateEventListUnit InstantiateUnitOBject(DataBase.BG.Event.PointData.Information info, int eventNo, bool isExec, bool isAlreadyReaded) { Maid maid = this.maid; GameObject gameObject = UnityEngine.Object.Instantiate(this.eventUnit.gameObject, this.eventUnit.transform); gameObject.SetActive(true); gameObject.name = info.title; PrivateEventListUnit component = gameObject.GetComponent(); component.SetInformation(info, this.conditionParent, this.conditionList); component.isViewMode = this.isViewMode; component.isEnabled = isExec; component.isAlreadyReaded = isAlreadyReaded; if (component.isEnabled && !component.isViewMode) { PrivateEventListUnit privateEventListUnit = component; privateEventListUnit.onClickEvent = (Action)Delegate.Combine(privateEventListUnit.onClickEvent, new Action(delegate() { PrivateModeMgr instance = PrivateModeMgr.Instance; if (instance == null) { return; } if (maid == null) { return; } DataBase.BG.Event @event = instance.SelectBG.GetEvent(true); @event.LoadScript(maid, eventNo); })); } return component; } [SerializeField] private PrivateEventListUnit eventUnit; [SerializeField] private UIGrid unitGrid; [SerializeField] private Transform conditionParent; [SerializeField] private UIWFConditionList conditionList; [SerializeField] private bool isViewMode; private readonly List unitList = new List(); }