예제 #1
0
    void Start()
    {
        gameObject.name = "TimeSystem";

        _hourText.text = _hour.ToString("D2") + " : ";
        _minText.text  = _minute.ToString("D2");
        if (_hour >= 12)
        {
            _meridiem.text = "PM";
        }
        else
        {
            _meridiem.text = "AM";
        }

        _globalMinLight = 0.5f;
        _globalMaxLight = 1.1f;

        Vector2 newPosition = GameManager.Instance.GetPlayer().transform.position;

        newPosition.y += 0.5f;
        _pointLight.transform.position = newPosition;

        onHourChangedCallback += UpdateLight;
        UpdateLight();
        StartCoroutine(UpdateTime(_interval));
    }
예제 #2
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();
        }
예제 #3
0
 public void Update(float deltaTime)
 {
     if (_timer >= _daySettingsDatabase.HourLength)
     {
         _timer = 0f;
         _dayModel.Hours++;
         OnHourChanged?.Invoke();
     }
     else
     {
         _timer += deltaTime;
     }
 }