Beispiel #1
0
        /// <summary>
        /// Тик контроллера
        /// </summary>
        public override void ControllerUpdate()
        {
            var dt = Time.deltaTime;

            _currentTime += dt;
            if (_currentTime >= _settings[_i])
            {
                _currentTime -= _settings[_i];
                _i++;
                if (_i == _settings.Length)
                {
                    _i = 0;
                }
                EventManager.TriggerEvent(GameEventTypes.DayTimeChanged, new DayTimeArgs((DayTimeTypes)_i));
                if (_currentDayTime == DayTimeTypes.Night)
                {
                    _currentDayTime = DayTimeTypes.Morning;
                }
                else
                {
                    _currentDayTime++;
                }

                _mid       = _settings[_i] / 2f;
                _eventFlag = false;
            }

            if (!_eventFlag && _currentTime >= _mid)
            {
                EventManager.TriggerEvent(GameEventTypes.MidOfDayTimeComes, new DayTimeArgs((DayTimeTypes)_i));
                _eventFlag = true;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="settings">Настройки времени каждой части суток</param>
 /// <param name="currentDayTime">Текущее время суток (если из сейваб например)</param>
 /// <param name="currentTime">Текущий момент времени (если из сейва, например)</param>
 public DayTimeController(DayTimeSettings settings, DayTimeTypes currentDayTime = DayTimeTypes.Morning, float currentTime = 0)
 {
     _settings[(int)DayTimeTypes.Morning] = settings.MorningLength;
     _settings[(int)DayTimeTypes.Day]     = settings.DayLength;
     _settings[(int)DayTimeTypes.Evening] = settings.EveningLength;
     _settings[(int)DayTimeTypes.Night]   = settings.NightLength;
     _currentTime = currentTime;
     _i           = (int)currentDayTime;
     _mid         = _settings[_i] / 2f;
 }
Beispiel #3
0
 public DayTimeArgs(DayTimeTypes dayTime)
 {
     DayTime = dayTime;
 }