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); } }