private void DoWarp(WarpLocation warpLocation) { Game1.warpFarmer(warpLocation.Name, warpLocation.CoordX, warpLocation.CoordY, flip: false); if (!Game1.isStartingToGetDarkOut()) { Game1.playMorningSong(); } else { Game1.changeMusicTrack("none"); } Game1.fadeToBlackAlpha = 0.99f; Game1.screenGlow = false; Game1.player.temporarilyInvincible = false; Game1.player.temporaryInvincibilityTimer = 0; Game1.displayFarmer = true; }
private void LocationAnswer(Farmer farmer, string answer) { Enum.TryParse <WarpLocationChoice>(answer, out var choice); if (choice == WarpLocationChoice.None) { return; } if (choice == WarpLocationChoice.Farm || choice == WarpLocationChoice.IslandFarm) { WarpLocation wlocation = WarpLocations.GetWarpLocation(choice); WarpPlayerTo(wlocation); return; } Building building = buildings.FirstOrDefault((Building b) => GetWarpLocationChoiceForBuildingType(b.buildingType.Value) == choice); building?.doAction(new Vector2((int)building.tileX.Value, (int)building.tileY.Value), farmer); }
private void ChooseWarpLocation() { buildings = new List <Building>(); List <Response> responses = new List <Response>(); responses.Add(new Response(WarpLocationChoice.Farm.ToString(), "Farm")); foreach (Building building in Game1.getFarm().buildings) { switch ((string)building.buildingType.Value) { case "Water Obelisk": responses.Add(new Response(WarpLocationChoice.Beach.ToString(), "Beach")); AddBuilding(building); break; case "Earth Obelisk": responses.Add(new Response(WarpLocationChoice.Mountain.ToString(), "Mountain")); AddBuilding(building); break; case "Desert Obelisk": responses.Add(new Response(WarpLocationChoice.Desert.ToString(), "Desert")); AddBuilding(building); break; case "Island Obelisk": responses.Add(new Response(WarpLocationChoice.Island.ToString(), "Ginger Island")); AddBuilding(building); if ((bool)(Game1.locations.First((GameLocation loc) => (string)loc.Name == "IslandWest") as IslandWest)?.farmObelisk.Value) { responses.Add(new Response(WarpLocationChoice.IslandFarm.ToString(), "Ginger Island Farm")); } break; case "Woods Obelisk": responses.Add(new Response(WarpLocationChoice.DeepWoods.ToString(), "Deep Woods")); AddBuilding(building); break; } } //Vector2 obelisk1 = Vector2.Zero; //Vector2 obelisk2 = Vector2.Zero; //foreach (KeyValuePair<Vector2, StardewValley.Object> obj in Game1.player.currentLocation.objects.Pairs) //{ // if (obj.Value.bigCraftable.Value && (obj.Value.ParentSheetIndex == 238)) // { // if (obelisk1.Equals(Vector2.Zero)) // { // obelisk1 = obj.Key; // } // else if (obelisk2.Equals(Vector2.Zero)) // { // obelisk2 = obj.Key; // break; // } // } //} //if (!obelisk2.Equals(Vector2.Zero)) //{ //} responses.Add(new Response(WarpLocationChoice.None.ToString(), "Cancel")); if (responses.Count == 2) { WarpLocation to = WarpLocations.GetWarpLocation(WarpLocationChoice.Farm); WarpPlayerTo(to); } else { Game1.currentLocation.createQuestionDialogue("Choose location:", responses.ToArray(), LocationAnswer); } }
//private void MiniObeliskAnswer(Farmer farmer, string answer) //{ // MiniObeliskObject miniObelisk = miniObelisks.First((MiniObeliskObject o) => o.Name.Equals(answer)); // Vector2? warpLocationCoords = GetValidWarpTile(Game1.getFarm(), miniObelisk.CoordX, miniObelisk.CoordY); // if (!warpLocationCoords.HasValue) // { // Game1.showRedMessage("Invalid Mini-Obelisk Warp Target Location"); // return; // } // WarpLocation warpLocation = new WarpLocation("Farm", (int)warpLocationCoords.Value.X, (int)warpLocationCoords.Value.Y); // WarpPlayerTo(warpLocation); //} private void WarpPlayerTo(WarpLocation warpLocation) { DoBeforeWarpAnimation(); DelayedAction.fadeAfterDelay(delegate { DoWarp(warpLocation); }, 1000); DoAfterWarpAnimation(); }