通行证修改

This commit is contained in:
huanghaipeng 2025-11-11 10:35:05 +08:00
parent 0abe2eaf68
commit 9d9eee8169
24 changed files with 24496 additions and 6123 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,10 +42,15 @@ export default class JiaZai extends cc.Component {
private static cachedWinStreakPrefab: cc.Prefab | null = null;
private winStreakNode: cc.Node | null = null;
// 缓存 通行证
private static cachedPassCheckPrefab: cc.Prefab | null = null;
private passCheckNode: cc.Node | null = null;
@property(cc.EditBox)
custom: cc.EditBox = null;
@property(cc.EditBox)
activateEdBox: cc.EditBox = null;
@property({ type: [cc.SpriteAtlas], tooltip: "方块颜色" })
Block_Color: Array<cc.SpriteAtlas> = [];
@ -113,6 +118,11 @@ export default class JiaZai extends cc.Component {
this.setShareInfo();
this.checkTasks();
this.checkAndSetPlayerPassLevel();
// this.checkDailyQuests();
//console.log("进入首页获取的share", cc.fx.GameConfig.GM_INFO.otherUid, cc.fx.GameConfig.GM_INFO.otherLevel);
cc.game.setFrameRate(63);
LQCollideSystem.is_enable = true;
//新手礼包
@ -219,6 +229,19 @@ export default class JiaZai extends cc.Component {
this.monthH();
};
});
bundle.load('prefab/passCheck', cc.Prefab, (err: Error, prefab: cc.Prefab) => {
if (err) {
cc.error(err.message || err);
return;
}
JiaZai.cachedPassCheckPrefab = prefab;
//等级大于21开启
if (cc.fx.GameConfig.GM_INFO.level >= 20) {
let top = this.node.getChildByName("Load").getChildByName("Top");
top.getChildByName("passBtn").active = true;
};
});
});
}
@ -390,7 +413,10 @@ export default class JiaZai extends cc.Component {
this.monthH();
}
};
if (cc.fx.GameConfig.GM_INFO.level >= 20) {
let top = this.node.getChildByName("Load").getChildByName("Top");
top.getChildByName("passBtn").active = true;
};
if (cc.fx.GameConfig.GM_INFO.level >= 17) {
let top = this.node.getChildByName("Load").getChildByName("Top");
top.getChildByName("hammer").active = true;
@ -443,6 +469,7 @@ export default class JiaZai extends cc.Component {
const rightElements2 = [
"shop",
"yicon",
"passBtn",
"xinshou",
"avatar",
"kuang"
@ -1124,7 +1151,7 @@ export default class JiaZai extends cc.Component {
|| order.itemid == "gold_4" || order.itemid == "gold_5" || order.itemid == "gold_6"
|| order.itemid == "unlimited_health_bundle_10" || order.itemid == "unlimited_health_bundle_20"
|| order.itemid == "unlimited_health_bundle_30" || order.itemid == "month_Card" || "reborn_Gift"
|| order.itemid == "starter_pack"
|| order.itemid == "starter_pack" || order.itemid == "battlepass"
) {
this.openLoad();
console.log("补发名称:", order.itemid);
@ -1161,6 +1188,9 @@ export default class JiaZai extends cc.Component {
cc.fx.GameConfig.GM_INFO.doubleCoin = 5;
cc.fx.GameConfig.GM_INFO.hp_Max = 5;
cc.fx.GameConfig.GM_INFO.hp = 5;
} else if (order.itemid == "battlepass") {
// 通行证订单
this.reissuePaaCheck();
}
let title = "充值补发奖励金币:" + coinTemp;
// MiniGameSdk.API.showToast(title);
@ -1795,6 +1825,388 @@ export default class JiaZai extends cc.Component {
}
}
reissuePaaCheck() {
cc.fx.GameConfig.GM_INFO.passCheckActivate = true;
Utils.getPassCheckInfo((res) => {
if (res.code === 1) {
let passCheckData;
if (typeof res.data.passCheck === 'string') {
passCheckData = JSON.parse(res.data.passCheck);
} else {
passCheckData = res.data.passCheck;
}
if (passCheckData && passCheckData[1]) {
passCheckData[1].activate = true;
} else {
console.error("passCheckData[1] 不存在");
return;
}
if (passCheckData && passCheckData[2]) {
passCheckData[2].activate = true;
} else {
console.error("passCheckData[2] 不存在");
return;
}
console.log("补发通行证", passCheckData)
Utils.setPassCheckInfo((res) => {
}, passCheckData)
}
})
}
openPassCheck() {
if (!JiaZai.cachedPassCheckPrefab) {
console.error('PassCheck prefab is not loaded yet.')
return;
}
var passCheck = null;
Utils.getPassCheckInfo((data) => {
passCheck = data.data.passCheck;
if (typeof passCheck === 'string') {
try {
passCheck = JSON.parse(passCheck);
console.log("解析后的 passCheck:", passCheck);
console.log("解析后的 progressLevel:", passCheck[2].activate);
} catch (e) {
console.error("JSON 解析失败:", e);
}
}
console.log("passCheck:", passCheck.time, Number(passCheck[2].time), passCheck.time > Number(passCheck[2].time));
if (passCheck.time > Number(passCheck[2].time)) {
this.checkAndSetPlayerPassLevel();
}
if (passCheck) {
if (this.passCheckNode) {
this.passCheckNode = null;
}
if (!this.passCheckNode || !cc.isValid(this.passCheckNode)) {
// 节点不存在或已被销毁,需要重新创建
this.passCheckNode = cc.instantiate(JiaZai.cachedPassCheckPrefab);
this.node.addChild(this.passCheckNode);
this.passCheckNode.getComponent("passCheck").setInfo(passCheck);
const hmScale = cc.fx.GameTool.adaptation();
if (hmScale == 1) return;
this.passCheckNode.scale = hmScale;
}
else {
// 节点存在且有效,直接激活
this.passCheckNode.active = true;
this.passCheckNode.getComponent("passCheck").setInfo(passCheck);
const hmScale = cc.fx.GameTool.adaptation();
if (hmScale == 1) return;
this.passCheckNode.scale = hmScale;
}
} else {
}
})
}
qinglishuju() {
let passCheck = null;
Utils.setPassCheckInfo(() => {
console.log("清空通行证", null);
// cc.fx.GameConfig.GM_INFO.playerPassLevel = 0;
cc.fx.StorageMessage.setStorage("ProgressIndex", 0);
this.checkAndSetPlayerPassLevel()
}, passCheck)
}
gengxindianshu() {
let shuju = parseInt(this.activateEdBox.string)
for (let i = 0; i < shuju; i++) {
setTimeout(() => {
if (i == shuju - 1) {
console.log("最后一次更新进度");
this.setPassProgress(true);
} else {
this.setPassProgress(false);
}
}, i * 500); // 间隔0.3秒(300毫秒)调用一次
}
}
setPassProgress(isLast = false) {
Utils.getPassCheckInfo((res) => {
if (res.code === 1) {
let passCheckData;
if (typeof res.data.passCheck === 'string') {
passCheckData = JSON.parse(res.data.passCheck);
} else {
passCheckData = res.data.passCheck;
}
if (passCheckData[2].time < res.data.time) {
// passCheckData[2].time = res.data.time;
passCheckData[1] = JSON.parse(JSON.stringify(passCheckData[2]));
passCheckData[2] = {
time: res.data.time + 5 * 60 * 1000,
progress: 1,
progressLevel: 1,
activate: false,
free: [],
passCheck: [],
}
cc.fx.GameConfig.GM_INFO.getProgress = 0;
cc.fx.GameConfig.GM_INFO.getProgressLevel = 1;
}
if (Number(passCheckData[2].progressLevel) > 30) {
console.log("进度已满");
passCheckData[2].progressLevel = 30;
passCheckData[2].progress = 4;
return;
}
const passCheckJson = cc.fx.GameConfig.PASS_CHECK;
console.log("设置进度", cc.fx.GameConfig.GM_INFO.getProgress);
cc.fx.GameConfig.GM_INFO.getProgress += 1;
const item = passCheckJson[cc.fx.GameConfig.GM_INFO.getProgressLevel - 1];
console.log("Item值", cc.fx.GameConfig.GM_INFO.getProgressLevel, item.token, item)
console.log("判断", cc.fx.GameConfig.GM_INFO.getProgress, item.token)
if (cc.fx.GameConfig.GM_INFO.getProgress < item.token) {
} else if (cc.fx.GameConfig.GM_INFO.getProgress == item.token) {
if (passCheckData && Array.isArray(passCheckData[2].free) && Array.isArray(passCheckData[2].passCheck)) {
// 给数组末尾添加激活状态1
if (passCheckData[2].free.length > 0) {
const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
passCheckData[2].free[lastIndex] = 1;
} else {
passCheckData[2].free.push(1);
}
// 只有在通行证已激活的情况下才更新passCheck数组
if (passCheckData[2].passCheck.length > 0) {
const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
passCheckData[2].passCheck[lastIndex] = 1;
} else {
passCheckData[2].passCheck.push(1);
}
}
}
else {
cc.fx.GameConfig.GM_INFO.getProgressLevel += 1;
cc.fx.GameConfig.GM_INFO.getProgress = 1;
}
if (passCheckData && passCheckData[2]) {
// 确保free和passCheck数组存在
passCheckData[2].progressLevel = cc.fx.GameConfig.GM_INFO.getProgressLevel;
passCheckData[2].progress = cc.fx.GameConfig.GM_INFO.getProgress;
}
console.log("保存的通行证数据", passCheckData);
// 保存更新后的数据
Utils.setPassCheckInfo((result) => {
if (result.code === 1) {
// console.log("GameScene 保存通行证成功");
} else {
// console.log("GameScene 保存通行证失败", result);
}
if (isLast) {
this.checkAndSetPlayerPassLevel();
setTimeout(() => {
MiniGameSdk.API.showToast("添加数据完成");
}, 500);
}
}, passCheckData);
} else {
console.log("获取通行证信息失败", res);
}
});
console.log("进度", cc.fx.GameConfig.GM_INFO.getProgressLevel, cc.fx.GameConfig.GM_INFO.getProgress);
}
checkAndSetPlayerPassLevel() {
const currentLevel = cc.fx.GameConfig.GM_INFO.level;
// 判断是否已经记录过playerPassLevel如果没有并且当前等级大于等于21级则记录
console.log("当前等级:", currentLevel, typeof currentLevel)
if (currentLevel >= 20) {
cc.fx.GameConfig.GM_INFO.playerPassLevel = currentLevel;
console.log("记录玩家起始关卡:", currentLevel);
let self = this;
Utils.getPassCheckInfo((data) => {
if (data.code == 1) {
if (data.data.time == null) {
let top = self.node.getChildByName("Load").getChildByName("Top");
top.getChildByName("passBtn").active = false;
} else {
console.log("获取getpassCheckLv1", data.data.passCheck, typeof data.data.passCheck, data.data.passCheck == "null");
cc.fx.GameConfig.GM_INFO.getItemType = 2;
if (data.data.passCheck == null || data.data.passCheck == "null") {
// let endTiem = data.data.time + 60 * 24 * 60 * 60 * 1000;
let endTiem = data.data.time + 5 * 60 * 1000;
let dataInfo = {
1: {
time: 0,
progress: 0,
progressLevel: 0,
activate: false,
free: [],
passCheck: [],
},
2: {
time: endTiem.toString(),
progress: 1,
progressLevel: 1,
activate: false,
free: [1],
passCheck: [1],
}
}
Utils.setPassCheckInfo(() => {
}, dataInfo)
cc.fx.GameConfig.GM_INFO.getProgressLevel = 1;
cc.fx.GameConfig.GM_INFO.getProgress = 1;
} else {
let passCheckLvObj = null;
let parsedData = null;
if (typeof data.data.passCheck === 'string') {
try {
parsedData = JSON.parse(data.data.passCheck);
passCheckLvObj = parsedData[2];
} catch (e) {
console.error("通行证数据解析失败:", e);
}
} else {
passCheckLvObj = data.data.passCheck[2];
}
let serverTime = Number(data.data.time);
let time1 = Number(parsedData[1].time);
let time2 = Number(parsedData[2].time);
// let allExpire = time2 + 30 * 24 * 60 * 60 * 1000;
// let newTime = serverTime + 60 * 24 * 60 * 60 * 1000;
let allExpire = time2 + 2 * 60 * 1000 + 30 * 1000; // 2 结束后 2分30秒
let newTime = serverTime + 5 * 60 * 1000; // 当前期的结束时间
let outTime = time1 + 2 * 60 * 1000 + 30 * 1000; // 1的清理时间
let now = new Date().getTime();
console.log("服务器" + new Date(serverTime).toLocaleString() + "\n"
+ "所有结束" + new Date(allExpire).toLocaleString() + "\n"
+ "Time1" + new Date(time1).toLocaleString() + "\n"
+ "Time2" + new Date(time2).toLocaleString() + "\n"
+ "当前结束" + new Date(newTime).toLocaleString()
);
console.log("通行证时间判断", serverTime >= allExpire, serverTime >= time2 && serverTime < allExpire, time2 == newTime);
if (serverTime >= allExpire) {
console.log("清理数据 超时进入");
// 清空数据
self.qinglishuju();
return;
} else {
if (serverTime >= time2 && serverTime < allExpire) {
let isGetItem = false;
if (passCheckLvObj.activate) {
for (let i = 0; i < passCheckLvObj.free.length; i++) {
if (passCheckLvObj.free[i] == 1 || passCheckLvObj.passCheck[i] == 1) {
isGetItem = true;
}
}
} else {
for (let i = 0; i < passCheckLvObj.free.length; i++) {
if (passCheckLvObj.free[i] == 1) {
isGetItem = true;
}
}
}
if (isGetItem) {
// 未领完
parsedData[1] = JSON.parse(JSON.stringify(parsedData[2]));
parsedData[2] = {
time: newTime.toString(),
progress: 1,
progressLevel: 1,
activate: false,
free: [1],
passCheck: [1],
}
cc.fx.GameConfig.GM_INFO.getItemType = 1;
cc.fx.GameConfig.GM_INFO.getProgressLevel = 1;
cc.fx.GameConfig.GM_INFO.getProgress = 1;
cc.fx.StorageMessage.setStorage("ProgressIndex", 1);
console.log("清理数据 过时进入赋值", cc.fx.GameConfig.GM_INFO.getItemType, parsedData);
Utils.setPassCheckInfo(() => { }, parsedData)
return;
} else {
// 清空数据
console.log("清理数据 领完");
self.qinglishuju();
return;
}
} else {
// 正常赋值
if (time2 == newTime) {
if (now < outTime) {
let isGetItem = false;
if (parsedData[1].activate) {
for (let i = 0; i < parsedData[1].free.length; i++) {
if (parsedData[1].free[i] == 1 || parsedData[1].passCheck[i] == 1) {
isGetItem = true;
}
}
} else {
for (let i = 0; i < parsedData[1].free.length; i++) {
if (parsedData[1].free[i] == 1) {
isGetItem = true;
}
}
}
if (isGetItem) {
cc.fx.GameConfig.GM_INFO.getItemType = 1;
} else {
cc.fx.GameConfig.GM_INFO.getItemType = 2;
}
console.log("清理数据 未到时间", cc.fx.GameConfig.GM_INFO.getItemType, parsedData);
} else {
// parsedData[1] = {
// time: "",
// progress: 0,
// progressLevel: 0,
// activate: false,
// free: [],
// passCheck: [],
// };
cc.fx.GameConfig.GM_INFO.getItemType = 2;
console.log("清理数据 第一期", cc.fx.GameConfig.GM_INFO.getItemType, parsedData);
// Utils.setPassCheckInfo(() => { }, parsedData)
}
}
}
}
cc.fx.GameConfig.GM_INFO.getProgressLevel = (passCheckLvObj && passCheckLvObj.progressLevel) || 1;
cc.fx.GameConfig.GM_INFO.getProgress = (passCheckLvObj && passCheckLvObj.progress) || 1;
}
}
}
})
} else {
}
}
closePassCheck() {
console.log("关闭过时数据", cc.fx.GameConfig.GM_INFO.getItemType)
this.checkAndSetPlayerPassLevel();
}
update(dt) {
if (this.newbieGift && this.monthlyCardNode) {
if (this.monthlyCardNode.active == true) {

View File

@ -163,7 +163,8 @@ export default class MapConroler extends cc.Component {
longAndShortWall: any;
adhesiveBlock: any[];
// mapInfo: number[][] = [];
getProgressLevel: number = 0;
getProgress: number = 0;
onLoad() {
MiniGameSdk.API.setNewCloudlevel();
@ -2059,6 +2060,11 @@ export default class MapConroler extends cc.Component {
this.check_NewMode();
setTimeout(() => {
this.node.parent.parent.getChildByName("Win").active = true;
// 记录通行证关卡
if (cc.fx.GameConfig.GM_INFO.level >= 21) {
this.setPassProgress();
}
this.Settlement();
if (cc.fx.GameConfig.GM_INFO.level >= 17) {
this.node.parent.parent.getChildByName("Win").getChildByName("WinStreak").active = true;
@ -2144,6 +2150,191 @@ export default class MapConroler extends cc.Component {
}
}
// setPassProgress() {
// console.log("设置进度", cc.fx.GameConfig.GM_INFO.getProgress);
// cc.fx.GameConfig.GM_INFO.getProgress += 1;
// const passCheckData = cc.fx.GameConfig.PASS_CHECK;
// const item = passCheckData[cc.fx.GameConfig.GM_INFO.getProgressLevel - 1];
// console.log("Item值", cc.fx.GameConfig.GM_INFO.getProgressLevel, item.token, item)
// console.log("判断", cc.fx.GameConfig.GM_INFO.getProgress <= item.token, typeof cc.fx.GameConfig.GM_INFO.getProgress, typeof item.token)
// if (cc.fx.GameConfig.GM_INFO.getProgress < item.token) {
// } else if (cc.fx.GameConfig.GM_INFO.getProgress == item.token) {
// }
// else {
// cc.fx.GameConfig.GM_INFO.getProgressLevel += 1;
// cc.fx.GameConfig.GM_INFO.getProgress = 1;
// // Utils.getPassCheckInfo(() => {
// // console.log("获取setPassCheckInfo");
// // })
// // let data2 = {
// // activate: cc.fx.GameConfig.GM_INFO.passCheckActivate,
// // free: [1],
// // passCheck: [1],
// // }
// // Utils.setPassCheckInfo(() => {
// // console.log("设置setPassCheckInfo");
// // }, data2)
// }
// Utils.getPassCheckInfo((res) => {
// if (res.code === 1) {
// try {
// let passCheckData;
// if (typeof res.data.passCheck === 'string') {
// passCheckData = JSON.parse(res.data.passCheck);
// } else {
// passCheckData = res.data.passCheck;
// }
// let now = new Date().getTime();
// // 确保free和passCheck数组存在
// if (passCheckData && Array.isArray(passCheckData[2].free) && Array.isArray(passCheckData[2].passCheck)) {
// // 给数组末尾添加激活状态1
// if (passCheckData[2].free.length > 0) {
// const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
// passCheckData[2].free[lastIndex] = 1;
// } else {
// passCheckData[2].free.push(1);
// }
// // 只有在通行证已激活的情况下才更新passCheck数组
// if (passCheckData[2].passCheck.length > 0) {
// const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
// passCheckData[2].passCheck[lastIndex] = 1;
// } else {
// passCheckData[2].passCheck.push(1);
// }
// passCheckData[2].progressLevel = cc.fx.GameConfig.GM_INFO.getProgressLevel;
// passCheckData[2].progress = cc.fx.GameConfig.GM_INFO.getProgress;
// passCheckData[2].time = now.toString();
// // 保存更新后的数据
// Utils.setPassCheckInfo((result) => {
// if (result.code === 1) {
// console.log("GameScene 保存通行证成功");
// } else {
// console.log("GameScene 保存通行证失败", result);
// }
// }, passCheckData);
// }
// } catch (error) {
// console.error("解析通行证数据失败", error);
// }
// } else {
// console.log("获取通行证信息失败", res);
// }
// });
// // let data = {
// // progressLevel: cc.fx.GameConfig.GM_INFO.getProgressLevel,
// // progress: cc.fx.GameConfig.GM_INFO.getProgress
// // }
// // Utils.setPassCheckLv(() => {
// // console.log("设置进度", data);
// // }, data)
// // if (data.progressLevel == 1 && data.progress == 1) {
// // let data2 = {
// // activate: cc.fx.GameConfig.GM_INFO.passCheckActivate,
// // free: [1],
// // passCheck: [1],
// // }
// // Utils.setPassCheckInfo(() => {
// // console.log("设置setPassCheckInfo");
// // }, data2)
// // }
// console.log("进度", cc.fx.GameConfig.GM_INFO.getProgressLevel, cc.fx.GameConfig.GM_INFO.getProgress);
// }
setPassProgress() {
Utils.getPassCheckInfo((res) => {
if (res.code === 1) {
let passCheckData;
if (typeof res.data.passCheck === 'string') {
passCheckData = JSON.parse(res.data.passCheck);
} else {
passCheckData = res.data.passCheck;
}
if (passCheckData[2].time < res.data.time) {
// passCheckData[2].time = res.data.time;
passCheckData[1] = JSON.parse(JSON.stringify(passCheckData[2]));
passCheckData[2] = {
time: res.data.time + 5 * 60 * 1000,
progress: 1,
progressLevel: 1,
activate: false,
free: [],
passCheck: [],
}
cc.fx.GameConfig.GM_INFO.getProgress = 0;
cc.fx.GameConfig.GM_INFO.getProgressLevel = 1;
}
if (Number(passCheckData[2].progressLevel) > 30) {
return;
}
console.log("设置进度", cc.fx.GameConfig.GM_INFO.getProgress);
cc.fx.GameConfig.GM_INFO.getProgress += 1;
const passCheckJson = cc.fx.GameConfig.PASS_CHECK;
const item = passCheckJson[cc.fx.GameConfig.GM_INFO.getProgressLevel - 1];
console.log("Item值", cc.fx.GameConfig.GM_INFO.getProgressLevel, item.token, item)
console.log("判断", cc.fx.GameConfig.GM_INFO.getProgress, item.token)
// let now = new Date().getTime();
if (cc.fx.GameConfig.GM_INFO.getProgress < item.token) {
} else if (cc.fx.GameConfig.GM_INFO.getProgress == item.token) {
if (passCheckData && Array.isArray(passCheckData[2].free) && Array.isArray(passCheckData[2].passCheck)) {
// 给数组末尾添加激活状态1
if (passCheckData[2].free.length > 0) {
const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
passCheckData[2].free[lastIndex] = 1;
} else {
passCheckData[2].free.push(1);
}
// 只有在通行证已激活的情况下才更新passCheck数组
if (passCheckData[2].passCheck.length > 0) {
const lastIndex = cc.fx.GameConfig.GM_INFO.getProgressLevel - 1;
passCheckData[2].passCheck[lastIndex] = 1;
} else {
passCheckData[2].passCheck.push(1);
}
}
}
else {
cc.fx.GameConfig.GM_INFO.getProgressLevel += 1;
cc.fx.GameConfig.GM_INFO.getProgress = 1;
}
if (passCheckData && passCheckData[2]) {
// 确保free和passCheck数组存在
passCheckData[2].progressLevel = cc.fx.GameConfig.GM_INFO.getProgressLevel;
passCheckData[2].progress = cc.fx.GameConfig.GM_INFO.getProgress;
// passCheckData[2].time = now.toString();
}
console.log("保存的通行证数据", passCheckData);
// 保存更新后的数据
Utils.setPassCheckInfo((result) => {
if (result.code === 1) {
// console.log("GameScene 保存通行证成功");
} else {
// console.log("GameScene 保存通行证失败", result);
}
}, passCheckData);
} else {
console.log("获取通行证信息失败", res);
}
});
console.log("进度", cc.fx.GameConfig.GM_INFO.getProgressLevel, cc.fx.GameConfig.GM_INFO.getProgress);
}
againLevel() {
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
this.adhesiveBlock = [];

View File

@ -56,6 +56,7 @@ export class GameConfig {
static PROP_INFO: ({ pos1: { x: number; y: number; z: number; }; pos2: { x: number; y: number; z: number; }; pos3: { x: number; y: number; z: number; }; pos4: { x: number; y: number; z: number; }; pos5: { x: number; y: number; z: number; }; pos6: { x: number; y: number; z: number; }; } | { pos1: { x: number; y: number; z: number; }; pos2: { x: number; y: number; z: number; }; pos3: { x: number; y: number; z: number; }; pos4: { x: number; y: number; z: number; }; pos5: { x: number; y: number; z: number; }; pos6?: undefined; })[];
static NEW_LEVEL: any;
static NEW_GUIDE: any;
static PASS_CHECK: any;
static TA: any;
static GE: any;
@ -119,11 +120,20 @@ export class GameConfig {
iosMonthOrder: string; //ios订单号月卡
iosReviveOrder: string; //ios订单号复活
iosStarterOrder: string; //ios订单号新手
iosPassCheckOrder: string; // ios通行证订单
starter_packTime: number; //新手礼包活动时间
wxFriend: boolean; //微信好友信息授权
wxUserInfo: boolean; //微信用户信息授权
winStreak: number; //连胜次数
winState: boolean //是否延续连胜状态
winState: boolean; //是否延续连胜状态
// playerPassLevel: number; // 玩家起始关卡
getProgressLevel: number; //获取进度关卡
getProgress: number; //获取进度
getItemType: number; // 领取物品的类型 1 2
// ProgressIndex: number; // 记录玩家当前进入通行证时关卡
// passCheckOpenTime: string; // 通行证开启时间
// passCheckPeriod: number; // 通行证期数
passCheckActivate: boolean; //是否激活通行证
tasks: {}; //任务
};
@ -284,10 +294,19 @@ export class GameConfig {
iosMonthOrder: "", //ios订单号月卡
iosReviveOrder: "", //ios订单号复活
iosStarterOrder: "", //ios订单号新手
iosPassCheckOrder: "", // ios通行证订单
starter_packTime: 0, //新手礼包活动时间
wxFriend: false, //微信好友信息授权
wxUserInfo: false, //微信用户信息授权
winState: false, //是否延续连胜状态
// playerPassLevel: 0, // 记录玩家起始关卡
getProgressLevel: 1, //获取进度关卡
getProgress: 0, //获取进度
getItemType: 2,
// ProgressIndex: 0, //获取进度索引
// passCheckOpenTime: "", // 通行证开启时间
// passCheckPeriod: 0, // 通行证期数
passCheckActivate: false,
winStreak: 0, //连胜
tasks: { levelPass: { value: 0, target: 0, state: 0 }, share: { value: 0, target: 0, state: 0 }, useEnergy: { value: 0, target: 0, state: 0 }, useProp: { value: 0, target: 0, state: 0 } }
};
@ -315,6 +334,16 @@ export class GameConfig {
// 可以根据需求对 newLevelData 进行处理
// //console.log("NEW_GUIDE.JSON 加载成功:", newLevelData);
})
cc.resources.load("Json/PASS_CHECK", (err: any, res: cc.JsonAsset) => {
if (err) {
console.error("加载 PASS_CHECK.JSON 失败:", err);
return;
}
const newLevelData = res.json;
this.PASS_CHECK = newLevelData.Sheet1;
// 可以根据需求对 newLevelData 进行处理
// //console.log("PASS_CHECK.JSON 加载成功:", newLevelData);
})
}

View File

@ -0,0 +1,443 @@
import NodePoolMgr from "../NodePool/NodePoolMgr";
// ListLayoutManager.ts
const { ccclass, property } = cc._decorator;
/**
*
*/
export enum ListLayoutType {
/**垂直排列 */
Vertical = 1,
/**水平排列 */
Horizontal = 2,
/**网格排列 */
Grid = 3
}
/**
*
*/
export enum GridDirection {
/**水平优先 */
Horizontal = 1,
/**垂直优先 */
Vertical = 2
}
@ccclass
export default class scrollViewList extends cc.Component {
/**NodePool处理器 */
@property({ type: cc.Node, tooltip: "NodePool处理器节点" })
public nodePoolNode: cc.Node = null;
/**列表项预制体 */
@property({ type: cc.Prefab, tooltip: "列表项预制体" })
public itemPrefab: cc.Prefab = null;
/**排列方式 */
@property({ type: cc.Enum(ListLayoutType), tooltip: "排列方式" })
public layoutType: ListLayoutType = ListLayoutType.Vertical;
/**网格布局方向 */
@property({
type: cc.Enum(GridDirection),
tooltip: "网格布局方向",
visible() {
return this.layoutType === ListLayoutType.Grid;
}
})
public gridDirection: GridDirection = GridDirection.Horizontal;
/**列表项之间X间隔 */
@property({ type: cc.Integer, tooltip: "列表项X间隔" })
public spacingX: number = 0;
/**列表项之间Y间隔 */
@property({ type: cc.Integer, tooltip: "列表项Y间隔" })
public spacingY: number = 0;
/**上间距 */
@property({ type: cc.Integer, tooltip: "上间距" })
public paddingTop: number = 0;
/**下间距 */
@property({ type: cc.Integer, tooltip: "下间距" })
public paddingBottom: number = 0;
/**左间距 */
@property({ type: cc.Integer, tooltip: "左间距" })
public paddingLeft: number = 0;
/**右间距 */
@property({ type: cc.Integer, tooltip: "右间距" })
public paddingRight: number = 0;
/**列表项宽度 */
@property({ type: cc.Integer, tooltip: "列表项宽度,-1表示使用预制体原始宽度" })
public itemWidth: number = -1;
/**列表项高度 */
@property({ type: cc.Integer, tooltip: "列表项高度,-1表示使用预制体原始高度" })
public itemHeight: number = -1;
/**是否自动调整content大小 */
@property({ tooltip: "是否自动调整content大小" })
public autoResizeContent: boolean = true;
// 私有属性
private scrollView: cc.ScrollView = null;
private content: cc.Node = null;
private nodePoolMgr: NodePoolMgr = null;
private dataList: any[] = [];
private itemNodes: cc.Node[] = [];
private itemWidthActual: number = 0;
private itemHeightActual: number = 0;
onLoad() {
this.init();
}
/**
*
*/
private init() {
this.scrollView = this.node.getComponent(cc.ScrollView);
if (!this.scrollView) {
console.error("scrollViewList: ScrollView component not found");
return;
}
this.content = this.scrollView.content;
if (!this.content) {
console.error("scrollViewList: Content node not found");
return;
}
// 设置content锚点
this.content.anchorX = 0;
this.content.anchorY = 1;
// 获取NodePoolMgr组件
if (this.nodePoolNode) {
this.nodePoolMgr = this.nodePoolNode.getComponent(NodePoolMgr);
}
if (!this.nodePoolMgr) {
console.error("scrollViewList: NodePoolMgr component not found");
return;
}
}
/**
*
* @param data
*/
public setData(data: any[]) {
this.dataList = data ? [...data] : [];
this.refreshContent();
}
/**
*
*/
private refreshContent() {
if (!this.content || !this.nodePoolMgr || !this.itemPrefab) {
console.warn("scrollViewList: Content, NodePoolMgr or itemPrefab not ready");
return;
}
// 清空现有内容
this.clearContent();
if (this.dataList.length === 0) {
return;
}
// 初始化实际宽高
this.initItemSize();
// 根据排列方式更新content大小
if (this.autoResizeContent) {
this.resizeContent();
}
// 创建列表项
this.createItems();
}
/**
*
*/
private initItemSize() {
// 如果设置了自定义尺寸,则使用自定义尺寸
if (this.itemWidth > 0) {
this.itemWidthActual = this.itemWidth;
} else {
// 否则使用预制体原始宽度
const tempNode = cc.instantiate(this.itemPrefab);
this.itemWidthActual = tempNode.width;
tempNode.destroy();
}
if (this.itemHeight > 0) {
this.itemHeightActual = this.itemHeight;
} else {
// 否则使用预制体原始高度
const tempNode = cc.instantiate(this.itemPrefab);
this.itemHeightActual = tempNode.height;
tempNode.destroy();
}
}
/**
* content大小
*/
private resizeContent() {
const dataLen = this.dataList.length;
switch (this.layoutType) {
case ListLayoutType.Vertical:
this.content.width = this.content.parent.width;
// 修正content高度计算确保最后一个项能完全显示
// 计算公式:顶部边距 + 所有项高度 + 间隔总和 + 底部边距
if (dataLen > 0) {
this.content.height = this.paddingTop +
dataLen * this.itemHeightActual +
Math.max(0, dataLen - 1) * this.spacingY +
this.paddingBottom;
} else {
this.content.height = this.paddingTop + this.paddingBottom;
}
if (cc.sys.isMobile) {
// 可以根据需要添加额外的底部填充
this.content.height += 20; // 添加20像素的额外空间
}
break;
case ListLayoutType.Horizontal:
this.content.height = this.content.parent.height;
// 修正content宽度计算
if (dataLen > 0) {
this.content.width = this.paddingLeft +
dataLen * this.itemWidthActual +
Math.max(0, dataLen - 1) * this.spacingX +
this.paddingRight;
} else {
this.content.width = this.paddingLeft + this.paddingRight;
}
break;
case ListLayoutType.Grid:
if (this.gridDirection === GridDirection.Horizontal) {
// 水平优先网格
const rowCount = Math.ceil(dataLen / this.getGridColCount());
if (rowCount > 0) {
this.content.height = this.paddingTop +
rowCount * this.itemHeightActual +
Math.max(0, rowCount - 1) * this.spacingY +
this.paddingBottom;
} else {
this.content.height = this.paddingTop + this.paddingBottom;
}
this.content.width = this.content.parent.width;
} else {
// 垂直优先网格
const colCount = Math.ceil(dataLen / this.getGridRowCount());
if (colCount > 0) {
this.content.width = this.paddingLeft +
colCount * this.itemWidthActual +
Math.max(0, colCount - 1) * this.spacingX +
this.paddingRight;
} else {
this.content.width = this.paddingLeft + this.paddingRight;
}
this.content.height = this.content.parent.height;
}
break;
}
}
/**
*
*/
private getGridColCount(): number {
if (this.layoutType !== ListLayoutType.Grid) return 1;
const contentWidth = this.content.parent.width - this.paddingLeft - this.paddingRight;
return Math.floor((contentWidth + this.spacingX) / (this.itemWidthActual + this.spacingX));
}
/**
*
*/
private getGridRowCount(): number {
if (this.layoutType !== ListLayoutType.Grid) return 1;
const contentHeight = this.content.parent.height - this.paddingTop - this.paddingBottom;
return Math.floor((contentHeight + this.spacingY) / (this.itemHeightActual + this.spacingY));
}
/**
*
*/
private createItems() {
const dataLen = this.dataList.length;
for (let i = 0; i < dataLen; i++) {
// 调用NodePoolMgr时传入指定的预制体
const itemNode = this.nodePoolMgr.getItem(this.itemPrefab);
if (!itemNode) {
console.error("scrollViewList: Failed to get item from NodePoolMgr");
continue;
}
itemNode.parent = this.content;
this.itemNodes.push(itemNode);
// 设置位置
this.setPosition(itemNode, i);
// 设置数据
const itemComponent = itemNode.getComponent('ListItem') || itemNode.getComponent(cc.Component);
if (itemComponent && typeof itemComponent['updateItem'] === 'function') {
itemComponent['updateItem'](this.dataList[i], i);
}
}
}
/**
*
* @param itemNode
* @param index
*/
private setPosition(itemNode: cc.Node, index: number) {
// 确保节点尺寸正确
if (this.itemWidth > 0) {
itemNode.width = this.itemWidth;
}
if (this.itemHeight > 0) {
itemNode.height = this.itemHeight;
}
switch (this.layoutType) {
case ListLayoutType.Vertical:
// 垂直排列:每个项在垂直方向上按顺序排列
// 修正位置计算,确保能正确显示所有项
const y = - (this.paddingTop + itemNode.height / 2 + index * (itemNode.height + this.spacingY));
itemNode.setPosition(this.paddingLeft + itemNode.width / 2, y);
break;
case ListLayoutType.Horizontal:
// 水平排列:每个项在水平方向上按顺序排列
const x = this.paddingLeft + itemNode.width / 2 + index * (itemNode.width + this.spacingX);
itemNode.setPosition(x, -this.content.height + this.content.height / 2);
break;
case ListLayoutType.Grid:
if (this.gridDirection === GridDirection.Horizontal) {
const col = index % this.getGridColCount();
const row = Math.floor(index / this.getGridColCount());
const gridX = this.paddingLeft + itemNode.width / 2 + col * (itemNode.width + this.spacingX);
const gridY = - (this.paddingTop + itemNode.height / 2 + row * (itemNode.height + this.spacingY));
itemNode.setPosition(gridX, gridY);
} else {
const row = index % this.getGridRowCount();
const col = Math.floor(index / this.getGridRowCount());
const gridX = this.paddingLeft + itemNode.width / 2 + col * (itemNode.width + this.spacingX);
const gridY = - (this.paddingTop + itemNode.height / 2 + row * (itemNode.height + this.spacingY));
itemNode.setPosition(gridX, gridY);
}
break;
}
}
/**
*
*/
private clearContent() {
// 回收所有节点
for (let i = 0; i < this.itemNodes.length; i++) {
this.nodePoolMgr.putItem(this.itemNodes[i]);
}
this.itemNodes = [];
this.content.removeAllChildren();
}
/**
*
* @param data
* @param index
*/
public addItem(data: any, index?: number) {
if (index === undefined || index >= this.dataList.length) {
this.dataList.push(data);
} else {
this.dataList.splice(index, 0, data);
}
this.refreshContent();
}
/**
*
* @param index
*/
public removeItem(index: number) {
if (index >= 0 && index < this.dataList.length) {
this.dataList.splice(index, 1);
this.refreshContent();
}
}
/**
*
* @param index
* @param data
*/
public updateItem(index: number, data: any) {
if (index >= 0 && index < this.dataList.length) {
this.dataList[index] = data;
// 更新对应节点
if (index < this.itemNodes.length) {
const itemComponent = this.itemNodes[index].getComponent('ListItem') ||
this.itemNodes[index].getComponent(cc.Component);
if (itemComponent && typeof itemComponent['updateItem'] === 'function') {
itemComponent['updateItem'](data, index);
}
}
}
}
/**
*
* @param index
*/
public getItemData(index: number): any {
if (index >= 0 && index < this.dataList.length) {
return this.dataList[index];
}
return null;
}
/**
*
*/
public getDataLength(): number {
return this.dataList.length;
}
/**
*
*/
public clearData() {
this.dataList = [];
this.refreshContent();
}
/**
*
*/
onDestroy() {
this.clearContent();
}
}

View File

@ -0,0 +1,81 @@
// NodePoolMgr.ts
const { ccclass } = cc._decorator;
@ccclass
export default class NodePoolMgr extends cc.Component {
// 私有属性
private nodePool: cc.NodePool = null;
private itemPrefab: cc.Prefab = null;
onLoad() {
this.init();
}
/**
*
*/
private init() {
this.nodePool = new cc.NodePool();
}
/**
*
* @param prefab 使
*/
public getItem(prefab?: cc.Prefab): cc.Node {
// 如果传入了新的预制体,则更新当前预制体
if (prefab) {
this.itemPrefab = prefab;
}
let itemNode: cc.Node = null;
if (this.nodePool.size() > 0) {
itemNode = this.nodePool.get();
} else if (this.itemPrefab) {
itemNode = cc.instantiate(this.itemPrefab);
} else {
console.warn("NodePoolMgr: No prefab available to instantiate item");
}
return itemNode;
}
/**
*
* @param itemNode
*/
public putItem(itemNode: cc.Node) {
if (itemNode) {
this.nodePool.put(itemNode);
}
}
/**
*
* @param prefab
*/
public setItemPrefab(prefab: cc.Prefab) {
this.itemPrefab = prefab;
}
/**
*
*/
public getItemPrefab(): cc.Prefab {
return this.itemPrefab;
}
/**
*
*/
public clear() {
// 销毁节点池中的所有节点
this.nodePool.clear();
}
/**
*
*/
onDestroy() {
this.clear();
}
}

View File

@ -209,6 +209,10 @@ export default class Utils {
cc.fx.GameConfig.GM_INFO.iosStarterOrder = null;
cc.fx.GameConfig.GM_INFO.iosStarterOrder = order;
}
else if (iosPayInfo.payment_name == "battlepass") {
cc.fx.GameConfig.GM_INFO.iosPassCheckOrder = null;
cc.fx.GameConfig.GM_INFO.iosPassCheckOrder = order;
}
else {
cc.fx.GameConfig.GM_INFO.iosShopOrder = null;
cc.fx.GameConfig.GM_INFO.iosShopOrder = order;
@ -1198,4 +1202,105 @@ export default class Utils {
}
}
static getpassCheckLv(callBack) {
if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid");
//旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid;
}
let setData = {
uid: cc.fx.GameConfig.GM_INFO.uid,
action: 'read',
}
Utils.POST("passCheckLv", setData, res => {
if (res.code === 1) {
console.log("请求通行证等级成功:", res);
if (callBack) callBack(res);
} else {
console.log("请求通行证等级失败:", res);
if (callBack) callBack(res);
}
});
}
}
static setPassCheckLv(callBack, data) {
if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid");
//旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid;
}
// let data = {
// progress: 2,
// progressLevel: 3,
// }
let setData = {
uid: cc.fx.GameConfig.GM_INFO.uid,
action: 'save',
passCheckLv: JSON.stringify(data),
}
console.log("设置通行证等级数据:", setData);
Utils.POST("passCheckLv", setData, res => {
if (res.code === 1) {
console.log("设置通行证等级成功", res);
if (callBack) callBack(res);
} else {
console.log("设置通行证等级失败", res);
}
})
}
}
static getPassCheckInfo(callBack) {
if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid");
//旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid;
}
let setData = {
uid: cc.fx.GameConfig.GM_INFO.uid,
action: 'read',
}
Utils.POST("passCheck", setData, res => {
console.log("获得通行证成功:", res);
if (res.code === 1) {
if (callBack) callBack(res);
} else {
if (callBack) callBack(res);
}
});
}
}
static setPassCheckInfo(callBack, data) {
if (typeof wx !== 'undefined' && wx !== null) {
let uid = cc.fx.StorageMessage.getStorage("uid");
//旧的读取数据设置数据方法,以强联网为主
if (uid != undefined && uid != "" && uid != null) {
cc.fx.GameConfig.GM_INFO.uid = uid;
}
let setData = {
uid: cc.fx.GameConfig.GM_INFO.uid,
action: 'save',
passCheck: JSON.stringify(data),
}
Utils.POST("passCheck", setData, res => {
if (res.code === 1) {
// console.log("请求通行证上传成功", res);
if (callBack) callBack(res);
} else {
console.log("请求通行证上传失败", res);
}
})
}
}
}

View File

@ -1027,6 +1027,49 @@ var GameTool = {
MiniGameSdk.API.shushu_SetSuperProperties(null, true);
},
getPassCheckPorp(porpId, propNumber, compensate) {
console.log("getPassCheckPorp道具:", typeof porpId, "數量:", typeof propNumber)
switch (porpId) {
case 1001:
cc.fx.GameTool.changeCoin(propNumber);
break;
case 2001:
cc.fx.GameConfig.GM_INFO.freezeAmount += propNumber;
cc.fx.GameTool.setUserProp(porpId, propNumber, (data) => {
})
break;
case 2002:
cc.fx.GameConfig.GM_INFO.hammerAmount += propNumber;
cc.fx.GameTool.setUserProp(porpId, propNumber, (data) => {
})
break;
case 2003:
cc.fx.GameConfig.GM_INFO.magicAmount += propNumber;
cc.fx.GameTool.setUserProp(porpId, propNumber, (data) => {
})
break;
case 3001:
console.log("getPassCheckPorp道具1:", porpId)
this.setUserPowerTime(900);
break;
case 3002:
this.setUserPowerTime(1800);
break;
case 3003:
this.setUserPowerTime(3600);
break;
}
const dataTemp = {
change_reason: "battlepass",
id: porpId,
num: propNumber,
compensate: compensate
}
console.log("通行证发放奖励", porpId, propNumber)
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
},
formatDate(date: Date): string {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
@ -1692,6 +1735,26 @@ var GameTool = {
return 1;
}
},
setGray(node: cc.Node, gray = true): void {
const grayMat = cc.Material.getBuiltinMaterial('2d-gray-sprite');
const normalMat = cc.Material.getBuiltinMaterial('2d-sprite');
const mat = gray ? grayMat : normalMat;
// 处理当前节点的 Sprite 组件
const sprite = node.getComponent(cc.Sprite);
if (sprite) {
sprite.setMaterial(0, mat);
}
// 处理当前节点的 Label 组件
const label = node.getComponent(cc.Label);
if (label) {
label.setMaterial(0, mat);
}
// 递归处理子节点
node.children.forEach(child => this.setGray(child, gray));
},
};

BIN
assets/UI/UI/passBtn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

@ -0,0 +1,184 @@
{
"Sheet1": [
{
"level": 1,
"free": "3001:1",
"paid": "1001:1500",
"token": 1
},
{
"level": 2,
"free": "2002:1",
"paid": "1001:500",
"token": 2
},
{
"level": 3,
"free": "2001:1",
"paid": "2003:2",
"token": 2
},
{
"level": 4,
"free": "3001:1",
"paid": "3002:1",
"token": 2
},
{
"level": 5,
"free": "2003:1",
"paid": "2002:1",
"token": 2
},
{
"level": 6,
"free": "1001:200",
"paid": "1001:500",
"token": 2
},
{
"level": 7,
"free": "2001:1",
"paid": "2003:2",
"token": 2
},
{
"level": 8,
"free": "2003:1",
"paid": "2001:2",
"token": 2
},
{
"level": 9,
"free": "1001:300",
"paid": "3002:1",
"token": 2
},
{
"level": 10,
"free": "2002:1",
"paid": "1001:1000",
"token": 4
},
{
"level": 11,
"free": "2001:1",
"paid": "2001:3",
"token": 4
},
{
"level": 12,
"free": "3001:1",
"paid": "3002:1",
"token": 4
},
{
"level": 13,
"free": "2003:2",
"paid": "1001:750",
"token": 4
},
{
"level": 14,
"free": "2001:2",
"paid": "2003:3",
"token": 4
},
{
"level": 15,
"free": "2002:1",
"paid": "3002:1",
"token": 4
},
{
"level": 16,
"free": "3001:1",
"paid": "1001:750",
"token": 4
},
{
"level": 17,
"free": "1001:300",
"paid": "2001:3",
"token": 4
},
{
"level": 18,
"free": "2003:2",
"paid": "2003:3",
"token": 4
},
{
"level": 19,
"free": "2001:2",
"paid": "3002:1",
"token": 4
},
{
"level": 20,
"free": "2002:1",
"paid": "1001:1500",
"token": 4
},
{
"level": 21,
"free": "3001:1",
"paid": "2003:3",
"token": 4
},
{
"level": 22,
"free": "1001:400",
"paid": "2002:1",
"token": 4
},
{
"level": 23,
"free": "2002:1",
"paid": "3003:1",
"token": 4
},
{
"level": 24,
"free": "3002:1",
"paid": "1001:750",
"token": 4
},
{
"level": 25,
"free": "1001:500",
"paid": "3002:1",
"token": 4
},
{
"level": 26,
"free": "2001:2",
"paid": "2001:3",
"token": 4
},
{
"level": 27,
"free": "1001:600",
"paid": "1001:750",
"token": 4
},
{
"level": 28,
"free": "2001:2",
"paid": "2003:3",
"token": 4
},
{
"level": 29,
"free": "2003:3",
"paid": "3003:1",
"token": 4
},
{
"level": 30,
"free": "1001:1200",
"paid": "1001:2000",
"token": 0
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -0,0 +1,438 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>15.png</key>
<dict>
<key>frame</key>
<string>{{1663,985},{162,38}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{162,38}}</string>
<key>sourceSize</key>
<string>{162,38}</string>
</dict>
<key>18yuan.png</key>
<dict>
<key>frame</key>
<string>{{1657,920},{182,63}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{182,63}}</string>
<key>sourceSize</key>
<string>{182,63}</string>
</dict>
<key>activate_btn.png</key>
<dict>
<key>frame</key>
<string>{{727,773},{394,160}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{394,160}}</string>
<key>sourceSize</key>
<string>{394,160}</string>
</dict>
<key>bright_bg.png</key>
<dict>
<key>frame</key>
<string>{{1814,781},{116,124}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{116,124}}</string>
<key>sourceSize</key>
<string>{116,124}</string>
</dict>
<key>description_1.png</key>
<dict>
<key>frame</key>
<string>{{731,2},{1079,126}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{1079,126}}</string>
<key>sourceSize</key>
<string>{1079,126}</string>
</dict>
<key>description_2.png</key>
<dict>
<key>frame</key>
<string>{{2,737},{300,460}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{300,460}}</string>
<key>sourceSize</key>
<string>{300,460}</string>
</dict>
<key>description_3.png</key>
<dict>
<key>frame</key>
<string>{{1805,192},{136,140}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{136,140}}</string>
<key>sourceSize</key>
<string>{136,140}</string>
</dict>
<key>description_5.png</key>
<dict>
<key>frame</key>
<string>{{731,557},{501,214}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{501,214}}</string>
<key>sourceSize</key>
<string>{501,214}</string>
</dict>
<key>description_6.png</key>
<dict>
<key>frame</key>
<string>{{1234,557},{421,431}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{421,431}}</string>
<key>sourceSize</key>
<string>{421,431}</string>
</dict>
<key>description_7.png</key>
<dict>
<key>frame</key>
<string>{{731,144},{770,270}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{770,270}}</string>
<key>sourceSize</key>
<string>{770,270}</string>
</dict>
<key>description_8.png</key>
<dict>
<key>frame</key>
<string>{{727,935},{426,70}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{426,70}}</string>
<key>sourceSize</key>
<string>{426,70}</string>
</dict>
<key>free.png</key>
<dict>
<key>frame</key>
<string>{{1943,192},{84,44}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{84,44}}</string>
<key>sourceSize</key>
<string>{84,44}</string>
</dict>
<key>get.png</key>
<dict>
<key>frame</key>
<string>{{1841,907},{95,86}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{95,86}}</string>
<key>sourceSize</key>
<string>{95,86}</string>
</dict>
<key>get_btn.png</key>
<dict>
<key>frame</key>
<string>{{1896,334},{218,78}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{218,78}}</string>
<key>sourceSize</key>
<string>{218,78}</string>
</dict>
<key>left_bg.png</key>
<dict>
<key>frame</key>
<string>{{1503,144},{300,261}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{300,261}}</string>
<key>sourceSize</key>
<string>{300,261}</string>
</dict>
<key>line.png</key>
<dict>
<key>frame</key>
<string>{{731,130},{1080,12}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{1080,12}}</string>
<key>sourceSize</key>
<string>{1080,12}</string>
</dict>
<key>lock.png</key>
<dict>
<key>frame</key>
<string>{{1577,407},{66,88}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{66,88}}</string>
<key>sourceSize</key>
<string>{66,88}</string>
</dict>
<key>miaoshu.png</key>
<dict>
<key>frame</key>
<string>{{731,416},{844,139}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{844,139}}</string>
<key>sourceSize</key>
<string>{844,139}</string>
</dict>
<key>no_bright_bg.png</key>
<dict>
<key>frame</key>
<string>{{1815,648},{116,124}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{116,124}}</string>
<key>sourceSize</key>
<string>{116,124}</string>
</dict>
<key>num_xg.png</key>
<dict>
<key>frame</key>
<string>{{727,1007},{29,41}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{29,41}}</string>
<key>sourceSize</key>
<string>{29,41}</string>
</dict>
<key>progress_bar_1.png</key>
<dict>
<key>frame</key>
<string>{{1753,407},{372,60}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{372,60}}</string>
<key>sourceSize</key>
<string>{372,60}</string>
</dict>
<key>progress_bar_2.png</key>
<dict>
<key>frame</key>
<string>{{1691,407},{372,60}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{372,60}}</string>
<key>sourceSize</key>
<string>{372,60}</string>
</dict>
<key>progress_bar_3.png</key>
<dict>
<key>frame</key>
<string>{{1657,407},{32,506}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{32,506}}</string>
<key>sourceSize</key>
<string>{32,506}</string>
</dict>
<key>progress_bar_4.png</key>
<dict>
<key>frame</key>
<string>{{1155,990},{32,506}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{32,506}}</string>
<key>sourceSize</key>
<string>{32,506}</string>
</dict>
<key>right_bg.png</key>
<dict>
<key>frame</key>
<string>{{464,737},{300,261}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{300,261}}</string>
<key>sourceSize</key>
<string>{300,261}</string>
</dict>
<key>skylineHealth.png</key>
<dict>
<key>frame</key>
<string>{{1691,781},{137,121}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{137,121}}</string>
<key>sourceSize</key>
<string>{137,121}</string>
</dict>
<key>tongpaizi.png</key>
<dict>
<key>frame</key>
<string>{{1933,644},{84,43}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{84,43}}</string>
<key>sourceSize</key>
<string>{84,43}</string>
</dict>
<key>tongpiao.png</key>
<dict>
<key>frame</key>
<string>{{1813,2},{188,175}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{188,175}}</string>
<key>sourceSize</key>
<string>{188,175}</string>
</dict>
<key>tongpiaozi.png</key>
<dict>
<key>frame</key>
<string>{{1815,334},{312,79}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{312,79}}</string>
<key>sourceSize</key>
<string>{312,79}</string>
</dict>
<key>tu.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{727,733}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{727,733}}</string>
<key>sourceSize</key>
<string>{727,733}</string>
</dict>
<key>wenhao.png</key>
<dict>
<key>frame</key>
<string>{{1896,554},{86,88}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{86,88}}</string>
<key>sourceSize</key>
<string>{86,88}</string>
</dict>
<key>yaoshi.png</key>
<dict>
<key>frame</key>
<string>{{1123,773},{106,122}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{106,122}}</string>
<key>sourceSize</key>
<string>{106,122}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>passCheck.png</string>
<key>size</key>
<string>{1990,1039}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:531c054d5be834269e2aab859c897ea0$</string>
<key>textureFileName</key>
<string>passCheck.png</string>
</dict>
</dict>
</plist>

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

View File

@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "Loading",
"_name": "ConfirmBox",
"_objFlags": 0,
"_parent": null,
"_children": [
@ -25,16 +25,22 @@
},
{
"__id__": 9
},
{
"__id__": 12
},
{
"__id__": 15
}
],
"_active": false,
"_components": [
{
"__id__": 12
"__id__": 23
}
],
"_prefab": {
"__id__": 13
"__id__": 24
},
"_opacity": 255,
"_color": {
@ -205,7 +211,7 @@
},
{
"__type__": "cc.Node",
"_name": "load",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
@ -230,8 +236,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 689,
"height": 656
"width": 994,
"height": 1462
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -283,7 +289,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "794efc8c-624c-469f-84c0-24ce84022c54"
"__uuid__": "71f0494c-f638-4d7a-a826-a9407bf2b27c"
},
"_type": 0,
"_sizeMode": 1,
@ -307,12 +313,12 @@
"asset": {
"__id__": 0
},
"fileId": "e0njfM7epDhL+otsGYSeCR",
"fileId": "eeHwB6Bq5CSbRJy0kYMgo0",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_name": "title",
"_objFlags": 0,
"_parent": {
"__id__": 1
@ -337,8 +343,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 135,
"height": 56.7
"width": 160,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -350,7 +356,7 @@
"ctor": "Float64Array",
"array": [
0,
0,
330.904,
0,
0,
0,
@ -389,10 +395,10 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "请稍后",
"_N$string": "请稍后",
"_fontSize": 45,
"_lineHeight": 45,
"_string": "商城充值",
"_N$string": "商城充值",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
@ -418,6 +424,418 @@
"fileId": "fa+8dDqrdLTrl/Ji8K9LMX",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 320,
"height": 195.6
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
89.865,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "网络异常\n请重新登录小游戏\n领取充值奖励",
"_N$string": "网络异常\n请重新登录小游戏\n领取充值奖励",
"_fontSize": 40,
"_lineHeight": 60,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "9149ix6q1AZ4VyIjmSGbdM",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Sprite",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 16
}
],
"_active": true,
"_components": [
{
"__id__": 19
},
{
"__id__": 20
}
],
"_prefab": {
"__id__": 22
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 519,
"height": 168
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-3.21,
-77.027,
0,
0,
0,
0,
1,
0.4,
0.4,
0
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 15
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
}
],
"_prefab": {
"__id__": 18
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 160,
"height": 100.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
13.174,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "确定",
"_N$string": "确定",
"_fontSize": 80,
"_lineHeight": 80,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "1f0NO1uLNIxrx1dYb9rOaL",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "d9be6eea-569b-46da-bb80-0d9c8b8f5263"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.1,
"clickEvents": [
{
"__id__": 21
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 15
},
"_id": ""
},
{
"__type__": "cc.ClickEvent",
"target": null,
"component": "",
"_componentId": "48bfeZuYFZE2qmgxbW2IigB",
"handler": "closeConfirmBox",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "58sKElg7lE9I935Fpq7n8Y",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,270 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "passCheckItemLv",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-165,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bright_bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 116,
"height": 124
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8d1ce904-0216-4aae-95bd-fd451329ff66"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": {
"__uuid__": "56aacf5e-256b-4c72-b5d1-3982932775c9"
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "81MVwoP/RKMJw2C+B97inZ",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "levelNum",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 6
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
16.586,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "15YnQ4dZlFUKUvNSZXgqVV",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]

View File

@ -0,0 +1,48 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class buyActivate extends cc.Component {
@property(cc.Button)
qiutBtn: cc.Button = null;
@property(cc.Button)
buyBtn: cc.Button = null;
@property(cc.Label)
countdown: cc.Label = null;
private callback: Function = null;
start() {
}
init(callback: Function, timeStr: string) {
// 初始化回调函数
this.callback = callback;
// 添加按钮事件监听
this.qiutBtn.node.on('click', this.onQuitBtnClick, this);
this.buyBtn.node.on('click', this.onBuyBtnClick, this);
this.countdown.string = timeStr;
}
// updateCountdown(str: string) {
// this.countdown.string = str;
// }
onQuitBtnClick() {
// 移除界面
this.node.destroy();
}
onBuyBtnClick() {
// 调用回调函数触发passCheck中的购买逻辑
if (this.callback && typeof this.callback === 'function') {
this.callback();
}
// 移除界面
this.node.destroy();
}
}

View File

@ -0,0 +1,851 @@
import JiaZai from "../../Script/JiaZai";
import Utils from "../../Script/module/Pay/Utils";
import NumberToImage from "../../Script/NumberToImage";
import { MiniGameSdk } from "../../Script/Sdk/MiniGameSdk";
const { ccclass, property } = cc._decorator;
@ccclass
export default class passCheck extends cc.Component {
@property(cc.Button)
descriptionBtn: cc.Button = null;
@property(cc.Button)
closetBtn: cc.Button = null;
@property(cc.Button)
activateBtn: cc.Button = null;
@property(cc.Sprite)
barSpr: cc.Sprite = null;
@property(cc.Node)
currentLv: cc.Node = null;
@property(cc.Node)
progress_1: cc.Node = null;
@property(cc.Node)
progress_2: cc.Node = null;
@property(cc.Node)
descriptionNode: cc.Node = null;
@property(cc.Label)
time: cc.Label = null;
// @property(cc.Prefab)
// passCheckItemLv: cc.Prefab = null;
@property(cc.Prefab)
buyActivate: cc.Prefab = null;
@property(cc.Button)
btnActivate1: cc.Button = null;
private timeNumber: number = 0;
private progressNum1: number = 0;
private progressNum2: number = 0;
private currentLvNum: number = 0;
private ProgressIndex: number = 0; // 记录当前进度索引
private countdownTimer: any = null;
private endTime: number = 0; // 结束时间戳(毫秒)
private passListData: Array<any> = []; // 存储处理后的passList数据
private btn_Touch: boolean = false;
private iosPrice: number = 0;
private iosProductId: string = "";
private iosCount: number = 1;
private onShowListener: () => void;
public passCheckMgr: any = null;
public oldPassCheckInfo: any = null;
protected onLoad(): void {
}
start() {
// 添加按钮事件监听
this.descriptionBtn.node.on('click', this.onDescriptionBtnClick, this);
this.closetBtn.node.on('click', this.onCloseBtnClick, this);
this.activateBtn.node.on('click', this.onActivateBtnClick, this);
// Utils.POST("login", { code: res.code, isDebug: isDebug, distinctId: cc.fx.GameConfig.GM_INFO.shushu_DistinctId }, ret => {
// console.log("__________请求结果", ret);
// if (!isCallBackCalled) {
// isCallBackCalled = true;
// if (ret.code === 1) { // 假设返回 code 为 1 表示成功
// Utils.openid = ret.data.openid;
// Utils.session_key = ret.data.session_key;
// Utils.uid = ret.data._id;
// }
// callBack(ret);
// }
// });
// this.initPassList();
this.onShowListener = null;
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
console.log("通行证添加监听");
this.onShowListener = () => {
console.log("回到前台,通行证添加监听");
this.onShow();
};
//@ts-ignore
wx.onShow(this.onShowListener);
}
this.btn_Touch = true;
}
setInfo(passCheck) {
this.onInit(passCheck);
}
onInit(passCheckInfo) {
const passCheckData = cc.fx.GameConfig.PASS_CHECK;
// let _playerPassLevel = cc.fx.GameConfig.GM_INFO.playerPassLevel
// let getUserLevel = cc.fx.GameConfig.GM_INFO.level;
let passCheck = null;
console.log("通行证里判断", cc.fx.GameConfig.GM_INFO.getItemType, cc.fx.GameConfig.GM_INFO.getItemType == 2);
if (cc.fx.GameConfig.GM_INFO.getItemType == 2) {
this.oldPassCheckInfo = passCheckInfo[1];
passCheck = passCheckInfo[2];
this.activateBtn.node.active = !passCheck.activate;
} else {
this.oldPassCheckInfo = passCheckInfo[2];
passCheck = passCheckInfo[1];
this.activateBtn.node.active = false;
}
this.ProgressIndex = cc.fx.StorageMessage.getStorage("ProgressIndex") || 1;
// 设置固定开始时间2025年11月4日10:00
// const startDate = new Date(2025, 10, 4, 10, 0, 0); // 月份从0开始所以11月是10
// const startTime = startDate.getTime();
// const now = new Date().getTime();
// // 计算结束时间(开始时间 + 60天
// this.endTime = passCheck.time + (60 * 24 * 60 * 60 * 1000); // 开始时间 + 60天的毫秒数
this.endTime = passCheck.time;
// this.ProgressIndex = 1;
console.log("检查是否是字符串", passCheck.progressLevel, passCheck);
// 检查是否是字符串,如果是则解析
// if (typeof passCheck1 === 'string') {
// try {
// passCheck1 = JSON.parse(passCheck1);
// // console.log("解析后的 passCheck1:", passCheck1);
// // console.log("解析后的 progressLevel:", passCheck1.progressLevel);
// } catch (e) {
// console.error("JSON 解析失败:", e);
// }
// }
if (typeof passCheck === 'string') {
try {
passCheck = JSON.parse(passCheck);
console.log("解析后的 passCheck:", passCheck);
console.log("解析后的 progressLevel:", passCheck.activate);
} catch (e) {
console.error("JSON 解析失败:", e);
}
}
console.log("passCheck.progressLevel", passCheck.progressLevel);
console.log("passCheck", passCheck);
this.timeNumber = 0;
this.progressNum1 = passCheck.progress;
if (passCheck.progressLevel > 30) {
passCheck.progressLevel = 30;
this.progressNum1 = passCheckData[passCheck.progressLevel - 1].token;
}
this.progressNum2 = passCheckData[passCheck.progressLevel - 1].token;
let lvNum = passCheck.progressLevel;
// let
console.log("lvNum", this.progressNum1, this.progressNum2);
if (this.progressNum1 == this.progressNum2) {
lvNum += 1;
this.currentLvNum = passCheck.progressLevel;
} else {
this.currentLvNum = passCheck.progressLevel - 1;
}
if (this.currentLvNum <= 0) {
this.currentLvNum = 1;
} else if (this.currentLvNum > 30) {
this.currentLvNum = 30;
}
if (lvNum >= 30) {
lvNum = 30;
}
NumberToImage.numberToImageNodes(lvNum, 35, 20, "month_", this.currentLv, true);
if (lvNum == 1 || (lvNum >= 10 && lvNum <= 19)) {
this.currentLv.x -= 5;
}
NumberToImage.numberToImageNodes(this.progressNum1, 20, 15, "mul", this.progress_1, true);
NumberToImage.numberToImageNodes(this.progressNum2, 20, 15, "mul", this.progress_2, true);
console.log("this.currentLvNum", this.currentLvNum);
cc.fx.GameConfig.GM_INFO.passCheckActivate = passCheck.activate;
// this.barSpr.fillRange = this.progressNum1 / this.progressNum2;
let barSprFillRange = this.progressNum1 / this.progressNum2;
this.barSpr.node.active = true;
let forInt = passCheck.progressLevel - this.ProgressIndex;
// if (forInt < 1) {
// forInt = 1;
// }
if (cc.fx.GameConfig.GM_INFO.getItemType == 1) {
forInt = 0;
// 当前是第二期领第一期物品
}
// let time = 0.3;
let fillRangeFun = (fillRange, time, reset?: boolean) => {
cc.tween(this.barSpr)
.delay(time)
.to(time, { fillRange: fillRange })
.call(() => {
console.log("fillRange", reset);
if (reset) {
this.barSpr.fillRange = 0;
if (this.progressNum1 == this.progressNum2) {
if (this.currentLvNum >= 30) {
NumberToImage.numberToImageNodes(4, 20, 15, "mul", this.progress_1, true);
} else {
NumberToImage.numberToImageNodes(0, 20, 15, "mul", this.progress_1, true);
}
let lvNumber = passCheck.progressLevel;
if (passCheck.progressLevel >= 30) {
lvNumber = 29;
}
NumberToImage.numberToImageNodes(passCheckData[lvNumber].token, 20, 15, "mul", this.progress_2, true);
}
// NumberToImage.numberToImageNodes(0, 20, 15, "mul", this.progress_1, true);
// NumberToImage.numberToImageNodes(0, 20, 15, "mul", this.progress_2, true);
// 可能还需要更新其他相关数据
// self.currentLvNum += 1;
// NumberToImage.numberToImageNodes(self.currentLvNum, 35, 20, "month_", self.currentLv, true);
}
})
.start();
}
// 确保动画按顺序执行
console.log("确保动画按顺序执行", forInt);
for (let j = 0; j < forInt; j++) {
cc.tween(this.barSpr).delay(j * 0.6 + 0.3).call(() => {
if (j == forInt - 1) {
// 最后一个动画,根据当前 fillRange 值决定
if (barSprFillRange == 1) {
// 延迟执行最后一个动画,确保前面的动画完成
fillRangeFun(1, 0.3, true);
} else {
fillRangeFun(barSprFillRange, 0.3);
}
} else {
// 中间的动画都填满到1
fillRangeFun(1, 0.3, true);
}
}).start();
}
if (forInt == 0) {
fillRangeFun(1, 0, true);
}
// cc.tween(this.barSpr)
// .delay(time)
// .to(time, { fillRange: 1 })
// .start();
// if (progress == 0) time = 0;
// cc.tween(child.getChildByName("progress").getComponent(cc.Sprite))
// .delay(j * 0.1)
// .to(time, { fillRange: progress })
// .start();
this.setbarNodePosX()
this.initCountDown();
console.log("activateBtn", passCheck.activate);
// 当前关卡的进度 1/4 当前关卡 5
// 当前领取到的关卡 免费 1 激活 2
// 从GameConfig中获取PASS_CHECK数据
this.passListData = [];
// 遍历数据并按照指定格式填充passList
for (let i = 0; i < passCheckData.length; i++) {
const item = passCheckData[i];
const level = item.level;
// 解析free字段 "2002:1" 格式
const freeParts = item.free.split(":");
const freeItemID = parseInt(freeParts[0]);
const freeItemNum = parseInt(freeParts[1]);
// 解析paid字段 "1001:500" 格式
const paidParts = item.paid.split(":");
const paidItemID = parseInt(paidParts[0]);
const paidItemNum = parseInt(paidParts[1]);
const freeValue = passCheck.free.length > i ? passCheck.free[i] : -1;
// const passCheckValue = passCheck.activate ? (passCheck.passCheck.length > i ? passCheck.passCheck[i] : -1) : -2;
const passCheckValue = passCheck.passCheck.length > i ? passCheck.passCheck[i] : -1
this.passListData.push({
id: i,
ItemID1: freeItemID,
ItemNum1: freeItemNum,
ItemID2: paidItemID,
ItemNum2: paidItemNum,
free: freeValue,
passCheck: passCheckValue
});
}
this.onShowList(this.passListData);
console.log("this.passListData", this.passListData);
}
onShowList(data: any) {
this.node.getChildByName("scrollViewNode").active = true;
var passCheckMgr = this.node.getChildByName("scrollViewNode").getComponent("passCheckMgr");
passCheckMgr.init(data, this.currentLvNum, this.oldPassCheckInfo, this.endTime);
this.passCheckMgr = passCheckMgr;
// passCheckMgr.updateProgressBars();
}
// 根据passList生成对应条数的Item
initPassListItems() {
}
initCountDown() {
this.time.node.active = true;
// 立即更新一次显示
this.updateCountdown();
// 每分钟更新一次倒计时
this.countdownTimer = setInterval(() => {
this.updateCountdown();
}, 60000); // 每60秒更新一次
}
updateCountdown() {
const now = new Date().getTime();
const distance = this.endTime - now;
if (distance <= 0) {
// 倒计时结束
if (this.countdownTimer) {
clearInterval(this.countdownTimer);
this.countdownTimer = null;
}
let barNode = this.node.getChildByName("centralNode").getChildByName("barNode")
barNode.x = 0;
this.activateBtn.node.active = false;
this.time.string = "已结束";
return;
}
// 计算天、小时、分钟
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
// 格式化显示
const formattedHours = hours.toString().padStart(2, '0');
const formattedMinutes = minutes.toString().padStart(2, '0');
if (days > 0) {
// 大于1天时显示 xx天xx时
this.time.string = `${days}${formattedHours}`;
} else {
// 小于1天时显示 xx时xx分
this.time.string = `${formattedHours}${formattedMinutes}`;
}
}
/**
* descriptionBtn事件descriptionNode节点
*/
onDescriptionBtnClick() {
// let setData = {
// uid: cc.fx.GameConfig.GM_INFO.uid,
// action: 'read',
// }
// Utils.POST("passCheck", setData, res => {
// //console.log("获得userLevel数据:", res);
// if (res.code === 1) {
// // console.log("服务器:获得通行证成功", res);
// try {
// const parsedData = JSON.parse(res.data.passCheck);
// console.log("服务器:获得通行证成功", res);
// console.log("parsedData:", parsedData);
// console.log("parsedData[0]:", parsedData.free[0]);
// } catch (error) {
// console.error('解析失败:', error);
// // 可能是对象已被字符串化,需要其他处理方式
// }
// // if (callBack) callBack(res);
// } else {
// console.log("服务器:获得通行证失败", res);
// // if (callBack) callBack(res);
// }
// });
if (this.descriptionNode) {
this.descriptionNode.active = true;
}
for (let i = 1; i <= 8; i++) {
let description = this.descriptionNode.getChildByName("description_" + i);
if (description) {
// 先隐藏节点
description.scale = 0;
description.active = true;
// 创建弹出动作序列
cc.tween(description)
.delay(i * 0.3) // 依次延迟
.to(0.3, { scale: 1 }, { easing: 'backOut' }) // 弹出效果
.start();
}
}
// 移除之前的事件监听
this.descriptionNode.getChildByName("solidColorBg").off(cc.Node.EventType.TOUCH_START);
// 添加新的事件监听
this.descriptionNode.getChildByName("solidColorBg").on(cc.Node.EventType.TOUCH_START, (event) => {
// 阻止事件冒泡
for (let i = 1; i <= 8; i++) {
let description = this.descriptionNode.getChildByName("description_" + i);
if (description) {
// 停止节点上的所有动作
cc.Tween.stopAllByTarget(description);
}
}
this.descriptionNode.active = false;
// event.stopPropagation();
// console.log("descriptionNode点击");
// // 使用动作隐藏节点
// cc.tween(this.descriptionNode)
// .to(0.3, { opacity: 0 })
// .call(() => {
// this.descriptionNode.active = false;
// this.descriptionNode.opacity = 255; // 恢复透明度以便下次使用
// })
// .start();
}, this);
}
/**
* closetBtn事件
*/
onCloseBtnClick() {
try {
// 先移除事件监听器
if (cc.sys.platform === cc.sys.WECHAT_GAME && this.onShowListener) {
console.log("shop移除onshow");
//@ts-ignore
wx.offShow(this.onShowListener);
this.onShowListener = null;
}
const now = new Date().getTime();
const distance = this.endTime - now;
if (cc.fx.GameConfig.GM_INFO.getItemType == 1 || distance <= 0) {
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
if (jiazaiComp) {
jiazaiComp.closePassCheck();
}
}
Utils.outTradeNo = null;
// 清理定时器
if (this.countdownTimer) {
clearInterval(this.countdownTimer);
this.countdownTimer = null;
}
// 执行完整的销毁逻辑
this.destroyPassCheck();
} catch (error) {
console.error("关闭通行证界面时发生错误:", error);
// 即使出错也要确保清理引用
this.cleanupAndDestroy();
}
}
private destroyPassCheck() {
try {
// 先隐藏节点
if (this.node && cc.isValid(this.node)) {
this.node.active = false;
}
// 清理 passCheckMgr 引用
this.passCheckMgr = null;
// 延迟销毁节点,给所有清理操作足够的时间
setTimeout(() => {
this.cleanupAndDestroy();
}, 100);
} catch (error) {
console.error("销毁通行证时出错:", error);
this.cleanupAndDestroy();
}
}
private cleanupAndDestroy() {
try {
if (this.node && cc.isValid(this.node)) {
try {
// 在销毁前确保 scrollViewNode 被移除
const scrollViewNode = this.node.getChildByName("scrollViewNode");
if (scrollViewNode && cc.isValid(scrollViewNode)) {
scrollViewNode.removeFromParent(true);
}
// 然后销毁主节点
this.node.destroy();
} catch (e) {
console.warn("销毁 passCheckNode 时出错:", e);
// 如果销毁失败,至少从父节点中移除
try {
if (this.node && cc.isValid(this.node)) {
this.node.removeFromParent();
}
} catch (e2) {
console.warn("从父节点移除 passCheckNode 时出错:", e2);
}
}
}
} catch (error) {
console.error("清理和销毁通行证时出错:", error);
}
}
onShow() {
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
console.log("从后台进入前台订单号:", cc.fx.GameConfig.GM_INFO.iosPassCheckOrder);
if (cc.fx.GameConfig.GM_INFO.iosPassCheckOrder != null && cc.fx.GameConfig.GM_INFO.iosPassCheckOrder != "") {
console.log("有苹果订单号,开始轮训");
const iosPassCheckOrder = cc.fx.GameConfig.GM_INFO.iosPassCheckOrder;
this.openLoad();
this.btn_Touch = true;
Utils.getIosPayInfo(iosPassCheckOrder,
(data) => {
console.log("获得轮训结果:", data);
const iosID = data.data?.payment_name || this.iosProductId;
let iosAmount = data.data?.goodsPrice || this.iosPrice;
iosAmount = parseInt(iosAmount);
if (data.code == 1) {
console.log("购买成功");
let name = "购买金币道具:" + iosID;
console.log("引力付费透传", iosAmount, iosPassCheckOrder, name);
MiniGameSdk.API.yinli_Pay(iosAmount, iosPassCheckOrder, name)
this.closeLoad();
// this.btn_Touch = true;
console.log("_________正式发货");
MiniGameSdk.API.showToast("充值成功");
// cc.fx.GameTool.shopBuy(iosID, false);
this.updatePassCheckActivateStatus();
// 刷新界面 解锁高级通行证 隐藏通行证按钮 进度条挪到中部
cc.fx.GameConfig.GM_INFO.iosPassCheckOrder = null;
}
else if (data.code == 0) {
console.log("用户自己取消充值");
MiniGameSdk.API.showToast("充值失败");
this.closeLoad();
this.btn_Touch = true;
const dataFail = {
outTradeNo: iosPassCheckOrder,
pay_amount: iosAmount,
payment_name: iosID,
payment_num: this.iosCount,
type: "ios",
fail_reason: "用户取消充值",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
cc.fx.GameConfig.GM_INFO.iosPassCheckOrder = null;
}
else if (data.code == 2) {
this.closeLoad();
this.btn_Touch = true;
console.log("轮训超时");
MiniGameSdk.API.showToast("请检查网络,如充值成功,请重新登录领取", 4);
const dataFail = {
outTradeNo: iosPassCheckOrder,
pay_amount: iosAmount,
payment_name: iosID,
payment_num: this.iosCount,
type: "ios",
fail_reason: "用户充值后,轮训结果超时",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
this.openConfirmBox();
}
// this.btn_Touch = true;
})
}
}
}
/**
* activateBtn事件
*/
onBuyActivate() {
// TODO: 待调用支付接口
// console.log("激活按钮点击,准备调用支付功能");
console.log("激活按钮点击,准备调用支付功能");
if (!this.btn_Touch) {
return;
}
this.btn_Touch = false;
const productId = "battlepass";
let id = "battlepass";
let price = 1800;
let count = 1;
// id = productId;
// switch (productId) {
// case "starter_pack":
// price = 300;
// break;
// }
console.log("获得商品id:", id, count, price);
let systemType = "Android";
try {
//@ts-ignore
const systemInfo = wx.getSystemInfoSync();
if (systemInfo.platform === 'ios') {
systemType = "ios";
}
} catch (e) {
console.error('获取系统信息失败', e);
}
if (systemType == "ios") {
// MiniGameSdk.API.showToast("IOS系统暂不支持支付");
// this.btn_Touch = true;
this.openLoad();
this.btn_Touch = true;
let iosPayInfo = {
price: price,
payment_name: productId,
payment_count: 1,
}
this.iosPrice = price;
this.iosProductId = productId;
this.iosCount = 1;
console.log("准备跳客服回话:");
console.log(this.iosProductId);
Utils.GoKEFu(iosPayInfo, (res) => {
if (res == "success") {
console.log("客服回话成功");
}
else {
console.log("客服回话失败");
this.closeLoad();
}
});
}
else {
this.openLoad();
this.btn_Touch = true;
Utils.buyProp(id, count, price, systemType, productId, (res) => {
if (res == null) {
MiniGameSdk.API.showToast("充值失败");
this.btn_Touch = true;
const dataFail = {
outTradeNo: Utils.outTradeNo,
pay_amount: price,
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: "网络异常,没有拉起支付",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
this.closeLoad();
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,
pay_amount: price,
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: name,
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail);
this.closeLoad();
return;
}
else {
Utils.getPayInfo((data) => {
// MiniGameSdk.API.showToast("充值成功");
console.log("7.28_______________充值成功,准备轮训", data);
//console.log("获得轮训结果:", data);
this.closeLoad();
if (data.data.pay_state == 1) {
this.btn_Touch = true;
MiniGameSdk.API.showToast("取消充值");
const dataFail2 = {
outTradeNo: Utils.outTradeNo,
pay_amount: price,
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: "用户取消支付",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail2);
}
else if (data.data.pay_state == 2) {
this.btn_Touch = true;
let name = "购买金币道具:" + productId;
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name);
console.log("充值成功,轮训成功,准备发货");
Utils.setPayInfo(
(res) => {
console.log("设置轮训结果:", res);
if (res.code === 1) {
console.log("正式发货", Utils.outTradeNo);
MiniGameSdk.API.showToast("充值成功");
// cc.fx.GameTool.shopBuy(productId, false);
this.updatePassCheckActivateStatus();
//
// this.updatePower();
//console.log("充值成功获得金币");
// 刷新界面 解锁高级通行证 隐藏通行证按钮 进度条挪到中部
}
else {
MiniGameSdk.API.showToast("网络异常,充值奖励将在登录后再次发放");
const dataFail4 = {
outTradeNo: Utils.outTradeNo,
pay_amount: price,
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: "成功付款,但是发货时请求服务器失败,充值成功未发货",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail4);
}
}, Utils.outTradeNo)
}
else {
const dataFail3 = {
outTradeNo: Utils.outTradeNo,
pay_amount: price,
payment_name: productId,
payment_num: 1,
type: systemType,
fail_reason: "拉起支付后,付款时网络异常付款失败",
}
cc.fx.GameTool.shushu_Track("payment_fail", dataFail3);
this.btn_Touch = true;
}
})
}
});
}
}
onActivateBtnClick() {
if (cc.fx.GameConfig.GM_INFO.getItemType == 1) {
MiniGameSdk.API.showToast("已过期");
} else {
let butActivate = cc.instantiate(this.buyActivate);
let timeStr = this.time.string;
butActivate.getComponent("buyActivate").init(() => {
this.onBuyActivate();
}, timeStr);
this.node.addChild(butActivate);
}
}
openLoad() {
const now = new Date().getTime();
const distance = this.endTime - now;
// 计算小时数
const hours = distance / (1000 * 60 * 60);
if (hours < 1) {
MiniGameSdk.API.showToast("剩余不足1小时请谨慎购买。");
}
this.node.getChildByName("Loading").active = true;
this.node.getChildByName("Loading").getChildByName("load").stopAllActions();
this.node.getChildByName("Loading").getChildByName("load").runAction(cc.rotateTo(2, 1080).repeatForever());
}
closeLoad() {
this.node.getChildByName("Loading").active = false;
}
openConfirmBox() {
this.closeLoad();
this.node.getChildByName("ConfirmBox").active = true;
}
closeConfirmBox() {
this.node.getChildByName("ConfirmBox").active = false;
}
private updatePassCheckActivateStatus() {
this.activateBtn.node.active = false;
cc.fx.GameConfig.GM_INFO.passCheckActivate = true;
this.setbarNodePosX();
// 获取passCheckMgr实例并更新激活状态
if (this.passCheckMgr && typeof this.passCheckMgr.refreshPassCheckItems === 'function') {
this.passCheckMgr.refreshPassCheckItems();
}
}
setbarNodePosX() {
let activate = cc.fx.GameConfig.GM_INFO.passCheckActivate;
let barNode = this.node.getChildByName("centralNode").getChildByName("barNode")
if (activate || cc.fx.GameConfig.GM_INFO.getItemType == 1) {
barNode.x = 0;
} else {
barNode.x = -253;
}
}
onDestroy() {
// 组件销毁时清除定时器
console.log("界面即将被销毁");
if (this.countdownTimer) {
clearInterval(this.countdownTimer);
this.countdownTimer = null;
}
}
}

View File

@ -0,0 +1,578 @@
import NumberToImage from "../../Script/NumberToImage";
const { ccclass, property } = cc._decorator;
@ccclass
export default class PassCheckItem extends cc.Component {
@property(cc.Prefab)
passCheckItemLvPrefab: cc.Prefab = null;
@property(cc.Sprite)
leftReward: cc.Sprite = null;
@property(cc.Sprite)
rightReward: cc.Sprite = null;
@property(cc.Node)
leftNum: cc.Node = null;
@property(cc.Node)
rightNum: cc.Node = null;
@property(cc.SpriteAtlas)
texture_atlas: cc.SpriteAtlas = null;
// 添加更多图集属性
@property(cc.SpriteAtlas)
newUserAtlas: cc.SpriteAtlas = null;
// @property(cc.SpriteAtlas)
// textureAtlas1: cc.SpriteAtlas = null;
@property(cc.SpriteAtlas)
uiAtlas: cc.SpriteAtlas = null;
// 数据
private data: any = null;
private itemIndex: number = 0;
private isUIInitialized: boolean = false;
// 1001 金币 2001 锤子 2003 魔棒 3001 15分钟无限体力 3002 30分钟 3003 1小时 3004 2小时 3005 3小时
// 添加物品ID到图片名称的映射
private itemImageMap: { [key: number]: { imageName: string, atlas: string } } = {
1001: { imageName: "coins4", atlas: "texture_atlas" }, // shop/img/texture_atlas-1
2001: { imageName: "iceb", atlas: "newUserAtlas" }, // action_bundle/img/newUser
2002: { imageName: "chuizi", atlas: "newUserAtlas" }, // action_bundle/img/newUser
2003: { imageName: "starb", atlas: "newUserAtlas" }, // action_bundle/img/newUser
3001: { imageName: "skylineHealth", atlas: "uiAtlas" }, // UI/UI/
3002: { imageName: "skylineHealth", atlas: "uiAtlas" }, // UI/UI/
3003: { imageName: "skylineHealth", atlas: "uiAtlas" }, // UI/UI/ skylineHealth
// 可以继续添加更多物品ID和对应图片的映射
};
private numImgmap: { [key: number]: { imageName: string, atlas: string } } = {
3001: { imageName: "15", atlas: "uiAtlas" },
3002: { imageName: "30min", atlas: "texture_atlas" },
3003: { imageName: "1h", atlas: "texture_atlas" },
}
init(data: any, index: number) {
this.data = data;
this.itemIndex = index;
console.log("111111")
this.updateUI();
}
initUI() {
if (!this.data) {
return;
}
// 防止重复初始化
if (this.isUIInitialized) {
return;
}
// 处理passCheckItemLv prefab的实例化
if (this.passCheckItemLvPrefab) {
// 实例化并添加新的prefab
const itemLvNode = cc.instantiate(this.passCheckItemLvPrefab);
itemLvNode.parent = this.node.parent;
itemLvNode.setPosition(this.node.x, this.node.y);
itemLvNode.zIndex = 2;
let bright_bg = itemLvNode.getChildByName("bright_bg").getComponent(cc.Sprite);
let levelNum = itemLvNode.getChildByName("levelNum");
let lvNum = this.itemIndex + 1
NumberToImage.numberToImageNodes(lvNum, 43, 15, "tili_", levelNum, true);
if (lvNum == 1 || (lvNum >= 10 && lvNum <= 19)) {
levelNum.x -= 5;
}
if (this.data.free === -1) {
// 未激活状态
if (this.uiAtlas) {
const spriteFrame = this.uiAtlas.getSpriteFrame("no_bright_bg");
if (spriteFrame) {
bright_bg.spriteFrame = spriteFrame;
}
cc.fx.GameTool.setGray(levelNum, true)
}
} else {
// 已激活状态
if (this.uiAtlas) {
const spriteFrame = this.uiAtlas.getSpriteFrame("bright_bg");
if (spriteFrame) {
bright_bg.spriteFrame = spriteFrame;
}
}
}
}
// 初始化按钮点击事件(只执行一次)
this.setupButtonEvents();
// 标记UI已初始化
this.isUIInitialized = true;
// 首次更新UI
this.updateUI();
}
// 专门用于设置按钮事件的方法
private setupButtonEvents() {
let node1 = this.node.getChildByName("leftNode");
let node2 = this.node.getChildByName("rightNode");
if (node1) {
let getBtn = node1.getChildByName("getBtn");
if (getBtn) {
getBtn.on('click', () => {
this.onGetRewardClicked(node1);
}, this);
}
}
if (node2) {
let getBtn = node2.getChildByName("getBtn");
if (getBtn) {
getBtn.on('click', () => {
this.onGetRewardClicked(node2);
}, this);
}
}
}
updateUI() {
if (!this.data) {
return;
}
// 根据数据更新界面元素
let node1 = this.node.getChildByName("leftNode");
let node2 = this.node.getChildByName("rightNode");
if (this.data.ItemID1 !== undefined && this.data.ItemNum1 !== undefined) {
this.updateItemInfo(this.data.ItemID1, this.data.ItemNum1, node1, this.data.free);
}
if (this.data.ItemID2 !== undefined && this.data.ItemNum2 !== undefined) {
this.updateItemInfo(this.data.ItemID2, this.data.ItemNum2, node2, this.data.passCheck);
}
if (this.data.free !== undefined) {
this.updateRewardState(this.data.free, node1);
}
if (this.data.passCheck !== undefined) {
this.updateRewardState(this.data.passCheck, node2);
}
}
updateRewardState(itemData: any, targetNode: cc.Node) {
// 更新免费状态的UI 0已领 1 未领
let getSpr = targetNode.getChildByName("get")
let getBtn = targetNode.getChildByName("getBtn")
let lock = targetNode.getChildByName("lock")
let activate = cc.fx.GameConfig.GM_INFO.passCheckActivate
if (lock) {
lock.active = false;
}
if (itemData === 1) {
getSpr.active = false;
getBtn.active = true;
if (lock && activate == false) {
lock.active = true;
getBtn.active = false;
}
} else if (itemData === 0) {
getSpr.active = true;
getBtn.active = false;
this.setNodeGray(targetNode)
} else {
if (lock && activate == false) {
lock.active = true;
}
getSpr.active = false;
getBtn.active = false;
}
}
updateItemInfo(itemID: number, itemNum: number, node: cc.Node, itemData: any) {
// 更新物品信息的UI
// console.log("Item info:", itemID, itemNum);
// 根据物品ID获取对应的图片名称和图集信息
const imageInfo = this.itemImageMap[itemID];
let freeRewardNode = node.getChildByName("freeReward");
let freeReward: cc.Sprite = null;
if (freeRewardNode) {
freeReward = freeRewardNode.getComponent(cc.Sprite);
}
if (imageInfo) {
// console.log(`Loading image for item ${itemID}: ${imageInfo.imageName} from atlas ${imageInfo.atlas}`);
// 根据图集名称获取对应的图集
let targetAtlas: cc.SpriteAtlas = null;
switch (imageInfo.atlas) {
case "texture_atlas":
targetAtlas = this.texture_atlas;
break;
case "newUserAtlas":
targetAtlas = this.newUserAtlas;
break;
case "uiAtlas":
targetAtlas = this.uiAtlas;
break;
default:
console.warn(`Unknown atlas: ${imageInfo.atlas}`);
break;
}
// 加载对应的图片资源
if (targetAtlas && freeReward) {
const spriteFrame = targetAtlas.getSpriteFrame(imageInfo.imageName);
if (spriteFrame) {
freeReward.spriteFrame = spriteFrame;
let imgScale = 1;
switch (itemID) {
case 1001:
imgScale = 1;
break;
case 2001:
imgScale = 0.7;
break;
case 2002:
imgScale = 0.6;
break;
case 2003:
imgScale = 0.6;
break;
default:
imgScale = 1.1;
break;
}
freeRewardNode.scale = imgScale;
} else {
console.warn(`Sprite frame ${imageInfo.imageName} not found in atlas ${imageInfo.atlas}`);
}
} else {
// console.log("默认图片");
}
} else {
console.warn(`No image found for item ID: ${itemID}`);
// 使用默认图片
}
let addTiem = node.getChildByName("addTiem");
addTiem.active = false;
let num1 = node.getChildByName("num_1");
let num_x = node.getChildByName("num_x");
num1.active = false;
num_x.active = false;
if ([3001, 3002, 3003].includes(itemID) && addTiem) {
addTiem.active = true;
const numImageInfo = this.numImgmap[itemID];
if (numImageInfo) {
let targetAtlas: cc.SpriteAtlas = null;
switch (numImageInfo.atlas) {
case "texture_atlas":
targetAtlas = this.texture_atlas;
break;
case "uiAtlas":
targetAtlas = this.uiAtlas;
break;
default:
console.warn(`Unknown atlas for num image: ${numImageInfo.atlas}`);
break;
}
if (targetAtlas) {
const spriteFrame = targetAtlas.getSpriteFrame(numImageInfo.imageName);
if (spriteFrame) {
let numSprite = addTiem.getComponent(cc.Sprite);
if (numSprite) {
numSprite.spriteFrame = spriteFrame;
}
} else {
console.warn(`Sprite frame ${numImageInfo.imageName} not found in atlas ${numImageInfo.atlas}`);
}
}
}
} else {
num1.active = true;
num_x.active = true;
NumberToImage.numberToImageNodes(itemNum, 50, 25, "pc_num_", num1, true);
if (itemData === 0) {
this.setNodeGray(num1)
this.setNodeGray(num_x)
}
num1.scale = 0.8;
// num_x.scale = 2;
// console.log("num1:", num_x, num1);
if (num_x && num1) {
// 计算数值的位数
const digitCount = itemNum.toString().length;
const offset = Math.max(0, digitCount);
const num_xWidth = num_x.width;
if (digitCount == 4) {
num_x.x = num1.x - (offset - 1) * num_xWidth - 20;
} else if (digitCount == 3) {
num_x.x = num1.x - offset * num_xWidth;
}
// console.log("digitCount:", digitCount);
}
}
}
updateItem(data: any, index: number) {
// 在这里处理数据更新
// console.log("Updating item with data:", data, "at index:", index);
// 你的数据更新逻辑
this.data = data;
this.itemIndex = index;
this.initUI();
}
// 数据改变时调用
public dataChanged() {
// console.log("Data changed, updating UI");
console.log("222222")
this.updateUI();
}
// 组件生命周期函数
protected onLoad() {
this.isUIInitialized = false;
}
protected start() {
// console.log("PassCheckItem component started");
}
// updateListItem(data) {
// console.log("更新列表数据", data)
// }
private onGetRewardClicked(targetNode: cc.Node) {
console.log("领取奖励按钮被点击", targetNode.name);
// 确定是左侧还是右侧的奖励
let isLeftReward = targetNode.name === "leftNode";
// 获取对应的物品ID和数量
let itemId = isLeftReward ? this.data.ItemID1 : this.data.ItemID2;
let itemNum = isLeftReward ? this.data.ItemNum1 : this.data.ItemNum2;
console.log("领取物品:", itemId, "数量:", itemNum);
// 调用领取奖励方法
this.claimReward(itemId, itemNum, isLeftReward);
}
private claimReward(itemId: number, itemNum: number, isLeftReward: boolean) {
// 根据物品ID处理不同类型的奖励
cc.fx.GameTool.getPassCheckPorp(itemId, itemNum, false)
// 更新本地状态
// this.updateLocalRewardState(isLeftReward);
// 更新UI显示
this.updateRewardUIAfterClaim(isLeftReward);
// 发送统计事件
// this.sendClaimEvent(itemId, itemNum);
const canvasTemp = cc.find("Canvas"); // 假设 Canvas 节点
console.log("领取奖励", canvasTemp.name);
if (canvasTemp) {
const JiaZai = canvasTemp.getComponent("JiaZai");
if (JiaZai) {
console.log("更新主界面数据")
// if (shuju.coin > 0) {
// JiaZai.updateCoin();
// }
// if (shuju.infinite_health > 0) {
// JiaZai.updatePower();
// }
switch (itemId) {
case 1001: // 金币
// this.claimCoins(itemNum);
JiaZai.updateCoin();
break;
case 2001: // 冰冻道具
// this.claimFreezeProp(itemNum);
break;
case 2002: // 锤子道具
// this.claimHammerProp(itemNum);
break;
case 2003: // 魔棒道具
// this.claimMagicProp(itemNum);
break;
default:
// console.warn("未知的物品ID:", itemId);
// this.claimInfiniteHealth(itemNum, itemId);
JiaZai.updatePower();
break;
}
}
}
}
private claimInfiniteHealth(amount: number, itemId: number) {
// cc.fx.GameTool.setUserPowerTime(amount);// 900 15分钟 1800 30分钟 3600 60分钟
}
// 领取金币
// private claimCoins(amount: number) {
// // cc.fx.GameTool.getPassCheckPorp()
// console.log("领取金币:", amount, "当前总金币:", cc.fx.GameConfig.GM_INFO.coin);
// }
// 领取冰冻
// private claimFreezeProp(amount: number) {
// cc.fx.GameConfig.GM_INFO.freezeAmount += amount;
// console.log("领取冰冻道具:", amount, "当前总数:", cc.fx.GameConfig.GM_INFO.freezeAmount);
// // // 更新本地存储
// // cc.fx.StorageMessage.setStorage("freezeAmount", cc.fx.GameConfig.GM_INFO.freezeAmount);
// // // 更新游戏中的道具显示
// // cc.systemEvent.emit('prop-updated', 'freeze', cc.fx.GameConfig.GM_INFO.freezeAmount);
// // const timestamp = Date.now();
// // let propInfo = cc.fx.StorageMessage.getStorage("prop");
// // propInfo.freezeAmount = cc.fx.GameConfig.GM_INFO.freezeAmount;
// // propInfo.timestamp = timestamp;
// // cc.fx.StorageMessage.setStorage("prop", propInfo);
// cc.fx.GameTool.setUserProp(2001, cc.fx.GameConfig.GM_INFO.freezeAmount, (data) => {
// })
// let data = {
// change_reason: "通行证",
// id: "2001",
// num: amount
// }
// cc.fx.GameTool.shushu_Track("resource_cost", data);
// }
//领取锤子道具
// private claimHammerProp(amount: number) {
// cc.fx.GameConfig.GM_INFO.hammerAmount += amount;
// console.log("领取锤子道具:", amount, "当前总数:", cc.fx.GameConfig.GM_INFO.hammerAmount);
// // // 更新本地存储
// // cc.fx.StorageMessage.setStorage("hammerAmount", cc.fx.GameConfig.GM_INFO.hammerAmount);
// // // 更新游戏中的道具显示
// // cc.systemEvent.emit('prop-updated', 'hammer', cc.fx.GameConfig.GM_INFO.hammerAmount);
// cc.fx.GameTool.setUserProp(2002, cc.fx.GameConfig.GM_INFO.hammerAmount, (data) => {
// })
// let data = {
// change_reason: "通行证",
// id: "2002",
// num: amount
// }
// cc.fx.GameTool.shushu_Track("resource_cost", data);
// }
//领取魔棒道具
// private claimMagicProp(amount: number) {
// cc.fx.GameConfig.GM_INFO.magicAmount += amount;
// console.log("领取魔棒道具:", amount, "当前总数:", cc.fx.GameConfig.GM_INFO.magicAmount);
// // // 更新本地存储
// // cc.fx.StorageMessage.setStorage("magicAmount", cc.fx.GameConfig.GM_INFO.magicAmount);
// // // 更新游戏中的道具显示
// // cc.systemEvent.emit('prop-updated', 'magic', cc.fx.GameConfig.GM_INFO.magicAmount);
// cc.fx.GameTool.setUserProp(2002, cc.fx.GameConfig.GM_INFO.magicAmount, (data) => {
// })
// let data = {
// change_reason: "通行证",
// id: "2003",
// num: amount
// }
// cc.fx.GameTool.shushu_Track("resource_cost", data);
// }
// 更新本地奖励状态
// private updateLocalRewardState(isLeftReward: boolean) {
// cc.systemEvent.emit('reward-claimed', this.itemIndex, isLeftReward);
// }
private updateRewardUIAfterClaim(isLeftReward: boolean) {
let targetNode = isLeftReward ?
this.node.getChildByName("leftNode") :
this.node.getChildByName("rightNode");
let num1 = targetNode.getChildByName("num_1");
let num_x = targetNode.getChildByName("num_x");
console.log("更新奖励UI:", isLeftReward);
if (targetNode) {
let getSpr = targetNode.getChildByName("get");
let getBtn = targetNode.getChildByName("getBtn");
if (getSpr && getBtn) {
getSpr.active = true;
getBtn.active = false;
this.setNodeGray(targetNode);
this.setNodeGray(num1);
}
}
this.updateRewardStateOnServer(isLeftReward);
}
private updateRewardStateOnServer(isLeftReward: boolean) {
console.log("更新奖励状态:", isLeftReward);
// 通知父组件更新服务器数据
// cc.systemEvent.emit('passcheck-reward-claimed', this.itemIndex, isLeftReward);
console.log("更新奖励状态:", isLeftReward);
// 向上循环查找 passCheckMgr 组件最多5次
// let currentNode = this.node;
// let parentCount = 0;
// let passCheckMgr = null;
// for (let i = 0; i < 5; i++) {
// parentCount++;
// if (currentNode.parent) {
// currentNode = currentNode.parent;
// console.log(`查找第${parentCount}层父节点: ${currentNode.name}`);
// // 检查当前节点是否有 passCheckMgr 组件
// passCheckMgr = currentNode.getComponent('passCheckMgr');
// if (passCheckMgr) {
// console.log(`找到 passCheckMgr 组件,需要 ${parentCount} 个 .parent`);
// break;
// }
// } else {
// console.log(`第${parentCount}层父节点不存在`);
// break;
// }
// }
let passCheckMgr = this.node.parent.parent.parent.parent.getComponent('passCheckMgr');
if (passCheckMgr && typeof passCheckMgr.updateRewardStatus === 'function') {
console.log("更新奖励状态到服务器:", this.itemIndex, isLeftReward);
passCheckMgr.updatePassCheckStatus(this.itemIndex, isLeftReward);
}
}
private setNodeGray(node: cc.Node, color?: cc.Color) {
let setColor = color || cc.color(190, 190, 190, 255);
for (let i = 0; i < node.children.length; i++) {
// console.log("设置子节点颜色", node.children[i]);
node.children[i].color = setColor;
}
}
}

View File

@ -0,0 +1,386 @@
import scrollViewList from "../../Script/module/List/scrollviewList";
import Utils from "../../Script/module/Pay/Utils";
import PassCheckItem from "./passCheckItem";
const { ccclass, property } = cc._decorator;
@ccclass
export default class passCheckMgr extends cc.Component {
private list: scrollViewList = null;
private passCheckItem: PassCheckItem = null;
listData: any[] = [];
private progressLevel: number = 0;
private progressBar3: cc.Node = null;
private progressBar4: cc.Node = null;
private ProgressIndex: number = 0;
private passCheckInfo: any[] = [];
private endTime: any;
private rewardUpdateTimeout: any = null;
private lastUpdateTime: number = 0;
private readonly UPDATE_DELAY: number = 200;
private isRewardTime: number = 0;
// private isLeftReward: boolean = false;
onLoad() {
cc.systemEvent.on('passcheck-reward-claimed', this.updateRewardStatus, this);
}
start() {
}
init(data: any[], progressLevel: number, oldPassCheckInfo: any[], time: any) {
// 确保组件已经被正确加载
if (!this.node) {
console.error("passCheckMgr: node is null");
return;
}
this.endTime = time;
this.passCheckInfo = oldPassCheckInfo;
// 设置当前进度等级
if (progressLevel !== undefined) {
this.progressLevel = progressLevel;
}
// 获取ScrollView组件使用不区分大小写的查找
let scrollViewNode: cc.Node | null = null;
const children = this.node.children;
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (child.name.toLowerCase() === "scrollview") {
scrollViewNode = child;
break;
}
}
if (!scrollViewNode) {
console.error("passCheckMgr: Cannot find ScrollView node under this.node");
console.log("Available children:", children.map(child => child.name));
return;
}
// 尝试获取scrollViewList组件如果没有则自动添加
this.list = scrollViewNode.getComponent(scrollViewList);
if (!this.list) {
console.log("passCheckMgr: scrollViewList component not found, adding it now");
this.list = scrollViewNode.addComponent(scrollViewList);
}
// 手动调用初始化,因为组件可能是在运行时添加的
this.list["init"]();
// 设置数据
this.listData = data;
this.list.setData(data);
// 创建进度条
this.setupProgressBars(scrollViewNode);
// 刷新list数据
// this.updateListItem(data);
}
private setupProgressBars(scrollViewNode: cc.Node) {
const content = scrollViewNode.getComponent(cc.ScrollView).content;
// 获取进度条节点
this.progressBar3 = this.node.getChildByName("scrollView").getChildByName("progress_bar_3");
this.progressBar4 = this.node.getChildByName("scrollView").getChildByName("progress_bar_4");
// 确保进度条节点存在
if (!this.progressBar3 || !this.progressBar4) {
console.error("passCheckMgr: Progress bar nodes not found");
return;
}
// 确保进度条有Sprite组件
let sprite3 = this.progressBar3.getComponent(cc.Sprite);
if (!sprite3) {
sprite3 = this.progressBar3.addComponent(cc.Sprite);
}
let sprite4 = this.progressBar4.getComponent(cc.Sprite);
if (!sprite4) {
sprite4 = this.progressBar4.addComponent(cc.Sprite);
}
// 设置进度条父节点为content
this.progressBar3.parent = content;
this.progressBar4.parent = content;
// 设置进度条属性
this.progressBar3.width = 32;
this.progressBar3.anchorX = 0.5;
this.progressBar3.anchorY = 0.5;
this.progressBar3.zIndex = 1; // 确保进度条在背景层
this.progressBar4.width = 32;
this.progressBar4.anchorX = 0.5;
this.progressBar4.anchorY = 0.5;
this.progressBar4.zIndex = 1; // 确保进度条在背景层
// 激活进度条
this.progressBar3.active = true;
this.progressBar4.active = true;
// 更新进度条显示
this.updateProgressBars();
}
// ... existing code ...
private updateProgressBars() {
// 确保进度条已创建
if (!this.progressBar3 || !this.progressBar4) {
console.log("passCheckMgr: Progress bars not created yet");
return;
}
// 确保有足够的数据来计算进度条位置
if (this.listData.length === 0) {
console.warn("passCheckMgr: No data to calculate progress bar positions");
return;
}
// 获取scrollViewList组件的配置
const itemHeight = this.list.itemHeight > 0 ? this.list.itemHeight : this.list["itemHeightActual"];
const spacingY = this.list.spacingY;
const paddingTop = this.list.paddingTop;
const paddingBottom = this.list.paddingBottom;
// 计算第一个item的中心Y位置
const firstItemCenterY = -paddingTop - itemHeight / 2;
// 计算最后一个item的中心Y位置
const lastIndex = this.listData.length - 1;
const lastItemCenterY = -paddingTop - itemHeight / 2 - lastIndex * (itemHeight + spacingY);
// 计算总长度
const totalLength = Math.abs(firstItemCenterY - lastItemCenterY);
const centerX = this.progressBar3.parent.width / 2;
// 设置总长度进度条 (progress_bar_3)
this.progressBar3.height = totalLength;
this.progressBar3.setAnchorPoint(0.5, 1);
this.progressBar3.setPosition(centerX, firstItemCenterY);
// 获取已保存的进度索引
this.ProgressIndex = cc.fx.StorageMessage.getStorage("ProgressIndex") || 0;
console.log("passCheckMgr: Saved ProgressIndex:", this.ProgressIndex > this.progressLevel, this.ProgressIndex, this.progressLevel, typeof this.ProgressIndex);
if (this.ProgressIndex > this.progressLevel) {
this.ProgressIndex = this.progressLevel;
}
console.log("passCheckMgr: ProgressIndex:", this.ProgressIndex);
const adjustedProgressIndex = Math.max(0, this.progressLevel - 1);
const adjustedStoredIndex = Math.max(0, this.ProgressIndex - 1);
// 计算进度位置
const progressIndex1 = Math.min(adjustedStoredIndex, this.listData.length - 1);
const progressIndex2 = Math.min(adjustedProgressIndex, this.listData.length - 1);
// 计算对应位置的Y坐标
const progressItemCenterY1 = -paddingTop - itemHeight / 2 - progressIndex1 * (itemHeight + spacingY);
const progressItemCenterY2 = -paddingTop - itemHeight / 2 - progressIndex2 * (itemHeight + spacingY);
// 计算进度条高度
const progressLength1 = Math.abs(firstItemCenterY - progressItemCenterY1);
const progressLength2 = Math.abs(firstItemCenterY - progressItemCenterY2);
this.progressBar4.setAnchorPoint(0.5, 1);
this.progressBar4.setPosition(centerX, firstItemCenterY);
this.progressBar4.height = progressLength1;
let growthLength = progressLength2 - progressLength1;
const targetHeight = progressLength1 + growthLength;
console.log("进度条更新:", {
currentLevel: this.progressLevel,
progressIndex1: progressIndex1,
progressIndex2: progressIndex2,
progressLength1: progressLength1,
progressLength2: progressLength2
});
if (growthLength > 0) {
cc.tween(this.progressBar4)
.delay(0.5)
.to(1, { height: targetHeight })
.call(() => {
this.progressBar4.height = progressLength2;
})
.start();
} else if (growthLength < 0) {
// 如果是倒退的情况(虽然不太可能)
this.progressBar4.height = progressLength2;
} else if (growthLength === 0 && progressLength2 === 0) {
// 特殊情况当进度为1级时进度条应该为0
this.progressBar4.height = 0;
}
cc.fx.StorageMessage.setStorage("ProgressIndex", this.progressLevel);
}
// ... existing code ...
// updateListItem(data) {
// this.passCheckItem.updateListItem(data);
// }
public updatePassCheckStatus(itemIndex?: number, isLeftReward?: boolean) {
const currentTime = Date.now();
// if (this.isRewardId == itemIndex && this.isLeftReward == isLeftReward) {
// return;
// }
// if (this.isRewardId == itemIndex &&
// this.isLeftReward == isLeftReward) {
// console.log("阻止短时间内重复领取相同奖励:", currentTime - this.lastUpdateTime, "ms");
// return;
// }
// console.log("=======", currentTime, this.lastUpdateTime, this.UPDATE_DELAY)
// console.log("更新数据", this.isRewardId, this.isLeftReward)
// this.lastUpdateTime = currentTime;
// this.isRewardId = itemIndex;
// this.isLeftReward = isLeftReward;
// 如果提供了itemIndex和isLeftReward则更新对应的奖励状态
if (itemIndex !== undefined && isLeftReward !== undefined) {
// 更新本地数据状态
if (this.listData[itemIndex]) {
if (isLeftReward) {
this.listData[itemIndex].free = 0; // 标记为已领取
} else {
this.listData[itemIndex].passCheck = 0; // 标记为已领取
}
}
}
// 构造要发送到服务器的数据
let now = this.endTime;
// console.log(now.toString());
let passCheck = null;
if (cc.fx.GameConfig.GM_INFO.getItemType == 2) {
passCheck = {
[1]: this.passCheckInfo,
[2]: {
time: now.toString(),
progress: cc.fx.GameConfig.GM_INFO.getProgress,
progressLevel: cc.fx.GameConfig.GM_INFO.getProgressLevel,
activate: cc.fx.GameConfig.GM_INFO.passCheckActivate, // activateValue,
free: this.listData.map(item => item.free),
passCheck: this.listData.map(item => item.passCheck),
}
};
} else {
passCheck = {
[1]: {
time: now.toString(),
progress: cc.fx.GameConfig.GM_INFO.getProgress,
progressLevel: cc.fx.GameConfig.GM_INFO.getProgressLevel,
activate: cc.fx.GameConfig.GM_INFO.passCheckActivate, // activateValue,
free: this.listData.map(item => item.free),
passCheck: this.listData.map(item => item.passCheck),
},
[2]: this.passCheckInfo,
}
}
console.log("保存数据", passCheck);
// 发送到服务器
Utils.setPassCheckInfo((res) => {
if (res.code === 1) {
console.log("通行证状态保存成功");
// this.refreshPassCheckItems();
} else {
console.log("通行证状态保存失败");
}
}, passCheck);
}
public refreshPassCheckItems() {
this.updatePassCheckStatus();
// 通知所有 passCheckItem 组件更新界面
if (this.list && this.list.node) {
// 通过ScrollView组件获取content节点
const scrollViewComponent = this.list.node.getComponent(cc.ScrollView);
if (scrollViewComponent && scrollViewComponent.content) {
const content = scrollViewComponent.content;
// 遍历所有子节点,查找 passCheckItem 组件并刷新
for (let i = 0; i < content.childrenCount; i++) {
const child = content.children[i];
// 查找 passCheckItem 节点(通常是间接子节点)
if (child.name === "passCheckItem") {
console.log("1111:", child.name);
// const passCheckItemNode = child.getChildByName("passCheckItem");
// if (passCheckItemNode) {
// console.log("2222:");
const passCheckItem = child.getComponent("passCheckItem");
if (passCheckItem) {
console.log("3333:");
passCheckItem.dataChanged();
}
// }
}
}
}
}
}
// private onRewardClaimed = (itemIndex: number, isLeftReward: boolean) => {
// console.log("收到奖励领取事件:", itemIndex, isLeftReward);
// this.updatePassCheckStatus(itemIndex, isLeftReward);
// }
public updateRewardStatus(itemIndex: number, isLeftReward: boolean) {
// this.updatePassCheckStatus(itemIndex, isLeftReward);
const currentTime = Date.now();
console.log("22222222222222222:", itemIndex, isLeftReward);
// 防止短时间内重复触发
if (currentTime - this.lastUpdateTime < this.UPDATE_DELAY) {
console.log("阻止短时间内重复更新:", currentTime - this.lastUpdateTime, "ms");
return;
}
this.isRewardTime = currentTime;
// 更新最后调用时间
this.lastUpdateTime = currentTime;
// 使用防抖机制,延迟处理奖励更新
if (this.rewardUpdateTimeout) {
clearTimeout(this.rewardUpdateTimeout);
}
this.rewardUpdateTimeout = setTimeout(() => {
this.updatePassCheckStatus(itemIndex, isLeftReward);
this.rewardUpdateTimeout = null;
}, 50);
}
public updateActivateStatus() {
this.updatePassCheckStatus();
}
protected onDestroy(): void {
console.log("销毁passCheckMgr");
cc.systemEvent.off('passcheck-reward-claimed', this.updateRewardStatus, this);
// 清理可能存在的列表数据
if (this.listData) {
this.listData = null;
}
// 如果列表组件存在,尝试清理它
if (this.list && cc.isValid(this.list.node)) {
try {
// 先清理数据
if (this.list.setData) {
this.list.setData([]);
}
} catch (e) {
console.warn("清理列表数据时出错:", e);
}
}
this.list = null;
this.passCheckItem = null;
}
}