From 9e627d3b692b6601ddb9c171f157bbdce27d6ad3 Mon Sep 17 00:00:00 2001 From: "YZ\\249929363" <249929363@qq.com> Date: Mon, 14 Jul 2025 18:24:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=94=AF=E4=BB=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/Block.ts | 1072 ++++++++++----------- assets/Script/GameManager.ts | 11 +- assets/Script/Map.ts | 15 +- assets/Script/SceneManager.ts | 26 +- assets/Script/Sdk/MiniGameSdk.ts | 4 +- assets/Script/module/Config/GameConfig.ts | 3 + assets/Script/module/Pay/Utils.ts | 32 +- assets/UI/UI/pop/gameui.png.meta | 4 +- assets/shop/script/shop.ts | 49 +- settings/project.json | 2 +- 10 files changed, 648 insertions(+), 570 deletions(-) diff --git a/assets/Script/Block.ts b/assets/Script/Block.ts index b4b77ca..466bb53 100644 --- a/assets/Script/Block.ts +++ b/assets/Script/Block.ts @@ -2,60 +2,60 @@ import CollisionDetection from "./CollisionDetection"; import { LQCollideSystem } from "./lq_collide_system/lq_collide_system"; import MapConroler from "./Map"; -const {ccclass, property} = cc._decorator; - export enum BlockType{ +const { ccclass, property } = cc._decorator; +export enum BlockType { /*普通地块 */ - "普通块" = 0, + "普通块" = 0, /*起点地块 */ - "叠加块下" = 1, + "叠加块下" = 1, /*湿地 */ - "钥匙块" = 2, + "钥匙块" = 2, /*山峰 */ - "上锁块" = 3, + "上锁块" = 3, /*终点地块 */ - "冻结块" = 4, + "冻结块" = 4, /*息壤 */ - "星星块" = 5, + "星星块" = 5, /*加固 */ - "炸弹块" = 6, + "炸弹块" = 6, /*加固 */ - "水平块" = 7, + "水平块" = 7, /*加固 */ - "垂直块" = 8, + "垂直块" = 8, /*加固 */ - "粘合块" = 9, + "粘合块" = 9, /*加固 */ - "叠加块上" = 10, + "叠加块上" = 10, } -export enum BlockColor{ +export enum BlockColor { /*起点地块 */ - "紫色" = 0, + "紫色" = 0, /*湿地 */ - "黄色" = 1, + "黄色" = 1, /*山峰 */ - "绿色" = 2, + "绿色" = 2, /*终点地块 */ - "蓝色" = 3, + "蓝色" = 3, /*息壤 */ - "粉色" = 4, + "粉色" = 4, /*加固 */ - "橘黄色" = 5, + "橘黄色" = 5, /*加固 */ - "青色" = 6, + "青色" = 6, /*加固 */ - "白色" = 7, + "白色" = 7, /*加固 */ - "红色" = 8, + "红色" = 8, /*加固 */ "灰色" = 9, } -export enum PathType{ +export enum PathType { err = "err", - up = "up", - down = "down", + up = "up", + down = "down", left = "left", right = "right", up_left = "up_left", @@ -82,7 +82,7 @@ export default class Block extends cc.Component { // // default: BlockType.Nomal, // displayName: '碰撞形状' // }) - + @property({ tooltip: '碰撞形状,None就是无敌,不参与碰撞', type: cc.Enum(BlockType), @@ -111,7 +111,7 @@ export default class Block extends cc.Component { ice_SpriteFrame: cc.SpriteAtlas = null; @property(sp.SkeletonData) - magic_SkeletonData: sp.SkeletonData = null; + magic_SkeletonData: sp.SkeletonData = null; // LIFE-CYCLE CALLBACKS: // @property(cc.SpriteAtlas) @@ -119,7 +119,7 @@ export default class Block extends cc.Component { private initialTouchOffset: cc.Vec2 = null; private offsetTolerance = 100; // 偏移容忍度; - allBlocks:any; //所有的方块,用于计算posX,posY消除 + allBlocks: any; //所有的方块,用于计算posX,posY消除 touchPoint: cc.Vec2 = null; //触摸点 isTouch: boolean = false; //是否触摸 posX: number = 0; //地图块的X坐标 @@ -129,8 +129,8 @@ export default class Block extends cc.Component { moveUp: boolean = true; //是否可以上移; moveDown: boolean = true; //是否可以下移; moveCorner: number = 0; //是否碰撞角落 - moveY:number = 0; //是否可以上下移动; - moveX:number = 0; //是否可以左右移动; + moveY: number = 0; //是否可以上下移动; + moveX: number = 0; //是否可以左右移动; touchPointX: number = 0; //触摸点X坐标; touchPointY: number = 0; //触摸点Y坐标; blockId: number = 0; //方块ID; @@ -140,23 +140,23 @@ export default class Block extends cc.Component { pz: boolean = false; over: boolean = false; //方块是否失效已消失 collider: any; - block_Info:any; + block_Info: any; _touchListener: any; - relative_Position:cc.Vec2; //点击和方块相对位置 + relative_Position: cc.Vec2; //点击和方块相对位置 private _eventManager: any; hit: cc.Node; otherCollider: any; moveStack: boolean; - touchDelta: cc.Vec2 = cc.v2(0, 0); + touchDelta: cc.Vec2 = cc.v2(0, 0); adhesiveNode: any; checkCollision: boolean = false; - onLoad () { + onLoad() { this.pz = false; - this.stacking = cc.v2(0,0); - this.adhesive = cc.v2(0,0); + this.stacking = cc.v2(0, 0); + this.adhesive = cc.v2(0, 0); this.adhesiveNode = []; this.collider = this.node.getComponent(cc.PolygonCollider); this.over = false; @@ -164,7 +164,7 @@ export default class Block extends cc.Component { } - start () { + start() { } @@ -172,9 +172,9 @@ export default class Block extends cc.Component { return JSON.parse(JSON.stringify(obj)); } //createAd 为是否创建粘合快图片 - init(block_Info,posX,posY,node,createAd){ + init(block_Info, posX, posY, node, createAd) { this.block_Info = this.jsonDeepClone(block_Info); - if(node) this.block_Info.node = node; + if (node) this.block_Info.node = node; this.type = block_Info.type; this.color = block_Info.color; this.blockId = block_Info.id; @@ -188,23 +188,23 @@ export default class Block extends cc.Component { this.initColor(); this.initType(); this.initBlocks(); - if(this.type != BlockType.叠加块上){ + if (this.type != BlockType.叠加块上) { this.node.on(cc.Node.EventType.TOUCH_START, this.touchStart, this); this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this); this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEnd, this); this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this); this.node['_touchListener'].setSwallowTouches(false); setTimeout(() => { - if(this.type == BlockType.粘合块){ - // 计算位置偏移 + if (this.type == BlockType.粘合块) { + // 计算位置偏移 const posOffset = cc.v2( this.node.x - this.block_Info.node.x, this.node.y - this.block_Info.node.y ); - if(createAd){ - if(this.node.zIndex >= this.block_Info.node.zIndex) + if (createAd) { + if (this.node.zIndex >= this.block_Info.node.zIndex) this.createAdhesive(); - else + else this.block_Info.node.getComponent("Block").createAdhesive(); } const targetNames = ['top', 'down', 'left', 'right']; @@ -220,7 +220,7 @@ export default class Block extends cc.Component { relativePos.x - posOffset.x, relativePos.y - posOffset.y ); - } + } }); this.adhesive = posOffset; @@ -230,25 +230,25 @@ export default class Block extends cc.Component { let mapInfo = MapConroler._instance.mapInfo; - for(let i=0; i 0){ - for(let i=0; i 0) { + for (let i = 0; i < this.adhesiveNode.length; i++) { let adhesive = this.adhesiveNode[i]; adhesive.getComponent("Adhesive").remove(); } @@ -429,8 +429,8 @@ export default class Block extends cc.Component { } //方块落点 - blockFall(point){ - if(this.over == true) return; + blockFall(point) { + if (this.over == true) return; // // 假设 MapConroler 有网格信息,这里简单示例 const mapWidth = MapConroler._instance.mapWidth; const mapHeight = MapConroler._instance.mapHeight; @@ -463,44 +463,44 @@ export default class Block extends cc.Component { this.block_Info.node.y = this.node.y - this.adhesive.y; } } - else if(this.type == 1){ + else if (this.type == 1) { this.block_Info.node.getComponent("Block").moveStack = false; this.block_Info.node.x = this.node.x + this.block_Info.node.getComponent("Block").stacking.x; this.block_Info.node.y = this.node.y + this.block_Info.node.getComponent("Block").stacking.y; } } } - - let jg = MapConroler._instance.checkPass(this.node,this.allBlocks); - if(jg >= 0){ + let jg = MapConroler._instance.checkPass(this.node, this.allBlocks); + + if (jg >= 0) { this.over = true; MapConroler._instance.changeState(); this.removeBoxCollider(); this.removeMapBlock(); this.removeAction(jg); } - else{ + else { MapConroler._instance.upDoor(this.color); - this.setVibrate("medium",1) + this.setVibrate("medium", 1) //@ts-ignore } } - removeBoxCollider(){ - for(let i=0; i0?1:-1,scaleY:scaleY>0?1:-1}) - .start(); + .to(0.3, { position: pos, scaleX: scaleX > 0 ? 1 : -1, scaleY: scaleY > 0 ? 1 : -1 }) + .start(); } - else if(this.type == BlockType.粘合块){ + else if (this.type == BlockType.粘合块) { this.removeAdhesive(); this.block_Info.node.getComponent("Block").removeAdhesive(); this.block_Info.node.getComponent("Block").restoreNomal(this.block_Info.node.getComponent("Block").posX, - this.block_Info.node.getComponent("Block").posY,false); + this.block_Info.node.getComponent("Block").posY, false); this.block_Info.node = null; } - else if(this.type == BlockType.炸弹块){ + else if (this.type == BlockType.炸弹块) { this.node.getChildByName("boom").getComponent("Boom").destroyBoom(false); } - + let time = 0.33; // this.node.zIndex = 0; let width = Math.floor(this.node.width / 120); @@ -548,44 +548,44 @@ export default class Block extends cc.Component { setTimeout(() => { - cc.fx.AudioManager._instance.playEffect("xiaochu",null); - }, 300 ); - this.setVibrate("light",3) + cc.fx.AudioManager._instance.playEffect("xiaochu", null); + }, 300); + this.setVibrate("light", 3) - if(diraction == 0){ - time = 0.33*height; + if (diraction == 0) { + time = 0.33 * height; // time = 0.99; - for(let i=0; i { let tempColor = this.color; setTimeout(() => { - MapConroler._instance.upDoor(tempColor); + MapConroler._instance.upDoor(tempColor); }, 250); MapConroler._instance.nextLevel(); @@ -603,43 +603,43 @@ export default class Block extends cc.Component { // this.node.active = false; // this.node.removeFromParent(); - }, time*1000); + }, time * 1000); } - - touchStart(event){ - if(this.over || MapConroler._instance.gameOver) return; + + touchStart(event) { + if (this.over || MapConroler._instance.gameOver) return; // 返回世界坐标 let touchLoc = event.getLocation(); // https://docs.cocos.com/creator/api/zh/classes/Intersection.html 检测辅助类 // let pos = this.collider.world.points - if(!this.collider.world){ + if (!this.collider.world) { return; } // 判断触摸点是否在多边形内 if (cc.Intersection.pointInPolygon(touchLoc, this.collider.world.points)) { - if(MapConroler._instance.hammer){ + if (MapConroler._instance.hammer) { this.eliminate(); this.isTouch = false; MapConroler._instance.hammerMask.active = false; MapConroler._instance.node.parent.getChildByName("Bottom").getChildByName("destroyBtn").getComponent("btnControl").setTouch(true); return false; - } - if(this.type != BlockType.上锁块 && this.type != BlockType.冻结块){ + } + if (this.type != BlockType.上锁块 && this.type != BlockType.冻结块) { MapConroler._instance.startUpdate(); - cc.fx.AudioManager._instance.playEffect("hit",null); + cc.fx.AudioManager._instance.playEffect("hit", null); this.node.zIndex = 200; - if(this.type == 9){ - if(this.block_Info.node){ + if (this.type == 9) { + if (this.block_Info.node) { this.block_Info.node.zIndex = 200; this.block_Info.node.getComponent("Block").hit.active = true; - MapConroler._instance.downDoor(this.block_Info.node.getComponent("Block").color,this.block_Info.node.getComponent("Block").type); + MapConroler._instance.downDoor(this.block_Info.node.getComponent("Block").color, this.block_Info.node.getComponent("Block").type); } } - else if(this.type == 1){ + else if (this.type == 1) { this.block_Info.node.getComponent("Block").moveStack = true; } @@ -650,14 +650,14 @@ export default class Block extends cc.Component { this.moveLeft = this.moveRight = this.moveUp = this.moveDown = true; this.isTouch = true; this.moveCorner = 0; - this.relative_Position = cc.v2(this.node.x-local.x,this.node.y-local.y); - MapConroler._instance.changeRiseFall(this.color,true); - MapConroler._instance.downDoor(this.color,this.type); - this.setVibrate("light",1) - if(this.hit) this.hit.active = true; + this.relative_Position = cc.v2(this.node.x - local.x, this.node.y - local.y); + MapConroler._instance.changeRiseFall(this.color, true); + MapConroler._instance.downDoor(this.color, this.type); + this.setVibrate("light", 1) + if (this.hit) this.hit.active = true; return true; } - else{ + else { this.isTouch = false; return false; } @@ -669,32 +669,32 @@ export default class Block extends cc.Component { } - touchEnd(event){ - if(MapConroler._instance.gameOver) return; - if(this.isTouch){ + touchEnd(event) { + if (MapConroler._instance.gameOver) return; + if (this.isTouch) { this.touchDelta = cc.v2(0, 0); this.checkCollision = false; - MapConroler._instance.changeRiseFall(this.color,false); - cc.fx.AudioManager._instance.playEffect("down",null); + MapConroler._instance.changeRiseFall(this.color, false); + cc.fx.AudioManager._instance.playEffect("down", null); MapConroler._instance.removeOneBlock(); this.isTouch = false; this.node.zIndex = this.level; this.hit.active = false; - if(this.type == 9){ - if(this.block_Info.node){ + if (this.type == 9) { + if (this.block_Info.node) { this.block_Info.node.getComponent("Block").hit.active = false; // this.block_Info.node.getComponent("Block").isTouch = false; } } this.touchPoint = event.getLocation(); - let local = cc.v2(this.node.x - 50,this.node.y + 50 ); - if(this.type != 10){ + let local = cc.v2(this.node.x - 50, this.node.y + 50); + if (this.type != 10) { //@ts-ignore this.blockFall(local); - if(this.type == 9){ - if(this.block_Info.node){ - let localTemp = cc.v2(this.block_Info.node.x-50,this.block_Info.node.y+50); + if (this.type == 9) { + if (this.block_Info.node) { + let localTemp = cc.v2(this.block_Info.node.x - 50, this.block_Info.node.y + 50); this.block_Info.node.getComponent("Block").blockFall(localTemp); } } @@ -702,11 +702,11 @@ export default class Block extends cc.Component { this.moveLeft = this.moveRight = this.moveUp = this.moveDown = true; } - + } touchMove(event: cc.Event.EventTouch) { - if(MapConroler._instance.gameOver) return; + if (MapConroler._instance.gameOver) return; // const currentTime = Date.now(); // // 如果距离上次移动时间小于间隔时间,直接返回 // if (currentTime - this.lastMoveTime < this.moveInterval) { @@ -721,38 +721,38 @@ export default class Block extends cc.Component { this.touchPointX = local.x; this.touchPointY = local.y; delta.x = this.touchPointX - this.node.x + this.relative_Position.x; - delta.y = this.touchPointY - this.node.y + this.relative_Position.y; + delta.y = this.touchPointY - this.node.y + this.relative_Position.y; // 限制移动速度 this.touchPointX = local.x; this.touchPointY = local.y; delta.x = this.touchPointX - this.node.x + this.relative_Position.x; - delta.y = this.touchPointY - this.node.y + this.relative_Position.y; + delta.y = this.touchPointY - this.node.y + this.relative_Position.y; // 限制移动速度 delta.x = Math.max(-this.maxSpeed, Math.min(this.maxSpeed, delta.x)); delta.y = Math.max(-this.maxSpeed, Math.min(this.maxSpeed, delta.y)); // 记录触摸移动的增量 - this.touchDelta = delta; + this.touchDelta = delta; } } //超出限制判断 - exceeds(stepx,stepy){ - + exceeds(stepx, stepy) { + } - eliminate(){ + eliminate() { //锤子状态消失 MapConroler._instance.pause = true; - if(MapConroler._instance.hammer == true) MapConroler._instance.hammer = false; + if (MapConroler._instance.hammer == true) MapConroler._instance.hammer = false; //如果方块是有特殊状态,则特殊处理 - if(this.type == BlockType.冻结块){ + if (this.type == BlockType.冻结块) { this.node.getChildByName("freeze").getComponent("Freeze").reduce(2); return; } - else if(this.type == BlockType.上锁块){ + else if (this.type == BlockType.上锁块) { this.node.getChildByName("lock").getComponent("Lock").reduce(); return; } @@ -766,26 +766,26 @@ export default class Block extends cc.Component { MapConroler._instance.judgeWin(1); setTimeout(() => { let pos = this.node.getPosition(); - if(self.type == BlockType.叠加块下){ + if (self.type == BlockType.叠加块下) { let scaleX = self.node.scaleX; let scaleY = self.node.scaleY; - self.block_Info.node.getComponent("Block").restoreNomal(this.posX,this.posY,true); + self.block_Info.node.getComponent("Block").restoreNomal(this.posX, this.posY, true); cc.tween(self.block_Info.node) - .to(0.1,{position:pos,scaleX:scaleX>0?1:-1,scaleY:scaleY>0?1:-1}) - .start(); + .to(0.1, { position: pos, scaleX: scaleX > 0 ? 1 : -1, scaleY: scaleY > 0 ? 1 : -1 }) + .start(); } - else if(self.type == BlockType.粘合块){ + else if (self.type == BlockType.粘合块) { self.block_Info.node.getComponent("Block").restoreNomal(self.block_Info.node.getComponent("Block").posX, - self.block_Info.node.getComponent("Block").posY,false); + self.block_Info.node.getComponent("Block").posY, false); } - else if(self.type == BlockType.炸弹块){ + else if (self.type == BlockType.炸弹块) { this.node.getChildByName("boom").getComponent("Boom").destroyBoom(false); } MapConroler._instance.nextLevel(); this.node.active = false; this.node.removeFromParent(); - //如果是锤子状态消除 + //如果是锤子状态消除 // if (!MapConroler._instance.ishammer) { // // 记录添加magic时的锚点 @@ -838,24 +838,24 @@ export default class Block extends cc.Component { }, 200); } - - setVibrate(type, count){ + + setVibrate(type, count) { // return; // console.log("最新:",cc.fx.GameConfig.GM_INFO.vibrateOpen,type); - if(!cc.fx.GameConfig.GM_INFO.vibrateOpen){ + if (!cc.fx.GameConfig.GM_INFO.vibrateOpen) { return; } - if(count == 1){ + if (count == 1) { //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // 判断是否在微信环境 //@ts-ignore wx.vibrateShort({ type: type, success: () => { - console.log("震动成功1111111111") + // console.log("震动成功1111111111") }, fail: (err) => { - console.log("震动失败1111111111",err); + // console.log("震动失败1111111111",err); } }); } else { @@ -863,7 +863,7 @@ export default class Block extends cc.Component { return; } let time = 150; - for(let i=0; i<4; i++){ + for (let i = 0; i < 4; i++) { setTimeout(() => { //@ts-ignore if (typeof wx !== 'undefined' && wx !== null) { // 判断是否在微信环境 @@ -871,50 +871,50 @@ export default class Block extends cc.Component { wx.vibrateShort({ type: type, success: () => { - console.log("震动成功222222222") + // console.log("震动成功222222222") }, fail: (err) => { - console.log("震动失败222222222",err); + // console.log("震动失败222222222", err); } }); } else { } - }, time*i); + }, time * i); } } - setMoveCorner(diraction){ + setMoveCorner(diraction) { return; } cmupdate() { - let cm:any = cc.director.getCollisionManager(); + let cm: any = cc.director.getCollisionManager(); cm.update(); } - restoreNomal(posX,posY,type){ + restoreNomal(posX, posY, type) { this.type = 0; this.block_Info.node = null; - this.moveStack = false; + this.moveStack = false; this.posX = posX; this.posY = posY; this.setMapBlock(); - this.level = 50 + this.posX - this.posY*3; + this.level = 50 + this.posX - this.posY * 3; this.node.zIndex = this.level; let j = 1000; - for(let i =0; i< this.node.children.length; i++){ - if(this.node.children[i].name == "New Node"){ + for (let i = 0; i < this.node.children.length; i++) { + if (this.node.children[i].name == "New Node") { j = i; } - if(i > j){ + if (i > j) { this.node.children[i].active = false; } } - if(type){ - for(let i=0; i 0){ - for(let i=0; i 0) { + for (let i = 0; i < this.allBlocks.length; i++) { let pos = this.allBlocks[i]; let x = this.posX + pos.x; - let y = this.posY + pos.y; + let y = this.posY + pos.y; MapConroler._instance.mapBlocksWall[x][y].getComponent("MapBlock").block_Id = this.node.uuid; } } } - removeMapBlock(){ - if(this.posX == 0 && this.posY == 0){ + removeMapBlock() { + if (this.posX == 0 && this.posY == 0) { return; } - if(this.allBlocks){ - if(this.allBlocks.length > 0){ - for(let i=0; i 0) { + for (let i = 0; i < this.allBlocks.length; i++) { + if (this.allBlocks[i]) { let pos = this.allBlocks[i]; let x = this.posX + pos.x; - let y = this.posY + pos.y; - if(MapConroler._instance.mapBlocksWall[x][y]){ - if(MapConroler._instance.mapBlocksWall[x][y].getComponent("MapBlock")) + let y = this.posY + pos.y; + if (MapConroler._instance.mapBlocksWall[x][y]) { + if (MapConroler._instance.mapBlocksWall[x][y].getComponent("MapBlock")) MapConroler._instance.mapBlocksWall[x][y].getComponent("MapBlock").block_Id = ""; } } - } - } + } + } } } //叠加块,位置差异,校准位置 - getStackingPos(){ - switch(this.node.name){ + getStackingPos() { + switch (this.node.name) { case "block0": - return cc.v2(-21,22); + return cc.v2(-21, 22); case "block1": - return cc.v2(-36,23); + return cc.v2(-36, 23); case "block2": - return cc.v2(-18,40); + return cc.v2(-18, 40); case "block3": - return cc.v2(-59,25); + return cc.v2(-59, 25); case "block4": - return cc.v2(-19,57); + return cc.v2(-19, 57); case "block5": - return cc.v2(-36,38); + return cc.v2(-36, 38); case "block6": - return cc.v2(-19,97); + return cc.v2(-19, 97); case "block7": - return cc.v2(-19,61); + return cc.v2(-19, 61); case "block8": - return cc.v2(-55,24); + return cc.v2(-55, 24); case "block9": - return cc.v2(-20,24); + return cc.v2(-20, 24); case "block10": - return cc.v2(-17,96); + return cc.v2(-17, 96); case "block11": - return cc.v2(-17,58); + return cc.v2(-17, 58); case "block12": - return cc.v2(-20,24); + return cc.v2(-20, 24); case "block13": - return cc.v2(-92,25); + return cc.v2(-92, 25); case "block14": - return cc.v2(-18,60); + return cc.v2(-18, 60); case "block15": - return cc.v2(-58,24); + return cc.v2(-58, 24); case "block16": - return cc.v2(-20,60); + return cc.v2(-20, 60); case "block17": - return cc.v2(-17,60); + return cc.v2(-17, 60); case "block18": - return cc.v2(-17,60); + return cc.v2(-17, 60); case "block19": - return cc.v2(-20,24); + return cc.v2(-20, 24); case "block20": - return cc.v2(-54,25); + return cc.v2(-54, 25); case "block21": - return cc.v2(-17,60); + return cc.v2(-17, 60); case "block22": - return cc.v2(-17,60); + return cc.v2(-17, 60); } } - update (dt: number) { + update(dt: number) { if (this.isTouch && this.touchDelta.mag() > 0) { - //this.moveLeft = this.moveRight = this.moveUp = this.moveDown = true; - const delta = this.touchDelta; - const newX = this.node.x + delta.x; - const newY = this.node.y + delta.y; - const distance = Math.sqrt(Math.pow(newX - this.node.x, 2) + Math.pow(newY - this.node.y, 2)); - let mag = Math.round(delta.mag()); + //this.moveLeft = this.moveRight = this.moveUp = this.moveDown = true; + const delta = this.touchDelta; + const newX = this.node.x + delta.x; + const newY = this.node.y + delta.y; + const distance = Math.sqrt(Math.pow(newX - this.node.x, 2) + Math.pow(newY - this.node.y, 2)); + let mag = Math.round(delta.mag()); - if(this.moveY === 1){ - if (this.touchPointY <= this.node.y + this.node.height/2){ - this.moveY = 0; - } - } else if(this.moveY === -1){ - if (this.touchPointY >= this.node.y + this.node.height/2){ - this.moveY = 0; - } + if (this.moveY === 1) { + if (this.touchPointY <= this.node.y + this.node.height / 2) { + this.moveY = 0; } + } else if (this.moveY === -1) { + if (this.touchPointY >= this.node.y + this.node.height / 2) { + this.moveY = 0; + } + } - if(this.moveX === 1){ - if (this.touchPointX <= this.node.x - this.node.width/2){ - this.moveX = 0; - } - else{ - } - } else if(this.moveX === -1){ - if (this.touchPointX >= this.node.x - this.node.width/2){ - this.moveX = 0; - } - else{ - } + if (this.moveX === 1) { + if (this.touchPointX <= this.node.x - this.node.width / 2) { + this.moveX = 0; } - if (distance > 100) { - mag = 10; - const speedScale = 0.5; - delta.x *= speedScale; - delta.y *= speedScale; + else { + } + } else if (this.moveX === -1) { + if (this.touchPointX >= this.node.x - this.node.width / 2) { + this.moveX = 0; + } + else { + } + } + if (distance > 100) { + mag = 10; + const speedScale = 0.5; + delta.x *= speedScale; + delta.y *= speedScale; + } else { + if (mag > 5) { + mag = Math.floor(mag / 5); + } + } + + // mag = 2; + const stepx = delta.x / mag; + const stepy = delta.y / mag; + + for (let index = 0; index < mag; index++) { + this.moveCorner = 0; + const tempX = this.node.x + stepx; + const tempY = this.node.y + stepy; + + if (!this.checkCollision) { + if (this.type !== 8 && this.type !== 10) { + this.node.x = Math.round(tempX); + } + if (this.type !== 7 && this.type !== 10) { + this.node.y = Math.round(tempY); + } } else { - if (mag > 5) { - mag = Math.floor(mag / 5); - } - } + const isXMain = Math.abs(stepx) > Math.abs(stepy); + if (isXMain) { + if (this.node.x > tempX) { + if (this.moveLeft && this.moveX === 0 && this.type !== 8 && this.type !== 10) { + this.node.x = tempX; + } + if (this.moveX !== 0) { + this.moveX = 0; + } + } else if (this.node.x <= tempX) { + if (this.moveRight && this.moveX === 0 && this.type !== 8 && this.type !== 10) { + this.node.x = tempX; + } + if (this.moveX !== 0) { + this.moveX = 0; + } + } - // mag = 2; - const stepx = delta.x / mag; - const stepy = delta.y / mag; - - for (let index = 0; index < mag; index++) { - this.moveCorner = 0; - const tempX = this.node.x + stepx; - const tempY = this.node.y + stepy; - - if (!this.checkCollision) { - if(this.type !== 8 && this.type !== 10){ - this.node.x = Math.round(tempX); - } - if(this.type !== 7 && this.type !== 10){ - this.node.y = Math.round(tempY); - } + if (this.node.y > tempY) { + if (this.moveDown && this.moveY === 0 && this.type !== 7 && this.type !== 10) { + this.node.y = tempY; + } + if (this.moveY !== 0) { + this.moveY = 0; + } + } else if (this.node.y <= tempY) { + if (this.moveUp && this.moveY === 0 && this.type !== 7 && this.type !== 10) { + this.node.y = tempY; + } + if (this.moveY !== 0) { + this.moveY = 0; + } + } } else { - const isXMain = Math.abs(stepx) > Math.abs(stepy); - if (isXMain) { - if (this.node.x > tempX) { - if (this.moveLeft && this.moveX === 0 && this.type !== 8 && this.type !== 10) { - this.node.x = tempX; - } - if(this.moveX !== 0){ - this.moveX = 0; - } - } else if (this.node.x <= tempX) { - if (this.moveRight && this.moveX === 0 && this.type !== 8 && this.type !== 10) { - this.node.x = tempX; - } - if(this.moveX !== 0){ - this.moveX = 0; - } + if (this.node.y > tempY) { + if (this.moveDown && this.moveY === 0 && this.type !== 7 && this.type !== 10) { + this.node.y = tempY; } + if (this.moveY !== 0) { + this.moveY = 0; + } + } else if (this.node.y <= tempY) { + if (this.moveUp && this.moveY === 0 && this.type !== 7 && this.type !== 10) { + this.node.y = tempY; + } + if (this.moveY !== 0) { + this.moveY = 0; + } + } - if (this.node.y > tempY) { - if (this.moveDown && this.moveY === 0 && this.type !== 7 && this.type !== 10) { - this.node.y = tempY; - } - if(this.moveY !== 0){ - this.moveY = 0; - } - } else if (this.node.y <= tempY) { - if (this.moveUp && this.moveY === 0 && this.type !== 7 && this.type !== 10) { - this.node.y = tempY; - } - if(this.moveY !== 0){ - this.moveY = 0; - } + if (this.node.x > tempX) { + if (this.moveLeft && this.moveX === 0 && this.type !== 8 && this.type !== 10) { + this.node.x = tempX; } - } else { - if (this.node.y > tempY) { - if (this.moveDown && this.moveY === 0 && this.type !== 7 && this.type !== 10) { - this.node.y = tempY; - } - if(this.moveY !== 0){ - this.moveY = 0; - } - } else if (this.node.y <= tempY) { - if (this.moveUp && this.moveY === 0 && this.type !== 7 && this.type !== 10) { - this.node.y = tempY; - } - if(this.moveY !== 0){ - this.moveY = 0; - } + if (this.moveX !== 0) { + this.moveX = 0; } - - if (this.node.x > tempX) { - if (this.moveLeft && this.moveX === 0 && this.type !== 8 && this.type !== 10) { - this.node.x = tempX; - } - if(this.moveX !== 0){ - this.moveX = 0; - } - } else if (this.node.x <= tempX) { - if (this.moveRight && this.moveX === 0 && this.type !== 8 && this.type !== 10) { - this.node.x = tempX; - } - if(this.moveX !== 0){ - this.moveX = 0; - } + } else if (this.node.x <= tempX) { + if (this.moveRight && this.moveX === 0 && this.type !== 8 && this.type !== 10) { + this.node.x = tempX; + } + if (this.moveX !== 0) { + this.moveX = 0; } } } - LQCollideSystem.update_logic(dt); } - // 移动完成后重置触摸增量 - this.touchDelta = cc.v2(0, 0); - + LQCollideSystem.update_logic(dt); + } + // 移动完成后重置触摸增量 + this.touchDelta = cc.v2(0, 0); + } - if(this.type == BlockType.叠加块下){ - if(this.block_Info.node!= null){ - if(this.block_Info.node.getComponent("Block").moveStack == true){ + if (this.type == BlockType.叠加块下) { + if (this.block_Info.node != null) { + if (this.block_Info.node.getComponent("Block").moveStack == true) { this.block_Info.node.x = this.node.x + this.block_Info.node.getComponent("Block").stacking.x; this.block_Info.node.y = this.node.y + this.block_Info.node.getComponent("Block").stacking.y; } } } - if(this.block_Info){ - if(this.block_Info.node != null){ - if(this.type == BlockType.粘合块){ - if(this.adhesive.x !=0 && this.adhesive.y!=0 && this.block_Info.node!= null){ - this.block_Info.node.x = this.node.x - this.adhesive.x; - this.block_Info.node.y = this.node.y - this.adhesive.y; - } - if(this.isTouch == true && this.block_Info.node.getComponent("Block").isTouch == false){ - LQCollideSystem.update_logic(dt); - this.block_Info.node.x = this.node.x - this.adhesive.x; - this.block_Info.node.y = this.node.y - this.adhesive.y; - } + if (this.block_Info) { + if (this.block_Info.node != null) { + if (this.type == BlockType.粘合块) { + if (this.adhesive.x != 0 && this.adhesive.y != 0 && this.block_Info.node != null) { + this.block_Info.node.x = this.node.x - this.adhesive.x; + this.block_Info.node.y = this.node.y - this.adhesive.y; } + if (this.isTouch == true && this.block_Info.node.getComponent("Block").isTouch == false) { + LQCollideSystem.update_logic(dt); + this.block_Info.node.x = this.node.x - this.adhesive.x; + this.block_Info.node.y = this.node.y - this.adhesive.y; + } + } } } } //精细更改 点击高亮位置 - setHitPosition(){ - this.hit.setPosition(13,-16); - switch(this.block_Info.block){ + setHitPosition() { + this.hit.setPosition(13, -16); + switch (this.block_Info.block) { case 0: - this.hit.setPosition(15,-20); - break; + this.hit.setPosition(15, -20); + break; case 1: - this.hit.setPosition(13,-17.5); + this.hit.setPosition(13, -17.5); break; case 2: - this.hit.setPosition(15,-16); + this.hit.setPosition(15, -16); break; case 4: - this.hit.setPosition(12,-18); + this.hit.setPosition(12, -18); break; case 6: - this.hit.setPosition(15,-14); + this.hit.setPosition(15, -14); break; case 7: - this.hit.setPosition(17,-9); + this.hit.setPosition(17, -9); break; case 8: - this.hit.setPosition(15,-14); + this.hit.setPosition(15, -14); break; case 9: - this.hit.setPosition(13,-13); + this.hit.setPosition(13, -13); break; case 10: - this.hit.setPosition(-5.5,-14); + this.hit.setPosition(-5.5, -14); break; case 11: - this.hit.setPosition(-6,-15); + this.hit.setPosition(-6, -15); break; case 12: - this.hit.setPosition(15,-15); + this.hit.setPosition(15, -15); break; case 13: - this.hit.setPosition(15,-13); + this.hit.setPosition(15, -13); break; case 13: - this.hit.setPosition(15,-14); + this.hit.setPosition(15, -14); break; case 14: - this.hit.setPosition(2,-7); + this.hit.setPosition(2, -7); break; case 15: - this.hit.setPosition(15,-16); + this.hit.setPosition(15, -16); break; case 16: - this.hit.setPosition(1,-15.5); + this.hit.setPosition(1, -15.5); break; case 17: - this.hit.setPosition(15,-14); + this.hit.setPosition(15, -14); break; case 18: - this.hit.setPosition(5,-13); + this.hit.setPosition(5, -13); break; case 21: - this.hit.setPosition(-2,-14); + this.hit.setPosition(-2, -14); break; case 22: - this.hit.setPosition(14,-14); + this.hit.setPosition(14, -14); break; } } diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index 7ff4483..8190fcc 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -39,6 +39,7 @@ export default class GameManager extends cc.Component { load3: boolean = false; load4: boolean = false; load5: boolean = false; + load6: boolean = false; scheduleCallback: any; timeNumber: number; @@ -55,7 +56,7 @@ export default class GameManager extends cc.Component { this.readMusicConfig(); - this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = false; + this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = this.load6 = false; setTimeout(() => { this.readUserData(); }, 200); @@ -214,6 +215,11 @@ export default class GameManager extends cc.Component { MiniGameSdk.API.shushu_Init(); Utils.getUserInfo((data) => { console.log("登陆成功", data); + if (data.outTradeNo.length > 0) { + console.log("______________________________有未发放奖励"); + cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.outTradeNo; + } + this.load6 = true; }); let levelInfo = cc.fx.StorageMessage.getStorage("level"); //旧的读取数据设置数据方法,以强联网为主 @@ -235,6 +241,7 @@ export default class GameManager extends cc.Component { this.load3 = true; this.load4 = true; this.load5 = true; + this.load6 = true; cc.fx.GameTool.getHealth(null); } // 存储用户数据 @@ -682,7 +689,7 @@ export default class GameManager extends cc.Component { } update(dt) { - if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0) { + if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.load6 == true && this.timeNumber <= 0) { this.load1 = this.load2 = false; MiniGameSdk.API.shushu_Login(); MiniGameSdk.API.yinli_Init(); diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index 58936a1..eef19d7 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -247,7 +247,7 @@ export default class MapConroler extends cc.Component { this.add_Time = 0; NumberToImage.getTimeMargin(this.timeNumber, 50, "time_", this.timeLabel) - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + this.updateCoin(); // var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber); // this.timeLabel.string = timeTemp.toString(); NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 50, 20, "level_", this.levelLabel, true) @@ -1520,7 +1520,8 @@ export default class MapConroler extends cc.Component { } cc.fx.GameTool.shushu_Track("resource_cost", dataTemp); MiniGameSdk.API.showToast("继续游戏"); - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + this.updateCoin(); + // NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); if (data.type == "time") { if (cc.fx.GameConfig.GM_INFO.review < 2) cc.fx.GameConfig.GM_INFO.review += 1; @@ -1791,7 +1792,8 @@ export default class MapConroler extends cc.Component { } handleBuySuccess(data) { - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + this.node.parent.parent.parent.getComponent("SceneManager").resetBtn(); + this.updateCoin(); this.pause = false; this.startBoom(); const timestamp = Date.now(); @@ -1850,6 +1852,10 @@ export default class MapConroler extends cc.Component { } + updateCoin() { + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); + } + //使用锤子道具 useHammer() { if (this.node.parent.getChildByName("Ice").active == true || this.hammer == true @@ -1899,6 +1905,7 @@ export default class MapConroler extends cc.Component { buyMagic() { if (cc.fx.GameConfig.GM_INFO.coin < 1500) { MiniGameSdk.API.showToast("金币不足,无法购买道具"); + this.node.parent.parent.parent.getComponent("SceneManager").resetBtn(); setTimeout(() => { this.openShop(); }, 500); @@ -1910,6 +1917,7 @@ export default class MapConroler extends cc.Component { buyHammer() { if (cc.fx.GameConfig.GM_INFO.coin < 1000) { MiniGameSdk.API.showToast("金币不足,无法购买道具"); + this.node.parent.parent.parent.getComponent("SceneManager").resetBtn(); setTimeout(() => { this.openShop(); }, 500); @@ -1921,6 +1929,7 @@ export default class MapConroler extends cc.Component { buyFreeze() { if (cc.fx.GameConfig.GM_INFO.coin < 1500) { MiniGameSdk.API.showToast("金币不足,无法购买道具"); + this.node.parent.parent.parent.getComponent("SceneManager").resetBtn(); setTimeout(() => { this.openShop(); }, 500); diff --git a/assets/Script/SceneManager.ts b/assets/Script/SceneManager.ts index 9676086..8fc200b 100644 --- a/assets/Script/SceneManager.ts +++ b/assets/Script/SceneManager.ts @@ -96,10 +96,10 @@ export default class SceneManager extends cc.Component { }, 1000); } -//更新关卡获得金币 + //更新关卡获得金币 updateWinCoin() { console.log("更新关卡获得金币"); - let winCoin = 40; + let winCoin = 40; if (winCoin > 0) { NumberToImage.numberToImageNodes(winCoin, 50, 8, "time_", this.winCoin, false); } else { @@ -117,8 +117,8 @@ export default class SceneManager extends cc.Component { } this.node.getChildByName("Game").getChildByName("bg").getComponent(cc.Sprite).spriteFrame = spriteFrame; }) - - NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level+1), 43, 15, "level_", this.level, true); + + NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true); //time金币数量 NumberToImage.numberToImageNodes(1000, 25, 15, "button_", this.timeCoin, false); } @@ -189,7 +189,7 @@ export default class SceneManager extends cc.Component { returnHome() { if (this.node.getChildByName("Pause").getChildByName("btn").getComponent("btnControl")._touch) { - this.closePause(); + this.closePause(); if (MapConroler._instance.gameStart == true) { MiniGameSdk.API.showToast("体力值减少"); // cc.fx.GameTool.setUserHealth(-1, (data) => { @@ -217,7 +217,7 @@ export default class SceneManager extends cc.Component { } }); - + setTimeout(() => { cc.director.loadScene("HomeScene"); }, 1200); @@ -269,7 +269,7 @@ export default class SceneManager extends cc.Component { } } - closeShop(){ + closeShop() { if (this.shopNode) { this.shopNode.active = false; } @@ -288,7 +288,7 @@ export default class SceneManager extends cc.Component { openPropBuy(name) { MapConroler._instance.pause = true; MapConroler._instance.stopBoom(); - + this.btnName = name; let propWindow = this.node.getChildByName("Game").getChildByName("propWindow"); propWindow.active = true; @@ -320,6 +320,12 @@ export default class SceneManager extends cc.Component { MapConroler._instance.buyMagic(); } } + + resetBtn() { + let propWindow = this.node.getChildByName("Game").getChildByName("propWindow"); + propWindow.getChildByName("buy_Btn").getComponent("btnControl").setTouch(true); + } + //打开商店 openShop() { if (!SceneManager.cachedShopPrefab) { @@ -338,6 +344,10 @@ export default class SceneManager extends cc.Component { // console.log("shopNode parent:", this.shopNode.parent); } + updateCoin() { + MapConroler._instance.updateCoin(); + } + closePropBuy() { MapConroler._instance.pause = false; diff --git a/assets/Script/Sdk/MiniGameSdk.ts b/assets/Script/Sdk/MiniGameSdk.ts index b85c88b..bb4b505 100644 --- a/assets/Script/Sdk/MiniGameSdk.ts +++ b/assets/Script/Sdk/MiniGameSdk.ts @@ -1127,7 +1127,7 @@ export namespace MiniGameSdk { }, // 根据环境变量设置 debug 模式 debug: !isProduction, - enableLog: true + enableLog: false }; // 创建 TA 实例 API._ta = new ThinkingAnalyticsAPI(config); @@ -1173,7 +1173,7 @@ export namespace MiniGameSdk { static updateCoinAndLevel() { if (typeof wx !== 'undefined' && wx !== null) { console.log("上传金币和关卡信息给数数") - API._ta.userSet({ current_level: cc.fx.GameConfig.GM_INFO.level }); + API._ta.userSet({ current_level: (cc.fx.GameConfig.GM_INFO.level + 1) }); API._ta.userSet({ current_coin: cc.fx.GameConfig.GM_INFO.coin }); } } diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index dcafb75..c4d402d 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -84,6 +84,7 @@ export class GameConfig { score: number; //总得分 scale: number; //玩家总计成功点火数 iosOutTradeNo: string; //ios订单号 + allOutTradeNo: any[]; //订单号数组 min_Time: number; //体力恢复的剩余时间 freezeAmount: number; //冻结道具次数 hammerAmount: number; //锤子道具次数 @@ -99,6 +100,7 @@ export class GameConfig { }; + //游戏内信息 static get Instance() { @@ -221,6 +223,7 @@ export class GameConfig { score: 0, //总得分 scale: 1, //玩家总计成功点火数 iosOutTradeNo: "", //ios订单号 + allOutTradeNo: [], //订单号数组 min_Time: 0, //体力恢复的剩余时间 freezeAmount: 0, //冻结道具次数 hammerAmount: 0, //锤子道具次数 diff --git a/assets/Script/module/Pay/Utils.ts b/assets/Script/module/Pay/Utils.ts index 7209c79..bc788af 100644 --- a/assets/Script/module/Pay/Utils.ts +++ b/assets/Script/module/Pay/Utils.ts @@ -1,3 +1,5 @@ +import { MiniGameSdk } from "../../Sdk/MiniGameSdk"; + export default class Utils { static uid: string = ""; static session_key = ""; @@ -19,7 +21,7 @@ export default class Utils { Utils.openid = ret.data.openid; Utils.session_key = ret.data.session_key; Utils.uid = ret.data._id; - callBack(Utils.uid); + callBack(ret); }) } else { console.log('登录失败!' + res.errMsg) @@ -35,19 +37,33 @@ export default class Utils { Utils.POST("wx/orderPaySig", { uid: Utils.uid, itemid: id, itemCount: count, itemPrice: price }, res => { if (res.code == 1) { Utils.outTradeNo = res.data.outTradeNo; + // let timeoutId: number; + // const timeoutDuration = 30000; // 30 秒超时时间 + // // 设置超时定时器 + // timeoutId = setTimeout(() => { + // console.error('支付请求超时'); + // callBack("请求支付超时"); + // }, timeoutDuration); //@ts-ignore wx.requestMidasPaymentGameItem({ signData: res.data.signData, paySig: res.data.paySig, signature: res.data.signature, success(res, errCode) { + // clearTimeout(timeoutId); // 清除超时定时器 console.log('成功', res, errCode); callBack(res); }, fail({ errMsg, errCode }) { - console.error('失败'); - console.error(errMsg, errCode) - callBack(null); + // clearTimeout(timeoutId); // 清除超时定时器 + console.log('失败'); + console.log(errMsg, errCode) + let data = { + errMsg: errMsg, + errCode: errCode, + err: "请求支付失败", + } + callBack(data); } }) } @@ -57,11 +73,12 @@ export default class Utils { } static getPayInfo(callBack) { - const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组 + const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组 let attempt = 0; // 轮询次数 const poll = () => { if (attempt >= delays.length) { + MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励"); callBack({ code: 0, data: { pay_state: -1 }, message: '轮询超时' }); return; } @@ -83,7 +100,7 @@ export default class Utils { } static setPayInfo(callBack) { - const delays = [1000, 5000, 10000, 20000, 30000]; // 延迟时间数组 + const delays = [1000, 3000, 3000, 3000, 3000];// 延迟时间数组 let attempt = 0; // 重试次数 const sendRequest = () => { if (attempt > delays.length) { @@ -134,11 +151,12 @@ export default class Utils { }); } static getIosPayInfo(callBack) { - const delays = [1000, 10000, 30000, 60000, 60000]; // 延迟时间数组 + const delays = [1000, 3000, 3000, 3000, 3000]; // 延迟时间数组 let attempt = 0; // 轮询次数 const poll = () => { if (attempt >= delays.length) { + MiniGameSdk.API.showToast("网络异常,如充值成功,重进游戏可领取奖励"); callBack({ code: 0, data: null, message: '轮询超时' }); return; } diff --git a/assets/UI/UI/pop/gameui.png.meta b/assets/UI/UI/pop/gameui.png.meta index 80dc9f6..88b3a84 100644 --- a/assets/UI/UI/pop/gameui.png.meta +++ b/assets/UI/UI/pop/gameui.png.meta @@ -8,8 +8,8 @@ "premultiplyAlpha": false, "genMipmaps": false, "packable": true, - "width": 2042, - "height": 1680, + "width": 2025, + "height": 1420, "platformSettings": {}, "subMetas": {} } \ No newline at end of file diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index 18e7938..9bab84a 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -139,7 +139,7 @@ export default class NewClass extends cc.Component { } onShow() { - if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null) { + if (cc.fx.GameConfig.GM_INFO.iosOutTradeNo != null && cc.fx.GameConfig.GM_INFO.iosOutTradeNo != "") { console.log("有苹果订单号,开始轮训"); Utils.getIosPayInfo((data) => { console.log("获得轮训结果:", data); @@ -254,9 +254,9 @@ export default class NewClass extends cc.Component { // Utils.GoKEFu(); if (systemType == "ios") { - MiniGameSdk.API.showToast("IOS系统暂不支持支付"); - this.btn_Touch = true; - // Utils.GoKEFu(); + // MiniGameSdk.API.showToast("IOS系统暂不支持支付"); + // this.btn_Touch = true; + Utils.GoKEFu(); } else { const data = { @@ -267,11 +267,11 @@ export default class NewClass extends cc.Component { type: systemType, } cc.fx.GameTool.shushu_Track("init_order", data); - + console.log("7.14_____________________", "调用充值接口"); Utils.buyProp(id, count, price, (res) => { console.log("获得充值结果", res); if (res == null) { - MiniGameSdk.API.showToast("网络异常,充值失败请稍后再试"); + MiniGameSdk.API.showToast("充值失败"); this.btn_Touch = true; const dataFail = { outTradeNo: Utils.outTradeNo, @@ -284,13 +284,32 @@ export default class NewClass extends cc.Component { cc.fx.GameTool.shushu_Track("payment_fail", dataFail); return; } + else if (res.err) { + MiniGameSdk.API.showToast("充值失败"); + console.log(res); + this.btn_Touch = true; + let name = "支付拉起失败"; + if (res.errCode == -2) { + name = "用户取消充值"; + } + const dataFail = { + outTradeNo: Utils.outTradeNo, + price: price, + payment_name: productId, + payment_num: 1, + type: systemType, + fail_reason: name, + } + cc.fx.GameTool.shushu_Track("payment_fail", dataFail); + return; + } else { Utils.getPayInfo((data) => { + console.log("7.14_______________充值成功,准备轮训"); console.log("获得轮训结果:", data); if (data.data.pay_state == 1) { this.btn_Touch = true; MiniGameSdk.API.showToast("取消充值"); - const dataFail2 = { outTradeNo: Utils.outTradeNo, price: price, @@ -303,9 +322,11 @@ export default class NewClass extends cc.Component { } else if (data.data.pay_state == 2) { this.btn_Touch = true; + console.log("7.14_______________充值成功,轮训成功,准备发货"); Utils.setPayInfo((data) => { console.log("设置轮训结果:", data); if (data.code === 1) { + console.log("7.14_________正式发货"); MiniGameSdk.API.showToast("充值成功"); cc.fx.GameTool.shopBuy(productId); console.log("充值成功获得金币"); @@ -333,12 +354,16 @@ export default class NewClass extends cc.Component { cc.fx.GameTool.shushu_Track("payment_fail", dataFail4); } NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); - this.node.parent.getComponent("JiaZai").updateCoin(); + if (this.node.parent.getComponent("JiaZai")) + this.node.parent.getComponent("JiaZai").updateCoin(); + else if (this.node.parent.getComponent("SceneManager")) { + this.node.parent.getComponent("SceneManager").updateCoin(); + } + }) } else { NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true); - this.node.parent.getComponent("JiaZai").updateCoin(); const dataFail3 = { outTradeNo: Utils.outTradeNo, price: price, @@ -348,6 +373,12 @@ export default class NewClass extends cc.Component { fail_reason: "拉起支付后,付款时网络异常付款失败", } cc.fx.GameTool.shushu_Track("payment_fail", dataFail3); + this.btn_Touch = true; + if (this.node.parent.getComponent("JiaZai")) + this.node.parent.getComponent("JiaZai").updateCoin(); + else if (this.node.parent.getComponent("SceneManager")) { + this.node.parent.getComponent("SceneManager").updateCoin(); + } } }) } diff --git a/settings/project.json b/settings/project.json index e2224fc..f174634 100644 --- a/settings/project.json +++ b/settings/project.json @@ -1,5 +1,5 @@ { - "last-module-event-record-time": 1751876016726, + "last-module-event-record-time": 1752481846169, "group-list": [ "default", "Map"