public static Climat getClimat(IDBContext db, Coordinates coordinates) { Climat rc = null; if (!Climat.GetByMap(db, coordinates, out rc)) { rc = new Climat(db, coordinates); } return(rc); }
public JsonResult CreateFromSoil(EGH01.Models.EGHMAP.MapPointView mp) { ViewBag.EGHLayout = "MAP"; RGEContext db = null; string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty"; ActionResult view = View("EGHMAPsoil"); db = new RGEContext(); view = View("EGHMAPsoil", db); String Latitude = mp.Latitude; ViewData["Latitude"] = Latitude; String Lat_m = mp.Lat_m; ViewData["Lat_m"] = Lat_m; String Lat_s = mp.Lat_s; ViewData["Lat_s"] = Lat_s; String Lngitude = mp.Lngitude; ViewData["Lngitude"] = Lngitude; String Lng_m = mp.Lng_m; ViewData["Lng_m"] = Lng_m; String Lng_s = mp.Lng_s; ViewData["Lng_s"] = Lng_s; float coords = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Latitude), int.Parse(Lat_m), float.Parse(Lat_s)); float coordm = EGH01DB.Primitives.Coordinates.dms_to_d(int.Parse(Lngitude), int.Parse(Lng_m), float.Parse(Lng_s)); EGH01DB.Primitives.Coordinates mapPoint = new Coordinates(coordm, coords); EGH01DB.Types.District district = new District(); EGH01DB.Primitives.MapHelper.GetRegion(db, mapPoint, out district); ViewData["district"] = district.name; ViewData["region"] = district.region.name; float time_migration = 0.0f; EGH01DB.Primitives.MapHelper.GetTimeMigration(db, mapPoint, out time_migration); string aeration_power = ""; float average_aeration_power = 0.0f; float max_aeration_power = 0.0f; string litology = ""; EGH01DB.Primitives.MapHelper.GetAerationZone(db, mapPoint, out aeration_power, out average_aeration_power, out max_aeration_power, out litology); float height = 0.0f; EGH01DB.Primitives.MapHelper.GetHeight(db, mapPoint, out height); EGH01DB.Types.SoilType soilType = new SoilType(); EGH01DB.Primitives.MapHelper.GetSoil(db, mapPoint, out soilType); EGH01DB.Primitives.Climat climat = new Climat(db, mapPoint); EGH01DB.Primitives.MapHelper.GetMonthTemperature(db, mapPoint, out climat); float[] period = climat.temperature; EGH01DB.Types.GroundType ground_type = new GroundType(); EGH01DB.Primitives.MapHelper.GetGroundCoef(db, mapPoint, out ground_type); var heights = new { Soilname = soilType.name, Soilmehsost = soilType.mehsost, Soiltype = soilType.soil_type, Soilsubtype = soilType.soil_subtype, Humidity = soilType.humidity, Gumusdepth = soilType.gumus_depth, Capmoisturecapacity = soilType.watercapacity, Petrolfiltrationcoef = soilType.petrol_filtration_coef, Fueloilfiltrationcoef = soilType.fuel_oil_filtration_coef, Dieselfiltrationcoef = soilType.diesel_filtration_coef, Hydrolyticacidity = soilType.hydrolytic_acidity, Oilcapacity = soilType.oil_capacity, Density = soilType.density, Carboncontent = soilType.carbon_content, Filtercoefinterval = soilType.filter_coef_interval, Porosityinterval = soilType.porosity_interval, Glinainterval = soilType.glina_interval, Mginterval = soilType.mg_interval, Phinterval = soilType.ph_interval, Densityinterval = soilType.density, Maxmoisturecapacityinterval = soilType.max_moisture_capacity_interval, Gumuspercentageinterval = soilType.gumus_percentage_interval, Klass = soilType.klass, Soiltypecode = soilType.soil_class_code, Wrbcode = soilType.wrb_code, Wrbnewcode = soilType.wrb_new_code, Rgbcode = soilType.rgb_code, Shtrihovka = soilType.shtrihovka, Height = height, Aeration_power = aeration_power, Average_aeration_power = average_aeration_power, Max_aeration_power = max_aeration_power, Litology = litology, Time_migration = time_migration, District = district.name, Region = district.region.name, Watercapacity = ground_type.watercapacity, Porosity = ground_type.porosity, Waterfilter = ground_type.waterfilter, Period = period }; return(Json(heights)); }
public static void HandleWeather(Tile currentTile, bool wasJustDiscoveredByAKeeper) { if (GameManager.Instance.ListEventSelected.Count <= 0) { return; } // Snow events if (GameManager.Instance.ListEventSelected.Contains("1")) { if (GameManager.Instance.NbTurn % nbDayInMonth < 5) { if ((currentTile.Type == TileType.Snow || currentTile.Type == TileType.Forest) && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null) { if (Random.Range(0, 100) <= weatherFrequency) { climat.TypeClimat = TypeClimat.Snow; weatherFrequency /= 2.0f; } else { climat.TypeClimat = TypeClimat.None; weatherFrequency += 20.0f; } } } } } else { if ((currentTile.Type == TileType.Snow || currentTile.Type == TileType.Forest) && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null) { climat.TypeClimat = TypeClimat.None; } } } // HButterfly events if (GameManager.Instance.ListEventSelected.Contains("2")) { if (wasJustDiscoveredByAKeeper) { if (GameManager.Instance.NbTurn % nbDayInWeek == 5 || GameManager.Instance.NbTurn % nbDayInWeek == 6) { if (currentTile.Type == TileType.Plain && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null && currentTile.GetComponentInChildren <nagePetitPoisson>() != null) { climat.TypeClimat = TypeClimat.Butterfly; } } } else { if (currentTile.Type == TileType.Plain && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null) { climat.TypeClimat = TypeClimat.None; } } } } } // HEat distorsion if (GameManager.Instance.ListEventSelected.Contains("3")) { if (GameManager.Instance.NbTurn % nbDayInWeek == 2 || GameManager.Instance.NbTurn % nbDayInWeek == 3) { if (currentTile.Type == TileType.Desert && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null) { if (Random.Range(0, 100) <= weatherFrequency) { climat.TypeClimat = TypeClimat.HeatDistorsion; weatherFrequency /= 2.0f; } else { climat.TypeClimat = TypeClimat.None; weatherFrequency += 20.0f; } } } } else { if (currentTile.Type == TileType.Desert && currentTile.State == TileState.Discovered) { if (currentTile.gameObject.GetComponentInChildren <Climat>() == null) { Debug.Log(currentTile.name + "n'a pas de climat en enfant"); return; } Climat climat = currentTile.gameObject.GetComponentInChildren <Climat>(); if (climat != null) { climat.TypeClimat = TypeClimat.None; } } } } }