Ejemplo n.º 1
0
    public static PlayerCheckin TextCountCheckin(
        CheckinLister lister, Message checkinEvent,
        Text textBox, Predicate allCheckedInPredicate = null,
        EventPredicate checkinPredicate = null,
        Callback onCheckin    = null,
        Callback onReset      = null,
        Message?checkoutEvent = null)
    {
        PlayerCheckin result = new PlayerCheckin(
            lister, checkinEvent, allCheckedInPredicate,
            checkinPredicate, checkoutEvent: checkoutEvent);

        Callback modifyText = () =>
        {
            textBox.text = string.Format("{0}/{1}", result.NumberCheckedIn(), lister().Count);
        };

        onCheckin  = onCheckin ?? delegate { };
        onCheckin += modifyText;

        onReset  = onReset ?? delegate { };
        onReset += modifyText;

        result.onCheckin = onCheckin;
        result.onReset   = onReset;
        return(result);
    }
Ejemplo n.º 2
0
 public PlayerCheckin(CheckinLister lister, Message checkinEvent,
                      Predicate allCheckedInPredicate = null,
                      EventPredicate checkinPredicate = null,
                      Callback onCheckin    = null,
                      Callback onReset      = null,
                      Message?checkoutEvent = null)
 {
     this.lister = lister;
     if (allCheckedInPredicate != null)
     {
         this.allCheckedInPredicate = allCheckedInPredicate;
     }
     if (checkinPredicate != null)
     {
         this.checkinPredicate = checkinPredicate;
     }
     if (onCheckin != null)
     {
         this.onCheckin = onCheckin;
     }
     if (onReset != null)
     {
         this.onReset = onReset;
     }
     GameManager.instance.notificationManager.CallOnMessageWithSender(checkinEvent, Checkin);
     if (checkoutEvent.HasValue)
     {
         GameManager.instance.notificationManager.CallOnMessageWithSender(checkoutEvent.Value, Checkout);
     }
 }