You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

62 lines
970 B

  1. using System;
  2. using UnityEngine;
  3. namespace SUISSEngine
  4. {
  5. [Serializable]
  6. public struct GridIndex
  7. {
  8. public GridIndex(int u, int v)
  9. {
  10. this.u = u;
  11. this.v = v;
  12. }
  13. public GridIndex(GridPoint point)
  14. {
  15. this.u = Mathf.RoundToInt(point.u);
  16. this.v = Mathf.RoundToInt(point.v);
  17. }
  18. public static GridIndex invalid
  19. {
  20. get
  21. {
  22. return new GridIndex(-1, -1);
  23. }
  24. }
  25. public bool isInvalid
  26. {
  27. get
  28. {
  29. return this.u < 0 || this.v < 0;
  30. }
  31. }
  32. public override string ToString()
  33. {
  34. return string.Format("({0},{1})", this.u, this.v);
  35. }
  36. public override int GetHashCode()
  37. {
  38. return this.u + 1000 * this.v;
  39. }
  40. public override bool Equals(object obj)
  41. {
  42. if (obj is GridIndex)
  43. {
  44. GridIndex gridIndex = (GridIndex)obj;
  45. return gridIndex.u == this.u && gridIndex.v == this.v;
  46. }
  47. return base.Equals(obj);
  48. }
  49. public int u;
  50. public int v;
  51. }
  52. }