void OnTriggerEnter2D(Collider2D other) { //Invoke ("FightEnable", 0.1f); CellScript otherCell = other.gameObject.GetComponent <CellScript> (); // if ((Gender == 0 && Gender != otherCell.Gender) && (Random.value > 0.1f)) { if (Sexuality > Rage) { //Fighting = false; Collider2D MotherColl = GetComponent <Collider2D>(); MotherColl.enabled = false; GameObject man = GameObject.Find("Manager"); ManagerScript manScript = man.GetComponent <ManagerScript> (); //spawn a baby with values inherited in a random range between the values of mother and father manScript.BirthPosition = transform.position + new Vector3(-RandomX * 2, -RandomY * 2, 0.0f); manScript.ChildHealth = Random.Range(otherCell.Health, Health); manScript.ChildRage = Random.Range(otherCell.Health, Health); manScript.ChildStrength = Random.Range(otherCell.Strength, Strength); manScript.ChildSexuality = Random.Range(otherCell.Sexuality, Sexuality); manScript.ChildSpeed = Random.Range(otherCell.moveSpeed, moveSpeed); manScript.ChildPerception = Random.Range(otherCell.Perception, Perception); manScript.ChildID = ID + otherCell.ID; manScript.ChildGenID = GenerationID += 1; manScript.SpawnChild(); Debug.Log(ID + " gave birth to " + otherCell.ID + "'s baby: " + manScript.ChildID + " generation " + manScript.ChildGenID); // transform the mother so it won't get eaten by the kid or the other way around Vector3 afterbirthPos = transform.position + new Vector3(RandomX * 2, RandomY * 2, 0.0f); transform.position = afterbirthPos; Sexuality -= 1; Rage += 1; Invoke("NoImmunity", 0.5f); } else { if (Strength > otherCell.Strength) { Health += otherCell.Health / 2; //Strength += 1; Debug.Log(ID + " killed " + otherCell.ID); if (Health < 100) { transform.localScale = new Vector3(Health, Health, 0); } else { Health = 100; transform.localScale = new Vector3(Health, Health, 0); } Destroy(other.gameObject); Rage -= 1; Sexuality += 1; } } }