增加,购买炸弹复活,修复一些界面BUG
This commit is contained in:
parent
8dfd09c993
commit
97eefaaac2
File diff suppressed because it is too large
Load Diff
|
@ -535,7 +535,7 @@ export default class Block extends cc.Component {
|
||||||
this.block_Info.node = null;
|
this.block_Info.node = null;
|
||||||
}
|
}
|
||||||
else if(this.type == BlockType.炸弹块){
|
else if(this.type == BlockType.炸弹块){
|
||||||
this.node.getChildByName("boom").getComponent("Boom").destroyBoom();
|
this.node.getChildByName("boom").getComponent("Boom").destroyBoom(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ export default class Block extends cc.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MapConroler._instance.judgeWin();
|
MapConroler._instance.judgeWin(0);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let tempColor = this.color;
|
let tempColor = this.color;
|
||||||
|
@ -761,7 +761,7 @@ export default class Block extends cc.Component {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.removeMapBlock();
|
this.removeMapBlock();
|
||||||
|
|
||||||
MapConroler._instance.judgeWin();
|
MapConroler._instance.judgeWin(1);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let pos = this.node.getPosition();
|
let pos = this.node.getPosition();
|
||||||
if(self.type == BlockType.叠加块下){
|
if(self.type == BlockType.叠加块下){
|
||||||
|
@ -777,7 +777,7 @@ export default class Block extends cc.Component {
|
||||||
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();
|
this.node.getChildByName("boom").getComponent("Boom").destroyBoom(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MapConroler._instance.nextLevel();
|
MapConroler._instance.nextLevel();
|
||||||
|
@ -1266,14 +1266,12 @@ export default class Block extends cc.Component {
|
||||||
this.touchDelta = cc.v2(0, 0);
|
this.touchDelta = cc.v2(0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(this.type == BlockType.叠加块上 && this.moveStack == true){
|
if(this.type == BlockType.叠加块下){
|
||||||
if((this.stacking.x != 0 || this.stacking.y!= 0) && this.block_Info.node!= null){
|
if(this.block_Info.node!= null){
|
||||||
this.isTouch = false;
|
if(this.block_Info.node.getComponent("Block").moveStack == true){
|
||||||
// this.node.x = this.block_Info.node.x + this.stacking.x;
|
this.block_Info.node.x = this.node.x + this.block_Info.node.getComponent("Block").stacking.x;
|
||||||
// this.node.y = this.block_Info.node.y + this.stacking.y;
|
this.block_Info.node.y = this.node.y + this.block_Info.node.getComponent("Block").stacking.y;
|
||||||
this.node.x = Math.round(this.block_Info.node.x + this.stacking.x);
|
}
|
||||||
this.node.y = Math.round(this.block_Info.node.y + this.stacking.y);
|
|
||||||
console.log("跟随移动",dt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.block_Info){
|
if(this.block_Info){
|
||||||
|
|
|
@ -124,6 +124,7 @@ export default class MapConroler extends cc.Component {
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
|
||||||
cc.fx.GameConfig.GM_INFO.review = 0;
|
cc.fx.GameConfig.GM_INFO.review = 0;
|
||||||
|
cc.fx.GameConfig.GM_INFO.reviewBoom = 0;
|
||||||
cc.fx.GameConfig.GM_INFO.gameState = true;
|
cc.fx.GameConfig.GM_INFO.gameState = true;
|
||||||
this.mask.opacity = 0;
|
this.mask.opacity = 0;
|
||||||
this.node.getChildByName("Adhesive").zIndex = 500;
|
this.node.getChildByName("Adhesive").zIndex = 500;
|
||||||
|
@ -1329,13 +1330,22 @@ export default class MapConroler extends cc.Component {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
judgeWin(){
|
judgeWin(number){
|
||||||
this.blockNum = this.blocks.length;
|
this.blockNum = this.blocks.length;
|
||||||
|
if(number == 1){
|
||||||
if((this.blockNum == 0 || this.blockNum == 1) &&!this.gameWin &&!this.gameOver){
|
if((this.blockNum == 0 || this.blockNum == 1) &&!this.gameWin &&!this.gameOver){
|
||||||
this.stopTimeCutDown();
|
this.stopTimeCutDown();
|
||||||
this.stopBoom();
|
this.stopBoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(number == 0){
|
||||||
|
if(this.blockNum == 0 &&!this.gameWin &&!this.gameOver){
|
||||||
|
this.stopTimeCutDown();
|
||||||
|
this.stopBoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//判断游戏成功下一关
|
//判断游戏成功下一关
|
||||||
nextLevel() {
|
nextLevel() {
|
||||||
|
@ -1377,7 +1387,7 @@ export default class MapConroler extends cc.Component {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.gameOver == true) {
|
if (this.gameOver == true) {
|
||||||
this.failLevel(null);
|
this.failLevel("time");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1452,15 +1462,28 @@ export default class MapConroler extends cc.Component {
|
||||||
// this.node.parent.parent.parent.destroy();
|
// this.node.parent.parent.parent.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
reviewLevel() {
|
//时间到了复活
|
||||||
|
reviewLevel(event,type) {
|
||||||
if(this.reviewState == true){
|
if(this.reviewState == true){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.reviewState = true;
|
this.reviewState = true;
|
||||||
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
|
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
|
||||||
|
|
||||||
let coin = 900;
|
let coin = 900;
|
||||||
|
let data = {
|
||||||
|
type: type,
|
||||||
|
coin: -coin
|
||||||
|
}
|
||||||
|
if(type == "time"){
|
||||||
if (cc.fx.GameConfig.GM_INFO.review == 1) coin = 1900;
|
if (cc.fx.GameConfig.GM_INFO.review == 1) coin = 1900;
|
||||||
else if (cc.fx.GameConfig.GM_INFO.review == 2) coin = 2500;
|
else if (cc.fx.GameConfig.GM_INFO.review == 2) coin = 2500;
|
||||||
|
}
|
||||||
|
else if(type == "boom"){
|
||||||
|
if (cc.fx.GameConfig.GM_INFO.reviewBoom == 1) coin = 1900;
|
||||||
|
else if (cc.fx.GameConfig.GM_INFO.reviewBoom == 2) coin = 2500;
|
||||||
|
}
|
||||||
|
data.coin = -coin;
|
||||||
// console.log("自身金币:",cc.fx.GameConfig.GM_INFO.coin,"消耗金币:",coin);
|
// console.log("自身金币:",cc.fx.GameConfig.GM_INFO.coin,"消耗金币:",coin);
|
||||||
if (cc.fx.GameConfig.GM_INFO.coin < Math.abs(coin)) {
|
if (cc.fx.GameConfig.GM_INFO.coin < Math.abs(coin)) {
|
||||||
MiniGameSdk.API.showToast("金币不足,无法加时间");
|
MiniGameSdk.API.showToast("金币不足,无法加时间");
|
||||||
|
@ -1472,13 +1495,14 @@ export default class MapConroler extends cc.Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.runRewive(-coin);
|
this.runRewive(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//执行复活函数
|
||||||
runRewive(data) {
|
runRewive(data) {
|
||||||
console.log("复活回调函数内", data);
|
console.log("复活回调函数内", data);
|
||||||
cc.fx.GameTool.changeCoin(data);
|
cc.fx.GameTool.changeCoin(data.coin);
|
||||||
MiniGameSdk.API.showToast("继续游戏");
|
MiniGameSdk.API.showToast("继续游戏");
|
||||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
if (cc.fx.GameConfig.GM_INFO.review < 2)
|
if (cc.fx.GameConfig.GM_INFO.review < 2)
|
||||||
|
@ -1486,9 +1510,11 @@ export default class MapConroler extends cc.Component {
|
||||||
|
|
||||||
this.gameOver = false;
|
this.gameOver = false;
|
||||||
this.gameWin = false;
|
this.gameWin = false;
|
||||||
|
this.pause = false;
|
||||||
|
if(data.type == "time"){
|
||||||
this.timeNumber = 21;
|
this.timeNumber = 21;
|
||||||
this.add_Time += 20;
|
this.add_Time += 20;
|
||||||
this.pause = false;
|
}
|
||||||
|
|
||||||
this.blockNum = this.blocks.length;
|
this.blockNum = this.blocks.length;
|
||||||
if (this.blockNum == 0 )this.nextLevel();
|
if (this.blockNum == 0 )this.nextLevel();
|
||||||
|
@ -1572,15 +1598,22 @@ export default class MapConroler extends cc.Component {
|
||||||
this.node.parent.parent.getChildByName("Lose").active = true;
|
this.node.parent.parent.getChildByName("Lose").active = true;
|
||||||
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
|
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
|
||||||
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
|
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
|
||||||
|
if (type) {
|
||||||
|
if (type == "time"){
|
||||||
let buyBtn = this.node.parent.parent.getChildByName("Lose").getChildByName("Time").getChildByName("buyBtn");
|
let buyBtn = this.node.parent.parent.getChildByName("Lose").getChildByName("Time").getChildByName("buyBtn");
|
||||||
buyBtn.getChildByName("coin1").active = buyBtn.getChildByName("coin2").active = buyBtn.getChildByName("coin3").active = false;
|
buyBtn.getChildByName("coin1").active = buyBtn.getChildByName("coin2").active = buyBtn.getChildByName("coin3").active = false;
|
||||||
if (cc.fx.GameConfig.GM_INFO.review == 0) buyBtn.getChildByName("coin1").active = true;
|
if (cc.fx.GameConfig.GM_INFO.review == 0) buyBtn.getChildByName("coin1").active = true;
|
||||||
else if (cc.fx.GameConfig.GM_INFO.review == 1) buyBtn.getChildByName("coin2").active = true;
|
else if (cc.fx.GameConfig.GM_INFO.review == 1) buyBtn.getChildByName("coin2").active = true;
|
||||||
else if (cc.fx.GameConfig.GM_INFO.review == 2) buyBtn.getChildByName("coin3").active = true;
|
else if (cc.fx.GameConfig.GM_INFO.review == 2) buyBtn.getChildByName("coin3").active = true;
|
||||||
if (type) {
|
}
|
||||||
if (type == "boom") {
|
if (type == "boom") {
|
||||||
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = false;
|
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = false;
|
||||||
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = true;
|
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = true;
|
||||||
|
let buyBtn = this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").getChildByName("buyBtn");
|
||||||
|
buyBtn.getChildByName("coin1").active = buyBtn.getChildByName("coin2").active = buyBtn.getChildByName("coin3").active = false;
|
||||||
|
if (cc.fx.GameConfig.GM_INFO.reviewBoom == 0) buyBtn.getChildByName("coin1").active = true;
|
||||||
|
else if (cc.fx.GameConfig.GM_INFO.reviewBoom == 1) buyBtn.getChildByName("coin2").active = true;
|
||||||
|
else if (cc.fx.GameConfig.GM_INFO.reviewBoom == 2) buyBtn.getChildByName("coin3").active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, time);
|
}, time);
|
||||||
|
|
|
@ -61,6 +61,8 @@ export class GameConfig {
|
||||||
mean_Time: number; //平均放箭速度
|
mean_Time: number; //平均放箭速度
|
||||||
hp: number; //体力值
|
hp: number; //体力值
|
||||||
review: number; //复活次数
|
review: number; //复活次数
|
||||||
|
reviewBoom: number; //炸弹复活次数
|
||||||
|
reviewDoor: number; //门复活次数
|
||||||
currSeed: number; //用于随机数种子
|
currSeed: number; //用于随机数种子
|
||||||
openid: string; //微信用户唯一id
|
openid: string; //微信用户唯一id
|
||||||
gameId: string; //游戏ID
|
gameId: string; //游戏ID
|
||||||
|
@ -92,8 +94,8 @@ export class GameConfig {
|
||||||
coinnum: number; //每局的金币数
|
coinnum: number; //每局的金币数
|
||||||
paid_user: boolean; //是否是付费用户
|
paid_user: boolean; //是否是付费用户
|
||||||
version: number; //版本号
|
version: number; //版本号
|
||||||
shushu_DistinctId: string //数数访客ID
|
shushu_DistinctId: string; //数数访客ID
|
||||||
shushu_AccountId: string //数数账号ID
|
shushu_AccountId: string; //数数账号ID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,6 +199,8 @@ export class GameConfig {
|
||||||
mean_Time: 0, //平均放箭速度
|
mean_Time: 0, //平均放箭速度
|
||||||
hp: 5, //体力值
|
hp: 5, //体力值
|
||||||
review:0, //复活次数
|
review:0, //复活次数
|
||||||
|
reviewBoom: 0, //炸弹复活次数
|
||||||
|
reviewDoor: 0, //门复活次数
|
||||||
currSeed: 200000, //用于随机数种子
|
currSeed: 200000, //用于随机数种子
|
||||||
openid:"", //微信用户唯一id
|
openid:"", //微信用户唯一id
|
||||||
gameId: "100001", //游戏ID
|
gameId: "100001", //游戏ID
|
||||||
|
@ -206,7 +210,7 @@ export class GameConfig {
|
||||||
useravatar:"", //用户头像地址
|
useravatar:"", //用户头像地址
|
||||||
guide: true, //是否有引导
|
guide: true, //是否有引导
|
||||||
url: "https://api.sparkus.cn",//访问域名
|
url: "https://api.sparkus.cn",//访问域名
|
||||||
coin: 0, //用户金币
|
coin: 10000, //用户金币
|
||||||
success: false, //用户游戏成功与否
|
success: false, //用户游戏成功与否
|
||||||
matchId: null, //用于埋点上传的ID
|
matchId: null, //用于埋点上传的ID
|
||||||
gameState:false,
|
gameState:false,
|
||||||
|
|
|
@ -16,14 +16,16 @@ const {ccclass, property} = cc._decorator;
|
||||||
export default class Boom extends cc.Component {
|
export default class Boom extends cc.Component {
|
||||||
static _instance: any;
|
static _instance: any;
|
||||||
time: number = 60;
|
time: number = 60;
|
||||||
|
over: boolean = false;
|
||||||
|
|
||||||
// mapInfo: number[][] = [];
|
// mapInfo: number[][] = [];
|
||||||
|
|
||||||
onLoad () {
|
onLoad () {
|
||||||
|
this.over = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
|
this.over = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
init(time){
|
init(time){
|
||||||
|
@ -38,7 +40,9 @@ export default class Boom extends cc.Component {
|
||||||
this.schedule(this.updateTime, 1);
|
this.schedule(this.updateTime, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyBoom(){
|
destroyBoom(type){
|
||||||
|
if(this.over) return;
|
||||||
|
this.over = true;
|
||||||
this.unschedule(this.updateTime);
|
this.unschedule(this.updateTime);
|
||||||
this.node.parent.getComponent("Block").resetFreeze();
|
this.node.parent.getComponent("Block").resetFreeze();
|
||||||
this.node.destroy();
|
this.node.destroy();
|
||||||
|
@ -54,16 +58,27 @@ export default class Boom extends cc.Component {
|
||||||
this.time --;
|
this.time --;
|
||||||
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
||||||
if(this.time <= 0){
|
if(this.time <= 0){
|
||||||
|
// 创建模拟触摸事件对象
|
||||||
|
const mockTouchEvent = {
|
||||||
|
getLocation: () => {
|
||||||
|
// 获取父节点的位置作为触摸落点
|
||||||
|
const parentPos = this.node.parent.getPosition();
|
||||||
|
return parentPos;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 触发父节点 Block 的 touchEnd 事件
|
||||||
|
this.node.parent.getComponent("Block").touchEnd(mockTouchEvent);
|
||||||
this.unschedule(this.updateTime);
|
this.unschedule(this.updateTime);
|
||||||
MapConroler._instance.failLevel("boom");
|
MapConroler._instance.failLevel("boom");
|
||||||
this.node.getChildByName("zhandan").active = true;
|
this.node.getChildByName("zhandan").active = true;
|
||||||
this.node.getChildByName("bg").active = false;
|
this.node.getChildByName("bg").active = false;
|
||||||
const skeleton = this.node.getChildByName("zhandan").getComponent(sp.Skeleton);
|
const skeleton = this.node.getChildByName("zhandan").getComponent(sp.Skeleton);
|
||||||
skeleton.setAnimation(1,"eff",false);
|
skeleton.setAnimation(1,"eff",false);
|
||||||
// 监听动画完成事件
|
// 监听动画完成事件,销毁自身爆炸节点
|
||||||
skeleton.setCompleteListener(() => {
|
skeleton.setCompleteListener(() => {
|
||||||
// 动画播放完成后销毁节点
|
// 动画播放完成后销毁节点
|
||||||
this.node.destroy();
|
this.destroyBoom(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.node.destroy();
|
// this.node.destroy();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
||||||
|
|
||||||
import JiaZai from "./JiaZai";
|
import JiaZai from "./JiaZai";
|
||||||
|
import MapConroler from "./Map";
|
||||||
import SceneManager from "./SceneManager";
|
import SceneManager from "./SceneManager";
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,8 +132,13 @@ export default class setUi extends cc.Component {
|
||||||
|
|
||||||
//退出游戏
|
//退出游戏
|
||||||
clickExit() {
|
clickExit() {
|
||||||
|
if(MapConroler._instance.gameStart == true) {
|
||||||
this.exit.active = true;
|
this.exit.active = true;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
MapConroler._instance.returnHome();
|
||||||
|
}
|
||||||
|
}
|
||||||
//取消
|
//取消
|
||||||
cancelExit() {
|
cancelExit() {
|
||||||
this.exit.active = false;
|
this.exit.active = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user