//get current planet type, used in resource subclasses, might prove unnecessary later, depends on Planet Getcomponent calls and children structure public Planet GetPlanetType() { if (typeName == "Planet") { Planet planet = GetComponent <Planet> (); //print ("planet = " + planet + ", planetType = " + planetType); return(planet); } if (typeName == "Earthlike") { Earthlike planet = GetComponent <Earthlike> (); //print ("planet = " + planet + ", planetType = " + planetType); return(planet); } if (typeName == "Desert") { Desert planet = GetComponent <Desert> (); //print ("planet = " + planet + ", planetType = " + planetType); return(planet); } if (typeName == "Barren") { Barren planet = GetComponent <Barren> (); //print ("planet = " + planet + ", planetType = " + planetType); return(planet); } else { return(null); } }
//Constructeur private TileFactory() { TileDesert = new Desert(); TilePlain = new Plain(); TileSwamp = new Swamp(); TileVolcano = new Volcano(); }
public GameObject InitializePlanet(Planet planet) { PlanetTextureGenerator texGen = null; GameObject planetGO = null; var planetData = (PlanetData)planet.GetSerializationData(); switch (planetData.Type) { case PlanetType.Terra: planetGO = Instantiate(_terraPrefab, Vector2.zero, Quaternion.identity); texGen = new Terra(PlanetTextureGenerator.DefaultResolution, planetData); break; case PlanetType.Gas: planetGO = Instantiate(_gasPrefab, Vector2.zero, Quaternion.identity); texGen = new Gas(PlanetTextureGenerator.DefaultResolution, planetData); break; case PlanetType.Desert: planetGO = Instantiate(_desertPrefab, Vector2.zero, Quaternion.identity); texGen = new Desert(PlanetTextureGenerator.DefaultResolution, planetData); break; default: throw new ArgumentOutOfRangeException(); } planetGO.name = planetData.Name; var planetTexture = new Texture2D(texGen.XSize, texGen.YSize); planetTexture.Resize(texGen.XSize, texGen.YSize, TextureFormat.RGB565, true); planetTexture.SetPixels(texGen.TextureColors); planetTexture.Apply(); var meshes = planetGO.GetComponentsInChildren <MeshRenderer>(); //0 - планета, 1 - облака, 2 - кольца, осторожнее с иерархией в префабе meshes[0].material.mainTexture = planetTexture; if (planetData.RingsMass > 0) { var rings = new PlanetRings(PlanetTextureGenerator.DefaultResolution / 2, planetData); var ringsTexture = new Texture2D(rings.XSize, rings.YSize); ringsTexture.SetPixels(rings.TextureColors); ringsTexture.Apply(); meshes[2].material.mainTexture = ringsTexture; } else { meshes[2].gameObject.SetActive(false); } planetGO.GetComponentInChildren <PlanetRotator>().RotationSpeed = planetData.RotationSpeed; planetGO.AddComponent <PlanetWatcher>().Planet = planet; return(planetGO); }
public void BeforeTests() { double testPrice = 12.32; int[] testPriority = { 1, 2, 3, 4 }; testDesert = new Desert(testPrice); testDrink = new Drink(testPrice); }
public ActionResult UpdateDeserts(int idofDese) { MehriamarqueeEntities meh = new MehriamarqueeEntities(); Desert its = new Desert(); its = meh.Deserts.Where(X => X.desertId == idofDese).FirstOrDefault(); return(View(its)); }
/// <summary> /// Checks if the travelling merchant is present at the desert. /// </summary> /// <param name="desert">The <see cref="Desert" /> instance.</param> /// <returns></returns> public static bool IsTravelingMerchantHere(this Desert desert) { if (Game1.currentSeason == "winter" && Game1.dayOfMonth >= 15) { return(Game1.dayOfMonth > 17); } return(true); }
public static bool Prefix(Desert __instance) { Game1.activeClickableMenu = new DialogueBox("Head to the right of the road"); return(false); /*Console.WriteLine("Exit desert by bus"); * Game1.warpFarmer("Backwoods", 25, 30, false); * return false;*/ }
public ActionResult EditDeserts(Desert de) { MehriamarqueeEntities meh = new MehriamarqueeEntities(); meh.Entry(de).State = System.Data.Entity.EntityState.Modified; meh.SaveChanges(); return(RedirectToAction("ViewDeserts")); }
public override int Effect(Deity creator) { Desert desert = new Desert(Program.GenerateNames.GetName("desert_names"), SelectedProvince, creator); int chance = rnd.Next(100); switch (SelectedProvince.LocalClimate) { case Climate.Arctic: desert.BiomeType = BiomeType.PolarDesert; break; case Climate.SubArctic: if (chance < 50) { desert.BiomeType = BiomeType.ColdDesert; } else { desert.BiomeType = BiomeType.Tundra; } break; case Climate.Temperate: if (chance < 50) { desert.BiomeType = BiomeType.ColdDesert; } else { desert.BiomeType = BiomeType.HotDesert; } break; case Climate.SubTropical: desert.BiomeType = BiomeType.HotDesert; break; case Climate.Tropical: desert.BiomeType = BiomeType.HotDesert; break; } SelectedProvince.PrimaryTerrainFeature = desert; SelectedProvince.isDefault = false; creator.TerrainFeatures.Add(desert); creator.LastCreation = desert; Program.WorldHistory.AddRecord(desert, desert.printTerrainFeature); return(0); }
public static void OpenDesertCatalogue() { if (Config.LimitDesertCatalogToBusFixed && !Game1.player.mailReceived.Contains("ccVault")) { Game1.activeClickableMenu = new DialogueBox(Helper.Translation.Get("desert-merchant-cannot-ship")); return; } var dict = Desert.getDesertMerchantTradeStock(Game1.player); AdjustPrices(ref dict, Config.FreeDesertCatalogue); Monitor.Log("Opening desert catalogue"); DelayedOpen(new ShopMenu(dict, 0, "DesertTrade", new Func <ISalable, Farmer, int, bool>(boughtTraderItem), null, null)); }
/// <summary> /// Returns a specific LandTerrain class based on the value of parameter iRange /// </summary> /// <param name="iRange"></param> /// <returns></returns> LandTerrain SelectNewTerrain(int iRange) { //Select a new terrain LandTerrain tempTerrain = new LandTerrain(); //Might randomize which Terrain the tempTerrain will be // Different terrain weighted differently switch (iRange) { case 0: //Forest tempTerrain = new Forest(); return(tempTerrain); case 1: //Grassland tempTerrain = new Grassland(); return(tempTerrain); case 2: //Lake tempTerrain = new Lake(); return(tempTerrain); case 3: //Mountain tempTerrain = new Mountain(); break; case 4: //Desert tempTerrain = new Desert(); break; case 5: //Swamp tempTerrain = new Swamp(); break; case 6: //Tundra tempTerrain = new Tundra(); break; case 7: //Jungle tempTerrain = new Jungle(); break; case 8: //Wasteland tempTerrain = new Wasteland(); break; } return(tempTerrain); }
public ActionResult UpdateDeserts(Desert de, string UpdatedQuantity) { MehriamarqueeEntities meh = new MehriamarqueeEntities(); de.quantityOfdesert = de.quantityOfdesert + int.Parse(UpdatedQuantity); meh.Entry(de).State = System.Data.Entity.EntityState.Modified; meh.SaveChanges(); QuantityupdatedDeserttable quant = new QuantityupdatedDeserttable(); quant.desertID = de.desertId; quant.Date = DateTime.Now; quant.Quantity = int.Parse(UpdatedQuantity); meh.QuantityupdatedDeserttables.Add(quant); meh.SaveChanges(); return(RedirectToAction("ViewDeserts")); }
private void LoadMap(Bytemap bitmap) { _tiles = new ITile[WIDTH, HEIGHT]; for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { ITile tile; bool special = TileIsSpecial(x, y); switch (bitmap[x, y]) { case 2: tile = new Forest(x, y, special); break; case 3: tile = new Swamp(x, y, special); break; case 6: tile = new Plains(x, y, special); break; case 7: tile = new Tundra(x, y, special); break; case 9: tile = new River(x, y); break; case 10: tile = new Grassland(x, y); break; case 11: tile = new Jungle(x, y, special); break; case 12: tile = new Hills(x, y, special); break; case 13: tile = new Mountains(x, y, special); break; case 14: tile = new Desert(x, y, special); break; case 15: tile = new Arctic(x, y, special); break; default: tile = new Ocean(x, y, special); break; } _tiles[x, y] = tile; } } }
public void Visit(Desert desert) { // Horizontal borders GameObject gameObject = new OutlineObstacle(new Water(new Obstacle(desert.levelWidth / 2, desert.blockHeight / 2, desert.levelWidth, desert.blockHeight))); gameObject.Decorate(); desert.AddStuff(gameObject); gameObject = new OutlineObstacle(new Water(new Obstacle(desert.levelWidth / 2, desert.levelHeight - desert.blockHeight + desert.blockHeight / 2, desert.levelWidth, desert.blockHeight))); gameObject.Decorate(); desert.AddStuff(gameObject); // Vertical borders gameObject = new OutlineObstacle(new Water(new Obstacle(desert.blockWidth / 2, desert.levelHeight / 2, desert.blockWidth, desert.levelHeight))); gameObject.Decorate(); desert.AddStuff(gameObject); gameObject = new OutlineObstacle(new Water(new Obstacle(desert.levelWidth - desert.blockWidth + desert.blockWidth / 2, desert.levelHeight / 2, desert.blockWidth, desert.levelHeight))); gameObject.Decorate(); desert.AddStuff(gameObject); }
/*****************/ /* Internal Code */ /*****************/ /// <summary>Checks an additional tile in the Desert for Secret Note #18's buried treasure.</summary> /// <param name="__instance">The Desert location.</param> /// <param name="xLocation">The X value of the tile being checked.</param> /// <param name="yLocation">The Y value of the tile being checked.</param> /// <param name="who">The player digging.</param> /// <param name="__result">The result of the original method.</param> /// <returns>True if the original method should run. False if it should be skipped.</returns> private static bool Desert_checkForBuriedItem(ref Desert __instance, int xLocation, int yLocation, Farmer who, ref string __result) { try { //imitate the original code in Desert.checkForBuriedItem, but check NewSecretNoteTile instead if (who.secretNotesSeen.Contains(18) && xLocation == NewSecretNoteTile.X && yLocation == NewSecretNoteTile.Y && !who.mailReceived.Contains("SecretNote18_done")) { who.mailReceived.Add("SecretNote18_done"); Game1.createObjectDebris(127, xLocation, yLocation, who.UniqueMultiplayerID, __instance); __result = ""; return(false); //skip the original method } else { return(true); //run the original method } } catch (Exception ex) { Monitor.LogOnce($"Harmony patch \"{nameof(HarmonyPatch_DesertSecretNoteTile)}\" has encountered an error. Prefix \"{nameof(Desert_checkForBuriedItem)}\" might malfunction or revert to default behavior. Full error message: \n{ex.ToString()}", LogLevel.Error); return(true); //run the original method } }
public bool AddDeserts(Desert desert) { string dishSql = $"insert into dishes (name) value ('{desert.Name}'); SELECT LAST_INSERT_ID();"; string desertSql = $"insert into deserts (dish_id,Price,Quantity,calories,description) values(@dish_id,{desert.Prices},{desert.Quantity},{desert.Calorie},'{desert.Description}')"; using (IDbConnection connection = Connection) { connection.Open(); var dish_id = connection.Query <int>(dishSql); int count = connection.Execute(desertSql, new { dish_id = dish_id }); if (count > 0) { return(true); } else { return(false); } } }
public void ChangeTileType(int x, int y, Terrain type) { bool special = TileIsSpecial(x, y); bool road = _tiles[x, y].Road; bool railRoad = _tiles[x, y].RailRoad; switch (type) { case Terrain.Forest: _tiles[x, y] = new Forest(x, y, special); break; case Terrain.Swamp: _tiles[x, y] = new Swamp(x, y, special); break; case Terrain.Plains: _tiles[x, y] = new Plains(x, y, special); break; case Terrain.Tundra: _tiles[x, y] = new Tundra(x, y, special); break; case Terrain.River: _tiles[x, y] = new River(x, y); break; case Terrain.Grassland1: case Terrain.Grassland2: _tiles[x, y] = new Grassland(x, y); break; case Terrain.Jungle: _tiles[x, y] = new Jungle(x, y, special); break; case Terrain.Hills: _tiles[x, y] = new Hills(x, y, special); break; case Terrain.Mountains: _tiles[x, y] = new Mountains(x, y, special); break; case Terrain.Desert: _tiles[x, y] = new Desert(x, y, special); break; case Terrain.Arctic: _tiles[x, y] = new Arctic(x, y, special); break; case Terrain.Ocean: _tiles[x, y] = new Ocean(x, y, special); break; } _tiles[x, y].Road = road; _tiles[x, y].RailRoad = railRoad; }
private void MergeElevationAndLatitude(int[,] elevation, int[,] latitude) { Log("Map: Stage 3 - Merge elevation and latitude into the map"); // merge elevation and latitude into the map for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { bool special = TileIsSpecial(x, y); switch (elevation[x, y]) { case 0: _tiles[x, y] = new Ocean(x, y, special); break; case 1: { switch (latitude[x, y]) { case 0: _tiles[x, y] = new Desert(x, y, special); break; case 1: _tiles[x, y] = new Plains(x, y, special); break; case 2: _tiles[x, y] = new Tundra(x, y, special); break; case 3: _tiles[x, y] = new Arctic(x, y, special); break; } } break; case 2: _tiles[x, y] = new Hills(x, y, special); break; default: _tiles[x, y] = new Mountains(x, y, special); break; } } } }
public override System.Web.Mvc.ActionResult LogOn(Desert.Models.LogOnModel model, string returnUrl) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.LogOn); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "returnUrl", returnUrl); return callInfo; }
public override System.Web.Mvc.ActionResult ChangePassword(Desert.Models.ChangePasswordModel model) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.ChangePassword); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); return callInfo; }
public IActionResult Deserts([FromBody] Desert desert) { bool value = _ownerService.AddDeserts(desert); return(Ok(value)); }
public DinnerViewModel() { Meal = new Meal(); Beverage = new Beverage(); Desert = new Desert(); }
public static Rectangle GetDesertMerchantBounds(this Desert desert) { return(new Rectangle(2112, 1280, 836, 280)); }
private SelectList GetItemTypesSelectList(Desert.DAL.Context ctx, object selectedValue) { IList<ItemTypeVM> list = Mapper.Map<IEnumerable<ItemType>, IList<ItemTypeVM>>(ctx.ItemTypes); SelectList selectList = new SelectList(list, "Id", "Name", selectedValue); return selectList; }
static void ResetBaseState(Desert instance) { return; }
/// <summary> /// Creates the map. /// </summary> /// <param name="randomizer">The randomizer.</param> /// <returns></returns> /// <exception cref="System.Exception">Unknow tile type</exception> public Map CreateMap(ISquareRandomizer randomizer) { Map map = new Map(new Point(25, 25)); CivilizationAlgorithms.PerlinNoise.GenerateHeightMap(100, 25, 25); for (int i = 0; i < 25; ++i) { for (int j = 0; j < 25; ++j) { Square.Square newSquare; switch (CivilizationAlgorithms.PerlinNoise.GetTileType(i, j)) { case ManagedTileType.Desert: newSquare = new Desert(); break; case ManagedTileType.Water: newSquare = new Water(); break; case ManagedTileType.Mountain: newSquare = new Mountain(); break; case ManagedTileType.Field: newSquare = new Field(); break; default: throw new System.Exception("Unknow tile type"); break; } switch (CivilizationAlgorithms.PerlinNoise.GetDecoratorType(i, j)) { case ManagedDecoratorType.Fruit : newSquare = new FruitSquareDecorator(newSquare); break; case ManagedDecoratorType.Iron : newSquare = new IronSquareDecorator(newSquare); break; default: //NADA break; } map.ReplaceSquare(new Point(i, j), newSquare); map.GetSquare(new Point(i, j)).Position = new Point(i, j); } } CivilizationAlgorithms.PerlinNoise.FindIdealPositions(); map.IdealPosition1 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().Y }; map.IdealPosition2 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().Y }; map.IdealPosition3 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().Y }; return map; }
/// <summary> /// Given the name of a shop property, return an instance of the vanilla menu that matches the property /// </summary> /// <param name="shopProperty">the name of the property, as outlined in the README.md</param> /// <param name="warpingShop">is true for animal shops and carpenter shops, which need special handling due to /// the fact it physically warps the players to hard-coded locations</param> /// <returns>An instance of the vanilla stores if the property matches, null otherwise</returns> public static IClickableMenu CheckVanillaShop(string shopProperty, out bool warpingShop) { warpingShop = false; switch (shopProperty) { case "Vanilla!PierreShop": { var seedShop = new SeedShop(); return(new ShopMenu(seedShop.shopStock(), 0, "Pierre")); } case "Vanilla!JojaShop": return(new ShopMenu(StardewValley.Utility.getJojaStock())); case "Vanilla!RobinShop": return(new ShopMenu(StardewValley.Utility.getCarpenterStock(), 0, "Robin")); case "Vanilla!RobinBuildingsShop": warpingShop = true; return(new CarpenterMenu()); case "Vanilla!ClintShop": return(new ShopMenu(StardewValley.Utility.getBlacksmithStock(), 0, "Clint")); case "Vanilla!ClintGeodes": return(new GeodeMenu()); case "Vanilla!ClintToolUpgrades": return(new ShopMenu(StardewValley.Utility.getBlacksmithUpgradeStock(Game1.player), 0, "ClintUpgrade")); case "Vanilla!MarlonShop": return(new ShopMenu(StardewValley.Utility.getAdventureShopStock(), 0, "Marlon")); case "Vanilla!MarnieShop": return(new ShopMenu(StardewValley.Utility.getAnimalShopStock(), 0, "Marnie")); case "Vanilla!MarnieAnimalShop": warpingShop = true; return(new PurchaseAnimalsMenu(StardewValley.Utility.getPurchaseAnimalStock())); case "Vanilla!TravellingMerchant": return(new ShopMenu(StardewValley.Utility.getTravelingMerchantStock((int)((long)Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed)), 0, "Traveler", StardewValley.Utility.onTravelingMerchantShopPurchase)); case "Vanilla!HarveyShop": return(new ShopMenu(StardewValley.Utility.getHospitalStock())); case "Vanilla!SandyShop": { var SandyStock = ModEntry.helper.Reflection.GetMethod(Game1.currentLocation, "sandyShopStock").Invoke <Dictionary <ISalable, int[]> >(); return(new ShopMenu(SandyStock, 0, "Sandy", onSandyShopPurchase)); } case "Vanilla!DesertTrader": return(new ShopMenu(Desert.getDesertMerchantTradeStock(Game1.player), 0, "DesertTrade", boughtTraderItem)); case "Vanilla!KrobusShop": { var sewer = new Sewer(); return(new ShopMenu(sewer.getShadowShopStock(), 0, "Krobus", sewer.onShopPurchase)); } case "Vanilla!DwarfShop": return(new ShopMenu(StardewValley.Utility.getDwarfShopStock(), 0, "Dwarf")); case "Vanilla!AdventureRecovery": return(new ShopMenu(StardewValley.Utility.getAdventureRecoveryStock(), 0, "Marlon_Recovery")); case "Vanilla!GusShop": { return(new ShopMenu(StardewValley.Utility.getSaloonStock(), 0, "Gus", (item, farmer, amount) => { Game1.player.team.synchronizedShopStock.OnItemPurchased(SynchronizedShopStock.SynchedShop.Saloon, item, amount); return false; })); } case "Vanilla!WillyShop": return(new ShopMenu(StardewValley.Utility.getFishShopStock(Game1.player), 0, "Willy")); case "Vanilla!WizardBuildings": warpingShop = true; return(new CarpenterMenu(true)); case "Vanilla!QiShop": Game1.activeClickableMenu = new ShopMenu(StardewValley.Utility.getQiShopStock(), 2); break; case "Vanilla!IceCreamStand": return(new ShopMenu(new Dictionary <ISalable, int[]> { { new Object(233, 1), new[] { 250, int.MaxValue } } })); } return(null); }
public ActionResult addNewStocksPost(NewItemsadding add, string Categorylist, string Unitlist) { MehriamarqueeEntities meh = new MehriamarqueeEntities(); try { if (Categorylist == "Vegetable") { Item it = new Item(); it.itemName = add.itemName; it.quantity = add.itemQuantity; it.salesPrice = add.itemSalePrice; it.purchasePrice = add.itemPurchasePrice; it.category = Categorylist; it.unit = Unitlist; meh.Items.Add(it); meh.SaveChanges(); QuantityupdatedItemtable quant = new QuantityupdatedItemtable(); quant.itemID = it.itemId; quant.Date = DateTime.Today; quant.Quantity = it.quantity; meh.QuantityupdatedItemtables.Add(quant); meh.SaveChanges(); TempData["message"] = "Stock Added Successfully"; } if (Categorylist == "Meats") { Item it = new Item(); it.itemName = add.itemName; it.quantity = add.itemQuantity; it.salesPrice = add.itemSalePrice; it.purchasePrice = add.itemPurchasePrice; it.category = Categorylist; it.unit = Unitlist; meh.Items.Add(it); meh.SaveChanges(); QuantityupdatedItemtable quant = new QuantityupdatedItemtable(); quant.itemID = it.itemId; quant.Date = DateTime.Today; quant.Quantity = it.quantity; meh.QuantityupdatedItemtables.Add(quant); meh.SaveChanges(); TempData["message"] = "Stock Added Successfully"; } if (Categorylist == "Grossory") { Item it = new Item(); it.itemName = add.itemName; it.quantity = add.itemQuantity; it.salesPrice = add.itemSalePrice; it.purchasePrice = add.itemPurchasePrice; it.category = Categorylist; it.unit = Unitlist; meh.Items.Add(it); meh.SaveChanges(); QuantityupdatedItemtable quant = new QuantityupdatedItemtable(); quant.itemID = it.itemId; quant.Date = DateTime.Today; quant.Quantity = it.quantity; meh.QuantityupdatedItemtables.Add(quant); meh.SaveChanges(); TempData["message"] = "Stock Added Successfully"; } if (Categorylist == "Beverages") { Beverage beverage = new Beverage(); beverage.beveragesName = add.itemName; beverage.quantityOfBeverages = add.itemQuantity; beverage.beveragesSalePrice = add.itemSalePrice; beverage.beveragesPurchasePrice = add.itemPurchasePrice; meh.Beverages.Add(beverage); meh.SaveChanges(); QuantityupdateBeveragestable quant = new QuantityupdateBeveragestable(); quant.beverageID = beverage.beverageId; quant.Date = DateTime.Today; quant.Quantity = beverage.quantityOfBeverages; meh.QuantityupdateBeveragestables.Add(quant); meh.SaveChanges(); TempData["message"] = "Stock Added Successfully"; } if (Categorylist == "Deserts") { Desert desert = new Desert(); desert.desertName = add.itemName; desert.quantityOfdesert = add.itemQuantity; desert.desertSalePrice = add.itemSalePrice; desert.desertPurchasePrice = add.itemPurchasePrice; meh.Deserts.Add(desert); meh.SaveChanges(); QuantityupdatedDeserttable quant = new QuantityupdatedDeserttable(); quant.desertID = desert.desertId; quant.Date = DateTime.Today; quant.Quantity = desert.quantityOfdesert; meh.QuantityupdatedDeserttables.Add(quant); meh.SaveChanges(); TempData["message"] = "Stock Added Successfully"; } } catch (Exception) { TempData["message"] = "Server problem !Try Again"; } return(RedirectToAction("addNewStocksGet")); }
/// <summary> /// Creates the map. /// </summary> /// <param name="randomizer">The randomizer.</param> /// <returns></returns> /// <exception cref="System.Exception">Unknow tile type</exception> public Map CreateMap(ISquareRandomizer randomizer) { Map map = new Map(new Point(25, 25)); CivilizationAlgorithms.PerlinNoise.GenerateHeightMap(100, 25, 25); for (int i = 0; i < 25; ++i) { for (int j = 0; j < 25; ++j) { Square.Square newSquare; switch (CivilizationAlgorithms.PerlinNoise.GetTileType(i, j)) { case ManagedTileType.Desert: newSquare = new Desert(); break; case ManagedTileType.Water: newSquare = new Water(); break; case ManagedTileType.Mountain: newSquare = new Mountain(); break; case ManagedTileType.Field: newSquare = new Field(); break; default: throw new System.Exception("Unknow tile type"); break; } switch (CivilizationAlgorithms.PerlinNoise.GetDecoratorType(i, j)) { case ManagedDecoratorType.Fruit: newSquare = new FruitSquareDecorator(newSquare); break; case ManagedDecoratorType.Iron: newSquare = new IronSquareDecorator(newSquare); break; default: //NADA break; } map.ReplaceSquare(new Point(i, j), newSquare); map.GetSquare(new Point(i, j)).Position = new Point(i, j); } } CivilizationAlgorithms.PerlinNoise.FindIdealPositions(); map.IdealPosition1 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition1().Y }; map.IdealPosition2 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition2().Y }; map.IdealPosition3 = new Point { X = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().X, Y = CivilizationAlgorithms.PerlinNoise.GetIdealPosition3().Y }; return(map); }
public QuickShopScreen() { string buttonTitle = GetTranslation("quickShop.button"); string pierreShopTitle = $"{buttonTitle} {GetButtonTranslation("pierreShop")}"; AddElement(new Button(pierreShopTitle, pierreShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(new List <ISalable>(Utility.getShopStock(true)), who: "Pierre"); } }); string harveyShopTitle = $"{buttonTitle} {GetButtonTranslation("harveyShop")}"; AddElement(new Button(harveyShopTitle, harveyShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getHospitalStock()); } }); string gusShopTitle = $"{buttonTitle} {GetButtonTranslation("gusShop")}"; AddElement(new Button(gusShopTitle, gusShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getSaloonStock(), who: "Gus"); } }); string robinShopTitle = $"{buttonTitle} {GetButtonTranslation("robinShop")}"; AddElement(new Button(robinShopTitle, robinShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getCarpenterStock(), who: "Robin"); } }); string carpenterTitle = $"{buttonTitle} {GetButtonTranslation("carpenter")}"; AddElement(new Button(carpenterTitle, carpenterTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new CarpenterMenu(); } }); string willyShopTitle = $"{buttonTitle} {GetButtonTranslation("willyShop")}"; AddElement(new Button(willyShopTitle, willyShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getFishShopStock(Game1.player), who: "Willy"); } }); string krobusShopTitle = $"{buttonTitle} {GetButtonTranslation("krobusShop")}"; AddElement(new Button(krobusShopTitle, krobusShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(new Sewer().getShadowShopStock(), who: "Krobus"); } }); string marnieShopTitle = $"{buttonTitle} {GetButtonTranslation("marnieShop")}"; AddElement(new Button(marnieShopTitle, marnieShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getAnimalShopStock(), who: "Marnie"); } }); string animalShopTitle = $"{buttonTitle} {GetButtonTranslation("animalShop")}"; AddElement(new Button(animalShopTitle, animalShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new PurchaseAnimalsMenu(Utility.getPurchaseAnimalStock()); } }); string merchantShopTitle = $"{buttonTitle} {GetButtonTranslation("merchantShop")}"; AddElement(new Button(merchantShopTitle, merchantShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu( Utility.getTravelingMerchantStock((int)((long)Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed)), who: "TravelerNightMarket", on_purchase: Utility.onTravelingMerchantShopPurchase); } }); string renovationTitle = $"{buttonTitle} {GetButtonTranslation("renovation")}"; AddElement(new Button(renovationTitle, renovationTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(HouseRenovation.GetAvailableRenovations(), on_purchase: HouseRenovation.OnPurchaseRenovation); } }); string clintShopTitle = $"{buttonTitle} {GetButtonTranslation("clintShop")}"; AddElement(new Button(clintShopTitle, clintShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithStock(), who: "Clint"); } }); if (Game1.player.toolBeingUpgraded.Value == null && Utility.getBlacksmithUpgradeStock(Game1.player).Values.Count != 0) { string upgradeTitle = $"{buttonTitle} {GetButtonTranslation("upgrade")}"; AddElement(new Button(upgradeTitle, upgradeTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithUpgradeStock(Game1.player)); } }); } string geodeTitle = $"{buttonTitle} {GetButtonTranslation("geode")}"; AddElement(new Button(geodeTitle, geodeTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new GeodeMenu(); } }); string specialOrdersBoardTitle = $"{buttonTitle} {GetButtonTranslation("specialOrdersBoard")}"; AddElement(new Button(specialOrdersBoardTitle, specialOrdersBoardTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new SpecialOrdersBoard(); } }); string morrisShopTitle = $"{buttonTitle} {GetButtonTranslation("morrisShop")}"; AddElement(new Button(morrisShopTitle, morrisShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getJojaStock()); } }); string dwarfShopTitle = $"{buttonTitle} {GetButtonTranslation("dwarfShop")}"; AddElement(new Button(dwarfShopTitle, dwarfShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getDwarfShopStock(), who: "Dwarf"); } }); string volcanoDungeonShopTitle = $"{buttonTitle} {GetButtonTranslation("volcanoDungeonShop")}"; Dictionary <ISalable, int[]> dictionary = new Dictionary <ISalable, int[]> { { new Boots(853), new[] { 0, int.MaxValue, 848, 100 } } }; AddElement(new Button(volcanoDungeonShopTitle, volcanoDungeonShopTitle) { OnLeftClicked = () => { Random random = new Random((int)(Game1.stats.DaysPlayed + 898U + (long)Game1.uniqueIDForThisGame)); Utility.AddStock(dictionary, new StardewValley.Object(Vector2.Zero, 286, int.MaxValue), 150); Utility.AddStock(dictionary, new StardewValley.Object(Vector2.Zero, 287, int.MaxValue), 300); Utility.AddStock(dictionary, new StardewValley.Object(Vector2.Zero, 288, int.MaxValue), 500); if (random.NextDouble() < 0.5) { Utility.AddStock(dictionary, new StardewValley.Object(Vector2.Zero, 244, int.MaxValue), 600); } else { Utility.AddStock(dictionary, new StardewValley.Object(Vector2.Zero, 237, int.MaxValue), 600); } if (random.NextDouble() < 0.25) { Utility.AddStock(dictionary, new Hat(77), 5000); } if (!Game1.player.craftingRecipes.ContainsKey("Warp Totem: Island")) { Utility.AddStock(dictionary, new StardewValley.Object(886, 1, true), 5000); } if (!Game1.player.cookingRecipes.ContainsKey("Ginger Ale")) { Utility.AddStock(dictionary, new StardewValley.Object(903, 1, true), 500); } Game1.activeClickableMenu = new ShopMenu(dictionary, who: "VolcanoShop", context: "VolcanoShop"); } }); string marlonShopTitle = $"{buttonTitle} {GetButtonTranslation("marlonShop")}"; AddElement(new Button(marlonShopTitle, marlonShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getAdventureShopStock(), who: "Marlon"); } }); string hatShopTitle = $"{buttonTitle} {GetButtonTranslation("hatShop")}"; AddElement(new Button(hatShopTitle, hatShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getHatStock()); } }); string casinoShopTitle = $"{buttonTitle} {GetButtonTranslation("casinoShop")}"; AddElement(new Button(casinoShopTitle, casinoShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Utility.getQiShopStock(), 2); } }); string qiSpecialOrdersBoardTitle = $"{buttonTitle} {GetButtonTranslation("qiSpecialOrdersBoard")}"; AddElement(new Button(qiSpecialOrdersBoardTitle, qiSpecialOrdersBoardTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new SpecialOrdersBoard("Qi"); } }); string sandyShopTitle = $"{buttonTitle} {GetButtonTranslation("sandyShop")}"; AddElement(new Button(sandyShopTitle, sandyShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(new List <ISalable>(Utility.getShopStock(false)), who: "Sandy"); } }); string desertShopTitle = $"{buttonTitle} {GetButtonTranslation("desertShop")}"; AddElement(new Button(desertShopTitle, desertShopTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(Desert.getDesertMerchantTradeStock(Game1.player)); } }); string islandTradeTitle = $"{buttonTitle} {GetButtonTranslation("islandTrade")}"; AddElement(new Button(islandTradeTitle, islandTradeTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(IslandNorth.getIslandMerchantTradeStock(Game1.player), who: "IslandTrade"); } }); string resortBarTitle = $"{buttonTitle} {GetButtonTranslation("resortBar")}"; AddElement(new Button(resortBarTitle, resortBarTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ShopMenu(dictionary, who: "Gus", context: "ResortBar"); } }); if (Game1.player.mailReceived.Contains("JojaMember")) { string joJaCdTitle = $"{buttonTitle} {GetButtonTranslation("joJaCD")}"; AddElement(new Button(joJaCdTitle, joJaCdTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new JojaCDMenu(Game1.temporaryContent.Load <Texture2D>("LooseSprites\\JojaCDForm")); } }); } string wizardTitle = $"{buttonTitle} {GetButtonTranslation("wizard")}"; AddElement(new Button(wizardTitle, wizardTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new CarpenterMenu(true); } }); if (!Game1.player.mailReceived.Contains("JojaMember")) { string bundlesTitle = $"{buttonTitle} {GetButtonTranslation("bundles")}"; AddElement(new Button(bundlesTitle, bundlesTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new JunimoNoteMenu(true, 1, true); } }); } string sewingTitle = $"{buttonTitle} {GetButtonTranslation("sewing")}"; AddElement(new Button(sewingTitle, sewingTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new TailoringMenu(); } }); string dyeTitle = $"{buttonTitle} {GetButtonTranslation("dye")}"; AddElement(new Button(dyeTitle, dyeTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new DyeMenu(); } }); string forgeTitle = $"{buttonTitle} {GetButtonTranslation("forge")}"; AddElement(new Button(forgeTitle, forgeTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new ForgeMenu(); } }); string minesTitle = $"{buttonTitle} {GetButtonTranslation("mines")}"; AddElement(new Button(minesTitle, minesTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = new MineElevatorMenu(); } }); string shipTitle = $"{buttonTitle} {GetButtonTranslation("ship")}"; AddElement(new Button(shipTitle, shipTitle) { OnLeftClicked = () => { Game1.activeClickableMenu = ShippingBin(); } }); if (Game1.player.toolBeingUpgraded.Value != null && Game1.player.daysLeftForToolUpgrade <= 0) { AddElement(new Button(GetTranslation("quickShop.button.getUpgradedTool"), GetTranslation("quickShop.button.getUpgradedTool")) { OnLeftClicked = () => { if (Game1.player.freeSpotsInInventory() > 0 || Game1.player.toolBeingUpgraded.Value is GenericTool) { Tool tool = Game1.player.toolBeingUpgraded.Value; Game1.player.toolBeingUpgraded.Value = null; Game1.player.hasReceivedToolUpgradeMessageYet = false; Game1.player.holdUpItemThenMessage(tool); if (tool is GenericTool) { tool.actionWhenClaimed(); } else { Game1.player.addItemToInventoryBool(tool); } Game1.exitActiveMenu(); } else { Game1.drawDialogue(Game1.getCharacterFromName("Clint"), Game1.content.LoadString("Data\\ExtraDialogue:Clint_NoInventorySpace", Game1.player.toolBeingUpgraded.Value.DisplayName)); } } }); } if (Game1.player.maxItems < 36) { AddElement(new Button(GetTranslation("quickShop.button.backpackUpgrade"), GetTranslation("quickShop.button.backpackUpgrade")) { OnLeftClicked = () => { if (Game1.player.maxItems == 12 && Game1.player.Money >= 2000) { Game1.player.Money -= 2000; Game1.player.maxItems.Value += 12; for (int index = 0; index < Game1.player.maxItems; ++index) { if (Game1.player.items.Count <= index) { Game1.player.items.Add(null); } } Game1.player.holdUpItemThenMessage(new SpecialItem(99, Game1.content.LoadString("Strings\\StringsFromCSFiles:GameLocation.cs.8708"))); Game1.exitActiveMenu(); } else if (Game1.player.maxItems < 36 && Game1.player.Money >= 10000) { Game1.player.Money -= 10000; Game1.player.maxItems.Value += 12; Game1.player.holdUpItemThenMessage(new SpecialItem(99, Game1.content.LoadString("Strings\\StringsFromCSFiles:GameLocation.cs.8709"))); for (int index = 0; index < Game1.player.maxItems; ++index) { if (Game1.player.items.Count <= index) { Game1.player.items.Add(null); } } Game1.exitActiveMenu(); } else if (Game1.player.maxItems != 36) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney2")); } } }); } if (Game1.player.daysUntilHouseUpgrade < 0 && !Game1.getFarm().isThereABuildingUnderConstruction()) { if (Game1.player.HouseUpgradeLevel < 3) { AddElement(new Button(GetTranslation("quickShop.button.houseUpgrade"), GetTranslation("quickShop.button.houseUpgrade")) { OnLeftClicked = () => { switch (Game1.player.houseUpgradeLevel) { case 0: if (Game1.player.Money >= 10000 && Game1.player.hasItemInInventory(388, 450)) { Game1.player.daysUntilHouseUpgrade.Value = 3; Game1.player.Money -= 10000; Game1.player.removeItemsFromInventory(388, 450); Game1.getCharacterFromName("Robin").setNewDialogue( Game1.content.LoadString( "Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money < 10000) { Game1.drawObjectDialogue( Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } Game1.drawObjectDialogue( Game1.content.LoadString( "Strings\\Locations:ScienceHouse_Carpenter_NotEnoughWood1")); break; case 1: if (Game1.player.Money >= 50000 && Game1.player.hasItemInInventory(709, 150)) { Game1.player.daysUntilHouseUpgrade.Value = 3; Game1.player.Money -= 50000; Game1.player.removeItemsFromInventory(709, 150); Game1.getCharacterFromName("Robin").setNewDialogue( Game1.content.LoadString( "Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money < 50000) { Game1.drawObjectDialogue( Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } Game1.drawObjectDialogue( Game1.content.LoadString( "Strings\\Locations:ScienceHouse_Carpenter_NotEnoughWood2")); break; case 2: if (Game1.player.Money >= 100000) { Game1.player.daysUntilHouseUpgrade.Value = 3; Game1.player.Money -= 100000; Game1.getCharacterFromName("Robin").setNewDialogue( Game1.content.LoadString( "Data\\ExtraDialogue:Robin_HouseUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); break; } if (Game1.player.Money >= 100000) { break; } Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); break; } } }); } else if ((Game1.MasterPlayer.mailReceived.Contains("ccIsComplete") || Game1.MasterPlayer.mailReceived.Contains("JojaMember") || Game1.MasterPlayer.hasCompletedCommunityCenter()) && new Town().daysUntilCommunityUpgrade <= 0 && !Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade")) { AddElement(new Button(GetTranslation("quickShop.button.houseUpgrade.communityUpgrade"), GetTranslation("quickShop.button.houseUpgrade.communityUpgrade.description")) { OnLeftClicked = () => { if (Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade")) { return; } if (Game1.player.Money >= 500000 && Game1.player.hasItemInInventory(388, 950)) { Game1.player.Money -= 500000; Game1.player.removeItemsFromInventory(388, 950); Game1.getCharacterFromName("Robin").setNewDialogue( Game1.content.LoadString("Data\\ExtraDialogue:Robin_PamUpgrade_Accepted")); Game1.drawDialogue(Game1.getCharacterFromName("Robin")); new Town().daysUntilCommunityUpgrade.Value = 3; } else if (Game1.player.Money < 500000) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney3")); } else { Game1.drawObjectDialogue( Game1.content.LoadString( "Strings\\Locations:ScienceHouse_Carpenter_NotEnoughWood3")); } } }); } } }
public static void RunGame() { Console.Clear(); Field.LoadField(); input = ChoiceGeneric.makeChoice(Console.ReadLine()); while (_room != 8 || _lifePoints > 0) { if (Console.ReadLine().ToLower() == "quit") { break; } switch (_room) { //#1 Field case (int)RoomList.Rooms.field: Field.LoadField(); continue; //#2 Forest case (int)RoomList.Rooms.forest: { Forest.LoadForest(); continue; } //#3 Mountain case (int)RoomList.Rooms.mountain: { Mountain.LoadMountain(); continue; } //#4 Beach case (int)RoomList.Rooms.beach: { Beach.LoadBeach(); continue; } //#5 Town case (int)RoomList.Rooms.town: { Town.LoadTown(); continue; } //#6 Desert case (int)RoomList.Rooms.desert: { Desert.LoadDesert(); continue; } //#7 Cave case (int)RoomList.Rooms.cave: break; } if (_lifePoints < 1) { _finalMessage = "You've died.\nWanna try again?\nIf yes, press '1'!"; Console.WriteLine(_finalMessage); var yesOrNo = Console.ReadLine(); if (ChoiceGeneric.makeChoice(yesOrNo) == 1) { RunGame(); } } if (_room == 8) { Console.WriteLine(_finalMessage = "You've successfully completed the first round"); } } }
public override System.Web.Mvc.ActionResult Edit(Desert.VMs.ItemEditStartVM vm) { var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.Edit); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "vm", vm); return callInfo; }
/// <summary> /// When input is received, check for shop tiles to open them as necessary /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { //context and button check if (!Context.CanPlayerMove) { return; } //Resets the boolean I use to check if a menu used to move the player around came from my mod //and lets me return them to their original location SourceLocation = null; PlayerPos = Vector2.Zero; //checks if i've changed marnie's stock already after opening her menu ChangedMarnieStock = false; if (!e.Button.IsActionButton()) { return; } Vector2 clickedTile = Vector2.Zero; clickedTile = Helper.Input.GetCursorPosition().GrabTile; //check if there is a tile property on Buildings layer var tileProperty = GetTileProperty(Game1.currentLocation, "Buildings", clickedTile); if (tileProperty == null) { return; } //check if there is a Shop property on clicked tile tileProperty.TryGetValue("Shop", out PropertyValue shopProperty); if (shopProperty != null) { //everything in this block is for the shop property "Shop" if (shopProperty == "Vanilla!PierreShop") { helper.Input.Suppress(e.Button); var seedShop = new SeedShop(); Game1.activeClickableMenu = new ShopMenu(seedShop.shopStock(), 0, "Pierre", null, null, null); } else if (shopProperty == "Vanilla!JojaShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getJojaStock(), 0, (string)null, null, null, null); } else if (shopProperty == "Vanilla!RobinShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getCarpenterStock(), 0, "Robin", null, null, null); } else if (shopProperty == "Vanilla!RobinBuildingsShop") { helper.Input.Suppress(e.Button); SourceLocation = Game1.currentLocation; PlayerPos = Game1.player.position.Get(); Game1.activeClickableMenu = new CarpenterMenu(false); } else if (shopProperty == "Vanilla!ClintShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithStock(), 0, "Clint", null, null, null); } else if (shopProperty == "Vanilla!ClintGeodes") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new GeodeMenu(); } else if (shopProperty == "Vanilla!ClintToolUpgrades") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithUpgradeStock(Game1.player), 0, "ClintUpgrade", null, null, null); } else if (shopProperty == "Vanilla!MarlonShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAdventureShopStock(), 0, "Marlon", null, null, null); } else if (shopProperty == "Vanilla!MarnieShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAnimalShopStock(), 0, "Marnie", null, null, null); } else if (shopProperty == "Vanilla!MarnieAnimalShop") { helper.Input.Suppress(e.Button); PlayerPos = Game1.player.position.Get(); SourceLocation = Game1.currentLocation; Game1.activeClickableMenu = new PurchaseAnimalsMenu(Utility.getPurchaseAnimalStock()); } else if (shopProperty == "Vanilla!TravellingMerchant") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getTravelingMerchantStock((int)((long)Game1.uniqueIDForThisGame + (long)Game1.stats.DaysPlayed)), 0, "Traveler", new Func <ISalable, Farmer, int, bool>(Utility.onTravelingMerchantShopPurchase), null, null); } else if (shopProperty == "Vanilla!HarveyShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getHospitalStock(), 0, null, null, null, null); } else if (shopProperty == "Vanilla!SandyShop") { helper.Input.Suppress(e.Button); var SandyStock = helper.Reflection.GetMethod(Game1.currentLocation, "sandyShopStock").Invoke <Dictionary <ISalable, int[]> >(); Game1.activeClickableMenu = new ShopMenu(SandyStock, 0, "Sandy", new Func <ISalable, Farmer, int, bool>(onSandyShopPurchase), null, null); } else if (shopProperty == "Vanilla!DesertTrader") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Desert.getDesertMerchantTradeStock(Game1.player), 0, "DesertTrade", new Func <ISalable, Farmer, int, bool>(boughtTraderItem), null, null); } else if (shopProperty == "Vanilla!KrobusShop") { helper.Input.Suppress(e.Button); var sewer = new Sewer(); Game1.activeClickableMenu = new ShopMenu(sewer.getShadowShopStock(), 0, "Krobus", new Func <ISalable, Farmer, int, bool>(sewer.onShopPurchase), null, null); } else if (shopProperty == "Vanilla!DwarfShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getDwarfShopStock(), 0, "Dwarf", null, null, null); } else if (shopProperty == "Vanilla!AdventureRecovery") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAdventureRecoveryStock(), 0, "Marlon_Recovery", null, null, null); } else if (shopProperty == "Vanilla!GusShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getSaloonStock(), 0, "Gus", (item, farmer, amount) => { Game1.player.team.synchronizedShopStock.OnItemPurchased(SynchronizedShopStock.SynchedShop.Saloon, item, amount); return(false); }, null, null); } else if (shopProperty == "Vanilla!WillyShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getFishShopStock(Game1.player), 0, "Willy", null, null, null); } else if (shopProperty == "Vanilla!WizardBuildings") { helper.Input.Suppress(e.Button); SourceLocation = Game1.currentLocation; PlayerPos = Game1.player.position.Get(); Game1.activeClickableMenu = new CarpenterMenu(true); } else if (shopProperty == "Vanilla!QiShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getQiShopStock(), 2, null, null, null, null); } else if (shopProperty == "Vanilla!IceCreamStand") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(new Dictionary <ISalable, int[]>() { { new StardewValley.Object(233, 1, false, -1, 0), new int[2] { 250, int.MaxValue } } }, 0, null, null, null, null); } else { //Extract the tile property value string ShopName = shopProperty.ToString(); if (Shops.ContainsKey(ShopName)) { helper.Input.Suppress(e.Button); Shops[ShopName].DisplayShop(); } else { Monitor.Log($"A Shop tile was clicked, but a shop by the name \"{ShopName}\" " + $"was not found.", LogLevel.Debug); } } } else { tileProperty.TryGetValue("AnimalShop", out shopProperty); if (shopProperty == null) { return; } else { string ShopName = shopProperty.ToString(); if (AnimalShops.ContainsKey(ShopName)) { helper.Input.Suppress(e.Button); AnimalShops[ShopName].DisplayShop(); } else { Monitor.Log($"An Animal Shop tile was clicked, but a shop by the name \"{ShopName}\" " + $"was not found.", LogLevel.Debug); } } } //TODO: add another else check if no tile properties were found for bigcraftables }
public ActionResult GetItemsForDish(List <string> items, List <string> Beve, List <string> Desert, int idofrequest) { MehriamarqueeEntities meh = new MehriamarqueeEntities(); List <Item> itemes = meh.Items.ToList(); List <Beverage> Beveitems = meh.Beverages.ToList(); List <Desert> Desetitems = meh.Deserts.ToList(); List <Dish> dihes = meh.Dishes.ToList(); for (int i = 0; i < items.Count; i++) { foreach (var itemcoun in dihes) { if (items[i] == itemcoun.dishName) { foreach (var getitems in itemes) { int count = 0; if (items[i + 1] == "true") { DishWithItem dishofitem = new DishWithItem(); dishofitem.dishId = itemcoun.dishID; dishofitem.itemId = getitems.itemId; dishofitem.priceOfItems = int.Parse(items[i + 3]); dishofitem.qunatityOfItems = int.Parse(items[i + 4]); dishofitem.requestID = idofrequest; Item getid = new Item(); using (MehriamarqueeEntities mh = new MehriamarqueeEntities()) { getid = mh.Items.Where(X => X.itemId == getitems.itemId).FirstOrDefault(); if (getid.quantity >= int.Parse(items[i + 4])) { getid.quantity = getid.quantity - int.Parse(items[i + 4]); mh.Entry(getid).State = System.Data.Entity.EntityState.Modified; mh.SaveChanges(); } else { TempData["message"] = "Quantity is low for required quantity"; goto exit ; } } meh.DishWithItems.Add(dishofitem); meh.SaveChanges(); i = i + 4; count++; } if (count == 0) { i = i + 3; } } } } } for (int i = 0; i < Beve.Count; i++) { foreach (var itemcoun in dihes) { if (Beve[i] == itemcoun.dishName) { foreach (var getitems in Beveitems) { int count = 0; if (Beve[i + 1] == "true") { beveragesWithFunctionWithMenu dishofitem = new beveragesWithFunctionWithMenu(); dishofitem.dishID = itemcoun.dishID; dishofitem.beverageID = getitems.beverageId; dishofitem.PriceBeverages = int.Parse(Beve[i + 3]); dishofitem.quantityBeverages = int.Parse(Beve[i + 4]); dishofitem.requestID = idofrequest; Beverage getid = new Beverage(); using (MehriamarqueeEntities mh = new MehriamarqueeEntities()) { getid = mh.Beverages.Where(X => X.beverageId == getitems.beverageId).FirstOrDefault(); if (getid.quantityOfBeverages >= int.Parse(Beve[i + 4])) { getid.quantityOfBeverages = getid.quantityOfBeverages - int.Parse(Beve[i + 4]); mh.Entry(getid).State = System.Data.Entity.EntityState.Modified; mh.SaveChanges(); } else { TempData["message"] = "Quantity is low for required quantity"; goto exit ; } } meh.beveragesWithFunctionWithMenus.Add(dishofitem); meh.SaveChanges(); i = i + 4; count++; } if (count == 0) { i = i + 3; } } } } } for (int i = 0; i < Desert.Count; i++) { foreach (var itemcoun in dihes) { if (Desert[i] == itemcoun.dishName) { foreach (var getitems in Desetitems) { int count = 0; if (Desert[i + 1] == "true") { DesertWithFunctionWithMenu dishofitem = new DesertWithFunctionWithMenu(); dishofitem.dishID = itemcoun.dishID; dishofitem.desertID = getitems.desertId; dishofitem.PriceDesert = int.Parse(Desert[i + 3]); dishofitem.quantityDesert = int.Parse(Desert[i + 4]); dishofitem.requestID = idofrequest; Desert getid = new Desert(); using (MehriamarqueeEntities mh = new MehriamarqueeEntities()) { getid = mh.Deserts.Where(X => X.desertId == getitems.desertId).FirstOrDefault(); if (getid.quantityOfdesert >= int.Parse(Desert[i + 4])) { getid.quantityOfdesert = getid.quantityOfdesert - int.Parse(Desert[i + 4]); mh.Entry(getid).State = System.Data.Entity.EntityState.Modified; mh.SaveChanges(); } else { TempData["message"] = "Quantity is low for required quantity"; goto exit ; } } meh.DesertWithFunctionWithMenus.Add(dishofitem); meh.SaveChanges(); i = i + 4; count++; } if (count == 0) { i = i + 3; } } } } } exit: FunctionRequestedTable func = meh.FunctionRequestedTables.Where(X => X.requestID == idofrequest).FirstOrDefault(); func.Status = "SERVED"; meh.Entry(func).State = System.Data.Entity.EntityState.Modified; meh.SaveChanges(); return(View("Index")); }