private void Sent(int i) { ETypeAnimal animal = GetByIndex(i); Debug.Log(animal + " + "); --_inventory.InventoryInPegi[animal]; ++_inventory.InventorySent[animal]; _downBar[i].fillAmount = 0; }
IEnumerator CreateNewAnimalDelayed(ETypeAnimal animal) { float timer = UnityEngine.Random.Range(GetPoblationInfo(animal).ReproductionMaxTime, GetPoblationInfo(animal).ReproductionMinTime); //Debug.Log(animal + ": " + timer); yield return(new WaitForSeconds(timer)); ReproduceOneAnimal(animal); StartCoroutine(CreateNewAnimalDelayed(animal)); }
AnimalPoblationInfo GetPoblationInfo(ETypeAnimal animalType) { for (int i = 0; i < _animalPoblation.Count; ++i) { if (_animalPoblation[i].AnimalType == animalType) { return(_animalPoblation[i]); } } return(null); }
AnimalController GetPrefab(ETypeAnimal animalType) { for (int i = 0; i < _animalPrefabs.Count; ++i) { if (_animalPrefabs[i].GetAnimalType() == animalType) { return(_animalPrefabs[i]); } } return(null); }
public void Init(ETypeAnimal typeAnimal) { _orbitMovement.Speed = UnityEngine.Random.Range(_minSpeed, _maxSpeed); _typeAnimal = typeAnimal; _input.MinTimeMovement = _minTimeChangeDirection; _input.MaxTimeMovement = _maxTimeChangeDirection; if (IsReproducing) { // DoJumpReproduction(false); } }
private void ReproduceOneAnimal(ETypeAnimal animal) { List <AnimalController> animals = new List <AnimalController>(); for (int i = _allAnimals.Count - 1; i >= 0; i--) { if (_allAnimals[i].GetAnimalType() == animal) { animals.Add(_allAnimals[i]); } } int randomAnimal = UnityEngine.Random.Range(0, animals.Count); AnimalController animalMother = animals[randomAnimal]; StartCoroutine(ReproduceOneAnimalCo(animalMother)); }
private void SetImageInLine(RectTransform minLimit, RectTransform maxLimit, int minAmount, int maxAmount, int currentAmont, ETypeAnimal animal, bool doAnim = true, bool scaleFactor = false, bool reverseScaleFactor = false) { float factor = (float)(currentAmont - minAmount) / (float)(maxAmount - minAmount); float distance = maxLimit.anchoredPosition.x - minLimit.anchoredPosition.x; float distanceFromOrigin = distance * factor; float newPosition = minLimit.anchoredPosition.x + distanceFromOrigin; if (_lastValue[animal] != currentAmont) { Vector2 finalPos = new Vector2(minLimit.anchoredPosition.x + distanceFromOrigin, _animalImages[animal].anchoredPosition.y); Vector3 finalScale = Vector3.one; if (scaleFactor) { finalScale = Vector3.Lerp(Vector3.one, Vector3.one * _scaleFactor, factor); } if (reverseScaleFactor) { finalScale = Vector3.Lerp(Vector3.one * _scaleFactor, Vector3.one, factor); } if (doAnim) { LeanTween.move(_animalImages[animal], finalPos, _animTime); LeanTween.scale(_animalImages[animal], finalScale, _animTime); } else { _animalImages[animal].anchoredPosition = finalPos; _animalImages[animal].localScale = finalScale; } _lastValue[animal] = currentAmont; } //rectTransform.anchoredPosition = new Vector2(minLimit.anchoredPosition.x + distanceFromOrigin, rectTransform.anchoredPosition.y); }
public void AddAnimalToPegi(ETypeAnimal typeAnimal) { ++InventoryInPegi[typeAnimal]; }