import Menu from "./Menu";
|
import Userdata from "./Userdata";
|
import Global from "./Global";
|
import SoundManager from "./SoundManager";
|
|
const {ccclass, property} = cc._decorator;
|
|
@ccclass
|
export default class MoreLevelItem extends cc.Component {
|
|
@property(cc.Label)
|
levelLabel: cc.Label = null;
|
|
@property(cc.Label)
|
needStarLabel: cc.Label = null;
|
|
private currIndex: number = -1;
|
private needStarSum: number = 0;
|
private button: cc.Button;
|
|
onLoad(){
|
this.button = this.getComponent(cc.Button);
|
}
|
|
init(index: number){
|
this.currIndex = index;
|
this.needStarSum = Global.moreLevelNeedStars(index);
|
|
this.levelLabel.string = (100 * index + 1) + " - " + (100 * index + 100);
|
this.needStarLabel.string = this.needStarSum.toString();
|
|
this.updateShow();
|
}
|
|
updateShow(){
|
//check stars
|
|
if (Global.OPENALL_LEVEL || Userdata.Stars >= this.needStarSum){
|
this.button.interactable = true;
|
|
this.button.node.color = cc.Color.WHITE;
|
this.needStarLabel.node.color = cc.Color.WHITE;
|
this.levelLabel.node.color = cc.Color.WHITE;
|
}else{
|
this.button.interactable = false;
|
|
this.button.node.color = cc.Color.GRAY;// cc.color(180,180,180);
|
this.needStarLabel.node.color = cc.Color.GRAY;//cc.color(180,180,180);
|
this.levelLabel.node.color = cc.Color.GRAY;//cc.color(180,180,180);
|
}
|
}
|
|
onClickItem(){
|
SoundManager.playButton();
|
Menu.instance.updateLevels(this.currIndex * 100 + 1);
|
}
|
}
|