private void MutateColor(Creature mother) { int r = mother.Color.R; int g = mother.Color.G; int b = mother.Color.B; r += Simulation.RandomInt(-5, 6); g += Simulation.RandomInt(-5, 6); b += Simulation.RandomInt(-5, 6); r = Mathf.ClampColorValue(r); g = Mathf.ClampColorValue(g); b = Mathf.ClampColorValue(b); Color = new Color(r, g, b); }
public Creature(Creature mother) { id = currentId++; //this.mother = mother; generation = mother.generation + 1; if (generation > _maximumGeneration) { _maximumGeneration = generation; } this.pos = mother.pos; this.viewAngle = EvoGame.RandomFloat() * Mathf.PI * 2; this.brain = mother.brain.CloneFullMesh(); SetupVariablesFromBrain(); CalculateFeelerPos(MAXIMUMFEELERDISTANCE); for (int i = 0; i < 10; i++) { brain.RandomMutation(0.1f); } int r = mother.color.R; int g = mother.color.G; int b = mother.color.B; r += EvoGame.RandomInt(-5, 6); g += EvoGame.RandomInt(-5, 6); b += EvoGame.RandomInt(-5, 6); r = Mathf.ClampColorValue(r); g = Mathf.ClampColorValue(g); b = Mathf.ClampColorValue(b); color = new Color(r, g, b); GenerateColorInv(); if (CreatureManager.SelectedCreature == null || CreatureManager.SelectedCreature.Energy < 100) { CreatureManager.SelectedCreature = this; } }