Inheritance: MonoBehaviour
コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: Mushroom.cs プロジェクト: VyturysJok/Intelektika
        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];
        }
コード例 #3
0
        public ActionResult Update(Habitat habitat)
        {
            repo.UpdateHabitat(habitat);
            return(RedirectToAction("Detail"));

            return(View());
        }
コード例 #4
0
    public void EnableInterior()
    {
        Habitat temp = GameObject.FindObjectOfType <Habitat> ();

        temp.interior.interiorMain.SetActive(true);
        temp.exterior.exteriorMain.SetActive(false);
    }
コード例 #5
0
    public void DisableGlowMap()
    {
        Habitat temp = GameObject.FindObjectOfType <Habitat> ();

        temp.interior.glowNote.SetActive(false);
//		temp.interior.glowNote.GetComponentInChildren<AnimateAlpha> ().StartAnimating();
    }
コード例 #6
0
 void Awake()
 {
     gameStateMachine = GetComponent <GameStateMachine>();
     selectedHabitat  = new Habitat();
     selectedHabitats = new List <Habitat>();
     curPhase         = Phase.start;
 }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: HabitatsController.cs プロジェクト: nordenm/mvc-zoo
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
        public void MoveBird(Bird bird, Habitat newHabitat)
        {
            Habitat currentHabitat = bird.CurrentHabitat;

            currentHabitat.RemoveInhabitant(bird);
            newHabitat.InsertInhabitant(bird);
            bird.CurrentHabitat = newHabitat;
        }
コード例 #12
0
        public void InsertHabitat(Habitat habitat)
        {
            if (habitat == null)
            {
                throw new ArgumentNullException(nameof(habitat));
            }

            _habitatRepository.Insert(habitat);
        }
コード例 #13
0
        public void DeleteHabitat(Habitat habitat)
        {
            if (habitat == null)
            {
                throw new ArgumentNullException(nameof(habitat));
            }

            _habitatRepository.Delete(habitat);
        }
コード例 #14
0
        public async Task <IActionResult> CriarHabitat([FromBody] HabitatDto habitatDto)
        {
            Habitat habitat = new Habitat(habitatDto.Nome);

            _dataContext.Add(habitat);
            await _dataContext.SaveChangesAsync();

            return(Ok(habitat));
        }
コード例 #15
0
        public ActionResult Create(Habitat habitat)
        {
            if (ModelState.IsValid)
            {
                repo.AddHabitat(habitat);
                return(RedirectToAction("Index"));
            }

            return(View(habitat));
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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));
        }
コード例 #18
0
 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);
 }
コード例 #19
0
        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());
        }
コード例 #20
0
        internal void Add(Habitat h)
        {
            if (!h.HasPowerGrid())
            {
                PowerGrid newPG = new PowerGrid();
                grids.Add(newPG.PowerGridInstanceID, newPG);
                newPG.Add(h);
            }

            h.OnPowerChanged();
        }
コード例 #21
0
ファイル: HabitatsController.cs プロジェクト: nordenm/mvc-zoo
        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));
        }
コード例 #22
0
        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));
        }
コード例 #23
0
 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();
         }
     }
 }
コード例 #24
0
        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);
        }
コード例 #25
0
ファイル: HabitatsController.cs プロジェクト: florin141/Zoo
        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"));
        }
コード例 #26
0
ファイル: Planner.cs プロジェクト: tinygrox/Kerbalism
        ///<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"
        }
コード例 #27
0
        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);
        }
コード例 #28
0
    // 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();
    }
コード例 #29
0
        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);
        }
コード例 #30
0
        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);
        }
コード例 #31
0
 void Start()
 {
     habitat = Habitat.CreateHabitat(habName,5,7);
 }