private void GenerateAnimal(AnimalController animal) { var temp = Instantiate <AnimalController>(animal, _animalParent); temp.Init(animal.GetAnimalType()); var angles = _planet.EcosystemAngles[_planet.EcosystemByAnimal[animal.GetAnimalType()]]; int value = UnityEngine.Random.Range(0, angles.Count); var area = angles[value]; int finalAngle = UnityEngine.Random.Range(area.StartAngle, area.EndAngle); float radians = Mathf.Deg2Rad * finalAngle; Vector2 finalPosition = new Vector2(Mathf.Sin(radians), Mathf.Cos(radians)); //Debug.Log(animal.GetAnimalType().ToString() + " : "+ finalAngle); //Vector2 finalPosition = Rotate(Vector2.up, finalAngle); /* * GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere); * go.name = animal.GetAnimalType().ToString(); * go.transform.position = finalPosition; */ //Vector2 point = UnityEngine.Random.insideUnitCircle; Vector2 point = finalPosition; temp.transform.position = point; _allAnimals.Add(temp); }
internal void AnimalAbducedSuccessFul(AnimalController animalBeingAbduced) { _inventory.AddAnimalToPegi(animalBeingAbduced.GetAnimalType()); SetAbductionMode(false); _allAnimals.Remove(animalBeingAbduced); --AnimalAmount[animalBeingAbduced.GetAnimalType()]; Destroy(animalBeingAbduced.gameObject); }
public void IsInArea(AnimalController animal) { EEcosystem ecosystem = EcosystemByAnimal[animal.GetAnimalType()]; if (!IsAngleOfEcosystem(animal.transform.position, ecosystem)) { animal.ChangeDirection(); } }
private IEnumerator ReproduceOneAnimalCo(AnimalController animalMother) { animalMother.IsReproducing = true; yield return(new WaitForSeconds(animalMother.ReproductionTime)); var newAnimal = Instantiate <AnimalController>(animalMother, _animalParent); newAnimal.IsReproducing = true; newAnimal.Init(animalMother.GetAnimalType()); newAnimal.transform.position = animalMother.transform.position; newAnimal.DoJumpReproduction(false); animalMother.DoJumpReproduction(true); _allAnimals.Add(newAnimal); ++AnimalAmount[animalMother.GetAnimalType()]; yield return(new WaitForSeconds(animalMother.ReproductionJumpTime)); animalMother.IsReproducing = false; newAnimal.IsReproducing = false; }