static void Main() { Park jurassic = new Park(); jurassic.AddNewPaddock("Carnivore Paddock", true, false, true, false, true); jurassic.AddNewPaddock("Atrium", true, true, true, false, false); jurassic.AddNewPaddock("Herbivore Paddock", false, true, true, true, false); jurassic.AddNewPaddock("Raptor Lounge", false, true, false, true, true); jurassic.AddNewPaddock("Hotel", true, false, false, true, true); Paddock location = jurassic.GetLocationbyName("carnivore"); jurassic.AddNewDino("T-Rex", "20,000 lbs", true, location); // jurassic.AddNewDino("Brachiosaurus", "124, 000 lbs", false, GetLocationbyName("herbivore")); // jurassic.AddNewDino("Pterodactyl", "550 lbs", true, GetLocationbyName("atrium")); // jurassic.AddNewDino("Velociraptor", "33 lbs", true, GetLocationbyName("raptorPen")); // jurassic.AddNewDino("Sam", "170 lbs", false, GetLocationbyName("hotel")); foreach (Dinosaur dino in jurassic.GetDinoList()) { Console.WriteLine("Species: " + dino.GetSpecies()); Console.WriteLine("Location: " + dino.GetLocation()); Console.WriteLine("TrampStamp: " + dino.GetId()); } foreach (Paddock pen in jurassic.GetPaddockList()) { Console.WriteLine("Paddock: " + pen.name); } }
/// <summary> /// /// </summary> /// <param name="subArea"></param> /// <param name="id"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="data"></param> /// <param name="dataKey"></param> /// <param name="createTime"></param> public MapInstance(int subAreaId, int id, int x, int y, int width, int height, string data, string dataKey, string createTime, List <int> f0teamCells, List <int> f1teamCells, bool subInstance = false) { Id = id; SubAreaId = subAreaId; X = x; Y = y; Width = width; Height = height; Data = data; DataKey = dataKey; CreateTime = createTime; FightTeam0Cells = f0teamCells; FightTeam1Cells = f1teamCells; m_subInstance = subInstance; m_cells = new List <MapCell>(); m_interactiveObjects = new List <InteractiveObject>(); m_cellById = new Dictionary <int, MapCell>(); m_entityById = new Dictionary <long, AbstractEntity>(); m_entityByName = new Dictionary <string, AbstractEntity>(); m_initialized = false; m_paddock = PaddockManager.Instance.GetByMapId(Id); FightManager = new FightManager(this); SubArea.AddUpdatable(this); SubArea.SafeAddHandler(base.Dispatch); SpawnManager.Instance.RegisterMap(this); Initialize(); }
// Start is called before the first frame update void Start() { hunger = GameObject.Find("HungerPaddock").GetComponent <Text>(); happiness = GameObject.Find("HappinessPaddock").GetComponent <Text>(); profiles = this.transform.GetComponentInParent <Paddock>(); updateValues(); }
/// <summary> /// /// </summary> /// <param name="map"></param> /// <param name="cellId"></param> public PaddockDoor(MapInstance map, int cellId) : base(map, cellId) { m_paddock = map.Paddock; if (m_paddock == null) { Logger.Info("null paddock on map " + map.Id); } }
private void Start() { Item item = new Item("Albino Goat"); SaveManager saveMgr = new SaveManager(new List <Animal>() { new Animal("Albino Goat") }); Paddock specificPaddock = new Paddock(); Animal animal = saveMgr.Remove(item.Name); specificPaddock.Add(animal); //UpdateStatOnAnimalAddEvent(onePercent); }
public void Handle([NotNull] PaddockCreateEvent message) { if (Guid.Empty == message.FarmId) { return; } var paddock = new Paddock { FarmId = message.FarmId, AreaInHectares = 0.0f, FieldsCode = "New Fields Code", Id = Guid.NewGuid() }; m_PaddocksRepository.Save(paddock); PublishPaddocksChangedEvent(paddock.FarmId); }
void placeDog(EnvironmentTile tile) { if (tile != null) { //Shpw the shop at the mouse position in the centre of the tile spawnedDog.transform.position = new Vector3(mRaycastHits[0].transform.position.x + 5, mRaycastHits[0].transform.position.y + 3, mRaycastHits[0].transform.position.z + 5); //Only place a dog if within a paddock and a dog isn't currently within that position if (Input.GetMouseButtonDown(0)) { if (tile.isPaddock) { if (currency.sufficientFunds(dogCost)) { if (tile.GetComponentInParent <Paddock>().addDogs()) { dogClone = dog.spawnDog(); dogClone.transform.position = tile.Position; //Assign the paddock to the dog dogB = dogClone.GetComponentInChildren <DogBehaviour>(); dogB.setTile(tile); dogB.setPaddock(tile.GetComponentInParent <Paddock>().getPaddock()); dogB.setPaddockTiles(tile.GetComponentInParent <Paddock>().getPaddockTiles()); interactingPaddock = mRaycastHits[0].transform.GetComponentInParent <Paddock>().getPaddock(); placingDog = false; currency.takeIncome(dogCost); level.addExp(standardExp); } } } //Destroy stand in Destroy(spawnedDog.gameObject); placingDog = false; } } }
private void CreatePaddocks() { IFarm[] farms = m_FarmsRepository.All.ToArray(); foreach (IFarm farm in farms) { for (var i = 1; i <= MaxNumberOfPaddocks; i++) { var paddock = new Paddock { FieldsCode = "Field Code " + i, AreaInHectares = i, FarmId = farm.Id }; m_PaddocksRepository.Save(paddock); } } }
public void FindByFarmId_ReturnsPaddocks_ForKnownFarmId( [NotNull] Paddock one, [NotNull] Paddock two, Guid farmId, [NotNull] PaddocksRepository sut) { // Arrange one.FarmId = farmId; two.FarmId = farmId; sut.Save(one); sut.Save(two); // Act IQueryable <IPaddock> actual = sut.FindByFarmId(farmId); // Assert Assert.AreEqual(2, actual.Count()); }
public void OnProcess() { //set up data table int NumLayers = 0; AllRootSystems.Rows.Clear(); foreach (Paddock p in paddock.ChildPaddocks) { foreach (Component c in p.Crops) { string PlantStatus; if (!c.Get("plant_status", out PlantStatus)) { throw new Exception("Could not find plant_status for crop :" + c.Name); } if (PlantStatus != "out") //if crop is not in ground, we don't care about it { if (c.GetObject("RootSystem", ref RootData)) //crop has a RootData structre { Dictionary <string, double> SWStrength = CalcSWSourceStrength(RootData); foreach (RootSystemZoneType zone in RootData.Zone) //add each zone to the table { AllRootSystems.Rows.Add(zone.ZoneName, c.Name, RootData.SWDemand, SWStrength, zone, true); } NumLayers = RootData.Zone[0].kl.Length; } else //crop does not have RootData structure, so make one. { Dictionary <string, double> SWStrength = new Dictionary <string, double>(); RootData = new RootSystemType(); RootData.Zone = new RootSystemZoneType[1]; RootData.Zone[0] = new RootSystemZoneType(); RootData.Zone[0].ZoneName = p.Name; RootData.Zone[0].ZoneArea = 1; if (!c.Get("sw_demand", out RootData.SWDemand)) { throw new Exception("Could not get sw_demand for crop " + c.Name); } if (!c.Get("root_depth", out RootData.Zone[0].RootDepth)) { throw new Exception("Could not get root_depth for crop " + c.Name); } if (!c.Get("ll", out RootData.Zone[0].ll)) { throw new Exception("Could not get ll for crop " + c.Name); } if (!c.Get("kl", out RootData.Zone[0].kl)) { throw new Exception("Could not get kl for crop " + c.Name); } SoilWat = (Component)p.LinkByType("SoilWat"); SWStrength.Add(p.Name, 1); if (!SoilWat.Get("dlayer", out RootData.Zone[0].dlayer)) { throw new Exception("Could not get dlayer for paddock " + p.Name); } AllRootSystems.Rows.Add(RootData.Zone[0].ZoneName, c.Name, RootData.SWDemand, SWStrength, RootData.Zone[0], true); NumLayers = RootData.Zone[0].kl.Length; } } } } //use LINQ to extract the paddocks for processing IEnumerable <string> paddockNames = AllRootSystems.AsEnumerable().Select <DataRow, string>(name => (string)name.ItemArray[0]).Distinct(); //do water allocation for each paddock foreach (string PaddockName in paddockNames) { IEnumerable <DataRow> RootZones = AllRootSystems.AsEnumerable().Where(row => row.ItemArray[0].Equals(PaddockName)); Paddock p = (Paddock)paddock.LinkByName(PaddockName); Component fieldProps = (Component)p.LinkByName("FieldProps"); double fieldArea; if (fieldProps == null || !fieldProps.Get("fieldArea", out fieldArea)) { throw new Exception("Could not find FieldProps component in field " + PaddockName); } Component Soil = (Component)p.LinkByType("SoilWat"); double[] SWDep; double[] dlayer; Soil.Get("dlayer", out dlayer); Soil.Get("sw_dep", out SWDep); double[] CropSWDemand = new double[RootZones.Count()]; for (int i = 0; i < RootZones.Count(); i++) //get demand for all crops in paddock using relative SW strength { Dictionary <string, double> PaddockSWDemands = (Dictionary <string, double>)RootZones.ToArray()[i].ItemArray[3]; CropSWDemand[i] = PaddockSWDemands[p.Name] * (double)RootZones.ToArray()[i].ItemArray[2]; } double[,] RelKLStrength = CalcRelKLStrength(RootZones, CropSWDemand); double[,] RelSWLayerStrength = CalcRelSWLayerStrength(RootZones, SWDep, NumLayers); double[,] SWSupply = CalcSWSupply(RootZones, SWDep, NumLayers); double[,] LayerUptake = new double[RootZones.Count(), NumLayers]; double[] LastCropSWDemand; double[,] LastSWSupply; int count = 0; do { count++; LastCropSWDemand = CropSWDemand; LastSWSupply = SWSupply; for (int i = 0; i < RootZones.Count(); i++) //get as much water as possible for the layer using relative kl strengths { RootSystemZoneType Zone = (RootSystemZoneType)RootZones.ToArray()[i].ItemArray[4]; for (int j = 0; j < NumLayers; j++) { if (MathUtility.Sum(CropSWDemand) < MathUtility.Sum(SWSupply)) { LayerUptake[i, j] = CropSWDemand[i] * RelSWLayerStrength[i, j]; } else { LayerUptake[i, j] = SWSupply[i, j] * RelKLStrength[j, i] * RootProportion(j, Zone.RootDepth, dlayer); } if (LayerUptake[i, j] < 0) { throw new Exception("Layer uptake should not be negative"); } } } DenseMatrix Uptake = DenseMatrix.OfArray(LayerUptake); Paddock CurrentPaddock; Component CurrentCrop; for (int i = 0; i < RootZones.Count(); i++) //subtract taken water from the supply and demand { CurrentPaddock = (Paddock)p.LinkByName((string)RootZones.ToArray()[i].ItemArray[0]); CurrentCrop = (Component)CurrentPaddock.LinkByName((string)RootZones.ToArray()[i].ItemArray[1]); CropSWDemand[i] -= Uptake.Row(i).Sum(); if (CurrentCrop != null && CurrentCrop.Name.ToLower().Equals("maize")) { CurrentCrop.Set("arb_water_uptake", Uptake.Row(i).ToArray()); } for (int j = 0; j < NumLayers; j++) { SWSupply[i, j] -= LayerUptake[i, j]; } } //subtract from soil water for (int j = 0; j < Uptake.ColumnCount; j++) { SWDep[j] -= Uptake.Column(j).Sum() / fieldArea; } Soil.Set("sw_dep", SWDep); } while (MathUtility.Sum(LastCropSWDemand) != MathUtility.Sum(CropSWDemand) && MathUtility.Sum(LastSWSupply) != MathUtility.Sum(SWSupply)); } }
/// <summary> /// /// </summary> /// <param name="character"></param> /// <param name="paddock"></param> public GameMountStorageExchangeAction(CharacterEntity character, Paddock paddock) : base(new MountStorageExchange(), character) { }
// The following event handler will be called once at the beginning of the simulation [EventHandler] public void OnInitialised() { string[] names; double[] estimates; string[] stringSeparators = new string[] { " " }; /// Hamze - I'm trying to find the soil name through looping all the childerns of the paddok (Maybe not very efficient but it's working for now) pad = MyPaddock.Parent.ChildPaddocks[0]; foreach (Component s in pad.Children) { if (s.Name.Contains("Water")) { names = s.Name.Split(stringSeparators, StringSplitOptions.None); soil_name = names[0]; } } /////////////////////////////////// Using GLM function to estimate the biochar properties estimates = GLMs(feedbio, PTemp); frac_c_biochar = estimates[0]; frac_labile = estimates[1]; biochar_cn = estimates[2]; bc_cec = estimates[3]; bc_cce = estimates[4]; /////////////////////////////////// bc_nh4 = new double[oc.Length]; thisPH = new double[ph.Length]; soil_cec = new double[oc.Length]; soil_cec_orig = new double[oc.Length]; titrat_val = new double[oc.Length]; MassComparison = new double[oc.Length]; LayerMass = new double[oc.Length]; biochar_bd = bd; for (int i = 0; i < ph.Length; i++) { thisPH[i] = ph[i]; soil_cec[i] = get_soil_CEC(i); titrat_val[i] = 216.51 * Math.Exp(ph[i] * (-0.91)); soil_cec_orig[i] = get_soil_CEC(i); LayerMass[i] = bd[i] * dlayer[i] * 10000; } biochar_ph_value = Math.Pow(10, -bc_cce); //To convert MRT to kb kb1 = Math.Log(2.0) / (MRT1 * 365); kb2 = Math.Log(2.0) / (MRT2 * 365); init_soil_fac = new double[oc.Length]; for (int i = 0; i < oc.Length; i++) { init_soil_fac[i] = 100 / (dlayer[i] * bd[i]); } //Only works for USA format dates - change in future? Maybe change input format? dayApp = Convert.ToInt32(date_of_application.Substring(3, 2)); moApp = Convert.ToInt32(date_of_application.Substring(0, 2)); yearApp = Convert.ToInt32(date_of_application.Substring(6, 4)); date = new DateTime(yearApp, moApp, dayApp); BiocharC_labile = new double[oc.Length]; BiocharC_resistant = new double[oc.Length]; BiocharC = new double[oc.Length]; firstTill = false; //initialize a lot of things dlt_c_biochar_co2 = new double[oc.Length]; dlt_c_biochar_biom = new double[oc.Length]; dlt_c_biochar_hum = new double[oc.Length]; dlt_c_min_biochar = new double[oc.Length]; dlt_n_min_biochar = new double[oc.Length]; n_demand_bc = new double[oc.Length]; n_avail_bc = new double[oc.Length]; yesterday_oc = new double[oc.Length]; saxon_bd = new double[oc.Length]; saxon_sat = new double[oc.Length]; till_bd = new double[oc.Length]; till_sat = new double[oc.Length]; cnr_bcf = new double[oc.Length]; scale_factor = new double[oc.Length]; dlt_dlayer = new double[oc.Length]; dlt_c_min_biochar_pot = new double[oc.Length]; total_stress = new double[oc.Length]; rainAmt = 0.0; initialBD = bd; q_ll = 0.01; }
public void setPaddock(Paddock setPaddock) { paddock = setPaddock; Pprofiles = paddock.GetComponentInChildren <PaddockProfiles>(); }
void placeFood(Paddock paddock) { paddock.addFood(10); }
private void Update() { // Check to see if the player has clicked a tile and if they have, try to find a path to that // tile. If we find a path then the character will move along it to the clicked tile. Ray screenClick = MainCamera.ScreenPointToRay(Input.mousePosition); int hits = Physics.RaycastNonAlloc(screenClick, mRaycastHits); //If the ray cast hits anything if (hits > 0) { //Grab the first ray cast hit and assign the tile to that transform tile = mRaycastHits[0].transform.GetComponent <EnvironmentTile>(); //Only update when asked to (bool) if (placingPaddock) { paddockStandIn.SetActive(true); placePaddockUpdate(tile, getPaddockSize()); } else if (placingDog) { placeDog(tile); } else if (removingDebris) { actionSprite.SetActive(true); actionSprite.GetComponent <Image>().sprite = remove; actionSprite.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 20, Input.mousePosition.z); clearDebris(tile); } else if (placingPaths) { actionSprite.SetActive(true); actionSprite.GetComponent <Image>().sprite = hammer; actionSprite.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 20, Input.mousePosition.z); placePathways(tile); } else if (placingShops) { burgerShop.SetActive(true); placeShopUpdate(tile); } else if (placingFood) { actionSprite.SetActive(true); actionSprite.GetComponent <Image>().sprite = foodSprite; actionSprite.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y + 20, Input.mousePosition.z); } else if (placingDeco) { if (tile == null) { tile = mRaycastHits[1].transform.GetComponent <EnvironmentTile>(); } placeDecoUpdate(tile); } //Unselect all buttons //Right mouse click //For stopping current action if (Input.GetMouseButtonDown(1)) { //Clear up any objects and variables within the scene placingDog = false; placingPaths = false; removingDebris = false; placingShops = false; placingFood = false; placingDeco = false; //Stand in profile.transform.localPosition = new Vector3(0, 300, 0); paddockProfile.transform.localPosition = new Vector3(0, 300, 0); //Sprite actionSprite.SetActive(false); if (spawnedDog != null) { Destroy(spawnedDog); } if (spawnedDeco != null) { Destroy(spawnedDeco); } if (placingPaddock) { Destroy(paddockStandIn); placingPaddock = false; } Destroy(burgerStandIn); } if (!inMenu && !doingAction()) { if (Physics.Raycast(screenClick, out mRaycastHits[0])) { //If the raycast is hitting a dog, and not just placing one if (mRaycastHits[0].transform.tag == "Dog" && !placingDog) { //Get the script and assign it to a gameobject profiles = mRaycastHits[0].transform.GetComponentInChildren <DogProfile>(); //Makes sure profiles has been initiated first before calling functions if (profiles != null && !inMenu) { profiles.showProfile(); showDogProfile(); } } else { //Stand in profile.transform.localPosition = new Vector3(0, 300, 0); } //If the raycast is hitting a dog, and not just placing one if (mRaycastHits[0].transform.tag == "Paddock" && !doingAction()) { if (Input.GetMouseButtonDown(0)) { if (placingFood) { if (currency.sufficientFunds(foodCost)) { interactingPaddock = mRaycastHits[0].transform.GetComponentInParent <Paddock>().getPaddock(); placeFood(interactingPaddock); actionSprite.SetActive(false); currency.takeIncome(foodCost); } } } //If on the specific part of the paddock if (!placingFood && !inMenu) { PProfiles = mRaycastHits[0].transform.GetComponentInParent <PaddockProfiles>(); PProfiles.showProfile(); showPaddockProfile(); } } else { paddockProfile.transform.localPosition = new Vector3(0, 300, 0); } if (mRaycastHits[0].transform.name == "Hooligan(Clone)" && eventActive) { if (Input.GetMouseButtonDown(0)) { events.releaseTheDogs(); eventActive = false; } } } } } }