At the moment I have seven if statements that resemble the following code:
if(hit.collider.gameObject.tag == "Colour1" && start_time > look_at_time)
{
new_colour1.ChangeObjectMaterialColour(hit.collider.gameObject.renderer.material.color);
var colums = GameObject.FindGameObjectsWithTag("column");
foreach( GameObject c in colums)
c.GetComponent<MeshRenderer>().materials[1].color = new_colour1.orignalMaterial;
}
else if(hit.collider.gameObject.tag == "Colour2" && start_time > look_at_time)
{
new_colour2.ChangeObjectMaterialColour(hit.collider.gameObject.renderer.material.color);
var colums = GameObject.FindGameObjectsWithTag("column");
foreach( GameObject c in colums)
c.GetComponent<MeshRenderer>().materials[1].color = new_colour2.orignalMaterial;
}
Each statement is roughly 6 lines of code and takes up a lot of space and can be a little tricky to read. What I'm wanting to do is find a way to re factor this so that my code is little less clunky and doesn't take up too much space.
I had thought about changing my collection of if statements into a switch statement but I discovered that switch statements can't handle two arguments like I have above. If there any other way I can re factor my code but keep the same functionality or am I stuck with my collection of if statements?
edit
Updated to contain two of my 7 statements. Please note, I am trying to reduce the amount of IF statements I have, or find a more clever way to do them. I don't want to add any more extra lines of code or if statements.