示例#1
0
        /// <summary>Raised after the in-game clock time changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnTimeChanged(object sender, TimeChangedEventArgs e)
        {
            if (Game1.timeOfDay == OurMoon.GetMoonRiseTime() && Game1.timeOfDay > 0600 && ModConfig.ShowMoonPhase)
            {
                Game1.addHUDMessage(new TCHUDMessage(
                                        Helper.Translation.Get("moon-text.moonrise", new { moonPhase = OurMoon.DescribeMoonPhase(), moonSet = OurMoon.GetMoonSetTime() }),
                                        OurMoon.CurrentPhase()));
            }

            if (Game1.timeOfDay == OurMoon.GetMoonSetTime() && ModConfig.ShowMoonPhase)
            {
                Game1.addHUDMessage(new TCHUDMessage(Helper.Translation.Get("moon-text.moonset", new { moonPhase = OurMoon.DescribeMoonPhase() }), OurMoon.CurrentPhase()));
            }

            if (OurMoon.IsEclipse)
            {
                Game1.globalOutdoorLighting = .5f;
                Game1.ambientLight          = nightColor;
                Game1.currentLocation.switchOutNightTiles();
                ResetTicker = 1;

                if (!Game1.currentLocation.IsOutdoors && Game1.currentLocation is DecoratableLocation)
                {
                    var loc = Game1.currentLocation as DecoratableLocation;
                    foreach (Furniture f in loc.furniture)
                    {
                        if (f.furniture_type.Value == Furniture.window)
                        {
                            Helper.Reflection.GetMethod(f, "addLights").Invoke(Game1.currentLocation);
                        }
                    }
                }

                if ((Game1.farmEvent == null && Game1.random.NextDouble() < (0.25 - Game1.player.team.AverageDailyLuck() / 2.0)) &&
                    Game1.spawnMonstersAtNight && Context.IsMainPlayer)
                {
                    if (ModConfig.Verbose)
                    {
                        Monitor.Log("Spawning a monster, or attempting to.", LogLevel.Debug);
                    }

                    if (Game1.random.NextDouble() < 0.25)
                    {
                        if (Game1.currentLocation.IsFarm)
                        {
                            Game1.getFarm().spawnFlyingMonstersOffScreen();
                            return;
                        }
                    }
                    else
                    {
                        Game1.getFarm().spawnGroundMonsterOffScreen();
                    }
                }
            }

            //moon 10-minute
            OurMoon.TenMinuteUpdate();
        }