I created different types of cubes for my cube class and based on the height of the cube, the cube type is different. This means changing the texture for the cube.
if (y >= 1)
{
SetUpIndicesAndVertices(x, map[x, z] - y, z, vertices, indices);
cubes.Add(new Cube.Stone(device, new Vector3(x, map[x, z] - y, z), stone));
}
else
{
SetUpIndicesAndVertices(x, map[x, z] - y, z, vertices, indices);
cubes.Add(new Cube.Grass(device, new Vector3(x, map[x, z] - y, z), grass));
}
So I thought this would work, but my texture for all cubes is still grass. I noticed in my draw method these few lines:
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
no++;
pass.Apply();
effect.VertexColorEnabled = false;
effect.TextureEnabled = true;
effect.Texture = grass;
Which sets every cube to grass. Is there a way that I can set the texture based on each cube type in the list "cubes"?