public void FindMate() { Creature[] possibleMates = Sight.SameCreature; lastReproductionTry = Time.time; if (possibleMates.Length > 0) { foreach (Creature possibleMate in possibleMates) { if (PreviousMates.ContainsKey(possibleMate)) { continue; } if (gender == possibleMate.gender) { continue; } if (gender == GenderType.Female && gestation.pregnant) { continue; } if (activity == CreatureActivity.Mating) { continue; } if (possibleMate.gender == GenderType.Female && possibleMate.gestation.pregnant) { continue; } if (possibleMate.activity == CreatureActivity.Mating) { continue; } if (GeneUtility.Relatives(this, possibleMate)) { continue; } if (CalculateMateCompatibility(this, possibleMate) || CalculateMateCompatibility(possibleMate, this)) { if (possibleMate.Nutrition > possibleMate.maxNutrition * 0.25f && possibleMate.Hydration > possibleMate.maxHydration * 0.25f) { if (gender == GenderType.Male) { StartMate(possibleMate); } else { possibleMate.StartMate(this); } } } else { possibleMate.PreviousMates.Add(this, Time.time); PreviousMates.Add(possibleMate, Time.time); } } } }
public void GetRelativeLink() { Creature link = GeneUtility.GetLink(creatureA, creatureB); if (link == null) { Debug.Log("[Utilities] No link found."); } else { Debug.Log("[Utilities] " + creatureA.ID + " and " + creatureB.ID + " have " + link.ID + " in common."); } }
public void GetCompatibility() { if (creatureA.PreviousMates.ContainsKey(creatureB)) { Debug.Log("[Utilities] " + creatureB.ID + " remembers " + creatureA.ID + " from a past meeting."); return; } if (creatureA.gender == creatureB.gender) { Debug.Log("[Utilities] " + creatureA.ID + " are both " + creatureA.gender.ToString().ToLower() + "."); return; } if (creatureA.gender == GenderType.Female && creatureA.Pregnant) { Debug.Log("[Utilities] " + creatureA.ID + " is pregnant."); return; } if (creatureA.activity == CreatureActivity.Mating) { Debug.Log("[Utilities] " + creatureA.ID + " is currently mating."); return; } if (creatureB.gender == GenderType.Female && creatureB.Pregnant) { Debug.Log("[Utilities] " + creatureB.ID + " is pregnant."); return; } if (creatureB.activity == CreatureActivity.Mating) { Debug.Log("[Utilities] " + creatureB.ID + " is currently mating."); return; } if (GeneUtility.Relatives(creatureA, creatureB)) { Debug.Log("[Utilities] " + creatureA.ID + " and " + creatureB.ID + " are relatives."); return; } if (Creature.CalculateMateCompatibility(creatureA, creatureB) || Creature.CalculateMateCompatibility(creatureB, creatureA)) { if (creatureB.Nutrition > creatureB.maxNutrition * 0.25f && creatureB.Hydration > creatureB.maxHydration * 0.25f) { Debug.Log("[Utilities] Compatible."); } else { Debug.Log("[Utilities] " + creatureB.ID + " has a critical " + (creatureB.Nutrition > creatureB.maxNutrition * 0.25f ? "nutrition" : "hydration") + " level."); } } }