public static Dictionary <int, List <Gene> > CalculateGenePairings(AnimalData female, AnimalData male, GeneType geneType) { byte[] femaleGene; byte[] maleGene; switch (geneType) { case GeneType.SIZE: femaleGene = female.SizeGene.geneBytes; maleGene = male.SizeGene.geneBytes; break; case GeneType.LONGEVITY: femaleGene = female.LongevityGene.geneBytes; maleGene = male.LongevityGene.geneBytes; break; case GeneType.UNKNOWN_1: return(null); case GeneType.FERTILITY: femaleGene = female.FertilityGene.geneBytes; maleGene = male.FertilityGene.geneBytes; break; case GeneType.IMMUNITY: femaleGene = female.ImmunityGene.geneBytes; maleGene = male.ImmunityGene.geneBytes; break; case GeneType.UNKNOWN_2: return(null); default: return(null); } Dictionary <int, List <Gene> > pairings = new Dictionary <int, List <Gene> >(); Gene[] genes = new Gene[4]; genes[0] = new Gene(femaleGene.Take(6).Concat(maleGene.Take(6)).ToArray()); genes[1] = new Gene(femaleGene.Skip(6).Take(6).Concat(maleGene.Take(6)).ToArray()); genes[2] = new Gene(femaleGene.Take(6).Concat(maleGene.Skip(6).Take(6)).ToArray()); genes[3] = new Gene(femaleGene.Skip(6).Take(6).Concat(maleGene.Skip(6).Take(6)).ToArray()); switch (geneType) { case GeneType.SIZE: case GeneType.LONGEVITY: foreach (Gene gene in genes) { int value = (int)(gene.GetGeneValue(GeneValueType.HOMOGENEITY) * 100f); if (!pairings.ContainsKey(value)) { pairings.Add(value, new List <Gene>() { gene }); } else { pairings[value].Add(gene); } } break; case GeneType.FERTILITY: case GeneType.IMMUNITY: foreach (Gene gene in genes) { int value = (int)(gene.GetGeneValue(GeneValueType.DIVERSITY) * 100f); if (!pairings.ContainsKey(value)) { pairings.Add(value, new List <Gene>() { gene }); } else { pairings[value].Add(gene); } } break; default: return(null); } return(pairings); }