Exemple #1
0
 private void Start()
 {
     _timerForWindow = DayTimeSystem.CreateDayTimer(TIME_DAYS_MAX, false);
     _timerForWindow.AddTimerFinishedListener(ShowWindow);
     _inProcess = false;
     _window.AddConfirmListener(OnConfirm);
 }
 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();
     }
 }
    public static DayTimer CreateDayTimer(int days, bool oneOff = true)
    {
        DayTimer dt = new DayTimer(ticksInDay, days, _tickChannel, oneOff);

        if (oneOff)
        {
            // dt.AddTimerFinishedListener(dt.Deactivate);
            dt.AddTimerFinishedListener(() => RemoveDayTimerFromTimers(dt));
        }
        _timers.Add(dt);
        return(dt);
    }
Exemple #5
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();
    }
Exemple #6
0
    private void Init()
    {
        if (_initialized)
        {
            return;
        }
        _numberLimit = _generalParameters.tasksDisplayLimitation;
        int time = _intervalParameters.baseProvidingPeriod;

        foreach (var p in _intervalParameters.providingPeriods)
        {
            if (p.Card == _taskData)
            {
                time = p.Period;
            }
        }
        _creationTimer = DayTimeSystem.CreateDayTimer(time, false);
        _creationTimer.AddTimerFinishedListener(Create);
        _placeForCreation.numberChanged.AddListener(CheckCardPlace);
        _initialized = true;
    }
    public void ProcessRequest(CardResourceRequest request)
    {
        CardResourceRequest reqToDisplace = null;

        foreach (CardResourceRequest r in _requests)
        {
            if (r.Data == request.Data)
            {
                reqToDisplace = r;
                break;
            }
        }
        _requests.Remove(reqToDisplace);
        _requests.Add(request);
        if (reqToDisplace == null)
        {
            DayTimer timer = InitProvidingTimer(request.Data);
            timer.AddTimerFinishedListener(() => InjectByRequest(request));
        }
        ResetProvidingTimer(request.Data);
        // CheckRequests();
    }