Ramaraunt1

block stuff voxel engine 1

Dec 27th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. /*
  5. * This is the base block class! This class is extended by other blocks.
  6. */
  7. public static class Utilities
  8. {
  9. public static Vector2[] returnUVs(Vector2 center, float tilesize)
  10. {
  11. Vector2[] UVs = new Vector2[4];
  12. UVs[0] = new Vector2(tilesize * center.x + tilesize, tilesize * center.y);
  13. UVs[1] = new Vector2(tilesize * center.x + tilesize, tilesize * center.y + tilesize);
  14. UVs[2] = new Vector2(tilesize * center.x, tilesize * center.y + tilesize);
  15. UVs[3] = new Vector2(tilesize * center.x, tilesize * center.y);
  16. return UVs;
  17. }
  18. }
  19. public class Block {
  20.  
  21.  
  22. private const float tilesize = 0.25f;
  23. private Vector2 uvTop { get; set; }
  24. private Vector2 uvBottom { get; set; }
  25. private Vector2 uvNorth { get; set; }
  26. private Vector2 uvSouth { get; set; }
  27. private Vector2 uvEast { get; set; }
  28. private Vector2 uvWest { get; set; }
  29. private BlockDirection blockDirection { get; set; }
  30.  
  31. private Gravity gravity = Gravity.None;
  32. private BlockType blockType = BlockType.NA;
  33.  
  34.  
  35.  
  36. public virtual SideType returnIfSolid(Side side)
  37. {
  38. return SideType.Solid; //all four sides are solid of default block.
  39. }
  40.  
  41.  
  42.  
  43. }
  44.  
  45. public enum BlockType
  46. {
  47. NA,
  48. Grass,
  49. Dirt,
  50. Rock,
  51. Gravel,
  52. Sand,
  53. Bedrock,
  54. Air,
  55. WaterSpring,
  56. WaterFlow5,
  57. WaterFlow4,
  58. WaterFlow3,
  59. WaterFlow2,
  60. WaterFlow1
  61. }
  62.  
  63. public enum Side
  64. {
  65. Top,
  66. Bottom,
  67. North,
  68. South,
  69. East,
  70. West
  71. }
  72.  
  73. public enum SideType
  74. {
  75. Open,
  76. Solid,
  77. SlabTop,
  78. SlabSideBottom,
  79. SlabSideTop,
  80. Watera
  81. }
  82. public enum Gravity
  83. {
  84. None,
  85. Yes
  86. }
  87.  
  88. public enum BlockDirection
  89. {
  90. Up,
  91. Down,
  92. North,
  93. South,
  94. East,
  95. West
  96. }
Advertisement
Add Comment
Please, Sign In to add comment