public void Setup(DNA dna = null) { root = new Node(Vector3.one * 0.5f); var leftArm0 = new Node(new Vector3(0.8f, 0.2f, 0.2f)); var rightArm0 = new Node(new Vector3(0.8f, 0.2f, 0.2f)); var leftArm1 = new Node(new Vector3(0.6f, 0.15f, 0.15f)); var rightArm1 = new Node(new Vector3(0.6f, 0.15f, 0.15f)); root.Connect(leftArm0, SideType.Left); root.Connect(rightArm0, SideType.Right); leftArm0.Connect(leftArm1, SideType.Left); rightArm0.Connect(rightArm1, SideType.Right); int hcount = Mathf.FloorToInt(count * 0.5f); for (int i = 0; i < count; i++) { var position = new Vector3((i - hcount) * size, 0f, 0f) + offset; JointSampleCreature creature = CreateCreature(i.ToString(), root, position, dna); population.AddCreature(creature); } population.Setup(); }
JointSampleCreature CreateCreature(string label, Node root, Vector3 position, DNA dna = null) { var group = new GameObject("Creature"); var body = Build(group.transform, root); group.transform.position = position; JointSampleCreature creature; if (dna == null) { creature = new JointSampleCreature(body); } else { creature = new JointSampleCreature(body, dna); } var tm = Instantiate(scoreLabelPrefab).GetComponent <TextMesh>(); tm.transform.parent = creature.Body.transform; tm.transform.localPosition = Vector3.up; scoreLabels.Add(creature, tm); return(creature); }