110 lines
5.3 KiB
TypeScript
110 lines
5.3 KiB
TypeScript
import GameModel from "../core/GameModel";
|
|
import ItemUtil from "../core/ItemUtil";
|
|
import WingUtil from "../wing/WingUtil";
|
|
import SKLoadData, { SKLoadType } from "../gear_2.3.4/util/SKLoadData";
|
|
import SKLoader from "../gear_2.3.4/util/SKLoader";
|
|
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class GameLoadScene extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
load_lb: cc.Label = null;
|
|
|
|
@property(cc.ProgressBar)
|
|
load_pb: cc.ProgressBar = null;
|
|
|
|
onLoad() {
|
|
cc.log("GameLoadScene")
|
|
// cc.game.setFrameRate(30);
|
|
// 遊戲加載
|
|
let list = [];
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/picPercent", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/picPercent2", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/picPercent3", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/picNotice", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/role", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/Npc", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/preRoleBrodcast", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/TalkUI", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Prefab, "Prefabs/BagPanel", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Atlas, "Common/ChatEmoji", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Atlas, "Common/role", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Atlas, "Common/pethead", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Atlas, "Common/huoban", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Atlas, "roleres/roleres", "正在加載遊戲資源..."));
|
|
list.push(new SKLoadData(SKLoadType.Dir, "horse", "正在加載遊戲資源..."));
|
|
// list.push(new SKLoadData(SKLoadType.Dir,"wing","正在加載翅膀資源..."));
|
|
let self = this;
|
|
this.load_pb.node.getComponent(cc.Widget).updateAlignment()
|
|
this.load_pb.totalLength = this.load_pb.node.width;
|
|
SKLoader.shared.load(list, (data: SKLoadData, progress: number) => {
|
|
if (self) {
|
|
self.load_pb.progress = progress;
|
|
self.load_lb.string = `${data.info}${(progress * 100).toFixed(2)}%`;
|
|
}
|
|
}, (data: SKLoadData, resources: any[], urls: string[]) => {
|
|
switch (data.url) {
|
|
case "Prefabs/picPercent":
|
|
GameModel.picPercent = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/picPercent2":
|
|
GameModel.picPercent2 = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/picPercent3":
|
|
GameModel.picPercent3 = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/picNotice":
|
|
GameModel.picNotice = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/role":
|
|
GameModel.role = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/Npc":
|
|
GameModel.npc = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/preRoleBrodcast":
|
|
GameModel.preRoleBrodcast = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Prefabs/TalkUI":
|
|
GameModel.talkUI = SKDataUtil.prefabByList(resources, 0);
|
|
break;
|
|
case "Common/ChatEmoji":
|
|
GameModel.chatEmojiAtlas = SKDataUtil.atlasByList(resources, 0);
|
|
break;
|
|
case "Common/role":
|
|
GameModel.roleHeadAtlas = SKDataUtil.atlasByList(resources, 0);
|
|
break;
|
|
case "Common/pethead":
|
|
GameModel.petHeadAtlas = SKDataUtil.atlasByList(resources, 0);
|
|
break;
|
|
case "Common/huoban":
|
|
GameModel.houBanHeadAtlas = SKDataUtil.atlasByList(resources, 0);
|
|
break;
|
|
case "roleres/roleres":
|
|
console.log(resources)
|
|
GameModel.rolePosterAtlas = SKDataUtil.atlasByList(resources, 0);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}, () => {
|
|
this.load_lb.string = `正在進入遊戲...`;
|
|
let self = this;
|
|
SKUIUtil.loadScene("MainScene", (completedCount, totalCount, item) => {
|
|
if (self) {
|
|
let progress = completedCount / totalCount;
|
|
let info = `加載遊戲場景...${(progress * 100).toFixed(2)}%`;
|
|
self.load_lb.string = info;
|
|
self.load_pb.progress = progress;
|
|
}
|
|
}, (sceneName: string) => {
|
|
GameModel.currentScene = sceneName;
|
|
});
|
|
});
|
|
}
|
|
}
|