private void StartBirthdayEvent() { //Here is were I am supposed to do all the cool stuff, is birthday day and we are in town this.Monitor.Log("Event started!", LogLevel.Info); StardewValley.NPC protoNPC = null; //Spawn a custom merchant with Robin-Wizard's sprite foreach (StardewValley.GameLocation loc in StardewValley.Game1.locations) { foreach (StardewValley.NPC npc in loc.characters) { this.Monitor.Log($"NPC found: {npc.getName()}", LogLevel.Info); if (npc.getName() == "Wizard" || npc.getName() == "Magnus") { protoNPC = npc; this.Monitor.Log("Wizard selected.", LogLevel.Info); } } } if (protoNPC == null) { this.Monitor.Log("No NPC with name Wizard or Magnus found.", LogLevel.Error); } newNpc = new StardewValley.NPC(protoNPC.Sprite, npcPosition, "Town", 2, protoNPC.getName(), new Dictionary <int, int[]>(), protoNPC.Portrait, false); newNpc.setTileLocation(npcPosition); newNpc.Speed = protoNPC.Speed; // Spawn Robin-Wizard in town Game1.getLocationFromName("Town").addCharacter(newNpc); // Try to stop Robin-Wizard newNpc.Halt(); newNpc.stopWithoutChangingFrame(); newNpc.movementPause = 1000000000; //Opens a dialogue as soon as the village is entered newNpc.setNewDialogue("We are ready to begin, @! I have hidden 26 summer spangles around town. Find them all, then come talk to me in the middle of the plaza for a reward."); if (!Game1.player.IsMainPlayer) { // Show dialogue Game1.drawDialogue(newNpc); } this.Monitor.Log("NPC spawned!", LogLevel.Info); // Change music, if we are currently on town change directly, else set // up a hook to change the music when the player enters town if (Game1.player.currentLocation.Name.Equals("Town")) { Game1.changeMusicTrack("WizardSong"); } else { helper.Events.Player.Warped += OnPlayerWarped; } // Roses positions // Entryway rosesPositions[0] = new Vector2(15, 52); rosesPositions[1] = new Vector2(6, 52); rosesPositions[2] = new Vector2(11, 58); rosesPositions[3] = new Vector2(25, 49); // Community Center rosesPositions[4] = new Vector2(7, 25); rosesPositions[5] = new Vector2(34, 18); rosesPositions[6] = new Vector2(48, 21); rosesPositions[7] = new Vector2(61, 17); rosesPositions[8] = new Vector2(70, 20); rosesPositions[9] = new Vector2(82, 17); // Top right rosesPositions[10] = new Vector2(94, 61); rosesPositions[11] = new Vector2(106, 20); rosesPositions[12] = new Vector2(115, 22); rosesPositions[13] = new Vector2(114, 33); // Bottom right rosesPositions[14] = new Vector2(113, 70); rosesPositions[15] = new Vector2(105, 75); rosesPositions[16] = new Vector2(107, 93); rosesPositions[17] = new Vector2(110, 100); // Bottom rosesPositions[18] = new Vector2(69, 100); rosesPositions[19] = new Vector2(61, 98); rosesPositions[20] = new Vector2(45, 102); rosesPositions[21] = new Vector2(42, 87); rosesPositions[22] = new Vector2(48, 77); // Bottom left rosesPositions[23] = new Vector2(22, 99); rosesPositions[24] = new Vector2(6, 84); rosesPositions[25] = new Vector2(26, 77); // Set up the color values for summer spangles Color[] colorChoice = new Color[] { new Color(0, 208, 255), new Color(99, 255, 210), new Color(255, 212, 0), new Color(255, 144, 122), new Color(255, 0, 238), new Color(206, 91, 255), }; // Create randomizer Random randColor = new Random(); int[] tints = new int[26]; for (int i = 0; i < 26; i++) { tints[i] = randColor.Next(0, 6); } // Set the vector to check if they have been picked up and spawn them for (int i = 0; i < 26; i++) { rosesFound[i] = false; // Get a random color Color tint = colorChoice[tints[i]]; // Spawn the roses Game1.getLocationFromName("Town").dropObject(new StardewValley.Objects.ColoredObject(593, 1, tint), rosesPositions[i] * 64f, Game1.viewport, true, (Farmer)null); } this.Monitor.Log("Spawned items!", LogLevel.Info); }
private void StartBirthdayEvent() { //Here is were I am supposed to do all the cool stuff, is birthday day and we are in town this.Monitor.Log("Event started!", LogLevel.Info); StardewValley.NPC protoNPC = null; //Spawn a custom merchant with Robin's sprite foreach (StardewValley.GameLocation loc in StardewValley.Game1.locations) { foreach (StardewValley.NPC npc in loc.characters) { if (npc.getName() == "Robin") { protoNPC = npc; } } } newNpc = new StardewValley.NPC(protoNPC.Sprite, npcPosition, "Town", 2, "Robin", new Dictionary <int, int[]>(), protoNPC.Portrait, false); newNpc.setTileLocation(npcPosition); newNpc.Speed = protoNPC.Speed; // Spawn Robin in town Game1.getLocationFromName("Town").addCharacter(newNpc); // Try to stop Robin newNpc.Halt(); newNpc.stopWithoutChangingFrame(); newNpc.movementPause = 1000000000; //Opens a dialogue as soon as the village is entered newNpc.setNewDialogue("Hello!, someone special has prepared a minigame for you! Find the 7 fairy roses hidden in town and come talk to me in the middle of the plaza!"); // Show dialogue Game1.drawDialogue(newNpc); // Change music, if we are currently on town change directly, else set // up a hook to change the music when the player enters town if (Game1.player.currentLocation.Name.Equals("Town")) { Game1.changeMusicTrack("WizardSong"); } else { helper.Events.Player.Warped += OnPlayerWarped; } // Roses positions rosesPositions[0] = new Vector2(15, 52); rosesPositions[1] = new Vector2(16, 52); rosesPositions[2] = new Vector2(15, 72); rosesPositions[3] = new Vector2(60, 55); rosesPositions[4] = new Vector2(44, 86); rosesPositions[5] = new Vector2(61, 97); rosesPositions[6] = new Vector2(62, 97); // Set the vector to check if they have been picked up and spawn them for (int i = 0; i < 7; i++) { rosesFound[i] = false; // Spawn the roses Game1.getLocationFromName("Town").dropObject(new StardewValley.Object(595, 1, false, -1, 4), rosesPositions[i] * 64f, Game1.viewport, true, (Farmer)null); } }