private Color GetGeneColor(AlienColorGeneValue colorGeneValue) { if (colorGeneValue.Value < 0) { return(Color.white); } return(colorGeneValue.Value >= colorGeneValue.ColorGeneData.Values.Count ? colorGeneValue.ColorGeneData.DefaultColor : colorGeneValue.ColorGeneData.Values[colorGeneValue.Value]); }
private void SetAllGenesToColor(AlienColorGeneValue colorGeneValue) { Color color = GetGeneColor(colorGeneValue); for (int i = 0; i < m_GeneValues.Count; i++) { AlienGeneValue currentGeneValue = m_GeneValues[i]; if (currentGeneValue.GeneSlot != null) { currentGeneValue.GeneSlot.Image.color = color; } } }
public void OnDominantClicked(AlienColorGeneValue geneValue) { bool isDominant = !geneValue.IsDominant; //don't activate if none available if (isDominant && m_DominantGenesAvailable == 0) { return; } geneValue.SetDominant(isDominant); m_DominantGenesAvailable = isDominant ? m_DominantGenesAvailable - 1 : m_DominantGenesAvailable + 1; SetDominantGenesAvailableText(m_DominantGenesAvailable); }
private int ResolveColorRules(AlienColorGeneValue firstParentColorGene, AlienColorGeneValue secondParentColorGene) { List <ColorRule> colorRules = firstParentColorGene.ColorGeneData.ColorRules; for (int i = 0; i < colorRules.Count; i++) { ColorRule currentColorRule = colorRules[i]; if (currentColorRule.FirstColor == firstParentColorGene.Value && currentColorRule.SecondColor == secondParentColorGene.Value) { return(currentColorRule.ResultColor); } } return(firstParentColorGene.ColorGeneData.Values.IndexOf(firstParentColorGene.ColorGeneData.DefaultColor)); }
private void FuseAlienGeneType(GeneType geneType, Alien firstParent, Alien secondParent) { AlienGeneValue firstParentGeneValue = firstParent.GetGeneFromType(geneType), secondParentGeneValue = secondParent.GetGeneFromType(geneType); AlienColorGeneValue firstParentColorGeneValue = firstParent.ColorGeneValue, secondParentColorGeneValue = secondParent.ColorGeneValue; m_AlienGeneData.GeneType = geneType; bool isColorGene = geneType == GeneType.COLOR; //if either parent has a predominant gene then use that gene value for the child if ((isColorGene && firstParentColorGeneValue.IsDominant) || (!isColorGene && firstParentGeneValue.IsDominant)) { m_AlienGeneData.Value = isColorGene ? firstParentColorGeneValue.Value : firstParentGeneValue.Value; firstParent.Child.SetGeneData(m_AlienGeneData); return; } if ((isColorGene && secondParentColorGeneValue.IsDominant) || (!isColorGene && secondParentGeneValue.IsDominant)) { m_AlienGeneData.Value = isColorGene ? secondParentColorGeneValue.Value : secondParentGeneValue.Value; firstParent.Child.SetGeneData(m_AlienGeneData); //both parents' child should be the same return; } //otherwise resolve based on priority if (isColorGene) { m_AlienGeneData.Value = ResolveColorRules(firstParentColorGeneValue, secondParentColorGeneValue); } else { GeneResolution geneResolution = GetGeneResolutionFromType(geneType); int firstParentPriorityGeneValue = geneResolution.PriorityOrder.IndexOf(firstParentGeneValue.Value), secondParentPriorityGeneValue = geneResolution.PriorityOrder.IndexOf(secondParentGeneValue.Value); //lowest priority wins m_AlienGeneData.Value = firstParentPriorityGeneValue < secondParentPriorityGeneValue ? firstParentGeneValue.Value : secondParentGeneValue.Value; } firstParent.Child.SetGeneData(m_AlienGeneData); }