damongant

Untitled

May 1st, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Graphics;
  7.  
  8. namespace PGN
  9. {
  10. public class Map
  11. {
  12. List<MapTile> tiles;
  13.  
  14. public List<MapTile> Tiles
  15. {
  16. get { return tiles; }
  17. set { tiles = value; }
  18. }
  19.  
  20. public IOrderedEnumerable<MapTile> GetTilesInDrawOrder()
  21. {
  22. return from x in Tiles
  23. orderby x.Layer ascending
  24. select x;
  25. }
  26. }
  27.  
  28. public class MapTile
  29. {
  30. Point position;
  31.  
  32. public Point Position
  33. {
  34. get { return position; }
  35. set { position = value; }
  36. }
  37.  
  38. string tilesetHash;
  39.  
  40. public string TilesetHash
  41. {
  42. get { return tilesetHash; }
  43. set { tilesetHash = value; }
  44. }
  45.  
  46. Point tilesetOffset;
  47.  
  48. public Point TilesetOffset
  49. {
  50. get { return tilesetOffset; }
  51. set { tilesetOffset = value; }
  52. }
  53.  
  54. int layer;
  55.  
  56. public int Layer
  57. {
  58. get { return layer; }
  59. set { layer = value; }
  60. }
  61.  
  62. PlayerPass playerPass;
  63.  
  64. public PlayerPass PlayerPass
  65. {
  66. get { return playerPass; }
  67. set { playerPass = value; }
  68. }
  69.  
  70. public Texture2D GetTexture()
  71. {
  72. return Utils.g.Service<AssetCache>().GetAsset<Tileset>(tilesetHash).GetTexture(Utils.g.GraphicsDevice);
  73. }
  74.  
  75. public Rectangle GetSourceRect()
  76. {
  77. return new Rectangle((int)TilesetOffset.X-1 * Utils.TILESIZE, (int)TilesetOffset.Y-1 * Utils.TILESIZE, Utils.TILESIZE, Utils.TILESIZE);
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment