public void Spawn(Vector3 pos) { Rect boundaries = new Rect(0, 0, 0, 0); for (int i = 0; i < setup.joints.Count; i++) { JointSetup s = setup.joints[i]; if (s == null) { continue; } OrganismJoint joint = OrganismManager.JointPool.Take(); joint.transform.SetParent(transform); s.Apply(joint); joints.Add(joint); Rect jointBounds = new Rect(s.position - Vector2.one * joint.Radius, new Vector2(joint.Radius * 2, joint.Radius * 2)); if (i == 0 || jointBounds.xMin < boundaries.xMin) { boundaries.xMin = jointBounds.xMin; } if (i == 0 || jointBounds.xMax > boundaries.xMax) { boundaries.xMax = jointBounds.xMax; } if (i == 0 || jointBounds.yMin < boundaries.yMin) { boundaries.yMin = jointBounds.yMin; boundaries.yMax = jointBounds.yMax; } } for (int i = 0; i < setup.muscles.Count; i++) { MuscleSetup s = setup.muscles[i]; if (setup.joints [s.jointA] == null || setup.joints [s.jointB] == null) { continue; } OrganismMuscle muscle = OrganismManager.MusclePool.Take(); muscle.jointA = joints[s.jointA]; muscle.jointB = joints[s.jointB]; muscle.transform.SetParent(transform); s.Apply(muscle); muscles.Add(muscle); } transform.position = pos + new Vector3(boundaries.center.x, -boundaries.yMin + 0.01f); gameObject.SetActive(true); }
public static void GetMuscleColors(OrganismMuscle muscle, SpriteRenderer activity) { activity.color = instance.GetColor(instance.activityRange, instance.maxActivity, muscle.frequency); }