public CharacterSelection(Game1 parent,GraphicsDevice device) { this.numOfPlayers = numOfPlayers; combatants = new LinkedList<CharacterInfo>(); this.parent = parent; //set up the back wall for the vertex buffer Shader.Vertex[] vertices = new Shader.Vertex[4]; float xWidth = 32, yWidth = 5, zWidth = 32, wallYDensity = 1, wallXDensity = 5; //set up the data for the back wall vertices[0] = new Shader.Vertex(new Vector3(-xWidth, yWidth, zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(-xWidth, 0, zWidth), new Vector2(0, wallYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(xWidth, yWidth, zWidth), new Vector2(wallXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(xWidth, 0, zWidth), new Vector2(wallXDensity, wallYDensity), new Vector3(0, 1, 0)); buffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); buffer.SetData(vertices); //set up the camera and world matrices view = Matrix.CreateLookAt(new Vector3(0, 0,30), new Vector3(0, 0, 0), Vector3.UnitY); projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 0.2f, 1000); world1 = Matrix.CreateScale(0.1f)*Matrix.CreateRotationX(-MathHelper.PiOver4)* Matrix.CreateTranslation(new Vector3(0, 0, 10)); world2 = Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver4) * Matrix.CreateTranslation(new Vector3(-5, 0, 5)); world3 = Matrix.CreateScale(0.1f) * Matrix.CreateRotationX(-MathHelper.PiOver4) * Matrix.CreateTranslation(new Vector3(5, 0, 5)); selectedCombatants = new List<string>(); timer = inputDelay; }
private void initBuffers(GraphicsDevice device) { Shader.Vertex[] vertices = new Shader.Vertex[4]; //set the vertices for the vertices vertices[0] = new Shader.Vertex(new Vector3(-xWidth, 0, zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(-xWidth, 0, -zWidth), new Vector2(0, floorYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(xWidth, 0, zWidth), new Vector2(floorXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(xWidth, 0, -zWidth), new Vector2(floorXDensity, floorYDensity), new Vector3(0, 1, 0)); //set up the vertex buffer for the vertices floorBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); //set the data for the vertices vertex buffer floorBuffer.SetData(vertices); vertices[0] = new Shader.Vertex(new Vector3(-xWidth, yWidth, zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(-xWidth, 0, zWidth), new Vector2(0, wallYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(xWidth, yWidth, zWidth), new Vector2(wallXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(xWidth, 0, zWidth), new Vector2(wallXDensity, wallYDensity), new Vector3(0, 1, 0)); //set up the front wall vertex buffer frontWallBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); frontWallBuffer.SetData(vertices); //set up the data for the right wall vertices[0] = new Shader.Vertex(new Vector3(xWidth, yWidth, zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(xWidth, 0, zWidth), new Vector2(0, wallYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(xWidth, yWidth, -zWidth), new Vector2(wallXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(xWidth, 0, -zWidth), new Vector2(wallXDensity, wallYDensity), new Vector3(0, 1, 0)); rightWallBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); rightWallBuffer.SetData(vertices); //set up the data for the back wall vertices[0] = new Shader.Vertex(new Vector3(xWidth, yWidth, -zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(xWidth, 0, -zWidth), new Vector2(0, wallYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(-xWidth, yWidth, -zWidth), new Vector2(wallXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(-xWidth, 0, -zWidth), new Vector2(wallXDensity, wallYDensity), new Vector3(0, 1, 0)); //set the bufers for the back wall backWallBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); backWallBuffer.SetData(vertices); //set up the data for the left wall vertices[0] = new Shader.Vertex(new Vector3(-xWidth, yWidth, -zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(-xWidth, 0, -zWidth), new Vector2(0, wallYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(-xWidth, yWidth, zWidth), new Vector2(wallXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(-xWidth, 0, zWidth), new Vector2(wallXDensity, wallYDensity), new Vector3(0, 1, 0)); //set the buffer for the left wall leftWallBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); leftWallBuffer.SetData(vertices); //set up the data for the ceiling vertices[0] = new Shader.Vertex(new Vector3(-xWidth, yWidth, -zWidth), new Vector2(0, 0), new Vector3(0, 1, 0)); vertices[1] = new Shader.Vertex(new Vector3(-xWidth, yWidth, zWidth), new Vector2(0, floorYDensity), new Vector3(0, 1, 0)); vertices[2] = new Shader.Vertex(new Vector3(xWidth, yWidth, -zWidth), new Vector2(floorXDensity, 0), new Vector3(0, 1, 0)); vertices[3] = new Shader.Vertex(new Vector3(xWidth, yWidth, zWidth), new Vector2(floorXDensity, floorYDensity), new Vector3(0, 1, 0)); //set the buffer for the ceiling ceilingBuffer = new VertexBuffer(device, Shader.Vertex.VertexDeclaration, 4, BufferUsage.WriteOnly); ceilingBuffer.SetData(vertices); }