Пример #1
0
        private void MessageReceived(object sender, ModMessageReceivedEventArgs e)
        {
            if (e.FromModID == this.ModManifest.UniqueID && e.Type == "Toggled")
            {
                Multiplayer message = e.ReadAs <Multiplayer>();

                // Display message to say difficulty toggled, delay in changes means opposite conditions are used for display purposes
                if (Game1.netWorldState.Value.SkullCavesDifficulty > 0)
                {
                    Game1.addHUDMessage(new HUDMessage($"Skull Cavern difficulty toggled to normal by {message.Player}", null));
                }
                else
                {
                    Game1.addHUDMessage(new HUDMessage($"Skull Cavern difficulty toggled to dangerous by {message.Player}", null));
                }

                // Update shrine tiles using opposite conditions
                if (this.config.ShrineToggle == true)
                {
                    Shrine.ApplyTiles(this.Helper, true);
                }
            }
        }
Пример #2
0
        // Toggle difficulty using button/key
        private void Toggle(object sender, ButtonPressedEventArgs e)
        {
            // Has button/key been pressed, shrine is not used
            if (this.config.ToggleDifficulty.JustPressed() == true && this.config.ShrineToggle == false)
            {
                // Has correct button been pushed, conditions for toggle been met and world is ready?
                if (ShouldToggle() == true && Context.IsWorldReady == true)
                {
                    // Yes, toggle difficulty

                    if (Game1.netWorldState.Value.SkullCavesDifficulty > 0)
                    {
                        // Normal
                        Game1.netWorldState.Value.SkullCavesDifficulty = 0;
                        Game1.addHUDMessage(new HUDMessage("Skull Cavern toggled to normal", null));
                    }
                    else
                    {
                        // Dangerous
                        Game1.netWorldState.Value.SkullCavesDifficulty = 1;
                        Game1.addHUDMessage(new HUDMessage("Skull Cavern toggled to dangerous", null));
                    }

                    // Log new difficulty, difficulty will update after the clock ticks in multiplayer (10 in-game minutes)
                    this.Monitor.Log("Skull Cavern Difficulty: " + Game1.netWorldState.Value.SkullCavesDifficulty, LogLevel.Trace);

                    Multiplayer message = new Multiplayer();
                    this.Helper.Multiplayer.SendMessage(message, "Toggled", modIDs: new[] { this.ModManifest.UniqueID });
                }

                else if (ShouldToggle() == false && Context.IsWorldReady == true)
                {
                    // No, display message to say difficulty can't be toggled

                    if (Game1.player.team.SpecialOrderActive("QiChallenge10") == true)
                    {
                        Game1.addHUDMessage(new HUDMessage("Skull Cavern Invasion is active", 3));
                    }

                    else
                    {
                        Game1.addHUDMessage(new HUDMessage("Skull Cavern Invasion not completed", 3));
                    }
                }
            }

            // Using shrine
            else if (true &&
                     (false
                      // Correct button is pressed
                      || e.Button == SButton.MouseRight ||
                      e.Button == SButton.ControllerA)
                     // World is ready
                     && Context.IsWorldReady == true
                     // Correct location
                     && Game1.currentLocation.NameOrUniqueName == "SkullCave"
                     // Player can move
                     && Game1.player.canMove == true
                     // Shrine is showing
                     && ShowShrine() == true)
            {
                GameLocation location = Game1.currentLocation;

                // If player clicks this location (shrine) display the appropriate response
                if (false ||
                    (e.Cursor.GrabTile.X == 2 && e.Cursor.GrabTile.Y == 2) ||
                    (e.Cursor.GrabTile.X == 2 && e.Cursor.GrabTile.Y == 3) ||
                    (e.Cursor.GrabTile.X == 2 && e.Cursor.GrabTile.Y == 4))
                {
                    if (ShouldToggle() == true)
                    {
                        if (Game1.netWorldState.Value.SkullCavesDifficulty > 0)
                        {
                            location.createQuestionDialogue("--Shrine Of Greater Challenge--^Summon an ancient magi-seal protection, returning the Skull Cavern to it's original state?", location.createYesNoResponses(), delegate(Farmer _, string answer)
                            {
                                if (answer == "Yes")
                                {
                                    ShrineMenu(1);
                                }
                            });
                        }
                        else
                        {
                            location.createQuestionDialogue("--Shrine Of Greater Challenge--^Dispel the ancient magi-seal of protection, allowing powerful monsters to enter the cavern?", location.createYesNoResponses(), delegate(Farmer _, string answer)
                            {
                                if (answer == "Yes")
                                {
                                    ShrineMenu(0);
                                }
                            });
                        }
                    }

                    // Skull Cavern Invasion is active, don't try and make the challenge easier
                    else if (ShouldToggle() == false && Game1.player.team.SpecialOrderActive("QiChallenge10") == true)
                    {
                        Game1.activeClickableMenu = new DialogueBox("Mr. Qi wants you to beat this fair and square. Ask again when Skull Cavern Invasion isn't active.");
                    }

                    // Shouldn't see this dialogue, kept in as a safeguard
                    else
                    {
                        Game1.activeClickableMenu = new DialogueBox("You haven't completed Skull Cavern Invasion... I don't think you can handle this yet.");
                    }
                }
            }
        }