/// <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; }
// DAY TIME SETTINGS public void SaveColorMode(bool mode) { BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/daytimeSettings.dat"); DayTimeSettings data = new DayTimeSettings(); data.isDayTime = mode; binaryFormatter.Serialize(file, data); file.Close(); }
public bool LoadColorMode() { if (File.Exists(Application.persistentDataPath + "/daytimeSettings.dat")) { BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/daytimeSettings.dat", FileMode.Open); DayTimeSettings data = (DayTimeSettings)binaryFormatter.Deserialize(file); file.Close(); return(data.isDayTime); } else { return(true); } }