Commit 63364e4b authored by haiyoucuv's avatar haiyoucuv

init

parent c69de84f
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "d33ae702-1557-46ba-b5b1-e5e98835465c",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "d33ae702-1557-46ba-b5b1-e5e98835465c@6c48a",
"displayName": "光",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "d33ae702-1557-46ba-b5b1-e5e98835465c",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "d33ae702-1557-46ba-b5b1-e5e98835465c@f9941",
"displayName": "光",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 750,
"height": 1624,
"rawWidth": 750,
"rawHeight": 1624,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-375,
-812,
0,
375,
-812,
0,
-375,
812,
0,
375,
812,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1624,
750,
1624,
0,
0,
750,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-375,
-812,
0
],
"maxPos": [
375,
812,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "d33ae702-1557-46ba-b5b1-e5e98835465c@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "d33ae702-1557-46ba-b5b1-e5e98835465c@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "e353df8e-f8e2-4925-8d4a-20b25d83c193",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "e353df8e-f8e2-4925-8d4a-20b25d83c193@6c48a",
"displayName": "第1关",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "e353df8e-f8e2-4925-8d4a-20b25d83c193",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "e353df8e-f8e2-4925-8d4a-20b25d83c193@f9941",
"displayName": "第1关",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 750,
"height": 555,
"rawWidth": 750,
"rawHeight": 555,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-375,
-277.5,
0,
375,
-277.5,
0,
-375,
277.5,
0,
375,
277.5,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
555,
750,
555,
0,
0,
750,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-375,
-277.5,
0
],
"maxPos": [
375,
277.5,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "e353df8e-f8e2-4925-8d4a-20b25d83c193@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "e353df8e-f8e2-4925-8d4a-20b25d83c193@6c48a"
}
}
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "06163308-920b-4b14-91ac-6853cab9944e",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "06163308-920b-4b14-91ac-6853cab9944e@6c48a",
"displayName": "第二关",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "06163308-920b-4b14-91ac-6853cab9944e",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "06163308-920b-4b14-91ac-6853cab9944e@f9941",
"displayName": "第二关",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 750,
"height": 536,
"rawWidth": 750,
"rawHeight": 536,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-375,
-268,
0,
375,
-268,
0,
-375,
268,
0,
375,
268,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
536,
750,
536,
0,
0,
750,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-375,
-268,
0
],
"maxPos": [
375,
268,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "06163308-920b-4b14-91ac-6853cab9944e@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "06163308-920b-4b14-91ac-6853cab9944e@6c48a"
}
}
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
"ver": "1.2.0", "ver": "1.2.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "64d2d23c-5da0-4b83-8455-065565ac925c", "uuid": "afb9ecca-3fb0-4e97-afe4-6eeb10cf5ce0",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {}
"isBundle": true
}
} }
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "5084325f-5785-4e49-bad2-8ba2bede881c",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "5084325f-5785-4e49-bad2-8ba2bede881c@6c48a",
"displayName": "banner",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "5084325f-5785-4e49-bad2-8ba2bede881c",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "5084325f-5785-4e49-bad2-8ba2bede881c@f9941",
"displayName": "banner",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 687,
"height": 154,
"rawWidth": 687,
"rawHeight": 154,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-343.5,
-77,
0,
343.5,
-77,
0,
-343.5,
77,
0,
343.5,
77,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
154,
687,
154,
0,
0,
687,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-343.5,
-77,
0
],
"maxPos": [
343.5,
77,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "5084325f-5785-4e49-bad2-8ba2bede881c@6c48a",
"atlasUuid": "",
"trimType": "auto"
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "5084325f-5785-4e49-bad2-8ba2bede881c@6c48a"
}
}
import { _decorator, Component, Node } from 'cc'; import { _decorator, Component, Node } from 'cc';
import { BundleCarColorsSysterm } from './Systerms/BundleCarColorsSysterm';
import { RoleCarColorsSysterm } from './Systerms/RoleCarColorsSysterm'; import { RoleCarColorsSysterm } from './Systerms/RoleCarColorsSysterm';
import { CarCarColorsSysterm } from './Systerms/CarCarColorsSysterm'; import { CarCarColorsSysterm } from './Systerms/CarCarColorsSysterm';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -16,7 +15,6 @@ export class CarColorsGlobalInstance extends Component { ...@@ -16,7 +15,6 @@ export class CarColorsGlobalInstance extends Component {
return this._instance; return this._instance;
} }
public bundleSysterm: BundleCarColorsSysterm = null
public roleSysterm: RoleCarColorsSysterm = null public roleSysterm: RoleCarColorsSysterm = null
public carSysterm: CarCarColorsSysterm = null public carSysterm: CarCarColorsSysterm = null
......
// Bundles列表 // Bundles列表
export const BundleNames = { export const BundleNames = {
UI: "UI", UI: "UI",
// CarColorsCars: "CarColorsCars",
CarColorsCharacter:"CarColorsCharacter", CarColorsCharacter:"CarColorsCharacter",
Audio:"Audio",
} }
export enum CarTypes { export enum CarTypes {
......
...@@ -7,63 +7,6 @@ const { ccclass, property } = _decorator; ...@@ -7,63 +7,6 @@ const { ccclass, property } = _decorator;
export class BundleCarColorsSysterm extends Component { export class BundleCarColorsSysterm extends Component {
bundles: Map<string, AssetManager.Bundle> = new Map() bundles: Map<string, AssetManager.Bundle> = new Map()
// 加载资源分包
async loadBundles() {
let bundleNames = Object.keys(BundleNames)
let bundleTotal = bundleNames.length
let bundleProgress = 0
find("UI/BundleLoading/ProgressBar").getComponent(ProgressBar).progress = bundleProgress / bundleTotal
find("UI/BundleLoading/Text").getComponent(Label).string = `资源包 ${bundleProgress}/${bundleTotal}`
const promiseList: Array<Promise<AssetManager.Bundle>> = []
bundleNames.forEach((name) => {
// console.log(name)
const promise: Promise<AssetManager.Bundle> = new Promise((res, rej) => {
assetManager.loadBundle(BundleNames[name], (err, bundle) => {
if (err) {
console.error(err)
rej(err)
return
}
// console.log(bundle)
bundleProgress += 1
this.bundles.set(BundleNames[name], bundle)
find("UI/BundleLoading/ProgressBar").getComponent(ProgressBar).progress = bundleProgress / bundleTotal
find("UI/BundleLoading/Text").getComponent(Label).string = `资源包 ${bundleProgress}/${bundleTotal}`
res(bundle)
})
})
promiseList.push(promise)
})
await Promise.all(promiseList)
}
// 角色资源————————————————————————————————————————————————————————————————————————————————
loadRolePrefab(): Array<Promise<Prefab>> {
const promiseList: Array<Promise<Prefab>> = []
const roleNames = Object.keys(RoleNames).filter(item => isNaN(Number(item)))
let total = roleNames.length
let progress = 0
roleNames.forEach((key) => {
const promise: Promise<Prefab> = new Promise((res, rej) => {
this.bundles.get(BundleNames.CarColorsCharacter).load(key, Prefab, (err, prefab: Prefab) => {
if (err) {
console.error(err)
rej(err)
return
}
find("UI/BundleLoading/ProgressBar").getComponent(ProgressBar).progress = progress / total
find("UI/BundleLoading/Text").getComponent(Label).string = `初始化角色 ${progress}/${total}`
res(prefab)
})
})
promiseList.push(promise)
})
return promiseList
}
// 加载关卡 // 加载关卡
loadLevels(lv: number): Promise<Prefab> { loadLevels(lv: number): Promise<Prefab> {
if (lv > 10) { if (lv > 10) {
......
import { import {
_decorator, _decorator, assetManager,
Component, Component,
find, find,
geometry, geometry,
...@@ -31,19 +31,25 @@ export class RoleCarColorsSysterm extends Component { ...@@ -31,19 +31,25 @@ export class RoleCarColorsSysterm extends Component {
isGaming: boolean = false isGaming: boolean = false
async loadRolePrefabs() { async loadRolePrefabs() {
const colors = Object.keys(CarColors).filter(item => isNaN(Number(item))) const colors = Object.keys(CarColors).filter(item => isNaN(Number(item)))
const prefabList: Array<Prefab> = await Promise.all(CarColorsGlobalInstance.instance.bundleSysterm.loadRolePrefab()) const rolePrefab = await new Promise<Prefab>((resolve) => {
prefabList.forEach((prefab, index) => { assetManager.getBundle("MainGame")
colors.forEach(color => { .load(`prefab/character_man`, Prefab, (err, prefab: Prefab) => {
const pool = new NodePool() if (err) {
this.rolePools.set(color, { pool, prefab }) resolve(null);
for (let i = 10; i--;) { return
const role = instantiate(prefab) }
role.getComponent(RoleCarColorsComponent).color = CarColors[color] resolve(prefab);
pool.put(role) })
} })
}) colors.forEach(color => {
const pool = new NodePool()
this.rolePools.set(color, { pool, prefab: rolePrefab })
for (let i = 10; i--;) {
const role = instantiate(rolePrefab)
role.getComponent(RoleCarColorsComponent).color = CarColors[color]
pool.put(role)
}
}) })
} }
......
...@@ -393,7 +393,7 @@ export class PlatformManager { ...@@ -393,7 +393,7 @@ export class PlatformManager {
if (sys.platform === sys.Platform.WECHAT_GAME){ if (sys.platform === sys.Platform.WECHAT_GAME){
const nowTime = new Date().getTime() const nowTime = new Date().getTime()
wx.shareAppMessage() wx.shareAppMessage()
CarColorsGlobalInstance.instance.bundleSysterm.scheduleOnce(()=>{ CarColorsGlobalInstance.instance.scheduleOnce(()=>{
if (new Date().getTime() - nowTime < 3000){ if (new Date().getTime() - nowTime < 3000){
fcallback && fcallback() fcallback && fcallback()
}else { }else {
......
...@@ -2,7 +2,6 @@ import { _decorator, find, instantiate, Label, ProgressBar } from 'cc'; ...@@ -2,7 +2,6 @@ import { _decorator, find, instantiate, Label, ProgressBar } from 'cc';
import { changeScene, showToast } from "db://assets/core/Module/UIFast"; import { changeScene, showToast } from "db://assets/core/Module/UIFast";
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import { CarColorsGlobalInstance } from "db://assets/CarColorsGame/Scrips/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/CarColorsGame/Scrips/CarColorsGlobalInstance";
import { ConfigKeys, GlobalData } from "db://assets/ScriptFrame/GlobalData";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene"; import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import Panel from "db://assets/core/Module/Panel"; import Panel from "db://assets/core/Module/Panel";
...@@ -42,18 +41,18 @@ export class FailPage extends Panel { ...@@ -42,18 +41,18 @@ export class FailPage extends Panel {
find("Scene/Levels").removeAllChildren() find("Scene/Levels").removeAllChildren()
CarColorsGlobalInstance.instance.roleSysterm.clearAll() CarColorsGlobalInstance.instance.roleSysterm.clearAll()
CarColorsGlobalInstance.instance.carSysterm.clearAll() CarColorsGlobalInstance.instance.carSysterm.clearAll()
CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level) => { // CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level) => {
const Level = instantiate(level) // const Level = instantiate(level)
find("Scene/Levels").addChild(Level) // find("Scene/Levels").addChild(Level)
for (let i = 0; i < Level.children.length; i++) { // for (let i = 0; i < Level.children.length; i++) {
CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i]) // CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i])
} // }
CarColorsGlobalInstance.instance.roleSysterm.initLevel() // CarColorsGlobalInstance.instance.roleSysterm.initLevel()
}).catch((err) => { // }).catch((err) => {
// console.log(err) // // console.log(err)
showToast("关卡正在制作中") // showToast("关卡正在制作中")
changeScene(HomeScene); // changeScene(HomeScene);
}) // })
AudioMgr.ins.playOneShot(AudioClipName.start); AudioMgr.ins.playOneShot(AudioClipName.start);
} }
} }
......
...@@ -47,18 +47,18 @@ export class StopPage extends Panel { ...@@ -47,18 +47,18 @@ export class StopPage extends Panel {
find("Scene/Levels").removeAllChildren() find("Scene/Levels").removeAllChildren()
CarColorsGlobalInstance.instance.roleSysterm.clearAll() CarColorsGlobalInstance.instance.roleSysterm.clearAll()
CarColorsGlobalInstance.instance.carSysterm.clearAll() CarColorsGlobalInstance.instance.carSysterm.clearAll()
CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level)=>{ // CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level)=>{
const Level = instantiate(level) // const Level = instantiate(level)
find("Scene/Levels").addChild(Level) // find("Scene/Levels").addChild(Level)
for(let i = 0; i < Level.children.length;i++){ // for(let i = 0; i < Level.children.length;i++){
CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i]) // CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i])
} // }
CarColorsGlobalInstance.instance.roleSysterm.initLevel() // CarColorsGlobalInstance.instance.roleSysterm.initLevel()
}).catch((err)=>{ // }).catch((err)=>{
// console.log(err) // // console.log(err)
showToast("关卡正在制作中") // showToast("关卡正在制作中")
changeScene(HomeScene); // changeScene(HomeScene);
}) // })
AudioMgr.ins.playOneShot(AudioClipName.start); AudioMgr.ins.playOneShot(AudioClipName.start);
} }
} }
......
...@@ -49,18 +49,18 @@ export class SuccessPage extends Panel { ...@@ -49,18 +49,18 @@ export class SuccessPage extends Panel {
find("Scene/Levels").removeAllChildren() find("Scene/Levels").removeAllChildren()
CarColorsGlobalInstance.instance.roleSysterm.clearAll() CarColorsGlobalInstance.instance.roleSysterm.clearAll()
CarColorsGlobalInstance.instance.carSysterm.clearAll() CarColorsGlobalInstance.instance.carSysterm.clearAll()
CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level) => { // CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level).then((level) => {
const Level = instantiate(level) // const Level = instantiate(level)
find("Scene/Levels").addChild(Level) // find("Scene/Levels").addChild(Level)
for (let i = 0; i < Level.children.length; i++) { // for (let i = 0; i < Level.children.length; i++) {
CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i]) // CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i])
} // }
CarColorsGlobalInstance.instance.roleSysterm.initLevel() // CarColorsGlobalInstance.instance.roleSysterm.initLevel()
}).catch((err) => { // }).catch((err) => {
// console.log(err) // // console.log(err)
showToast("关卡正在制作中") // showToast("关卡正在制作中")
changeScene(HomeScene); // changeScene(HomeScene);
}) // })
} }
} }
......
import { _decorator, Button, loadWasmModuleBullet, Node } from "cc"; import { _decorator, assetManager, Button, loadWasmModuleBullet, Node } from "cc";
import Scene from "db://assets/core/Module/Scene"; import Scene from "db://assets/core/Module/Scene";
import { changeScene, hideWaiting, showPanel, showWaiting } from "db://assets/core/Module/UIFast"; import { changeScene, hideWaiting, showPanel, showWaiting } from "db://assets/core/Module/UIFast";
import store from "../store/store"; import store from "../store/store";
......
import { _decorator, find, instantiate } from 'cc'; import { _decorator, assetManager, find, instantiate, Prefab } from 'cc';
import Scene from "db://assets/core/Module/Scene"; import Scene from "db://assets/core/Module/Scene";
import { changeScene, showToast } from "db://assets/core/Module/UIFast"; import { changeScene, showToast } from "db://assets/core/Module/UIFast";
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene"; import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import { BundleCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/BundleCarColorsSysterm";
import { CarColorsGlobalInstance } from "db://assets/CarColorsGame/Scrips/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/CarColorsGame/Scrips/CarColorsGlobalInstance";
import { RoleCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/RoleCarColorsSysterm"; import { RoleCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/RoleCarColorsSysterm";
import { CarCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/CarCarColorsSysterm"; import { CarCarColorsSysterm } from "db://assets/CarColorsGame/Scrips/Systerms/CarCarColorsSysterm";
import { ConfigKeys, GlobalData } from "db://assets/ScriptFrame/GlobalData"; import { ConfigKeys, GlobalData } from "db://assets/ScriptFrame/GlobalData";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('MainGame') @ccclass('MainGame')
...@@ -16,14 +16,12 @@ export class MainGame extends Scene { ...@@ -16,14 +16,12 @@ export class MainGame extends Scene {
static skin: string = "MainGame"; static skin: string = "MainGame";
static bundle: string = "MainGame"; static bundle: string = "MainGame";
level: number = 0;
async start() { async start() {
this.initData() this.initData()
// 挂载资源包管理系统
CarColorsGlobalInstance.instance.bundleSysterm = this.node.addComponent(BundleCarColorsSysterm)
await CarColorsGlobalInstance.instance.bundleSysterm.loadBundles()
// 人物管理系统 // 人物管理系统
CarColorsGlobalInstance.instance.roleSysterm = this.node.addComponent(RoleCarColorsSysterm) CarColorsGlobalInstance.instance.roleSysterm = this.node.addComponent(RoleCarColorsSysterm)
await CarColorsGlobalInstance.instance.roleSysterm.loadRolePrefabs() await CarColorsGlobalInstance.instance.roleSysterm.loadRolePrefabs()
...@@ -31,14 +29,14 @@ export class MainGame extends Scene { ...@@ -31,14 +29,14 @@ export class MainGame extends Scene {
// 汽车管理系统 // 汽车管理系统
CarColorsGlobalInstance.instance.carSysterm = this.node.addComponent(CarCarColorsSysterm) CarColorsGlobalInstance.instance.carSysterm = this.node.addComponent(CarCarColorsSysterm)
await this.startGame(); await this.nextLevel();
} }
async startGame(){ async nextLevel() {
find("Scene/Parkings").children.forEach((child, index)=>{ find("Scene/Parkings").children.forEach((child, index) => {
if (index < 4){ if (index < 4) {
child.name = "empty" child.name = "empty"
}else{ } else {
child.name = "lock" child.name = "lock"
child.children[0].children[0].active = false child.children[0].children[0].active = false
child.children[0].children[1].active = true child.children[0].children[1].active = true
...@@ -47,31 +45,43 @@ export class MainGame extends Scene { ...@@ -47,31 +45,43 @@ export class MainGame extends Scene {
child.children[1]?.removeFromParent() child.children[1]?.removeFromParent()
}) })
find("Scene/Parkings").active = true find("Scene/Parkings").active = true
this.level++;
CarColorsGlobalInstance.instance.roleSysterm.clearAll() CarColorsGlobalInstance.instance.roleSysterm.clearAll()
CarColorsGlobalInstance.instance.carSysterm.clearAll() CarColorsGlobalInstance.instance.carSysterm.clearAll()
CarColorsGlobalInstance.instance.bundleSysterm.loadLevels(
GlobalData.instance.getConfigData(ConfigKeys.GameSaveData).level const level = await new Promise<Prefab>((resolve) => {
).then((level) => { assetManager.getBundle("MainGame")
console.log("instantiate(level)") .load(`Levels/level${this.level}`, Prefab, (err, prefab: Prefab) => {
const Level = instantiate(level) if (err) {
find("Scene/Levels").addChild(Level) resolve(null);
for(let i = 0; i < Level.children.length;i++){ return
CarColorsGlobalInstance.instance.carSysterm.addCar(Level.children[i]) }
} resolve(prefab);
CarColorsGlobalInstance.instance.roleSysterm.initLevel() });
}).catch((err)=>{ });
console.log(err)
showToast("关卡正在制作中") if(!level) {
showToast("没有更多关卡了");
changeScene(HomeScene); changeScene(HomeScene);
}) return;
}
const levelNode = instantiate(level);
find("Scene/Levels").addChild(levelNode);
for (let i = 0; i < levelNode.children.length; i++) {
CarColorsGlobalInstance.instance.carSysterm.addCar(levelNode.children[i]);
}
CarColorsGlobalInstance.instance.roleSysterm.initLevel()
AudioMgr.ins.playOneShot(AudioClipName.start); AudioMgr.ins.playOneShot(AudioClipName.start);
} }
initData(){ initData() {
let gameSaveData: {level: number} = GlobalData.instance.getConfigData(ConfigKeys.GameSaveData) let gameSaveData: { level: number } = GlobalData.instance.getConfigData(ConfigKeys.GameSaveData)
if (gameSaveData === null){ if (gameSaveData === null) {
gameSaveData = { gameSaveData = {
level: 1 level: 1
} }
......
...@@ -8,14 +8,14 @@ interface IPlayOptions { ...@@ -8,14 +8,14 @@ interface IPlayOptions {
export enum AudioClipName { export enum AudioClipName {
bgm = "bgm", bgm = "Audio/bgm",
button_ok = "button_ok", button_ok = "Audio/button_ok",
start = "start", start = "Audio/start",
upgrade = "upgrade", upgrade = "Audio/upgrade",
crash = "crash", crash = "Audio/crash",
brake = "brake", brake = "Audio/brake",
win = "win", win = "Audio/win",
helico = "helico", helico = "Audio/helico",
} }
/** /**
...@@ -91,7 +91,7 @@ export class AudioMgr { ...@@ -91,7 +91,7 @@ export class AudioMgr {
playOneShot(sound: AudioClip | AudioClipName | string, options: IPlayOptions = {}) { playOneShot(sound: AudioClip | AudioClipName | string, options: IPlayOptions = {}) {
options = { options = {
bundleName: "Audio", bundleName: "resources",
volume: this.soundVolume, volume: this.soundVolume,
...options ...options
}; };
...@@ -121,7 +121,7 @@ export class AudioMgr { ...@@ -121,7 +121,7 @@ export class AudioMgr {
play(sound: AudioClip | AudioClipName | string, options: { loop?: boolean } & IPlayOptions = {}) { play(sound: AudioClip | AudioClipName | string, options: { loop?: boolean } & IPlayOptions = {}) {
options = { options = {
bundleName: "Audio", bundleName: "resources",
loop: true, loop: true,
volume: 1, volume: 1,
...options ...options
......
...@@ -5,7 +5,5 @@ ...@@ -5,7 +5,5 @@
"uuid": "0936edb3-4792-4cb7-8563-b3a68055aebb", "uuid": "0936edb3-4792-4cb7-8563-b3a68055aebb",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {}
"isBundle": true
}
} }
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "9e36692c-ee49-4b8c-a0d1-4bc8a962ecca",
"files": [],
"subMetas": {},
"userData": {}
}
{
"ver": "1.0.1",
"importer": "ttf-font",
"imported": true,
"uuid": "e8e67735-dc38-4dfb-821c-864fff0c7de6",
"files": [
".json",
"zzgfyht.ttf"
],
"subMetas": {},
"userData": {}
}
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