123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- // 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) {}
- }
|