Skip to content

Commit

Permalink
enable coloring by agent metabolism
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBuhler committed Jul 12, 2020
1 parent f9da486 commit f3a0381
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ public void Render () {
}
}
break;
case State.ColoringOptions.BY_METABOLISM:
{
float range = Simulation.Parameters.Metabolism.MAX - Simulation.Parameters.Metabolism.MIN;
float a = Simulation.Parameters.Metabolism.MIN + range * 1 / 3;
float b = Simulation.Parameters.Metabolism.MIN + range * 2 / 3;
if ( vision < a ) {
renderer.sharedMaterial = Materials.LOW_METABOLISM;
} else if ( vision < b ) {
renderer.sharedMaterial = Materials.MEDIUM_METABOLISM;
} else {
renderer.sharedMaterial = Materials.HIGH_METABOLISM;
}
}
break;
}
}

Expand Down
14 changes: 14 additions & 0 deletions Materials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public class Materials {

public static readonly Material DEFAULT;

public static readonly Material LOW_METABOLISM;
public static readonly Material MEDIUM_METABOLISM;
public static readonly Material HIGH_METABOLISM;

public static readonly Material MALE;
public static readonly Material FEMALE;

Expand Down Expand Up @@ -45,6 +49,16 @@ static Materials () {
HIGH_VISION = new Material(Shaders.Legacy.DIFFUSE) {
color = Color.blue
};

LOW_METABOLISM = new Material(Shaders.Legacy.DIFFUSE) {
color = Color.blue
};
MEDIUM_METABOLISM = new Material(Shaders.Legacy.DIFFUSE) {
color = new Color(0.5f, 0, 0.5f, 1) // purple
};
HIGH_METABOLISM = new Material(Shaders.Legacy.DIFFUSE) {
color = Color.red
};
}

}
1 change: 1 addition & 0 deletions State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ public class State {

public enum ColoringOptions {
DEFAULT,
BY_METABOLISM,
BY_SEX,
BY_VISION
}
Expand Down
8 changes: 8 additions & 0 deletions UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public void ColorsDefaultToggled (bool value) {
}
}

public void ColorsMetabolismToggled (bool value) {
if ( value ) {
State.COLORING_OPTION = State.ColoringOptions.BY_METABOLISM;
colorsDescription.text = "low is blue, medium is purple, high is red";
Simulation.Render();
}
}

public void ColorsSexToggled (bool value) {
if ( value ) {
State.COLORING_OPTION = State.ColoringOptions.BY_SEX;
Expand Down
Loading

0 comments on commit f3a0381

Please sign in to comment.