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.
96 lines
2.9 KiB
96 lines
2.9 KiB
import GameMgr from "../../FrameWork/Mgr/GameMgr";
|
|
import User from "../../FrameWork/User/User";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import PrefabManage from "../PrefabManager/PrefabManage";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class SingleItem extends cc.Component {
|
|
|
|
@property(cc.Label)
|
|
gameTitle: cc.Label = null;
|
|
|
|
@property(cc.Sprite)
|
|
gameIcon: cc.Sprite = null;
|
|
|
|
@property(cc.Node)
|
|
levelPoint: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
levelMasks: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
lightEffect: cc.Node = null;
|
|
|
|
curConfig = null;
|
|
itemState = 0; //0 未开发 1 未解锁 2 已通关 3 已解锁
|
|
|
|
|
|
initView(config) {
|
|
this.curConfig = config;
|
|
|
|
this.gameTitle.string = config.title;
|
|
Common5.getSpriteFrameFromBundle("FirstSelectScene", "picture/zoomLevel/" + config.titleIconUrl, this.gameIcon);
|
|
for (const point of this.levelPoint) {
|
|
point.getChildByName("lab").getComponent(cc.Label).string = config.index + 1;
|
|
}
|
|
this.updateUI();
|
|
}
|
|
|
|
updateUI() {
|
|
for (const mask of this.levelPoint) {
|
|
mask.active = false;
|
|
}
|
|
for (const mask of this.levelMasks) {
|
|
mask.active = false;
|
|
}
|
|
this.lightEffect.active = false;
|
|
|
|
if (!this.curConfig.isCanPlay) {
|
|
this.levelPoint[2].active = true;
|
|
this.levelMasks[3].active = true;
|
|
this.itemState = 0;
|
|
return;
|
|
}
|
|
|
|
let curGameLevelIndex = User.getCurGameLevelIndex();
|
|
if (this.curConfig.index > curGameLevelIndex) {
|
|
this.levelPoint[2].active = true;
|
|
this.levelMasks[2].active = true;
|
|
this.itemState = 1;
|
|
} else if (this.curConfig.index < curGameLevelIndex) {
|
|
this.levelPoint[0].active = true;
|
|
this.levelMasks[0].active = true;
|
|
this.itemState = 2;
|
|
} else {
|
|
this.levelPoint[1].active = true;
|
|
this.levelMasks[1].active = true;
|
|
this.itemState = 3;
|
|
this.lightEffect.active = true;
|
|
cc.tween(this.lightEffect)
|
|
.to(1, { opacity: 100 })
|
|
.to(1, { opacity: 255 })
|
|
.union()
|
|
.repeatForever()
|
|
.start();
|
|
}
|
|
}
|
|
|
|
onItemClick() {
|
|
// Common5.playEffect("sound/按键点击");
|
|
if (this.itemState == 0) {
|
|
PrefabManage.showTextTips('正在努力开发中!');
|
|
return;
|
|
} else if (this.itemState == 1) {
|
|
PrefabManage.showTextTips('未来还没来,一切皆可能');
|
|
return;
|
|
} else if (this.itemState == 2) {
|
|
PrefabManage.showTextTips('过去已过去,计较也无用');
|
|
return;
|
|
}
|
|
|
|
Common5.selectGameInfo = this.curConfig;
|
|
GameMgr.getInstance_custom().onLoadToGameScene_custom();
|
|
}
|
|
}
|
|
|