Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Content;
  8. using Microsoft.Xna.Framework.Graphics;
  9.  
  10. namespace multi.GameUtility.Map.Elements
  11. {
  12. class SpawnPoint : IMapElement
  13. {
  14. public Vector2 Position { get; set; }
  15. private Texture2D texture { get; set; }
  16. private VertexPositionNormalTexture[] vertexCollection {get;set;}
  17.  
  18.  
  19. public SpawnPoint(Vector2 position)
  20. {
  21. Position = position;
  22. }
  23.  
  24. public void Draw(GraphicsDevice graphicsDevice, BasicEffect ef)
  25. {
  26. ef.TextureEnabled = true;
  27. ef.Texture = texture;
  28. ef.EnableDefaultLighting();
  29. ef.World = Matrix.CreateTranslation(new Vector3(Position.X, 0, Position.Y));
  30. graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertexCollection, 0, vertexCollection.Count() / 3, VertexPositionNormalTexture.VertexDeclaration);
  31. ef.World = Matrix.Identity;
  32. }
  33.  
  34. public void Load(ContentManager content)
  35. {
  36. texture = content.Load<Texture2D>("MapElements\\SpawnPoint");
  37.  
  38. vertexCollection = new VertexPositionNormalTexture[6];
  39.  
  40. VertexPositionNormalTexture singleVertex = new VertexPositionNormalTexture();
  41. singleVertex.Normal = Vector3.Up;
  42. singleVertex.Position = new Vector3(-1, 0, -1);
  43. singleVertex.TextureCoordinate = new Vector2(0, 0);
  44. vertexCollection[0] = singleVertex;
  45.  
  46. singleVertex = new VertexPositionNormalTexture();
  47. singleVertex.Normal = Vector3.Up;
  48. singleVertex.Position = new Vector3(-1, 0, 1);
  49. singleVertex.TextureCoordinate = new Vector2(0, 1);
  50. vertexCollection[1] = singleVertex;
  51.  
  52. singleVertex = new VertexPositionNormalTexture();
  53. singleVertex.Normal = Vector3.Up;
  54. singleVertex.Position = new Vector3(1, 0, -1);
  55. singleVertex.TextureCoordinate = new Vector2(1, 0);
  56. vertexCollection[2] = singleVertex;
  57.  
  58. singleVertex = new VertexPositionNormalTexture();
  59. singleVertex.Normal = Vector3.Up;
  60. singleVertex.Position = new Vector3(-1, 0, 1);
  61. singleVertex.TextureCoordinate = new Vector2(0,1);
  62. vertexCollection[3] = singleVertex;
  63.  
  64. singleVertex = new VertexPositionNormalTexture();
  65. singleVertex.Normal = Vector3.Up;
  66. singleVertex.Position = new Vector3(1, 0, 1);
  67. singleVertex.TextureCoordinate = new Vector2(1, 1);
  68. vertexCollection[4] = singleVertex;
  69.  
  70. singleVertex = new VertexPositionNormalTexture();
  71. singleVertex.Normal = Vector3.Up;
  72. singleVertex.Position = new Vector3(1, 0, -1);
  73. singleVertex.TextureCoordinate = new Vector2(1, 0);
  74. vertexCollection[5] = singleVertex;
  75.  
  76. }
  77.  
  78. public void Update()
  79. {
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement