public void Init(List <GeneType> pickedGenes, GeneSlot geneSlotPrefab, Action <AlienGeneValue> callback, Action <AlienColorGeneValue> colorCallback) { //instantiate genes and add to values bool hasColorGene = false; for (int i = 0; i < pickedGenes.Count; i++) { GeneType geneType = pickedGenes[i]; hasColorGene = hasColorGene || geneType == GeneType.COLOR; GeneSlot geneSlot = Object.Instantiate(geneSlotPrefab, m_GeneContainer); geneSlot.Init(geneType, geneSlotPrefab.name, OnDominantToggleClicked); InitGeneValue(geneType, geneSlot); } //if color gene, set the color of all other gene images to that of the color if (hasColorGene) { SetAllGenesToColor(m_ColorGeneValue); } OnDominantClicked += callback; OnDominantColorGeneClicked += colorCallback; }
private void InitGeneValue(GeneType geneType, GeneSlot geneSlot) { //special case for color gene if (geneType == GeneType.COLOR) { m_ColorGeneValue.GeneSlot = geneSlot; SetGeneColor(); return; } AlienGeneValue currentGeneValue = GetGeneFromType(geneType); currentGeneValue.GeneSlot = geneSlot; SetGeneImage(currentGeneValue); }