public static void CreateChild(GameObject mama, GameObject papa) { Debug.Log("NEW CHILD"); Creature newBorn; GameObject newBornGameObject; if (mama.GetComponent <HerbivoreBrain>() != null) { newBorn = new HerbivoreBrain(); newBornGameObject = HerbivorePrefab; } else { newBorn = new CarnivoreBrain(); newBornGameObject = CarnivorePrefab; } // Sex int rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().mSex = rand == 1 ? Creature.Sex.FEMALE : Creature.Sex.MALE; // Body type rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().mBody.mBodyType = rand == 1 ? mama.GetComponent <Creature>().mBody.mBodyType : papa.GetComponent <Creature>().mBody.mBodyType; // Head - Active rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().mHead.mActive = rand == 1 ? mama.GetComponent <Creature>().mHead.mActive : papa.GetComponent <Creature>().mHead.mActive; // Head - Passive rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().mHead.mPassive = rand == 1 ? mama.GetComponent <Creature>().mHead.mPassive : papa.GetComponent <Creature>().mHead.mPassive; // Front limb - active rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().FrontLimb.mActive = rand == 1 ? mama.GetComponent <Creature>().FrontLimb.mActive : papa.GetComponent <Creature>().FrontLimb.mActive; // Front limb - passive rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().FrontLimb.mPassive = rand == 1 ? mama.GetComponent <Creature>().FrontLimb.mPassive : papa.GetComponent <Creature>().FrontLimb.mPassive; // Back limb - active rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().BackLimb.mActive = rand == 1 ? mama.GetComponent <Creature>().BackLimb.mActive : papa.GetComponent <Creature>().BackLimb.mActive; // Back limb - passive rand = Random.Range(1, 2); newBornGameObject.GetComponent <Creature>().BackLimb.mPassive = rand == 1 ? mama.GetComponent <Creature>().BackLimb.mPassive : papa.GetComponent <Creature>().BackLimb.mPassive; Instantiate(newBornGameObject, mama.transform.position, Quaternion.identity); }
public static void CreateChildPlayer(GameObject mama, GameObject papa) { Creature newBorn; GameObject newBornGameObject; GameObject oldMe; if (mama.GetComponent <CreatureBehaviorScript>().creature.mCreatureType == Creature.CreatureType.HERBIVORE) { newBorn = new HerbivoreBrain(); oldMe = HerbivorePrefab; oldMe.GetComponent <Creature>().mCreatureType = Creature.CreatureType.HERBIVORE; } else { newBorn = new CarnivoreBrain(); oldMe = CarnivorePrefab; oldMe.GetComponent <Creature>().mCreatureType = Creature.CreatureType.HERBIVORE; } Vector3 pos = new Vector3(mama.transform.position.x, mama.transform.position.y, mama.transform.position.z + 2); GameObject oldMeJdid = Instantiate(oldMe, pos, Quaternion.identity); oldMeJdid.GetComponent <Creature>().mSex = mama.GetComponent <CreatureBehaviorScript>().creature.mSex; oldMeJdid.GetComponent <Creature>().mBody = mama.GetComponent <CreatureBehaviorScript>().creature.mBody; oldMeJdid.GetComponent <Creature>().FrontLimb = mama.GetComponent <CreatureBehaviorScript>().creature.FrontLimb; oldMeJdid.GetComponent <Creature>().BackLimb = mama.GetComponent <CreatureBehaviorScript>().creature.BackLimb; oldMeJdid.GetComponent <Creature>().mHead = mama.GetComponent <CreatureBehaviorScript>().creature.mHead; // Sex int rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.mSex = rand == 1 ? Creature.Sex.FEMALE : Creature.Sex.MALE; // Body type rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.mBody.mBodyType = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.mBody.mBodyType : papa.GetComponent <Creature>().mBody.mBodyType; // Head - Active rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.mHead.mActive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.mHead.mActive : papa.GetComponent <Creature>().mHead.mActive; // Head - Passive rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.mHead.mPassive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.mHead.mPassive : papa.GetComponent <Creature>().mHead.mPassive; // Front limb - active rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.FrontLimb.mActive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.FrontLimb.mActive : papa.GetComponent <Creature>().FrontLimb.mActive; // Front limb - passive rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.FrontLimb.mPassive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.FrontLimb.mPassive : papa.GetComponent <Creature>().FrontLimb.mPassive; // Back limb - active rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.BackLimb.mActive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.BackLimb.mActive : papa.GetComponent <Creature>().BackLimb.mActive; // Back limb - passive rand = Random.Range(1, 3); Debug.Log("Random = " + rand); mama.GetComponent <CreatureBehaviorScript>().creature.BackLimb.mPassive = rand == 1 ? mama.GetComponent <CreatureBehaviorScript>().creature.BackLimb.mPassive : papa.GetComponent <Creature>().BackLimb.mPassive; }