public static void StartTaskRestoration(ITaskCard card, int days)
 {
     if (card.State == TaskCardStates.Executed)
     {
         DayTimer dt = DayTimeSystem.CreateDayTimer(days);
         dt.AddTimerFinishedListener(card.Restore);
         dt.StartTimer();
     }
 }
 public static void StartTaskExecuting(ITaskCard card, int days)
 {
     if (card.State == TaskCardStates.Standalone)
     {
         DayTimer dt = DayTimeSystem.CreateDayTimer(days);
         card.State = TaskCardStates.Executing;
         dt.AddTimerFinishedListener(card.Execute);
         dt.StartTimer();
     }
 }
Example #3
0
    private void OnTaskCardAdded(MonitoredStorage storage, GameObject card, ICard cardData)
    {
        ITaskCard         taskCard = cardData as ITaskCard;
        TaskCardFormatter cf       = card.GetComponent <TaskCardFormatter>();

        if (cf == null || taskCard == null)
        {
            return;
        }
        int time = storage.Days;

        cf.ActivateCardRemainTime(time);
        DayTimer dt = DayTimeSystem.CreateDayTimer(time);

        dt.AddNewDayListener(cf.UpdateCardRemainTime);
        dt.AddTimerFinishedListener(cf.DeactivateCardRemainTime);
        dt.AddTimerFinishedListener(() => storage.Storage.RemoveCard(cardData));
        dt.AddTimerFinishedListener(() => storage.OnExpired.Invoke(taskCard));
        storage.Timers[cardData] = dt;
        dt.StartTimer();
    }