global.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. export default {
  2. _caller: null, // 调用方指针
  3. map: null,
  4. map_layer: null,
  5. players: [], // 玩家信息
  6. players_position: [], // 玩家当前位置信息
  7. players_trail: [], // 玩家轨迹信息
  8. focusPlayerId: 0, // 当前选中的玩家ID
  9. checkPoints: [], // 检查点列表
  10. routes: [], // 路线列表
  11. setCaller(data) {
  12. this._caller = data // 指针复制,是同一个对象
  13. },
  14. setPlayers(data) {
  15. this.players = data // 指针复制,是同一个对象
  16. },
  17. setPlayersPosition(data) {
  18. this.players_position = data // 指针复制,是同一个对象
  19. },
  20. setPlayersTrail(data) {
  21. this.players_trail = data // 指针复制,是同一个对象
  22. },
  23. setCheckPoints(data) {
  24. this.checkPoints = data // 指针复制,是同一个对象
  25. },
  26. setRoutes(data) {
  27. this.routes = data // 指针复制,是同一个对象
  28. },
  29. getPlayerById(playerId) {
  30. if (!(playerId > 0)) return
  31. var player = null
  32. if (this.players != null && this.players.length > 0) {
  33. player = this.players.find(o => o.id === playerId)
  34. }
  35. // console.log("[getPlayerById]", playerId, player)
  36. return player
  37. },
  38. getPlayerPositionById(playerId) {
  39. if (!(playerId > 0)) return
  40. var player_position = null
  41. if (this.players_position != null && this.players_position.length > 0) {
  42. player_position = this.players_position.find(o => o.id === playerId)
  43. }
  44. // console.log("[getPlayerPositionById]", playerId, player_position)
  45. return player_position
  46. },
  47. getPlayerTrailById(playerId) {
  48. if (!(playerId > 0)) return
  49. var player_trail = null
  50. if (this.players_trail != null && this.players_trail.length > 0) {
  51. player_trail = this.players_trail.find(o => o.id === playerId)
  52. }
  53. // console.log("[getPlayerTrailById]", playerId, player_trail)
  54. return player_trail
  55. },
  56. getCheckPointById(cpId) {
  57. if (!(cpId > 0)) return
  58. var checkPoint = null
  59. if (this.checkPoints != null && this.checkPoints.length > 0) {
  60. checkPoint = this.checkPoints.find(o => o.cp_id === cpId)
  61. }
  62. // console.log("[getCheckPointById]", cpId, checkPoint)
  63. return checkPoint
  64. },
  65. getRouteById(rtId) {
  66. if (!(rtId > 0)) return
  67. var route = null
  68. if (this.routes != null && this.routes.length > 0) {
  69. route = this.routes.find(o => o.id === rtId)
  70. }
  71. // console.log("[getCheckPointById]", rtId, route)
  72. return route
  73. },
  74. }