MapObject.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using UnityEngine;
  2. using System.Collections;
  3. public class MapObject : MonoBehaviour, IMapObject
  4. {
  5. public enum StartPostionDirect
  6. {
  7. Bottom = 0,
  8. BottomLeft = 1,
  9. BottomRight = 2,
  10. Top = 3,
  11. TopLeft = 4,
  12. TopRight = 5,
  13. Left = 6,
  14. Right = 7,
  15. Center = 8,
  16. None = 9,
  17. }
  18. private static System.Array startPosDirArr = System.Enum.GetValues(typeof(StartPostionDirect));
  19. public static StartPostionDirect GetStartPositionDirect(int code)
  20. {
  21. return (StartPostionDirect)startPosDirArr.GetValue(code);
  22. }
  23. protected int _id;
  24. protected int _typeId;
  25. protected TeamUtil.Team _team;
  26. protected Map map;
  27. public StartPostionDirect startPositionDirect;
  28. public virtual void Init(Map map)
  29. {
  30. this.map = map;
  31. }
  32. public int id
  33. {
  34. get{
  35. return _id;
  36. }
  37. set{
  38. _id = value;
  39. }
  40. }
  41. public virtual TeamUtil.Team team
  42. {
  43. get{
  44. return _team;
  45. }
  46. set{
  47. _team = value;
  48. }
  49. }
  50. public int typeId
  51. {
  52. get{
  53. return _typeId;
  54. }
  55. set{
  56. _typeId = value;
  57. }
  58. }
  59. public virtual Vector3 position
  60. {
  61. get{return transform.position;}
  62. set{transform.position = value;}
  63. }
  64. public Vector3 GetStartPosition()
  65. {
  66. Vector3 pos = position;
  67. if(startPositionDirect == StartPostionDirect.Bottom)
  68. {
  69. pos.z -= 4f;
  70. }
  71. else if(startPositionDirect == StartPostionDirect.BottomLeft)
  72. {
  73. pos.z -= 3f;
  74. pos.x -= 3f;
  75. }
  76. else if(startPositionDirect == StartPostionDirect.BottomRight)
  77. {
  78. pos.z -= 3f;
  79. pos.x += 3f;
  80. }
  81. else if(startPositionDirect == StartPostionDirect.Top)
  82. {
  83. pos.z += 4f;
  84. }
  85. else if(startPositionDirect == StartPostionDirect.TopLeft)
  86. {
  87. pos.z += 3f;
  88. pos.x -= 3f;
  89. }
  90. else if(startPositionDirect == StartPostionDirect.TopRight)
  91. {
  92. pos.z += 3f;
  93. pos.x += 3f;
  94. }
  95. else if(startPositionDirect == StartPostionDirect.Left)
  96. {
  97. pos.x -= 4f;
  98. }
  99. else if(startPositionDirect == StartPostionDirect.Right)
  100. {
  101. pos.x += 4f;
  102. }
  103. return pos;
  104. }
  105. public int col
  106. {
  107. get{return Map.XToColumn(position.x);}
  108. }
  109. public int row
  110. {
  111. get{return Map.ZToRow(position.z);}
  112. }
  113. public virtual void Remove()
  114. {
  115. }
  116. }