void AcceptTraits(HeritableTraits inheritance) { growthRate = inheritance.GrowthRate; radius = inheritance.Radius; cellCycle = inheritance.CellCycle; telomere = inheritance.Telomere; }
// Divide Splits the cell into two daugter cell void Divide() { // Determin Inheritance HeritableTraits inheritance = PassTraits(); float newRadius = inheritance.Radius + 0f; Debug.Log(newRadius); // Calculate new centers float tmpTheta = Random.Range(-Mathf.PI, Mathf.PI); float tmpPhi = Random.Range(-Mathf.PI / 2f, Mathf.PI / 2f); Vector3 newPosition1 = transform.position + new Vector3(newRadius * Mathf.Sin(tmpPhi) * Mathf.Cos(tmpTheta), newRadius * Mathf.Sin(tmpPhi) * Mathf.Sin(tmpTheta), newRadius * Mathf.Cos(tmpPhi)); Vector3 newPosition2 = transform.position + new Vector3(-newRadius * Mathf.Sin(tmpPhi) * Mathf.Cos(tmpTheta), -newRadius * Mathf.Sin(tmpPhi) * Mathf.Sin(tmpTheta), -newRadius * Mathf.Cos(tmpPhi)); Debug.Log(newPosition1.ToString("F4")); Debug.Log(newPosition2.ToString("F4")); // Create Daugter 1 cellPrefab = Instantiate(cellPrefab) as GameObject; cellPrefab.transform.position = newPosition1; TumorCell daughter1 = cellPrefab.GetComponent <TumorCell>(); daughter1.AcceptTraits(inheritance); // Create Daugter 2 cellPrefab = Instantiate(cellPrefab) as GameObject; cellPrefab.transform.position = newPosition2; TumorCell daughter2 = cellPrefab.GetComponent <TumorCell>(); daughter2.AcceptTraits(inheritance); // Destroy parent Destroy(gameObject); }
private HeritableTraits PassTraits() { int newTelomere = telomere - (int)Mathf.Round(Random.Range(0f, 2f)); int newCellCycle = 1; float newRadius = Mathf.Pow(2, -1f / 3f) * radius; // Calculate new radius to conserve volume HeritableTraits inheritance = new HeritableTraits(growthRate, newRadius, newCellCycle, newTelomere); return(inheritance); }