public LevelWallVertexBuffer(VertexPositionTexture[] wallVertices, VertexPositionTexture[] wallEdgeVertices, Texture2D wallTexture, Texture2D edgeTexture, Color color) { this.wallVertices = LevelRenderer.GetColoredVertices(wallVertices, color); WallBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, wallVertices.Length, BufferUsage.WriteOnly); WallBuffer.SetData(this.wallVertices); WallTexture = wallTexture; this.wallEdgeVertices = LevelRenderer.GetColoredVertices(wallEdgeVertices, color); WallEdgeBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, wallEdgeVertices.Length, BufferUsage.WriteOnly); WallEdgeBuffer.SetData(this.wallEdgeVertices); EdgeTexture = edgeTexture; }
public void Append(VertexPositionTexture[] wallVertices, VertexPositionTexture[] wallEdgeVertices, Color color) { WallBuffer.Dispose(); WallBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, this.wallVertices.Length + wallVertices.Length, BufferUsage.WriteOnly); int originalWallVertexCount = this.wallVertices.Length; Array.Resize(ref this.wallVertices, originalWallVertexCount + wallVertices.Length); Array.Copy(LevelRenderer.GetColoredVertices(wallVertices, color), 0, this.wallVertices, originalWallVertexCount, wallVertices.Length); WallBuffer.SetData(this.wallVertices); WallEdgeBuffer.Dispose(); WallEdgeBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, this.wallEdgeVertices.Length + wallEdgeVertices.Length, BufferUsage.WriteOnly); int originalWallEdgeVertexCount = this.wallEdgeVertices.Length; Array.Resize(ref this.wallEdgeVertices, originalWallEdgeVertexCount + wallEdgeVertices.Length); Array.Copy(LevelRenderer.GetColoredVertices(wallEdgeVertices, color), 0, this.wallEdgeVertices, originalWallEdgeVertexCount, wallEdgeVertices.Length); WallEdgeBuffer.SetData(this.wallEdgeVertices); }
public LevelWallVertexBuffer(VertexPositionTexture[] wallVertices, VertexPositionTexture[] wallEdgeVertices, Texture2D wallTexture, Texture2D edgeTexture, Color color) { if (wallVertices.Length == 0) { throw new ArgumentException("Failed to instantiate a LevelWallVertexBuffer (no wall vertices)."); } if (wallVertices.Length == 0) { throw new ArgumentException("Failed to instantiate a LevelWallVertexBuffer (no wall edge vertices)."); } this.wallVertices = LevelRenderer.GetColoredVertices(wallVertices, color); WallBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, wallVertices.Length, BufferUsage.WriteOnly); WallBuffer.SetData(this.wallVertices); WallTexture = wallTexture; this.wallEdgeVertices = LevelRenderer.GetColoredVertices(wallEdgeVertices, color); WallEdgeBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, wallEdgeVertices.Length, BufferUsage.WriteOnly); WallEdgeBuffer.SetData(this.wallEdgeVertices); EdgeTexture = edgeTexture; }
public void SetBodyVertices(VertexPositionTexture[] vertices, Color color) { bodyVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); bodyVertices.SetData(LevelRenderer.GetColoredVertices(vertices, color)); }