public async Task <IActionResult> Edit(int id, [Bind("HabitatId,CodigoHabitat,NombreHabitat")] Habitat habitat) { if (id != habitat.HabitatId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(habitat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HabitatExists(habitat.HabitatId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(habitat)); }
public void ParseStringToVariables(string values) { var parsedValues = values.Replace(",", string.Empty); IsEdible = parsedValues[0] == 'e'; CapShapeValue = (CapShape)parsedValues[1]; CapSurfaceValue = (CapSurface)parsedValues[2]; CapColorValue = (CapColor)parsedValues[3]; BruisesValue = (Bruises)parsedValues[4]; OdorValue = (Odor)parsedValues[5]; GillAttachmentValue = (GillAttachment)parsedValues[6]; GillSpacingValue = (GillSpacing)parsedValues[7]; GillSizeValue = (GillSize)parsedValues[8]; GillColorValue = (GillColor)parsedValues[9]; StalkShapeValue = (StalkShape)parsedValues[10]; StalkRootValue = (StalkRoot)parsedValues[11]; StalkSurfaceAboveRingValue = (StalkSurfaceAboveRing)parsedValues[12]; StalkSurfaceBelowRingValue = (StalkSurfaceBelowRing)parsedValues[13]; StalkColorAboveRingValue = (StalkColorAboveRing)parsedValues[14]; StalkColorBelowRingValue = (StalkColorBelowRing)parsedValues[15]; VeilTypeValue = (VeilType)parsedValues[16]; VeilColorValue = (VeilColor)parsedValues[17]; RingNumberValue = (RingNumber)parsedValues[18]; RingTypeValue = (RingType)parsedValues[19]; SporePrintColorValue = (SporePrintColor)parsedValues[20]; PopulationValue = (Population)parsedValues[21]; HabitatValue = (Habitat)parsedValues[22]; }
public ActionResult Update(Habitat habitat) { repo.UpdateHabitat(habitat); return(RedirectToAction("Detail")); return(View()); }
public void EnableInterior() { Habitat temp = GameObject.FindObjectOfType <Habitat> (); temp.interior.interiorMain.SetActive(true); temp.exterior.exteriorMain.SetActive(false); }
public void DisableGlowMap() { Habitat temp = GameObject.FindObjectOfType <Habitat> (); temp.interior.glowNote.SetActive(false); // temp.interior.glowNote.GetComponentInChildren<AnimateAlpha> ().StartAnimating(); }
void Awake() { gameStateMachine = GetComponent <GameStateMachine>(); selectedHabitat = new Habitat(); selectedHabitats = new List <Habitat>(); curPhase = Phase.start; }
private void AnswerToActionListener(ActionResponseEvent actionResponseEvent) { if (!actionResponseEvent.ActionEvent.Action.Definition.Name.Equals("RecruitmentAction")) { return; } if (actionResponseEvent.SelectedAnswer.Name.Equals("Cancel")) { return; } Habitat habitat = actionResponseEvent.ActionEvent.Action.Params["habitat"] as Habitat; Entity owner = actionResponseEvent.ActionEvent.Target; Army army = owner.GetComponent <Army>(); Fraction fraction = army.Fraction; int maxHire = (int)actionResponseEvent.ActionEvent.Action.Params["population"]; int amount = maxHire * 17; Resource resource = new Resource(new ResourceDefinition("Gold"), amount); RemoveResourceFromFractionEvent removeResource = new RemoveResourceFromFractionEvent(resource, fraction); _eventBus.Post(removeResource); if (!removeResource.Success && removeResource.CountOfDividend == 0) { return; } int hireAmount = removeResource.Success ? maxHire : removeResource.CountOfDividend; army.Creatures[0].Count += hireAmount; habitat.Current -= hireAmount; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Weather,Vegetation,ItineraryId")] Habitat habitat) { if (id != habitat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(habitat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HabitatExists(habitat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ItineraryId"] = new SelectList(_context.Itinerary, "Id", "Code", habitat.ItineraryId); return(View(habitat)); }
public void Migrate() { List <Habitat> neighbors = CurrentHabitat.GetNeighbors().Where(h => h.IsEmpty).ToList(); int idx = Rng.Next(neighbors.Count); Habitat nextHabitat = neighbors[idx]; Population.MoveBird(this, nextHabitat); }
private void PopulatePopulation(int numBirds) { for (int i = 0; i < numBirds; i++) { Habitat habitat = this.Territory.GetHabitat(i, i); AddBird(habitat, Sex.Male, Age.Adult); } }
public void MoveBird(Bird bird, Habitat newHabitat) { Habitat currentHabitat = bird.CurrentHabitat; currentHabitat.RemoveInhabitant(bird); newHabitat.InsertInhabitant(bird); bird.CurrentHabitat = newHabitat; }
public void InsertHabitat(Habitat habitat) { if (habitat == null) { throw new ArgumentNullException(nameof(habitat)); } _habitatRepository.Insert(habitat); }
public void DeleteHabitat(Habitat habitat) { if (habitat == null) { throw new ArgumentNullException(nameof(habitat)); } _habitatRepository.Delete(habitat); }
public async Task <IActionResult> CriarHabitat([FromBody] HabitatDto habitatDto) { Habitat habitat = new Habitat(habitatDto.Nome); _dataContext.Add(habitat); await _dataContext.SaveChangesAsync(); return(Ok(habitat)); }
public ActionResult Create(Habitat habitat) { if (ModelState.IsValid) { repo.AddHabitat(habitat); return(RedirectToAction("Index")); } return(View(habitat)); }
public async Task <IActionResult> Create([Bind("HabitatId,CodigoHabitat,NombreHabitat")] Habitat habitat) { if (ModelState.IsValid) { _context.Add(habitat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(habitat)); }
public async Task <IActionResult> Create([Bind("Id,nombre,clima,vegetacion")] Habitat habitat) { if (ModelState.IsValid) { _context.Add(habitat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(habitat)); }
public bool isOptimal(Habitat cH) { for (int i = 0; i < gameStateMachine.playerManager.currentPlayer.habitat.Length; i++) { if (cH.habitat == gameStateMachine.playerManager.currentPlayer.habitat[i]) { return(true); } } return(false); }
public void Can_serialize_dependent_type_properties() { var jungle = new Habitat <Animal> { Continent = "South America", Species = new CatAnimal { Name = "Tiger", Color = "Orange" } }; Console.WriteLine(jungle.ToJson()); }
internal void Add(Habitat h) { if (!h.HasPowerGrid()) { PowerGrid newPG = new PowerGrid(); grids.Add(newPG.PowerGridInstanceID, newPG); newPG.Add(h); } h.OnPowerChanged(); }
public async Task <IActionResult> Create([Bind("Id,Name,Weather,Vegetation,ItineraryId")] Habitat habitat) { if (ModelState.IsValid) { _context.Add(habitat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ItineraryId"] = new SelectList(_context.Itinerary, "Id", "Code", habitat.ItineraryId); return(View(habitat)); }
public async Task <IActionResult> Create([Bind("HabitatId,Name,UserId")] Habitat habitat) { if (ModelState.IsValid) { _context.Add(habitat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", habitat.UserId); return(View(habitat)); }
public void FadeOutInvalidHabitats(List <GameObject> validHabitats) { for (int i = 0; i < 84; i++) { GameObject currentGameObject = darwinia[i]; Habitat currentHabitat = currentGameObject.GetComponent <Habitat>(); if (!validHabitats.Contains(currentGameObject)) { currentGameObject.GetComponent <Habitat>().FadeOut(); } } }
private Bird AddBird(Habitat habitat, Sex sex, Age age) { // Bird bird = new Bird(this, habitat, sex, age, birdIDCounter); Bird bird = new Bird(this, sex, age, birdIDCounter); birdIDCounter++; habitat.InsertInhabitant(bird); bird.CurrentHabitat = habitat; Inhabitants.Add(bird); return(bird); }
public IActionResult Create(HabitatDto model) { var habitat = new Habitat { Name = model.Name, Description = model.Description, Picture = model.Picture.ToBase64String(), }; _habitatService.InsertHabitat(habitat); return(RedirectToAction("Index")); }
///<summary> Add stress sub-panel, including tooltips </summary> private static void AddSubPanelStress(Panel p) { // get first living space rule // - guaranteed to exist, as this panel is not rendered if it doesn't // - even without crew, it is safe to evaluate the modifiers that use it Rule rule = Profile.rules.Find(k => k.modifiers.Contains("living_space")); // render title p.AddSection(Local.Planner_STRESS, string.Empty, //"STRESS" () => { p.Prev(ref special_index, panel_special.Count); enforceUpdate = true; }, () => { p.Next(ref special_index, panel_special.Count); enforceUpdate = true; }); // render living space data // generate details tooltips string living_space_tooltip = Lib.BuildString ( Local.Planner_volumepercapita, "<b>\t", Lib.HumanReadableVolume(vessel_analyzer.volume / Math.Max(vessel_analyzer.crew_count, 1)), "</b>\n", //"volume per-capita: Local.Planner_ideallivingspace, "<b>\t", Lib.HumanReadableVolume(PreferencesComfort.Instance.livingSpace), "</b>" //"ideal living space: ); p.AddContent(Local.Planner_livingspace, Habitat.Living_space_to_string(vessel_analyzer.living_space), living_space_tooltip); //"living space" // render comfort data if (rule.modifiers.Contains("comfort")) { p.AddContent(Local.Planner_comfort, vessel_analyzer.comforts.Summary(), vessel_analyzer.comforts.Tooltip()); //"comfort" } else { p.AddContent(Local.Planner_comfort, "n/a"); //"comfort" } // render pressure data if (rule.modifiers.Contains("pressure")) { string pressure_tooltip = vessel_analyzer.pressurized ? Local.Planner_analyzerpressurized1 //"Free roaming in a pressurized environment is\nvastly superior to living in a suit." : Local.Planner_analyzerpressurized2; //"Being forced inside a suit all the time greatly\nreduces the crews quality of life.\nThe worst part is the diaper." p.AddContent(Local.Planner_pressurized, vessel_analyzer.pressurized ? Local.Planner_pressurized_yes : Local.Planner_pressurized_no, pressure_tooltip); //"pressurized""yes""no" } else { p.AddContent(Local.Planner_pressurized, "n/a"); //"pressurized" } // render life estimate double mod = Modifiers.Evaluate(env_analyzer, vessel_analyzer, resource_sim, rule.modifiers); p.AddContent(Local.Planner_lifeestimate, Lib.HumanReadableDuration(rule.fatal_threshold / (rule.degeneration * mod))); //"duration" }
public void RepoCanAddHabitatToDatabase() { ConnectMocksToDatastore(); Habitat newHabitat = new Habitat { HabitatId = 1, Name = "x", HabitatTypeId = 3 }; repo.AddHabitat(newHabitat); int actual_habitat_count = repo.GetHabitats().Count; int expected_habitat_count = 1; Assert.AreEqual(expected_habitat_count, actual_habitat_count); }
// Use this for initialization void Start() { if (LinkedHab == null) { LinkedHab = transform.root.GetComponent <Habitat>(); } if (LinkedHab == null) { UnityEngine.Debug.LogWarning("Hab resource interface not linked!"); this.enabled = false; } OnStart(); }
public void CountAnimalsTest() { // expected Mock.SetupStatic(typeof(Case)); int expected = 10; Mock.Arrange(() => Case.room.CountAnimals()).Returns(5); Mock.Arrange(() => Case.pasture.CountAnimals()).Returns(5); //actual Habitat habitat = new Habitat(); int actualAnimals = habitat.CountAnimals(); Assert.AreEqual(expected, actualAnimals); }
public void GetFoodTest() { // expected Mock.SetupStatic(typeof(Case)); double expected = 10.0; Mock.Arrange(() => Case.room.GetFood()).Returns(5.0); Mock.Arrange(() => Case.pasture.GetFood()).Returns(5.0); //actual Habitat habitat = new Habitat(); double actualFood = habitat.GetFood(); Assert.AreEqual(expected, actualFood); }
void Start() { habitat = Habitat.CreateHabitat(habName,5,7); }