global.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. setCaller(data) {
  11. this._caller = data // 指针复制,是同一个对象
  12. },
  13. setPlayers(data) {
  14. this.players = data // 指针复制,是同一个对象
  15. },
  16. setPlayersPosition(data) {
  17. this.players_position = data // 指针复制,是同一个对象
  18. },
  19. setPlayersTrail(data) {
  20. this.players_trail = data // 指针复制,是同一个对象
  21. },
  22. setCheckPoints(data) {
  23. this.checkPoints = data // 指针复制,是同一个对象
  24. },
  25. getPlayerById(playerId) {
  26. if (!(playerId > 0)) return
  27. var player = null
  28. if (this.players != null && this.players.length > 0) {
  29. player = this.players.find(o => o.id === playerId)
  30. }
  31. // console.log("[getPlayerById]", playerId, player)
  32. return player
  33. },
  34. getPlayerPositionById(playerId) {
  35. if (!(playerId > 0)) return
  36. var player_position = null
  37. if (this.players_position != null && this.players_position.length > 0) {
  38. player_position = this.players_position.find(o => o.id === playerId)
  39. }
  40. // console.log("[getPlayerPositionById]", playerId, player_position)
  41. return player_position
  42. },
  43. getPlayerTrailById(playerId) {
  44. if (!(playerId > 0)) return
  45. var player_trail = null
  46. if (this.players_trail != null && this.players_trail.length > 0) {
  47. player_trail = this.players_trail.find(o => o.id === playerId)
  48. }
  49. // console.log("[getPlayerTrailById]", playerId, player_trail)
  50. return player_trail
  51. },
  52. getCheckPointById(cpId) {
  53. if (!(cpId > 0)) return
  54. var checkPoint = null
  55. if (this.checkPoints != null && this.checkPoints.length > 0) {
  56. checkPoint = this.checkPoints.find(o => o.cp_id === cpId)
  57. }
  58. // console.log("[getCheckPointById]", cpId, checkPoint)
  59. return checkPoint
  60. },
  61. }