コード例 #1
0
        private GameObject MakeNewDog(int min, int max)
        {
            _futureGeneration = GameManager.Instance.GenerationManager.ReturnFutureGeneration();
            if (_futureGeneration.ReturnAvailableSlot() == null)
            {
                _generationManager.GetComponent <GenerationManager>().UpdateGeneration();
                _futureGeneration = _generationManager.GetComponent <GenerationManager>().ReturnFutureGeneration();
            }

            GameObject dog    = Instantiate(_cardPrefab);
            Dog        newDog = dog.GetComponent <Dog>();

            // Make sure to balance genders
            if (_futureGeneration.GetComponent <Generation>().ReturnMales() > _futureGeneration.GetComponent <Generation>().ReturnFemales())
            {
                newDog.SetSex("Female");
            }
            else if (_futureGeneration.GetComponent <Generation>().ReturnMales() < _futureGeneration.GetComponent <Generation>().ReturnFemales())
            {
                newDog.SetSex("Male");
            }
            else
            {
                newDog.SetSex();
            }
            // Set Name & Sex
            newDog.SetName();

            // Set parents
            Dog parent0 = _cardSlots.GetComponentsInChildren <CardSlot>()[0].Item.GetComponent <Dog>();
            Dog parent1 = _cardSlots.GetComponentsInChildren <CardSlot>()[1].Item.GetComponent <Dog>();


            newDog.SetParents(parent0.gameObject, parent1.gameObject);
            // Set Size
            newDog.SetSize(Constrain((parent0.ReturnSize() + parent1.ReturnSize()) / 2 + Random.Range(_decrease, _increase)));
            // Set Bark
            newDog.SetBark(Constrain((parent0.ReturnBark() + parent1.ReturnBark()) / 2 + Random.Range(min, max)));
            // Set Endurance
            newDog.SetEndurance(Constrain((parent0.ReturnEndurance() + parent1.ReturnEndurance()) / 2 + Random.Range(min, max)));
            // Set Scent
            newDog.SetScent(Constrain((parent0.ReturnScent() + parent1.ReturnScent()) / 2 + Random.Range(min, max)));
            // Set Hearing
            newDog.SetHearing(Constrain((parent0.ReturnHearing() + parent1.ReturnHearing()) / 2 + Random.Range(min, max)));
            // Set Demeanor
            newDog.SetDemeanor(Constrain((parent0.ReturnDemeanor() + parent1.ReturnDemeanor()) / 2 + Random.Range(min, max)));
            // Set Sight
            newDog.SetSight(Constrain((parent0.ReturnSight() + parent1.ReturnSight()) / 2 + Random.Range(min, max)));
            // Set Intelligence
            newDog.SetIntelligence(Constrain((parent0.ReturnIntelligence() + parent1.ReturnIntelligence()) / 2 + Random.Range(min, max)));
            // Set Hair
            newDog.SetHairLength(Constrain((parent0.ReturnHair() + parent1.ReturnHair()) / 2 + Random.Range(_decrease, _increase)));
            // Set Strenth
            newDog.SetStrength(Constrain((parent0.ReturnStrength() + parent1.ReturnStrength()) / 2 + Random.Range(min, max)));


            return(dog);
        }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (_nextGeneration.GetComponent <Generation>().ReturnAvailableSlot() == null)
     {
         UpdateGeneration();
     }
 }