Down.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName, { PopName } from "../EventName/EventName";
  8. import RoleQueue from "../GameLogic/RoleQueue";
  9. import BarrierDrag from "../GameLogic/barrierDrag";
  10. import HTTPS, { NetPost } from "../Template/HTTPS";
  11. import LocalData from "../Template/LocalData";
  12. import MyComponent from "../Template/MyComponent";
  13. import PopManger from "./PopManger";
  14. const { ccclass, property } = cc._decorator;
  15. @ccclass
  16. export default class Down extends MyComponent {
  17. pauseTime = 10
  18. //现在是否正在弹射
  19. static NowJumping: boolean = false
  20. @property(cc.Label)
  21. TimeStop: cc.Label = null
  22. @property(cc.Label)
  23. NowInSeat: cc.Label = null
  24. onLoad(): void {
  25. Down.NowJumping = false
  26. this.init()
  27. this.regEvent(EventName.UserPropTime, this.UserPropTime, this)
  28. this.regEvent(EventName.UserPropJump, this.UserPropJump, this)
  29. this.regEvent(EventName.UpdataPropCount, this.UpdataPropCount, this)
  30. }
  31. init() {
  32. // {
  33. // "Version": "1.0.0",
  34. // "Code": 200,
  35. // "Message": "操作成功。",
  36. // "Data": 14,
  37. // "DataCount": 0,
  38. // "PageCount": 0,
  39. // "Mac": "",
  40. // "Timestamp": "2024-11-06T17:52:15.88151+08:00"
  41. // }
  42. HTTPS.Instance.post(NetPost.GetUserProp, {}).then(resp => {
  43. if (resp.Data.Prop1) {
  44. LocalData.getInstance().setTimeStopCount(resp.Data.Prop1)
  45. } else {
  46. LocalData.getInstance().setTimeStopCount(0)
  47. }
  48. if (resp.Data.Prop2) {
  49. LocalData.getInstance().setNowSitDownCount(resp.Data.Prop2)
  50. } else {
  51. LocalData.getInstance().setNowSitDownCount(0)
  52. }
  53. })
  54. }
  55. UpdataPropCount() {
  56. this.TimeStop.string = LocalData.getInstance().getNowSitDownCount().toString()
  57. this.NowInSeat.string = LocalData.getInstance().getNowSitDownCount().toString()
  58. }
  59. UserPropTime() {
  60. LocalData.getInstance().LessTimeStopCount()
  61. console.log('执行时间停止一次');
  62. // let btn = event.target as cc.Node
  63. // btn.getComponent(cc.Button).interactable = false
  64. PopManger.getInstance().Pop(PopName.TimePause)
  65. //暂停
  66. cc.systemEvent.emit(EventName.PauseCountDown)
  67. this.scheduleOnce(() => {
  68. if (this.isValid) {
  69. cc.systemEvent.emit(EventName.RestoreCountDown)
  70. }
  71. }, this.pauseTime)
  72. }
  73. UserPropJump() {
  74. LocalData.getInstance().LessNowSitDownCount()
  75. console.log('执行弹射入座一次');
  76. Down.NowJumping = true
  77. // let btn = event.target as cc.Node
  78. // btn.getComponent(cc.Button).interactable = false
  79. BarrierDrag.PlayJump = true
  80. cc.systemEvent.emit(EventName.NowSitDowninSeat)
  81. }
  82. clickTimeStopBtn(event: cc.Event.EventTouch) {
  83. if (LocalData.getInstance().getTimeStopCount() > 0) {
  84. let TimeStop = this.node.getChildByName("TimeStop").getComponent(cc.Button)
  85. TimeStop.interactable = false
  86. cc.systemEvent.emit(EventName.UserPropTime)
  87. } else {
  88. // //看广告
  89. PopManger.getInstance().Pop(PopName.UserProp, { PropType: 0 })
  90. }
  91. }
  92. clickNowSitDownBtn(event: cc.Event.EventTouch) {
  93. if (LocalData.getInstance().getNowSitDownCount() > 0) {
  94. let NowInSeat = this.node.getChildByName("NowInSeat").getComponent(cc.Button)
  95. NowInSeat.interactable = false
  96. cc.systemEvent.emit(EventName.UserPropJump)
  97. } else {
  98. // //看广告
  99. PopManger.getInstance().Pop(PopName.UserProp, { PropType: 1 })
  100. }
  101. }
  102. // update (dt) {}
  103. }