private void YearEndedHandler()
    {
        currentYear++;
        OnYearChanged.Invoke(currentYear);

        StartCoroutine(CountdownToNextYear());
    }
    private IEnumerator CountdownToFirstYear()
    {
        yield return(Countdown(firstYearPlanningTime));

        GameState = GameState.SeasonElapsing;

        currentYear++;
        OnYearChanged.Invoke(currentYear);

        _seasonManager.BeginYear();
    }
Ejemplo n.º 3
0
        protected override void OnUpdate()
        {
            DeltaTime    = Time.DeltaTime * TimeSpeed;
            ElapsedTime += DeltaTime;

            Second += DeltaTime;
            if (Second >= TimeInHour)
            {
                Hour   += 1;
                Second -= TimeInHour;
                if (Hour < HoursInDay)
                {
                    OnHourChanged?.Invoke(Hour);
                }
            }
            if (Hour >= HoursInDay)
            {
                Day  += 1;
                Hour -= HoursInDay;
                OnHourChanged?.Invoke(Hour);

                if (Day < DaysInMonth)
                {
                    OnDayChanged?.Invoke(Day);
                }
            }
            if (Day >= DaysInMonth)
            {
                Month += 1;
                Day   -= DaysInMonth;
                OnDayChanged?.Invoke(Day);

                if (Month < MonthsInYear)
                {
                    OnMonthChanged?.Invoke(Month);
                }
            }
            if (Month >= MonthsInYear)
            {
                Year  += 1;
                Month -= MonthsInYear;
                OnMonthChanged?.Invoke(Month);
                OnYearChanged?.Invoke(Year);
            }

            Entities
            .WithName("MyTimeManager")
            .ForEach((Entity entity,
                      ref MyTimeTag timeData) =>
            {
                //timeData.ElapsedTime = ElapsedTime;
                //just have a default timetag to force update.
            }).ScheduleParallel();
        }