map.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package constant
  2. import (
  3. ctime "github.com/cherry-game/cherry/extend/time"
  4. )
  5. const (
  6. MapCreateMainCityNumber = 10 // 尝试创建主城次数,失败则返回
  7. MapMoveSpeedMin = 1000 // 最小移动速度
  8. MapTileMeetBattleCount = 5 // 单次触发遭遇战的数量
  9. MapLeastStartWarMinite = 1 // 最少宣战时间
  10. MapInitObjectID = 10000 // 初始化对象ID
  11. MapCastleSiegeTime = 10 * ctime.MillisecondsPerMinute // 攻城持续时间
  12. MapMaxTileRetreat = 30 // 最大撤退数
  13. MapDefaultStateID = 1 // 默认出生州
  14. MapLeastSiegeWaitTime = 10 * ctime.MillisecondsPerSecond // 最少攻城等待时间
  15. MapLeastSnatchWaitTime = 10 * ctime.MillisecondsPerSecond // 最少掠夺等待时间
  16. MapLeastDiscardWaitTime = 10 * ctime.MillisecondsPerSecond // 最少放弃等待时间
  17. MapLeastOccupyWaitTime = 10 * ctime.MillisecondsPerSecond // 最少占领等待时间
  18. MapLeastBattleWaitTime = 1 * ctime.MillisecondsPerSecond // 最少战斗等待时间
  19. MapMaxBattleWaitTime = 30 * ctime.MillisecondsPerSecond // 最大战斗等待时间,毕竟状态卡死
  20. )
  21. const (
  22. MapMainForceWaitTimePart1 = ctime.MillisecondsPerSecond // 主力出击第一阶段等待时间
  23. MapMainForceWaitTimePart2 = 5 * ctime.MillisecondsPerSecond // 主力出击第二阶段等待时间
  24. MapSiegeSquadWaitTimePart1 = ctime.MillisecondsPerSecond // 拆迁队出击第一阶段等待时间
  25. MapSiegeSquadWaitTimePart2 = 5 * ctime.MillisecondsPerSecond // 拆迁队出击第二阶段等待时间
  26. MapAutoSiegeWaitTimePart3 = ctime.MillisecondsPerSecond // 自动攻城第三阶段等待时间
  27. )
  28. const (
  29. MapAutoSiegeStage_MainForce_WaitTime = ctime.MillisecondsPerSecond // 自动攻城主力出击阶段等待时间
  30. MapAutoSiegeStage_SiegeSquad_WaitTime = 5 * ctime.MillisecondsPerSecond // 自动攻城拆迁队出击阶段等待时间
  31. )
  32. const (
  33. MapTowerWidth_Res int32 = 20
  34. MapTowerHeight_Res int32 = 20
  35. MapTowerWidth_Monster int32 = 20
  36. MapTowerHeight_Monster int32 = 20
  37. MapTowerWidth_Build int32 = 20
  38. MapTowerHeight_Build int32 = 20
  39. MapTowerHeight_Castle int32 = 50
  40. MapTowerWidth_Castle int32 = 50
  41. MapTowerWidth_March int32 = 20
  42. MapTowerHeight_March int32 = 20
  43. )
  44. const (
  45. MapMarkCommand_Min = 0 // 地图标记指令最小值
  46. MapMarkCommand_Max = 6 // 地图标记指令最大值
  47. )
  48. const (
  49. MapWalkableTile = 1
  50. MapMaxPathDistance = 500 // 寻路最大距离
  51. )
  52. func GetStartWarWaitTime(requiredMinites int64) int64 {
  53. return max(requiredMinites, MapLeastStartWarMinite) * ctime.MillisecondsPerMinute
  54. }
  55. func IsWalkableTile(value int32) bool {
  56. return value >= MapWalkableTile
  57. }
  58. var (
  59. evenOffsets = [][2]int32{
  60. // x + 1
  61. {1, 0},
  62. {1, -1},
  63. // x - 1
  64. {-1, 0},
  65. {-1, -1},
  66. // x
  67. {0, -1},
  68. {0, 1},
  69. }
  70. oddOffsets = [][2]int32{
  71. // x + 1
  72. {1, 0},
  73. {1, 1},
  74. // x - 1
  75. {-1, 0},
  76. {-1, 1},
  77. // x
  78. {0, -1},
  79. {0, 1},
  80. }
  81. )
  82. func EvenOffsets() [][2]int32 {
  83. return evenOffsets
  84. }
  85. func OddOffsets() [][2]int32 {
  86. return oddOffsets
  87. }
  88. const MapTile_Unknown int32 = 0
  89. const (
  90. MapTile_Start = 1
  91. MapTile_Space int32 = 1 // 空地
  92. MapTile_Hil int32 = 2 // 山
  93. MapTile_Water int32 = 3 // 水
  94. MapTile_End = 100000
  95. )
  96. const (
  97. MapCastle_Start = 100001
  98. MapCastle_Dock1 int32 = 101401 // 码头(横向)
  99. MapCastle_Dock2 int32 = 101402 // 码头(纵向)
  100. MapCastle_End = 200000
  101. )
  102. const (
  103. MapBuild_Start = 200001
  104. MapBuild_SiegeBase int32 = 200001 // 攻城地基
  105. MapBuild_LeaguePoint int32 = 201001 // 联盟驻地
  106. MapBuild_LeagueCamp int32 = 201003 // 同盟大营
  107. MapBuild_LeagueFlag int32 = 201005 // 联盟旗帜
  108. MapBuild_ArrowTower int32 = 201006 // 箭塔
  109. MapBuild_Barricade int32 = 201007 // 拒马
  110. MapBuild_MainCity int32 = 202001 // 玩家主城
  111. MapBuild_CityBase int32 = 202002 // 玩家地基
  112. MapBuild_Camp int32 = 202003 // 营账
  113. MapBuild_End = 300000
  114. )
  115. const (
  116. MapRes_Start = 300001
  117. MapRes_End = 400000
  118. )
  119. func IsMapTile(configID int32) bool {
  120. return configID >= MapTile_Start && configID <= MapTile_End
  121. }
  122. func IsMapCastle(configID int32) bool {
  123. return configID >= MapCastle_Start && configID <= MapCastle_End
  124. }
  125. func IsMapBuild(configID int32) bool {
  126. return configID >= MapBuild_Start && configID <= MapBuild_End
  127. }
  128. func IsMapRes(configID int32) bool {
  129. return configID >= MapRes_Start && configID <= MapRes_End
  130. }
  131. func IsMapMarkCommandFail(command int32) bool {
  132. return command < MapMarkCommand_Min || command > MapMarkCommand_Max
  133. }
  134. // 是否为可掠夺建筑
  135. func IsSnatchableBuild(configID int32) bool {
  136. // 当前只有主城可以掠夺
  137. return configID == MapBuild_MainCity
  138. }