// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import EventName, { PopName } from "../EventName/EventName"; import RoleQueue from "../GameLogic/RoleQueue"; import BarrierDrag from "../GameLogic/barrierDrag"; import HTTPS, { NetPost } from "../Template/HTTPS"; import LocalData from "../Template/LocalData"; import MyComponent from "../Template/MyComponent"; import PopManger from "./PopManger"; const { ccclass, property } = cc._decorator; @ccclass export default class Down extends MyComponent { pauseTime = 10 //现在是否正在弹射 static NowJumping: boolean = false @property(cc.Label) TimeStop: cc.Label = null @property(cc.Label) NowInSeat: cc.Label = null onLoad(): void { Down.NowJumping = false this.init() this.regEvent(EventName.UserPropTime, this.UserPropTime, this) this.regEvent(EventName.UserPropJump, this.UserPropJump, this) this.regEvent(EventName.UpdataPropCount, this.UpdataPropCount, this) } init() { // { // "Version": "1.0.0", // "Code": 200, // "Message": "操作成功。", // "Data": 14, // "DataCount": 0, // "PageCount": 0, // "Mac": "", // "Timestamp": "2024-11-06T17:52:15.88151+08:00" // } HTTPS.Instance.post(NetPost.GetUserProp, {}).then(resp => { if (resp.Data.Prop1) { LocalData.getInstance().setTimeStopCount(resp.Data.Prop1) } else { LocalData.getInstance().setTimeStopCount(0) } if (resp.Data.Prop2) { LocalData.getInstance().setNowSitDownCount(resp.Data.Prop2) } else { LocalData.getInstance().setNowSitDownCount(0) } }) } UpdataPropCount() { this.TimeStop.string = LocalData.getInstance().getNowSitDownCount().toString() this.NowInSeat.string = LocalData.getInstance().getNowSitDownCount().toString() } UserPropTime() { LocalData.getInstance().LessTimeStopCount() console.log('执行时间停止一次'); // let btn = event.target as cc.Node // btn.getComponent(cc.Button).interactable = false PopManger.getInstance().Pop(PopName.TimePause) //暂停 cc.systemEvent.emit(EventName.PauseCountDown) this.scheduleOnce(() => { if (this.isValid) { cc.systemEvent.emit(EventName.RestoreCountDown) } }, this.pauseTime) } UserPropJump() { LocalData.getInstance().LessNowSitDownCount() console.log('执行弹射入座一次'); Down.NowJumping = true // let btn = event.target as cc.Node // btn.getComponent(cc.Button).interactable = false BarrierDrag.PlayJump = true cc.systemEvent.emit(EventName.NowSitDowninSeat) } clickTimeStopBtn(event: cc.Event.EventTouch) { if (LocalData.getInstance().getTimeStopCount() > 0) { let TimeStop = this.node.getChildByName("TimeStop").getComponent(cc.Button) TimeStop.interactable = false cc.systemEvent.emit(EventName.UserPropTime) } else { // //看广告 PopManger.getInstance().Pop(PopName.UserProp, { PropType: 0 }) } } clickNowSitDownBtn(event: cc.Event.EventTouch) { if (LocalData.getInstance().getNowSitDownCount() > 0) { let NowInSeat = this.node.getChildByName("NowInSeat").getComponent(cc.Button) NowInSeat.interactable = false cc.systemEvent.emit(EventName.UserPropJump) } else { // //看广告 PopManger.getInstance().Pop(PopName.UserProp, { PropType: 1 }) } } // update (dt) {} }