public Tree(Game game, Vector3 scale, Vector3 rotation, Vector3 position,Camera cam) { this.world = Matrix.CreateScale(scale) * Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z) * Matrix.CreateTranslation(position); this.camera = cam; this.position = position; this.texture = ImageLibrary.getInstance().getImage("Tree"); Vector3[] verts = new Vector3[] { new Vector3(-1, 0, 0), new Vector3(-1, 2, 0), new Vector3(1, 2, 0), new Vector3(1, 2, 0), new Vector3(1, 0, 0), new Vector3(-1, 0, 0) }; int[] triangles = new int[] { 0,1,2, 3,4,5 }; Vector2[] uv = new Vector2[] { new Vector2(0, 1), new Vector2(0, 0), new Vector2(1, 0), new Vector2(1,0), new Vector2(1, 1), new Vector2(0, 1) }; int[] trianglesuv = new int[] { 0,1,2, 3,4,5 }; ConvertMesh myMesh = new ConvertMesh(); vertices = myMesh.returnTriangle(verts, triangles, uv, trianglesuv); vertexBuffer = new VertexBuffer(game.GraphicsDevice, typeof(VertexPositionTexture), vertices.Length, BufferUsage.None); vertexBuffer.SetData<VertexPositionTexture>(vertices); effect = new BasicEffect(game.GraphicsDevice); }
public Character(Game game, Vector3 scale, Vector3 rotation, Vector3 position, Texture2D texture, Camera camera, Node target) { this.scale = scale; this.target = target; this.camera = camera; this.world = Matrix.CreateScale(scale) * Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z) * Matrix.CreateTranslation(position); this.position = position; this.rotation = rotation; this.texture = texture; Vector3[] _verts = new Vector3[] { new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), new Vector3(1, 0, -1), new Vector3(1,0,1) }; int[] triangles = new int[] { 0,1,2, 2,1,3 }; Vector2[] uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1,0), new Vector2(0, 1), new Vector2(1, 1) }; int[] trianglesuv = new int[] { 0,1,2, 3,4,5 }; ConvertMesh myMesh = new ConvertMesh(); verts = myMesh.returnTriangle(_verts, triangles, uv, trianglesuv); vertexBuffer = new VertexBuffer(game.GraphicsDevice, typeof(VertexPositionTexture), verts.Length, BufferUsage.None); vertexBuffer.SetData<VertexPositionTexture>(verts); effect = new BasicEffect(game.GraphicsDevice); }
public Grid(Game game,Camera mainCamera,int Rows, int Columns) { this.Rows = Rows; this.Columns = Columns; nodes = new Node[Rows, Columns]; for (int x = 0; x < Columns; x++) { for (int y = 0; y < Rows; y++) { float positionX = 1 * x; float positionY = 1 * y; nodes[x, y] = new Node(game, new Vector3(1.25f, 0, 1.25f), new Vector3(0, 0, 0), new Vector3(positionX*2.5f, 0, positionY*2.5f),ImageLibrary.getInstance().getImage("Floor"), mainCamera); nodes[x, y].x = x; nodes[x, y].y = y; } } }
protected override void Initialize() { nodePath = new List<Node>(); towers = new List<Tree>(); this.keyboard = new KeyboardManager(); this.allTrees = new Tree[0]; this.IsMouseVisible = true; cam = new Camera(this, new Vector3(6, 4, 22)); base.Initialize(); }