public async Task <ActionResult <Phylum> > PostPhylum(Phylum phylum) { _context.Phylumes.Add(phylum); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPhylum", new { id = phylum.Id }, phylum)); }
public async Task <DataResult <PhylumModel> > GetPhylumById(int id) { try { Phylum entity = await _phylumRepository.GetById(id); if (entity == null) { return(new DataResult <PhylumModel> { Success = false, ErrorCode = ErrorCode.NotFound, }); } PhylumModel model = _mapper.Map(entity); return(new DataResult <PhylumModel> { Success = true, Data = model, }); } catch (Exception ex) { _logger.LogError(ex, $"Problems with getting Phylum by id : {id}"); return(new DataResult <PhylumModel> { Success = false, ErrorCode = ErrorCode.InternalError, }); } }
public async Task <IActionResult> PutPhylum(int id, Phylum phylum) { if (id != phylum.Id) { return(BadRequest()); } _context.Entry(phylum).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhylumExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Result> UpdatePhylum(int id, PhylumModel model) { try { Phylum entity = await _phylumRepository.GetById(id); if (entity == null) { return(new Result { Success = false, ErrorCode = ErrorCode.NotFound, }); } return(await _phylumRepository.Update(_mapper.MapUpdate(entity, model))); } catch (Exception ex) { _logger.LogError(ex, $"Problems with updating Phylum by id : {id}"); return(new DataResult <PhylumModel> { Success = false, ErrorCode = ErrorCode.InternalError, }); } }
public async Task <DataResult <PhylumModel> > CreatePhylum(PhylumModel model) { try { Phylum entity = _mapper.MapBack(model); DataResult <Phylum> result = await _phylumRepository.Add(entity); return(new DataResult <PhylumModel> { Success = result.Success, ErrorCode = result.ErrorCode, Data = _mapper.Map(result.Data), }); } catch (Exception ex) { _logger.LogError(ex, $"Problems with creating Phylum"); return(new DataResult <PhylumModel> { Success = false, ErrorCode = ErrorCode.InternalError, }); } }
// Initiate spawning and showing of intro private IEnumerator Start() { Phylum phylum = SpawnManager.Instance.phyla[0]; // Get the phylum AnimalInfo.LoadAnimalInfo(phylum, isStaticAnimals); // Loads animal info for phylum yield return(ShowIntro()); // Wait for intro to show and hide SpawnManager.Instance.SpawnInfoAnimals(); // Spawn animals for info }
private IEnumerator ShowIntro() { // Wait for the intro UI to fade in. yield return(StartCoroutine(UIController.Instance.ShowIntroUI())); // Show the reticle (since there is now a selection slider) and hide the radial. Phylum phylum = SpawnManager.Instance.phyla[0]; // Get the phylum AnimalInfo.LoadAnimalInfo(phylum, isStaticAnimals); // Loads animal info for phylum m_Reticle.Show(); m_SelectionRadial.Hide(); // Wait for the selection slider to finish filling. yield return(StartCoroutine(m_SelectionSlider.WaitForBarToFill())); // Wait for the intro UI to fade out. yield return(StartCoroutine(UIController.Instance.HideIntroUI())); }
public static void LoadAnimalInfo(Phylum phylum, bool isStatic) { // TODO: Handle JToken returned as JObject, data file might be corrupted // Load the data file using JSONParser JArray jArray = (JSONParser.ReadJson("data")).ToObject <JArray>(); // TODO: Better parsing algo // Get the animal info belonging the phylum var animals = from p in jArray where p["name"].ToString() == phylum.name select(JArray) p["animals"]; // For each result in the returned JArray of animal set foreach (var result in animals) { // For each animal in the returned result foreach (var animal in result) { // Check where to assign the info, loop thru all animals in phylum foreach (var pAnimal in phylum.animals) { // Check the name of the animal for match if (pAnimal.GetComponent <Animal>().Name == animal["Scientific Name"].ToString() || pAnimal.GetComponent <Animal>().Name == animal["Common Name"].ToString()) { JObject o = JObject.Parse(animal.ToString()); // Convert the given animal to a JObject string info = ""; // For each info about the returned animal, build string info foreach (var item in o) { info += item.Key + ": " + item.Value.ToString() + "\n"; } if (!isStatic) { pAnimal.GetComponent <Animal>().info = info; // Assign final info string to pAnimal } } } } } }
public async Task <int?> AddPhylum(string phylumText, int?kingdomId) { if (!String.IsNullOrEmpty(phylumText)) { var phylumId = await _artifactRepository.PhylumExists(phylumText); if (phylumId != null) { return(phylumId); } else { Phylum newPhylum = new Phylum() { Name = phylumText, KingdomId = kingdomId }; _context.Add(newPhylum); await _context.SaveChangesAsync(); return(newPhylum.Id); } } return(null); }
// ---------------------------------------------------- // Functions used for spawning animals in Minigame mode // ---------------------------------------------------- public GameObject SpawnGameAnimals() { // If the game is SEE, there must be more than 1 phlyum // The game consist of 1 phylum and 1 extra phlyum // You need to spawn n number of animals from original // phylum and add 1 animal from extra phlyum if (gameType == ScoreManager.MinigameType.SEE && phyla.Length > 1) { int phylumNum = Random.Range(0, phyla.Length); // Choose a random phylum to instantiate animals from Phylum phylum = phyla[phylumNum]; // Assign random to var phylum // Get random phylum to instantiate extra animal int extraPhylumNum; // Get an random int to assign extra phylum from do { extraPhylumNum = Random.Range(0, phyla.Length); // Must not be equal to original phylum } while (extraPhylumNum == phylumNum); Phylum extraPhylum = phyla[extraPhylumNum]; // Using random int assign the extra phlyum // Get random animal from the extra phylum int extraAnimalNum = Random.Range(0, extraPhylum.animals.Length); GameObject extraAnimal = extraPhylum.animals[extraAnimalNum]; // Create a list of animals to hold animals from original phylum GameObject[] tmp = phylum.GetRandomUniqueAnimalList(spawnNum - 1); List <GameObject> animalsList = new List <GameObject>(); // Add all animals in tmp for (int i = 0; i < tmp.Length; i++) { animalsList.Add(tmp[i]); } // Add the extra animal animalsList.Add(extraAnimal); // Convert list back to array GameObject[] animals = animalsList.ToArray(); // Shuffle the animals Shuffler.Shuffle(animals); return(SpawnGameObjectList(animals, extraAnimal)); } // If the game is HEAR, there is only 1 "phylum" required // here the phylum is just a temporary storage for ALL animals // that produces sound. You simply need to get random animals // and a random int to have as the answer (animals[i]) else { // TODO: Handle when the spawnNum is // greater than the number of animals w/ // sound to avoid duplicate animals Phylum wSound = phyla[0]; // Get animals with sound GameObject[] animals = wSound.GetRandomUniqueAnimalList(spawnNum); // List of animals to be spawned GameObject corrAnimal = animals[Random.Range(0, animals.Length)]; // Use this animal to play sound // Shuffle the animals Shuffler.Shuffle(animals); return(SpawnGameObjectList(animals, corrAnimal)); } }