protected override void doRun()
        {
            // Show the menu of types.
            List <Response> types = Types.Select((t) => new Response(t.Key,
                                                                     Helper.Translation.Get($"nightEvents.type.{t.Key}"))).ToList();

            if (Constants.TargetPlatform == GamePlatform.Android)
            {
                types.RemoveAll((r) => r.responseKey == "leave");
            }
            Game1.drawObjectQuestionDialogue
                (Helper.Translation.Get("nightEvents.type.question"), types);

            Game1.currentLocation.afterQuestion = (Farmer _who, string type) =>
            {
                Game1.currentLocation.afterQuestion = null;

                // If "leave", we're done.
                if (type == "leave")
                {
                    extinguish();
                    return;
                }

                // Gather the appropriate predictions.
                List <NightEventPrediction> predictions =
                    NightEvents.ListNextEventsForDate(Utilities.Now(), 3,
                                                      Types[type]);
                if (predictions.Count == 0)
                {
                    throw new Exception($"Could not predict night events of {type} type.");
                }

                // Show a list of the predictions.
                List <string> predictionStrings = predictions.Select((p) =>
                                                                     unbreak(Helper.Translation.Get($"nightEvents.prediction.{p.type}",
                                                                                                    new { date = p.date.Localize() }).ToString())).ToList();
                showDialogues(new List <string>
                {
                    string.Join("^", predictionStrings),
                    unbreak(Helper.Translation.Get("nightEvents.closing")),
                });
                Game1.afterDialogues = extinguish;
            };
        }
예제 #2
0
        private NightEventType getCurrentEvent()
        {
            WorldDate tonight = Utilities.Now();

            List <NightEventPrediction> predictions =
                NightEvents.ListNextEventsForDate(tonight, 1);

            if (predictions.Count >= 1 && predictions[0].date == tonight)
            {
                switch (predictions[0].type)
                {
                case NightEventType.Meteorite:
                case NightEventType.StrangeCapsule:
                    return(predictions[0].type);
                }
            }

            if (tonight.Season == "winter" && tonight.DayOfMonth == 28)
            {
                return(NightEventType.NewYear);
            }

            return(NightEventType.None);
        }
        private NightEvents.Event getCurrentEvent()
        {
            SDate tonight = SDate.Now();

            List <NightEvents.Prediction> predictions =
                NightEvents.ListNextEventsFromDate(tonight, 1);

            if (predictions.Count >= 1 && predictions[0].date == tonight)
            {
                switch (predictions[0].@event)
                {
                case NightEvents.Event.Meteorite:
                case NightEvents.Event.StrangeCapsule:
                    return(predictions[0].@event);
                }
            }

            if (tonight.Season == "winter" && tonight.Day == 28)
            {
                return(NightEvents.Event.NewYear);
            }

            return(NightEvents.Event.None);
        }