private double CalcIrrigation(Irrigation irrigation) { if (irrigation?.HasCubicMeterPerMonth == true) { return(irrigation.CubicMeterPerMonth.Value * irrigation.WaterActivities.Drink.Value * 12 / 100.0); } else if (irrigation?.HasPump == true) { return(CalcPumps(irrigation.Pumps, false)); } return(0); }
private void InitialiteConsumables() { AnimalFood animalFood = new AnimalFood(); AnimalWater animalWater = new AnimalWater(); Fertilizer fertilizer = new Fertilizer(); Fungicide fungicide = new Fungicide(50); Herbicide herbicide = new Herbicide(50); Irrigation irrigation = new Irrigation(); Pesticide pesticide = new Pesticide(50); Vaccine vaccine = new Vaccine(50); market.AddConsumable(animalFood); market.AddConsumable(animalWater); market.AddConsumable(fertilizer); market.AddConsumable(fungicide); market.AddConsumable(herbicide); market.AddConsumable(irrigation); market.AddConsumable(pesticide); market.AddConsumable(vaccine); }
public async Task <Irrigation> CalculateIrrigation(User user, CurrentProduction production) { HttpClient client = new HttpClient(); Irrigation irrigation = new Irrigation(); HttpResponseMessage response = new HttpResponseMessage(); if (response.IsSuccessStatusCode) { Stream stream = await response.Content.ReadAsStreamAsync(); using (var reader = new StreamReader(stream)) { while (!reader.EndOfStream) { //faz alguma coisa com esse dado } } } return(null); }
public static Bitmap MapTileGraphicC2(int xC2, int yC2) => MapTileGraphic[(((xC2 + 2 * Map.Instance.Xdim) % (2 * Map.Instance.Xdim)) - yC2 % 2) / 2, yC2]; // Return tile graphics for civ2-coords input // Extract icon from civ2.exe file //public static void ImportCiv2Icon() //{ // try // { // Civ2Icon = Icon.ExtractAssociatedIcon(Settings.Civ2Path + "civ2.exe"); // } // catch // { // Debug.WriteLine("Civ2.exe not found!"); // } //} public static void TerrainBitmapsImportFromFile(string path) { // Read file in local directory. If it doesn't exist there, read it in root civ2 directory. var terrain1 = new Bitmap(640, 480, PixelFormat.Format32bppRgba); //var terrain1 = new Image<Rgba32>(640, 480); string FilePath_local = path + Path.DirectorySeparatorChar + "TERRAIN1.GIF"; string FilePath_root = Settings.Civ2Path + "TERRAIN1.GIF"; if (File.Exists(FilePath_local)) { terrain1 = new Bitmap(FilePath_local); } else if (File.Exists(FilePath_root)) { terrain1 = new Bitmap(FilePath_root); } else { Debug.WriteLine("TERRAIN1.GIF not found!"); } var terrain2 = new Bitmap(640, 480, PixelFormat.Format32bppRgba); FilePath_local = path + Path.DirectorySeparatorChar + "TERRAIN2.GIF"; FilePath_root = Settings.Civ2Path + "TERRAIN2.GIF"; if (File.Exists(FilePath_local)) { terrain2 = new Bitmap(FilePath_local); } else if (File.Exists(FilePath_root)) { terrain2 = new Bitmap(FilePath_root); } else { Debug.WriteLine("TERRAIN2.GIF not found!"); } // Initialize objects Desert = new Bitmap[4]; Plains = new Bitmap[4]; Grassland = new Bitmap[4]; ForestBase = new Bitmap[4]; HillsBase = new Bitmap[4]; MtnsBase = new Bitmap[4]; Tundra = new Bitmap[4]; Glacier = new Bitmap[4]; Swamp = new Bitmap[4]; Jungle = new Bitmap[4]; Ocean = new Bitmap[4]; Coast = new Bitmap[8, 4]; River = new Bitmap[16]; Forest = new Bitmap[16]; Mountains = new Bitmap[16]; Hills = new Bitmap[16]; RiverMouth = new Bitmap[4]; Road = new Bitmap[9]; Railroad = new Bitmap[9]; // Define transparent colors Color transparentGray = Color.FromArgb(135, 135, 135); // Define transparent back color (gray) Color transparentPink = Color.FromArgb(255, 0, 255); // Define transparent back color (pink) Color transparentCyan = Color.FromArgb(0, 255, 255); // Define transparent back color (cyan) // Tiles for (int i = 0; i < 4; i++) { Desert[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), 1, 64, 32)); Desert[i].ReplaceColors(transparentGray, Colors.Transparent); Desert[i].ReplaceColors(transparentPink, Colors.Transparent); Plains[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (2 * 1) + (1 * 32), 64, 32)); Plains[i].ReplaceColors(transparentGray, Colors.Transparent); Plains[i].ReplaceColors(transparentPink, Colors.Transparent); Grassland[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (3 * 1) + (2 * 32), 64, 32)); Grassland[i].ReplaceColors(transparentGray, Colors.Transparent); Grassland[i].ReplaceColors(transparentPink, Colors.Transparent); ForestBase[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (4 * 1) + (3 * 32), 64, 32)); ForestBase[i].ReplaceColors(transparentGray, Colors.Transparent); ForestBase[i].ReplaceColors(transparentPink, Colors.Transparent); HillsBase[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (5 * 1) + (4 * 32), 64, 32)); HillsBase[i].ReplaceColors(transparentGray, Colors.Transparent); HillsBase[i].ReplaceColors(transparentPink, Colors.Transparent); MtnsBase[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (6 * 1) + (5 * 32), 64, 32)); MtnsBase[i].ReplaceColors(transparentGray, Colors.Transparent); MtnsBase[i].ReplaceColors(transparentPink, Colors.Transparent); Tundra[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (7 * 1) + (6 * 32), 64, 32)); Tundra[i].ReplaceColors(transparentGray, Colors.Transparent); Tundra[i].ReplaceColors(transparentPink, Colors.Transparent); Glacier[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (8 * 1) + (7 * 32), 64, 32)); Glacier[i].ReplaceColors(transparentGray, Colors.Transparent); Glacier[i].ReplaceColors(transparentPink, Colors.Transparent); Swamp[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (9 * 1) + (8 * 32), 64, 32)); Swamp[i].ReplaceColors(transparentGray, Colors.Transparent); Swamp[i].ReplaceColors(transparentPink, Colors.Transparent); Jungle[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (10 * 1) + (9 * 32), 64, 32)); Jungle[i].ReplaceColors(transparentGray, Colors.Transparent); Jungle[i].ReplaceColors(transparentPink, Colors.Transparent); Ocean[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), (11 * 1) + (10 * 32), 64, 32)); Ocean[i].ReplaceColors(transparentGray, Colors.Transparent); Ocean[i].ReplaceColors(transparentPink, Colors.Transparent); } // 4 small dither tiles DitherBlank = new Bitmap[2, 2]; DitherDots = new Bitmap[2, 2]; for (int tileX = 0; tileX < 2; tileX++) { for (int tileY = 0; tileY < 2; tileY++) { DitherBlank[tileX, tileY] = terrain1.Clone(new Rectangle((tileX * 32) + 1, (tileY * 16) + 447, 32, 16)); DitherDots[tileX, tileY] = DitherBlank[tileX, tileY]; DitherDots[tileX, tileY].ReplaceColors(transparentGray, Colors.Transparent); DitherDots[tileX, tileY].ReplaceColors(transparentPink, Colors.Transparent); } } // Blank tile Blank = terrain1.Clone(new Rectangle(131, 447, 64, 32)); Blank.ReplaceColors(transparentGray, Colors.Transparent); // Dither base (only useful for grasland?) DitherBase = terrain1.Clone(new Rectangle(196, 447, 64, 32)); // Replace black dither pixels with base pixels DitherDesert = new Bitmap[2, 2]; // 4 dither tiles for one 64x32 map tile DitherPlains = new Bitmap[2, 2]; DitherGrassland = new Bitmap[2, 2]; DitherForest = new Bitmap[2, 2]; DitherHills = new Bitmap[2, 2]; DitherMountains = new Bitmap[2, 2]; DitherTundra = new Bitmap[2, 2]; DitherGlacier = new Bitmap[2, 2]; DitherSwamp = new Bitmap[2, 2]; DitherJungle = new Bitmap[2, 2]; Color replacementColor; for (int tileX = 0; tileX < 2; tileX++) { // For 4 directions (NE, SE, SW, NW) for (int tileY = 0; tileY < 2; tileY++) { DitherDesert[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherPlains[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherGrassland[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherForest[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherHills[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherMountains[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherTundra[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherGlacier[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherSwamp[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); DitherJungle[tileX, tileY] = new Bitmap(32, 16, PixelFormat.Format32bppRgba); for (int col = 0; col < 32; col++) { for (int row = 0; row < 16; row++) { // replacementColor = DitherBlank.GetPixel(tileX * 32 + col, tileY * 16 + row); replacementColor = DitherBlank[tileX, tileY].GetPixel(col, row); if (replacementColor == Color.FromArgb(0, 0, 0)) { DitherDesert[tileX, tileY].SetPixel(col, row, Desert[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherPlains[tileX, tileY].SetPixel(col, row, Plains[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherGrassland[tileX, tileY].SetPixel(col, row, Grassland[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherForest[tileX, tileY].SetPixel(col, row, ForestBase[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherHills[tileX, tileY].SetPixel(col, row, HillsBase[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherMountains[tileX, tileY].SetPixel(col, row, MtnsBase[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherTundra[tileX, tileY].SetPixel(col, row, Tundra[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherGlacier[tileX, tileY].SetPixel(col, row, Glacier[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherSwamp[tileX, tileY].SetPixel(col, row, Swamp[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); DitherJungle[tileX, tileY].SetPixel(col, row, Jungle[0].GetPixel((tileX * 32) + col, (tileY * 16) + row)); } else { DitherDesert[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherPlains[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherGrassland[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherForest[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherHills[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherMountains[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherTundra[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherGlacier[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherSwamp[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); DitherJungle[tileX, tileY].SetPixel(col, row, Color.FromArgb(0, 0, 0, 0)); } } } } } // Rivers, Forest, Mountains, Hills for (int i = 0; i < 16; i++) { River[i] = terrain2.Clone(new Rectangle((i % 8) + 1 + ((i % 8) * 64), 3 + (i / 8) + ((2 + (i / 8)) * 32), 64, 32)); River[i].ReplaceColors(transparentGray, Colors.Transparent); River[i].ReplaceColors(transparentPink, Colors.Transparent); Forest[i] = terrain2.Clone(new Rectangle((i % 8) + 1 + ((i % 8) * 64), 5 + (i / 8) + ((4 + (i / 8)) * 32), 64, 32)); Forest[i].ReplaceColors(transparentGray, Colors.Transparent); Forest[i].ReplaceColors(transparentPink, Colors.Transparent); Mountains[i] = terrain2.Clone(new Rectangle((i % 8) + 1 + ((i % 8) * 64), 7 + (i / 8) + ((6 + (i / 8)) * 32), 64, 32)); Mountains[i].ReplaceColors(transparentGray, Colors.Transparent); Mountains[i].ReplaceColors(transparentPink, Colors.Transparent); Hills[i] = terrain2.Clone(new Rectangle((i % 8) + 1 + ((i % 8) * 64), 9 + (i / 8) + ((8 + (i / 8)) * 32), 64, 32)); Hills[i].ReplaceColors(transparentGray, Colors.Transparent); Hills[i].ReplaceColors(transparentPink, Colors.Transparent); } // River mouths for (int i = 0; i < 4; i++) { RiverMouth[i] = terrain2.Clone(new Rectangle(i + 1 + (i * 64), (11 * 1) + (10 * 32), 64, 32)); RiverMouth[i].ReplaceColors(transparentGray, Colors.Transparent); RiverMouth[i].ReplaceColors(transparentPink, Colors.Transparent); RiverMouth[i].ReplaceColors(transparentCyan, Colors.Transparent); } // Coast for (int i = 0; i < 8; i++) { Coast[i, 0] = terrain2.Clone(new Rectangle((2 * i) + 1 + (2 * i * 32), 429, 32, 16)); // N Coast[i, 0].ReplaceColors(transparentGray, Colors.Transparent); Coast[i, 1] = terrain2.Clone(new Rectangle((2 * i) + 1 + (2 * i * 32), 429 + (1 * 1) + (1 * 16), 32, 16)); // S Coast[i, 1].ReplaceColors(transparentGray, Colors.Transparent); Coast[i, 2] = terrain2.Clone(new Rectangle((2 * i) + 1 + (2 * i * 32), 429 + (2 * 1) + (2 * 16), 32, 16)); // W Coast[i, 2].ReplaceColors(transparentGray, Colors.Transparent); Coast[i, 3] = terrain2.Clone(new Rectangle((2 * (i + 1)) + (((2 * i) + 1) * 32), 429 + (2 * 1) + (2 * 16), 32, 16)); // E Coast[i, 3].ReplaceColors(transparentGray, Colors.Transparent); } // Road & railorad for (int i = 0; i < 9; i++) { Road[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), 364, 64, 32)); Road[i].ReplaceColors(transparentGray, Colors.Transparent); Road[i].ReplaceColors(transparentPink, Colors.Transparent); Railroad[i] = terrain1.Clone(new Rectangle(i + 1 + (i * 64), 397, 64, 32)); Railroad[i].ReplaceColors(transparentGray, Colors.Transparent); Railroad[i].ReplaceColors(transparentPink, Colors.Transparent); } Irrigation = terrain1.Clone(new Rectangle(456, 100, 64, 32)); Irrigation.ReplaceColors(transparentGray, Colors.Transparent); Irrigation.ReplaceColors(transparentPink, Colors.Transparent); Farmland = terrain1.Clone(new Rectangle(456, 133, 64, 32)); Farmland.ReplaceColors(transparentGray, Colors.Transparent); Farmland.ReplaceColors(transparentPink, Colors.Transparent); Mining = terrain1.Clone(new Rectangle(456, 166, 64, 32)); Mining.ReplaceColors(transparentGray, Colors.Transparent); Mining.ReplaceColors(transparentPink, Colors.Transparent); Pollution = terrain1.Clone(new Rectangle(456, 199, 64, 32)); Pollution.ReplaceColors(transparentGray, Colors.Transparent); Pollution.ReplaceColors(transparentPink, Colors.Transparent); Shield = terrain1.Clone(new Rectangle(456, 232, 64, 32)); Shield.ReplaceColors(transparentGray, Colors.Transparent); Shield.ReplaceColors(transparentPink, Colors.Transparent); terrain1.Dispose(); terrain2.Dispose(); }
public double GetTotalIrrigation() { return(Irrigation.Sum()); }
public double GetAnnualAvgIrrigation() { return(Irrigation.Sum() / ((float)Counts.Sum() / 365.25)); }
public List <double> GetMonthlyAvgIrrigation() { return(Irrigation.Select(x => x / (((double)Counts[Irrigation.IndexOf(x)]) / 365.25 * 12.0)).ToList()); }
public bool IsCheckHasProblemIrrigation(Irrigation irrigation) { return(irrigation?.QualityProblem.HasProblem == true); }
public bool IsCheckIrrigation(bool?isIrrigation, Irrigation irrigation) { return((isIrrigation == true) ? IsCheckHasProblemIrrigation(irrigation) : false); }
public bool IsCheckProblem(WaterSources waterSources, Plumbing plumbing, GroundWater groundWater, River river, Pool pool, Irrigation irrigation) { return(IsCheckPlumbing(waterSources?.Plumbing, plumbing) || IsCheckUnderGround(waterSources?.UnderGround, groundWater) || IsCheckPool(waterSources?.Pool, pool) || IsCheckRiver(waterSources?.River, river) || IsCheckIrrigation(waterSources?.Irrigation, irrigation)); }
private bool checkIrrigation(Irrigation irrigate) { return(irrigate != null && checkPumps(irrigate.Pumps)); }
public CubicMeterSurfaceManage(Pool pool, River river, Irrigation irrigation, Rain rain) { River = river; Irrigation = irrigation; Rain = rain; }
private void AddWaterOrFood() { int selectedTerrainIndex = map.getTerrainIndex(player.Terrains, true); if (selectedTerrainIndex == -1) { Console.WriteLine("Opción no valida..."); } else { Terrain selectedTerrain = map.Terrains[selectedTerrainIndex]; int playerTerrainIndex = player.Terrains.IndexOf(selectedTerrain); Terrain terrain = player.Terrains[playerTerrainIndex]; if (!terrain.HasBuilding()) { Console.WriteLine("No tienes un edificio en este terreno..."); } else { Building terrainBuilding = terrain.Building; if (terrainBuilding.GetType() == typeof(Plantation)) { Plantation plantationBuilding = terrainBuilding as Plantation; List <Consumable> availableConsumables = new List <Consumable>(); bool hasAvailableConsumables = false; while (!hasAvailableConsumables) { availableConsumables = player.GetAvailableConsumables(new List <string> { "Irrigation", "Fertilizer" }); string option = CheckIfCanAddConsumableToTerrain(availableConsumables); if (option == "out") { return; } else if (option == "continue") { hasAvailableConsumables = true; } } Console.WriteLine("Elige uno de los productos disponibles:"); for (int i = 0; i < availableConsumables.Count; i++) { Console.WriteLine($"({i + 1}) - {availableConsumables[i].Name}"); } int userOption = Int32.Parse(Console.ReadLine()); if (userOption < 1 || userOption > availableConsumables.Count) { Console.WriteLine("Opción no valida..."); return; } Consumable selectedConsumable = availableConsumables[userOption - 1]; if (selectedConsumable.GetType() == typeof(Irrigation)) { Irrigation irrigationConsumable = selectedConsumable as Irrigation; plantationBuilding.Water += irrigationConsumable.QuantityAdded; Console.WriteLine($"Se agrego riego correctamente. Nuevo nivel de agua: {plantationBuilding.Water}"); } else if (selectedConsumable.GetType() == typeof(Fertilizer)) { Fertilizer fertilizerConsumable = selectedConsumable as Fertilizer; plantationBuilding.Nutrients += fertilizerConsumable.QuantityAdded; Console.WriteLine($"Se agrego fertilizante correctamente. Nuevo nivel de nutrientes: {plantationBuilding.Nutrients}"); } else { return; } int indexOfConsumable = player.consumables.IndexOf(selectedConsumable); player.consumables.RemoveAt(indexOfConsumable); } else if (terrainBuilding.GetType() == typeof(Livestock)) { Livestock liveStockBuilding = terrainBuilding as Livestock; List <Consumable> availableConsumables = new List <Consumable>(); bool hasAvailableConsumables = false; while (!hasAvailableConsumables) { availableConsumables = player.GetAvailableConsumables(new List <string> { "AnimalFood", "AnimalWater" }); string option = CheckIfCanAddConsumableToTerrain(availableConsumables); if (option == "out") { return; } else if (option == "continue") { hasAvailableConsumables = true; } } Console.WriteLine("Elige uno de los productos disponibles:"); for (int i = 0; i < availableConsumables.Count; i++) { Console.WriteLine($"({i + 1}) - {availableConsumables[i].Name}"); } int userOption = Int32.Parse(Console.ReadLine()); if (userOption < 1 || userOption > availableConsumables.Count) { Console.WriteLine("Opción no valida..."); return; } Consumable selectedConsumable = availableConsumables[userOption - 1]; if (selectedConsumable.GetType() == typeof(AnimalWater)) { AnimalWater animalWaterConsumable = selectedConsumable as AnimalWater; liveStockBuilding.Water += animalWaterConsumable.QuantityAdded; Console.WriteLine($"Se agrego agua correctamente. Nuevo nivel de agua: {liveStockBuilding.Water}"); } else if (selectedConsumable.GetType() == typeof(AnimalFood)) { AnimalFood animalFoodConsumable = selectedConsumable as AnimalFood; liveStockBuilding.Food += animalFoodConsumable.QuantityAdded; Console.WriteLine($"Se agrego comida correctamente. Nuevo nivel de nutrientes: {liveStockBuilding.Food}"); } else { return; } int indexOfConsumable = player.consumables.IndexOf(selectedConsumable); player.consumables.RemoveAt(indexOfConsumable); } else { return; } } } }