static void Main(string[] args) { // Initialize Zara randomizer _random = new Random(DateTime.Now.Millisecond); ZaraEngine.Helpers.InitializeRandomizer((a, b) => (float)(a + ((b - a) * _random.NextDouble()))); // Initialize our weather _weatherForTrepliev = new WeatherDescription(); _weatherForTrepliev.SetTemperature(27f); _weatherForTrepliev.SetWindSpeed(0.1f); _weatherForTrepliev.SetRainIntensity(0.15f); _weatherForFreud = new WeatherDescription(); _weatherForFreud.SetTemperature(57f); _weatherForFreud.SetWindSpeed(5.0f); _weatherForFreud.SetRainIntensity(0f); // Initialize our in-game time _dateTime = DateTime.Now; _timeOfDay = TimesOfDay.Evening; // Initialize our persons. They will share the same game time and time of day Func <DateTime?> gameTimeFunc = () => _dateTime; Func <TimesOfDay> timeOfDayFunc = () => _timeOfDay; _person1 = InitialzeNewPerson("Trepliev", _weatherForTrepliev, gameTimeFunc, timeOfDayFunc); _person2 = InitialzeNewPerson("Freud", _weatherForFreud, gameTimeFunc, timeOfDayFunc); Console.WriteLine("Zara is running"); // Start the "game loop" _loop = new System.Threading.Thread(LoopThread, 0); _loop.Start(); }
public Movie(JObject o) { Url = new Uri((string)o["url"]); Label = (string)o["accessibilityLabel"]; string fileType = (string)o["type"]; if (fileType == "video") { FileType = FileTypes.Video; } else { FileType = FileTypes.Unknown; } Id = (string)o["id"]; string timeOfDay = (string)o["timeOfDay"]; if (timeOfDay == "day") { TimeOfDay = TimesOfDay.Day; } else if (timeOfDay == "night") { TimeOfDay = TimesOfDay.Night; } else { TimeOfDay = TimesOfDay.Unknown; } }
public override void _Ready() { /* Zara Initialization code start =======>> */ ZaraEngine.Helpers.InitializeRandomizer(_random.RandfRange); _dateTime = DateTime.Now; _timeOfDay = TimesOfDay.Evening; _health = new HealthController(this); _body = new BodyStatusController(this); _weather = new WeatherDescription(); _player = new PlayerStatus(); _inventory = new InventoryController(this); _body.Initialize(); _health.Initialize(); /* <<======= Zara Initialization code end */ #region Demo App Init // Defaults _weather.SetTemperature(21f); _weather.SetWindSpeed(10f); _weather.SetRainIntensity(0.12f); #endregion }
public override void OnStart() { /* Zara Initialization code start =======>> */ // Initialize Zara randomizer _random = new Random(DateTime.Now.Millisecond); ZaraEngine.Helpers.InitializeRandomizer((a, b) => (float)(a + ((b - a) * _random.NextDouble()))); _dateTime = DateTime.Now; _timeOfDay = TimesOfDay.Evening; _health = new HealthController(this); _body = new BodyStatusController(this); _weather = new WeatherDescription(); _player = new PlayerStatus(); _inventory = new InventoryController(this); _body.Initialize(); _health.Initialize(); /* <<======= Zara Initialization code end */ #region Demo App Init // Defaults _weather.SetTemperature(24f); _weather.SetWindSpeed(8f); _weather.SetRainIntensity(0.06f); #endregion }
public static TimeOfDayViewModel Parse(TimesOfDay obj) { return(new TimeOfDayViewModel() { Id = obj.Id, Name = obj.Name }); }
void SetTimeOfDay(TimesOfDay timeOfDayIn) { if (timeOfDayStatus != timeOfDayIn) { timeOfDayStatus = timeOfDayIn; currentTransition = 0f; } }
// Use this for initialization void Start() { nightLights = FindObjectsOfType <NightLight>(); TurnOffNightLights(); //print(nightLights.Length + " nightlights found"); sun = transform.Find("Sun").GetComponent <Light>(); fullDayCycle = 100f; fullDayCyclePortion = fullDayCycle / 10f; cycleTransition = fullDayCycle / 10f; dawnColour = new Color32(255, 223, 143, 255); dayColour = new Color32(255, 255, 255, 255); eveningColour = new Color32(234, 112, 33, 255); nightColour = new Color32(255, 255, 255, 255); currentColour = dayColour; //print("current colour: " + currentColour.r + ", " + currentColour.g + ", " + currentColour.b); timeOfDayStartDict = new Dictionary <TimesOfDay, float>(); timeOfDayStartDict.Add(TimesOfDay.daytime, fullDayCyclePortion); timeOfDayStartDict.Add(TimesOfDay.evening, fullDayCyclePortion * 5f); timeOfDayStartDict.Add(TimesOfDay.lateEvening, fullDayCyclePortion * 6f); timeOfDayStartDict.Add(TimesOfDay.night, fullDayCyclePortion * 7f); timeOfDayStartDict.Add(TimesOfDay.lateNight, fullDayCyclePortion * 8f); timeOfDayStartDict.Add(TimesOfDay.dawn, fullDayCyclePortion * 9f); timeOfDayColourDict = new Dictionary <TimesOfDay, Color32>(); timeOfDayColourDict.Add(TimesOfDay.daytime, dayColour); timeOfDayColourDict.Add(TimesOfDay.evening, eveningColour); timeOfDayColourDict.Add(TimesOfDay.lateEvening, nightColour); timeOfDayColourDict.Add(TimesOfDay.night, nightColour); timeOfDayColourDict.Add(TimesOfDay.lateNight, nightColour); timeOfDayColourDict.Add(TimesOfDay.dawn, dawnColour); timeOfDayEarthRotationDict = new Dictionary <TimesOfDay, float>(); timeOfDayEarthRotationDict.Add(TimesOfDay.daytime, 0f); timeOfDayEarthRotationDict.Add(TimesOfDay.evening, 65f); timeOfDayEarthRotationDict.Add(TimesOfDay.lateEvening, 45f); timeOfDayEarthRotationDict.Add(TimesOfDay.night, 0f); timeOfDayEarthRotationDict.Add(TimesOfDay.lateNight, -35f); timeOfDayEarthRotationDict.Add(TimesOfDay.dawn, -65f); timeofDayIntensityDict = new Dictionary <TimesOfDay, float>(); timeofDayIntensityDict.Add(TimesOfDay.daytime, 0.85f); timeofDayIntensityDict.Add(TimesOfDay.evening, 1.2f); timeofDayIntensityDict.Add(TimesOfDay.lateEvening, 0.25f); timeofDayIntensityDict.Add(TimesOfDay.night, 0.2f); timeofDayIntensityDict.Add(TimesOfDay.lateNight, 0.25f); timeofDayIntensityDict.Add(TimesOfDay.dawn, 1.2f); timeOfDayStatus = TimesOfDay.daytime; currentTime = timeOfDayStartDict[TimesOfDay.evening]; currentTransition = 10f; currentRotation = timeOfDayEarthRotationDict[TimesOfDay.daytime]; currentIntensity = timeofDayIntensityDict[TimesOfDay.daytime]; }
public OperationResult Create(TimesOfDay item) { try { _dao.Create(item); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = false, Exception = e }); } }
public async Task <OperationResult> CreateAsync(TimesOfDay item) { try { await _dao.CreateAsync(item); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = false, Exception = e }); } }
public void Unpack(BinaryReader reader) { ZeroTimeOfYear = reader.ReadDouble(); ZeroYear = reader.ReadUInt32(); DayLength = reader.ReadSingle(); DaysPerYear = reader.ReadUInt32(); YearSpec = reader.ReadPString(); reader.AlignBoundary(); TimesOfDay.Unpack(reader); uint numDaysOfTheWeek = reader.ReadUInt32(); for (uint i = 0; i < numDaysOfTheWeek; i++) { var weekDay = reader.ReadPString(); reader.AlignBoundary(); DaysOfTheWeek.Add(weekDay); } Seasons.Unpack(reader); }
private void InitializeTimesOfDay() { TimesOfDay.Add(new SVTimeOfDay() { Time = "6am", StoresOpeningAtTime = new List <SVWikiLink>() { Shops.TravelingCart, Shops.WizardsTower, }, StoresClosingAtTime = new List <SVWikiLink>(), }); TimesOfDay.Add(new SVTimeOfDay() { Time = "8am", StoresOpeningAtTime = new List <SVWikiLink>() { Shops.Museum, }, StoresClosingAtTime = new List <SVWikiLink>(), }); TimesOfDay.Add(new SVTimeOfDay() { Time = "9am", StoresOpeningAtTime = new List <SVWikiLink>() { Shops.Blacksmith, Shops.CarpenterShop, Shops.GeneralStore, Shops.FishShop, Shops.JojaMart, Shops.MarniesRanch, Shops.Oasis, }, StoresClosingAtTime = new List <SVWikiLink>(), }); TimesOfDay.Add(new SVTimeOfDay() { Time = "12pm", StoresOpeningAtTime = new List <SVWikiLink>() { Shops.Saloon, }, StoresClosingAtTime = new List <SVWikiLink>(), }); TimesOfDay.Add(new SVTimeOfDay() { Time = "2pm", StoresOpeningAtTime = new List <SVWikiLink>() { Shops.AdventurersGuild, }, StoresClosingAtTime = new List <SVWikiLink>() { }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "3pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.Clinic, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "4pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.Blacksmith, Shops.MarniesRanch, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "5pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.BusStop, Shops.CarpenterShop, Shops.FishShop, Shops.GeneralStore, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "6pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.Museum, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "8pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.TravelingCart, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "10pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.AdventurersGuild, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "11pm", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.JojaMart, Shops.WizardsTower, }, }); TimesOfDay.Add(new SVTimeOfDay() { Time = "12am", StoresOpeningAtTime = new List <SVWikiLink>() { }, StoresClosingAtTime = new List <SVWikiLink>() { Shops.Saloon, Shops.Oasis }, }); }
/// <summary> /// Gets the date and time of the next occurrence from <paramref name="now"/>. /// </summary> /// <param name="now">The current date and time assumed to be an universal time if not specified to avoid invalid and ambiguous times.</param> /// <returns>The date and time of the next occurrence in local time.</returns> protected override DateTime GetNextTime(DateTime inNow) { var now = inNow.AsLocalTime(); // consider first occurrence var firstOccurrence = (timesOfDayQueue == null); // initialize timesOfDayQueue if necessary if (timesOfDayQueue == null) { // consider current dayOfWeek not in requested WeekDays if ((WeekDays & FlagsEnum.PowerOfTwo <RecurrentWeekDays>(now.DayOfWeek)) != FlagsEnum.PowerOfTwo <RecurrentWeekDays>(now.DayOfWeek)) { timesOfDayQueue = new Queue <TimeSpan>(TimesOfDay); } else { // order the timesOfDay according to the current date and time timesOfDayQueue = new Queue <TimeSpan>(TimesOfDay .SkipWhile(match => match <= now.TimeOfDay) .Concat(TimesOfDay) .Take(TimesOfDay.Count()) .DefaultIfEmpty(TimesOfDay.First())); } } // remove the current timeOfDay from the queue var timeOfDay = timesOfDayQueue.Dequeue(); // add the current timeOfDay to the end timesOfDayQueue.Enqueue(timeOfDay); // get today to maintain the specified timeOfDay across the daylight time var today = now.Date.AsLocalTime(); // shift today if necessary in order to calculate correctly the next date if ((firstOccurrence && now.TimeOfDay < timeOfDay) || (!firstOccurrence && timesOfDayQueue.Count > 1 && timeOfDay > timesOfDayQueue.Min())) { today = today.AddDays(-1); } // get the next date var nextDate = GetNextDateByDayOfWeek(today); // keep the found next date var index = (int)nextDate.DayOfWeek; if (nextDates[index] != null && nextDates[index].Value < nextDate) { nextDate = nextDates[index].Value.AddDays(7 * Weeks); } nextDates[index] = nextDate; // consider next time validity if (TimeZoneContext.Current.TimeZoneInfo.IsInvalidTime(nextDate.Add(timeOfDay)) && Behavior.InvalidTime == InvalidTimeBehavior.Skip) { // get the next valid time return(GetNextTime(nextDate)); } // consider next time ambiguity if (TimeZoneContext.Current.TimeZoneInfo.IsAmbiguousTime(nextDate.Add(timeOfDay)) && Behavior.AmbiguousTime == AmbiguousTimeBehavior.DaylightTime) { // get the next time from the universal time return(nextDate.AsUniversalTime().Add(timeOfDay).AsLocalTime()); } // get the next time from the local time return(nextDate.Add(timeOfDay)); }
/// <summary> /// Gets the date and time of the next occurrence from <paramref name="now"/>. /// </summary> /// <param name="now">The current date and time assumed to be an universal time if not specified to avoid invalid and ambiguous times.</param> /// <returns>The date and time of the next occurrence in local time.</returns> protected override DateTime GetNextTime(DateTime inNow) { if (inNow.Kind == DateTimeKind.Unspecified) { throw new InvalidTimeZoneException("DateTime Kind should be set. Unspecified is unsupported!"); } var now = inNow.AsLocalTime(); // consider first occurrence var firstOccurrence = (timesOfDayQueue == null); // initialize timesOfDayQueue if necessary if (timesOfDayQueue == null) { // consider current dayOfWeek not in requested WeekDays if (Days == 0 && (WeekDays & FlagsEnum.PowerOfTwo <RecurrentWeekDays>(now.DayOfWeek)) != FlagsEnum.PowerOfTwo <RecurrentWeekDays>(now.DayOfWeek)) { timesOfDayQueue = new Queue <TimeSpan>(TimesOfDay); } else { // order the timesOfDay according to the current date and time timesOfDayQueue = new Queue <TimeSpan>(TimesOfDay .SkipWhile(match => match <= now.TimeOfDay) .Concat(TimesOfDay) .Take(TimesOfDay.Count()) .DefaultIfEmpty(TimesOfDay.First())); } } // remove the current timeOfDay from the queue var timeOfDay = timesOfDayQueue.Dequeue(); // add the current timeOfDay to the end timesOfDayQueue.Enqueue(timeOfDay); // get today to maintain the specified timeOfDay across the daylight time var today = now.Date; // shift today if necessary in order to calculate correctly the next date if ((firstOccurrence && now.TimeOfDay < timeOfDay) || (!firstOccurrence && timesOfDayQueue.Count > 1 && timeOfDay > timesOfDayQueue.Min())) { today = today.AddDays(Days != 0 ? -Days : -1); } // get the next date var nextDate = (Days != 0) ? today.AddDays(Days) : GetNextDateByDayOfWeek(today); // consider next time validity if (TimeZoneContext.Current.TimeZoneInfo.IsInvalidTime(nextDate.Add(timeOfDay)) && Behavior.InvalidTime == InvalidTimeBehavior.Skip) { // get the next valid time return(GetNextTime(nextDate)); } // consider next time ambiguity if (TimeZoneContext.Current.TimeZoneInfo.IsAmbiguousTime(nextDate.Add(timeOfDay)) && Behavior.AmbiguousTime == AmbiguousTimeBehavior.DaylightTime) { // get the next time from the universal time return(nextDate.AsUniversalTime().Add(timeOfDay).AsLocalTime()); } // get the next time from the local time return(nextDate.Add(timeOfDay)); }
public static bool HasFlags(this TimesOfDay time, TimesOfDay f) { return((time & f) == f); }
// Start is called before the first frame update void Start() { /* Zara Initialization code start =======>> */ ZaraEngine.Helpers.InitializeRandomizer(UnityEngine.Random.Range); _dateTime = DateTime.Now; _timeOfDay = TimesOfDay.Evening; _health = new HealthController(this); _body = new BodyStatusController(this); _weather = new WeatherDescription(); _player = new PlayerStatus(); _inventory = new InventoryController(this); _body.Initialize(); _health.Initialize(); /* <<======= Zara Initialization code end */ #region Demo app init // Let's add some items to the inventory to play with in this demo var flaskWithWater = new ZaraEngine.Inventory.Flask(); flaskWithWater.FillUp(WorldTime.Value); //flaskWithWater.Disinfect(WorldTime.Value); _jacket = new ZaraEngine.Inventory.WaterproofJacket(); _pants = new ZaraEngine.Inventory.WaterproofPants(); _boots = new ZaraEngine.Inventory.RubberBoots(); _hat = new ZaraEngine.Inventory.LeafHat(); _inventory.AddItem(flaskWithWater); _inventory.AddItem(_jacket); _inventory.AddItem(_pants); _inventory.AddItem(_boots); _inventory.AddItem(_hat); var meat = new ZaraEngine.Inventory.Meat { Count = 1 }; // We just gathered two of spoiled Meat. meat.AddGatheringInfo(WorldTime.Value.AddHours(-5), 2); // We just gathered one item of fresh Meat. These will spoil in MinutesUntilSpoiled game minutes. meat.AddGatheringInfo(WorldTime.Value, 1); _inventory.AddItem(new ZaraEngine.Inventory.Cloth { Count = 20 }); _inventory.AddItem(meat); _inventory.AddItem(new ZaraEngine.Inventory.AntisepticSponge { Count = 5 }); _inventory.AddItem(new ZaraEngine.Inventory.Bandage { Count = 5 }); _inventory.AddItem(new ZaraEngine.Inventory.Acetaminophen { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Antibiotic { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Aspirin { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.EmptySyringe { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Loperamide { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Oseltamivir { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Sedative { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.AtropineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.EpinephrineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.AntiVenomSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.DoripenemSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.MorphineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.DisinfectingPellets { Count = 5 }); RefreshConsumablesUICombo(); RefreshToolsUICombo(); // Defaults _weather.SetTemperature(27f); _weather.SetWindSpeed(2f); _weather.SetRainIntensity(0f); #endregion }
// Start is called before the first frame update void Start() { /* Zara Initialization code start =======>> */ ZaraEngine.Helpers.InitializeRandomizer((a, b) => UnityEngine.Random.Range(a, b)); _dateTime = DateTime.Now; _timeOfDay = TimesOfDay.Evening; _health = new HealthController(this); _body = new BodyStatusController(this); _weather = new WeatherDescription(); _player = new PlayerStatus(); _inventory = new InventoryController(this); ClothesGroups.Initialize(this); _body.Initialize(); _health.Initialize(); /* <<======= Zara Initialization code end */ // Let's add some items to the inventory to play with in this demo var flaskWithWater = new ZaraEngine.Inventory.Flask(); flaskWithWater.FillUp(WorldTime.Value); //flaskWithWater.Disinfect(WorldTime.Value); _jacket = new ZaraEngine.Inventory.WaterproofJacket(); _pants = new ZaraEngine.Inventory.WaterproofPants(); _boots = new ZaraEngine.Inventory.RubberBoots(); _hat = new ZaraEngine.Inventory.LeafHat(); _inventory.AddItem(flaskWithWater); _inventory.AddItem(_jacket); _inventory.AddItem(_pants); _inventory.AddItem(_boots); _inventory.AddItem(_hat); _inventory.AddItem(new ZaraEngine.Inventory.Cloth { Count = 20 }); _inventory.AddItem(new ZaraEngine.Inventory.Meat { Count = 3 }); _inventory.AddItem(new ZaraEngine.Inventory.Bandage { Count = 5 }); _inventory.AddItem(new ZaraEngine.Inventory.Acetaminophen { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Antibiotic { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Aspirin { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.EmptySyringe { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Loperamide { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Oseltamivir { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.Sedative { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.AtropineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.EpinephrineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.AntiVenomSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.DoripenemSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.MorphineSolution { Count = 10 }); _inventory.AddItem(new ZaraEngine.Inventory.DisinfectingPellets { Count = 5 }); RefreshConsumablesUICombo(); RefreshToolsUICombo(); // Defaults _weather.SetTemperature(27f); _weather.SetWindSpeed(0.1f); _weather.SetRainIntensity(0f); }