Exemplo n.º 1
0
        public static bool Initialise(DateTime start, Action <TimeRange, List <ScheduledEvent> > action)
        {
            if (Screen.width <= Screen.height)
            {
                periodStart = start.Date;
            }
            int delta = DayOfWeek.Monday - start.DayOfWeek;

            start = start.AddDays(delta > 0 ? delta - 7 : delta);
            if (Screen.width > Screen.height)
            {
                periodStart = start.Date;
            }
            var period = new TimeRange(start, start + new TimeSpan(6, 0, 0, 0));

            if (!Manager.provider.TryGetModule(out Integrations.Schedule module))
            {
                Manager.instance.transform.Find("Schedule").gameObject.SetActive(false); return(false);
            }
            var dayList   = period.DayList();
            var _schedule = Manager.Data.ActiveChild.Schedule?.Where(h => dayList.Contains(h.start.Date)).ToList();

            if (_schedule?.Count > 0)
            {
                action(period, _schedule);
            }
            else
            {
                UnityThread.executeCoroutine(module.GetSchedule(period, (schedule) => action(period, schedule.ToList())));
            }
            return(true);
        }