Spring774
2025-10-30 a972605e1cf8122330de5b6ff53857be130972be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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);
    }
}