我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

193 lines
8.7 KiB

import { ryw_Event } from "../FrameWork/Event/EventEnum";
import EventMgr from "../FrameWork/Event/EventMgr";
import GameMgr from "../FrameWork/Mgr/GameMgr";
import GameReport, { ENTERTYPE } from "../FrameWork/Report/ZyZyReport";
import User from "../FrameWork/User/User";
import AppPlatform from "../FrameWork/Util/AppPlatform";
import Utilit from "../FrameWork/Util/Utilit";
import Common5 from "../Platform/th/Common5";
import TTAPI from "../Platform/tt/TTAPI";
import DayUnlock from "../ttFrame/manager/DayUnlock";
import PhysicalPowerManger from "../ttFrame/manager/PhysicalPowerManger";
import Game from "./Game";
import MainScene from "./MainSceneScript";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ExitTip extends cc.Component {
protected start(): void {
}
nextFunc(){
let levels = Common5.gameConfig.GameAllType[Common5.curWordGameType].Levels;
let nextLevel = -1;
for (let i = 0; i < levels.length; i++){
if (levels[i] == Common5.selectGameNum){
if (i < levels.length - 1){
nextLevel = levels[i+1];
}
break;
}
}
if (nextLevel !=-1){
User.setLeveNum_custom(nextLevel);
User.setLevelAryy_custom(nextLevel);
User.saveDataToServer()
console.log('保存下一个+++')
Common5.selectGameInfo = Common5.gameConfig.zmGameConfig[nextLevel];
Common5.selectGameNum = nextLevel;
EventMgr.emitEvent_custom(ryw_Event.updateLevel);
Common5.wordGameType = 0;
}
else {
let levelArr = User.getLevelAryy_custom();
for (let i = 0; i < Common5.gameConfig.GameAllType[Common5.curWordGameType].Levels.length; i++){
let level = Common5.gameConfig.GameAllType[Common5.curWordGameType].Levels[i]
if (levelArr[level] == 0){
nextLevel = level;
Common5.selectGameInfo = Common5.gameConfig.zmGameConfig[nextLevel];
Common5.selectGameNum = nextLevel;
User.setLeveNum_custom(nextLevel);
User.setLevelAryy_custom(nextLevel);
Common5.wordGameType = 0;
EventMgr.emitEvent_custom(ryw_Event.updateLevel);
break;
}
}
}
if (nextLevel == -1){
let levelArr = User.getSuccessLevels();
let find = false;
for (let i = 0; i < Common5.gameConfig.GameAllType[Common5.curWordGameType].Levels.length; i++){
let level = Common5.gameConfig.GameAllType[Common5.curWordGameType].Levels[i]
for (let j = 0; j < levelArr.length; j++){
if (level == levelArr[j]){
find = true;
break;
}
}
if (!find){
nextLevel = level;
break;
}
}
}
Common5.selectGameNum = nextLevel;
if (Common5.selectGameNum == -1){
Common5.showTips_custom("恭喜您已通关!")
return;
}
let inGameFunc = ()=>{
// Common5.showTips_custom("请稍等,资源正在加载中......");
MainScene.ins.showLoading();
Common5.stopMusic();
if (Common5.selectGameInfo.subbundle !="" && Common5.selectGameInfo.subbundle != undefined){
let subbundle = cc.assetManager.loadBundle(Common5.selectGameInfo.subbundle,(err,subbundle)=>{
cc.assetManager.loadBundle(Common5.selectGameInfo.bundle, function (err: Error, bundle: cc.AssetManager.Bundle) {
MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").removeAllChildren();
MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").destroyAllChildren();
console.log("remove all children!")
Common5.getPrefabFromBundle(Common5.selectGameInfo.bundle,Common5.selectGameInfo.url,MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode"),(prefab)=>{
// prefab.width = Game.ins.maskNode.width;
// prefab.height = Game.ins.maskNode.width;
if (Common5.selectGameNum != 0){
User.setFirstIn(false);
}
if (Common5.selectGameInfo.isTer){
Common5.getPrefabFromBundle("ZoomGame","prefab/view/TerrTip");
}
User.setLeveNum_custom(Common5.selectGameNum);
// prefab.scale = Game.ins.maskNode.width/prefab.width;
// prefab.setPosition(0,0);
// console.log("prefab.width",prefab.width,prefab.height,prefab.position,MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").position)
// Common5.hideTips_custom();
MainScene.ins.hidLoading();
Game.ins.reset();
MainScene.ins.isLoading = false;
})
});
})
}
else {
cc.assetManager.loadBundle(Common5.selectGameInfo.bundle, function (err: Error, bundle: cc.AssetManager.Bundle) {
MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").destroyAllChildren();
MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").removeAllChildren();
console.log("remove all children!")
Common5.getPrefabFromBundle(Common5.selectGameInfo.bundle,Common5.selectGameInfo.url,MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode"),(prefab)=>{
// prefab.width = Game.ins.maskNode.width;
// prefab.height = Game.ins.maskNode.width;
if (Common5.selectGameNum != 0){
User.setFirstIn(false);
}
if (Common5.selectGameInfo.isTer){
Common5.getPrefabFromBundle("ZoomGame","prefab/view/TerrTip");
}
User.setLeveNum_custom(Common5.selectGameNum);
// prefab.scale = Game.ins.maskNode.width/prefab.width;
// prefab.setPosition(0,0);
// console.log("prefab.width",prefab.width,prefab.height,prefab.position,MainScene.ins.GameNode.getChildByName("mask").getChildByName("prefabNode").position)
Common5.hideTips_custom();
MainScene.ins.hidLoading();
Game.ins.reset();
MainScene.ins.isLoading = false;
})
});
}
}
if (Common5.isNoEnergyMode == 0) {
if (PhysicalPowerManger.isCanUserPhysical()) {
inGameFunc();
} else {
console.log("体力不够");
Common5.getPrefabFromBundle("ZoomGame", "Prefabs/UI/WxtlUI", null, (prefab) => {
})
}
} else {
inGameFunc();
}
this.btnCloseFunc();
}
btnVideo(){
let tab = {
onClose: (finish) => {
if (finish) {
if(Common5.selectGameInfo){
Common5.ReportDY("inLevel", Common5.selectGameInfo.title2 + "-AD-跳过本关");
GameReport.ADReport('跳过本关',Common5.selectGameInfo.title2,1)
}
this.nextFunc();
}
else {
GameReport.ADReport('跳过本关',Common5.selectGameInfo.title2,0)
Common5.showTips_custom("广告未看完");
}
this.node.removeFromParent();
}, onFailed: () => {
this.node.removeFromParent();
}
}
AppPlatform.playVideo_custom(tab);
}
btnCloseFunc() {
this.node.removeFromParent();
}
btnExit(){
Game.ins.exitGame();
this.node.removeFromParent();
}
btnShare(){
AppPlatform.PlatformShare(()=>{
},'','')
}
}