public SyncEventContext(Event pattern, IEnumerable<Event> events, EventList calendar, EventListManager mgr)
 {
     Pattern = pattern;
      Events = events;
      EventList = calendar;
      EventListManager = mgr;
 }
Beispiel #2
0
    public override IAction ActionOnEnter(Player obj)
    {
        // Get specific event
        EventAction eventAction = EventListManager.GetInstance().GetAction(obj);

        // Pack UI actions
        ActionList result = new ActionList();

        LambdaCompletableAction action = new LambdaCompletableAction(null);                 // 3

        action.preAction = () => {
            NotifyPlotEnter(obj);

            EventDeck.SetActive(true);                                                      // 1
            // Create Event Card
            GameObject EventCardModel = Instantiate(EventModel);
            // ... with the corresponding event sprite
            SpriteRenderer EventCardRenderer = EventCardModel.GetComponentInChildren <SpriteRenderer>();
            EventCardRenderer.sprite
                = EventListManager.GetInstance().EventSprite[eventAction];
            // When target is reached, show the skip button.
            EventCardRenderer
            .GetComponent <EventCardDraw>()
            .ListenTargetReached(
                new LambdaAction(() =>
            {
                SkipButtonUI skipButtonUI = SkipButtonUI.GetInstance();

                skipButtonUI.MaxTime = 5f;
                skipButtonUI.Enable();
                // When the skip button is clicked, destroy the EventCard
                // and hide the event deck
                // note: skip button UI is disabled on click
                skipButtonUI.ListenClick(
                    new LambdaAction(() =>
                {
                    EventDeck.SetActive(false);                                             // 1
                    Destroy(EventCardModel);
                    // Then FINALLY mark this completable action as complete
                    action.PerformOnComplete();                                             // 3
                }));
            }));
        };

        result.AddBlockingAction(action);
        result.AddNonBlockAction(eventAction);

        /* LOGICAL BUG
         * // TODO
         * result.OnActionComplete = new LambdaAction(() =>
         * {
         *  TurnDirector.Ins.EndOfPhase();
         * });
         * //*/
        NotifyPlotEnter(obj);

        return(result);
    }
        private static void Create(Schedule schedule, Event evt, EventListManager mgr)
        {
            if (schedule != null)
             {
            Item root = StaticSettings.EventTargetDatabase.GetItem(mgr.SiteSettings.SchedulesRoot.ID);
            if (root != null)
            {
               using (new SecurityDisabler())
               {
                  Item newSched =
                     root.Add(string.Join("", new[] {EventListManager.SchedulePrefix, "-", evt.Title}),
                        StaticSettings.ScheduleTemplate);

                  schedule.SaveRecurrence(newSched);
                  schedule.ID = newSched.ID.ToString();

                  PublishUtil.Publishing(newSched, false, false);
               }
            }
             }
        }