Commit ea301bff authored by liujiangnan's avatar liujiangnan

feat: 只预加载游乐场,其他的都改为后台加载

parent eff3d751
{
"ver": "1.2.9",
"uuid": "15dd8bcb-0545-4b46-9dfb-c5beaf7d0b68",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "a907fca7-97bb-4052-b89c-413543f2839d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "7b6672a3-eb2b-4a37-8888-ba894cf5e5ac",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "e0366195-c65c-42ac-8be2-785074e46502",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "4fe6bcf2-edd4-42e3-b4f5-c403ced94748",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}
\ No newline at end of file
import { asyncCallNetworkApiGet, asyncCallNetworkApiPost, buttonOnClick } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.AudioClip)
bgMusic1: cc.AudioClip = null;
addPreloadImage() {
// this._imageResList.push({ url: this.data.pic_url });
}
async onLoadEnd() {
const btnReturn = cc.find('Canvas/bg/btn_return');
buttonOnClick(btnReturn, () => {
global.middleLayer.loadOnlineBundle('NJ_YouLeChang');
});
const pid = global.middleLayer.getData('NJ_menu');
const classDataStr = await asyncCallNetworkApiGet('/api/syllabus/v1/list', {
pid: pid,
cludeoffline: 1,
});
const classData = JSON.parse(classDataStr);
let activeLevelIds;
let kidInfo;
if (global.middleLayer.isLogin == false) {
// 游客模式
activeLevelIds = [];
kidInfo = null;
} else {
kidInfo = await global.middleLayer.getUserInfo();
activeLevelIds = kidInfo.active_levels.map(item => item.syllabus_id);
}
const ballData = classData.rows.map((row, idx) => {
let locked = true;
if (activeLevelIds.includes(row.id) || idx==0) {
locked = false;
}
return { id: row.id, locked: locked, online_status: row.online_status };
});
for (let i = 0; i < 5; i++) {
const data = ballData[i];
const idx = i;
const star = cc.find(`Canvas/bg/star_${idx}`);
const icon = cc.find(`Canvas/bg/star_${idx}/icon`);
const lock = cc.find(`Canvas/bg/star_${idx}/lock`);
const dark = cc.find(`Canvas/bg/line_${idx}/line`);
const light = cc.find(`Canvas/bg/line_${idx}/light`);
if (!data || data.locked) {
icon.active = false;
lock.active = true;
dark.active = true;
light.active = false;
} else {
icon.active = true;
lock.active = false;
dark.active = false;
light.active = true;
}
// 不在球上控制解锁逻辑了,球的级别都能点进去, 统一都给解锁开
if (data && !data.locked && global.middleLayer.isLogin != false) {
if (!kidInfo.unlock_syllabuses || !kidInfo.unlock_syllabuses.includes(data.id)) {
await asyncCallNetworkApiPost('/api/oxford/v1/kid/unlock', {
kidid: kidInfo.id,
syllabusid: data.id,
token: cc.sys.localStorage.getItem('token')
})
}
}
buttonOnClick(star, async () => {
if (!data || (data && data.online_status != 1 && data.locked)) {
global.middleLayer.showTips("精彩在路上~ 敬请期待!");
return;
}
if (data.locked) {
if (global.middleLayer.isLogin == false) {
// 游客
// 提示先登录后购买
global.middleLayer.showConfirm("需要登录后才能使用,去登录吗?", ()=>{
global.middleLayer.loadOnlineBundle('NJ_login');
});
return;
}
// 弹出激活码
global.middleLayer.showActiveWindow();
return;
}
global.middleLayer.setData('nextLevelId', ballData[idx + 1] ? ballData[idx + 1].id : null);
global.middleLayer.setData('NJ_menu_select_idx', idx);
if (idx == 0) {
global.middleLayer.setData('NJ_QianShuiTing', data.id);
global.middleLayer.loadOnlineBundle('NJ_QianShuiTing');
} else if (idx == 1) {
global.middleLayer.setData('NJ_ShaMo', data.id);
global.middleLayer.loadOnlineBundle('NJ_ShaMo');
} else if (idx == 2) {
global.middleLayer.setData('NJ_NongChang', data.id);
global.middleLayer.loadOnlineBundle('NJ_NongChang');
} else if (idx == 3) {
global.middleLayer.setData('NJ_XueShan', data.id);
global.middleLayer.loadOnlineBundle('NJ_XueShan');
} else if (idx == 4) {
global.middleLayer.setData('NJ_TianKong', data.id);
global.middleLayer.loadOnlineBundle('NJ_TianKong');
}
});
}
// 播放背景音乐
cc.audioEngine.stopMusic();
cc.audioEngine.playMusic(this.bgMusic1, true);
}
protected update(dt: number): void {
for (let idx = 0; idx < 4; idx++) {
const line = cc.find(`Canvas/bg/line_${idx}`);
const starLeft = cc.find(`Canvas/bg/star_${idx}`);
const starRight = cc.find(`Canvas/bg/star_${idx + 1}`);
line.x = (starLeft.x + starRight.x) / 2;
line.y = (starLeft.y + starRight.y) / 2;
line.scaleX = Math.abs(starLeft.x - starRight.x) / line.width;
line.scaleY = Math.abs(starLeft.y - starRight.y) / line.height;
}
}
}
{
"ver": "1.0.8",
"uuid": "ffd94a6f-1445-4cba-8b2c-a62a5d8678dd",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -779,7 +779,7 @@ export default class NewClass extends middleLayerBase {
}
runInnerBundle(bundleName) {
const arr = ['NJ_YouLeChang', 'NJ_login', 'NJ_menu', 'NJ_QianShuiTing'];
const arr = this.needInitPreloadPage.map(item => item.bundleName);
if (!arr.includes(bundleName)) {
return false;
}
......@@ -1157,12 +1157,12 @@ export default class NewClass extends middleLayerBase {
}
needInitPreloadPage = [
{bundleName: 'NJ_YouLeChang', name: '游乐场(1/4)'},
{bundleName: 'NJ_login', name: '郊外(2/4)'},
{bundleName: 'NJ_menu', name: '星空(3/4)'},
{bundleName: 'NJ_QianShuiTing', name: '潜水艇(4/4)'},
{bundleName: 'NJ_YouLeChang', name: '游乐场'},
];
needAppPreloadpage = [
{bundleName: 'NJ_menu', name: '星空'},
{bundleName: 'NJ_QianShuiTing', name: '潜水艇'},
{bundleName: 'NJ_login', name: '郊外'},
{bundleName: 'NJ_MoTianLun', name: '摩天轮'},
{bundleName: 'NJ_YueDuJiaYouZhan', name: '阅读加油站'},
{bundleName: 'NJ_MonkyTree', name: '天梯'},
......
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
const currentStage = "NJ_QianShuiTing";
const nextStage = "NJ_TipsDone";
const tipsNode = cc.find("tips", this.node)
let tipsStage = cc.sys.localStorage.getItem('SYS_GUIDE_TIPS');
if(!tipsStage) {
tipsStage = currentStage;
cc.sys.localStorage.setItem('SYS_GUIDE_TIPS', tipsStage);
}
if(tipsStage == currentStage) {
tipsNode.active = true;
cc.sys.localStorage.setItem('SYS_GUIDE_TIPS', nextStage);
}
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "2ab456e3-244a-4346-994f-64159f6dd4ba",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
const currentStage = "NJ_Menu";
const nextStage = "NJ_QianShuiTing";
const tipsNode = cc.find("tips", this.node)
let tipsStage = cc.sys.localStorage.getItem('SYS_GUIDE_TIPS');
if(!tipsStage) {
tipsStage = currentStage;
cc.sys.localStorage.setItem('SYS_GUIDE_TIPS', tipsStage);
}
if(tipsStage == currentStage) {
tipsNode.active = true;
cc.sys.localStorage.setItem('SYS_GUIDE_TIPS', nextStage);
}
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "970e8d32-b267-4da5-b464-70b63b2fda30",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "81251087-6819-45d6-be6c-b855d6d10795",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "6c51ad86-b4e5-481a-9fc1-55e20c037de3",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 434,
"height": 116,
"platformSettings": {},
"subMetas": {
"bg_oxford": {
"ver": "1.0.4",
"uuid": "7b1313f4-8982-4a72-80ef-e7ffad66968b",
"rawTextureUuid": "6c51ad86-b4e5-481a-9fc1-55e20c037de3",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1.5,
"offsetY": 0,
"trimX": 1,
"trimY": 3,
"width": 429,
"height": 110,
"rawWidth": 434,
"rawHeight": 116,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c9f76946-d2a9-4479-9b51-9901e146a911",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment