Spring774
2025-10-27 a621979f62588ed1a899d17c937dc3aee8670ec1
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
const { ccclass, property } = cc._decorator;
 
/**
 * 道具类型
 */
export enum PROP_TYPE {
    SHOOT3,
    TIMES3,
    WALL
}
 
@ccclass
export default class Global extends cc.Component {
    //physics tags
    public static TAG_Obstacle = 998;
    public static TAG_WALL = 999;
    public static TAG_WALL_BOTTOM = 1000;
 
    public static BALL_SPEED = 400;
    public static MAX_BALLS = 800;
 
    public static WALL_TIME = 5;
    public static PROP_WALL_RATE = 0.025;
 
    //获得奖励总需积分
    public static REWARD_NEED_SCORE = 4057;//总分数
    public static THUNDER_COST = 200;//闪电花费钻石
 
    //积分奖励 钻石
    public static SCORE_REWARD_GEM = 30;
    public static WATCH_VIDEO_GEM = 30;//看视频获得钻石
 
    //复活消耗
    public static REVIVE_COST_GEM = 200;
 
    public static PROP_SHOOT_COST = 50;
    public static PROP_TIMES_COST = 100;
    public static PROP_WALL_COST = 100;
 
    public static SKIN_COST = 500;
 
    public static THREE_STARS_TOTAL_TIME = 135;
    public static SHOW_PROP_TIP_TIME = 30;
 
    public static DEBUG = false;
    public static OPENALL_LEVEL = false;
 
    public static firstOpenMenu = true;
    public static firstOpenGame = true;
 
    public static MAX_MORE_LEVELS = 50;
    public static MAX_STAGE = 100;//100一个小章节
 
    private static lastPropType = 0;
 
    //获取今日日期字符串,代表日期的当地写法(不含小时、分和秒)。
    static getTodayString(): string {
        let now = new Date();
 
        let year = now.getFullYear();
        let month = now.getMonth() + 1;
        let day = now.getDate();
        return ''.concat(year.toString(), month.toString(), day.toString());
    }
 
    static getNextPropType(selectLevel: number): PROP_TYPE {
        let rand = Math.random();
        let propType = PROP_TYPE.SHOOT3;
        //let timesRand = Global.PROP_WALL_RATE + (0.55 - Math.min(0.25, selectLevel * 0.00125));
        if (rand < Global.PROP_WALL_RATE) {
            propType = PROP_TYPE.WALL;
        } else {
            if (this.lastPropType != PROP_TYPE.TIMES3) {
                propType = PROP_TYPE.TIMES3;
            } else {
                propType = PROP_TYPE.SHOOT3;
            }
        }
 
        this.lastPropType = propType;
        return propType;
    }
 
    static getPropDropCount(createTimes: number, selectLevel: number): number {
        if (selectLevel < 10) {
            return Math.min(30, createTimes * 2 + 2);
        } else if (selectLevel < 20) {
            return Math.min(30, Math.floor(createTimes * 2.5) + 2);
        } else if (selectLevel < 30) {
            return Math.min(40, Math.floor(createTimes * 3) + 2);
        } else if (selectLevel < 45) {
            return Math.min(40, Math.floor(createTimes * 3.5) + 3);
        } else if (selectLevel < 60) {
            return Math.min(40, Math.floor(createTimes * 4) + 3);
        } else if (selectLevel < 80) {
            return Math.min(50, Math.floor(createTimes * 4.5) + 3);
        } else if (selectLevel < 100) {
            return Math.min(50, Math.floor(createTimes * 5) + 4);
        } else if (selectLevel < 125) {
            return Math.min(50, Math.floor(createTimes * 5.5) + 4);
        } else {
            return Math.min(60, Math.floor(createTimes * 6) + 4);
        }
    }
 
    //index 更多关卡每100关索引加1
    public static moreLevelNeedStars(index: number): number {
        if (index > 49) {
            index = 49;
        }
        return Math.floor((100 * index) * (index * 0.0165 + 2));
    }
 
    //加载界面
    public static loadingScene(sceneName: string) {
        cc.loader.loadRes("prefabs/ui/Loading", (err, prefab) => {
            let loading = cc.find('Canvas/Loading');
            if (loading) {
                loading.active = false;
            }
 
            let _node = cc.instantiate(prefab);
            _node.name = 'Loading';
            cc.game.addPersistRootNode(_node);
 
            _node.runAction(
                cc.callFunc(() => {
                    cc.director.preloadScene(sceneName, () => {
                        cc.director.loadScene(sceneName);
                    });
                })
            );
 
        });
    }
 
    //显示积分奖励界面
    static showScoreRewardUI(parentNode: cc.Node, node: cc.Node) {
        let loading = cc.find('Canvas/Loading');
        if (loading) {
            loading.zIndex = 999;
            loading.active = true;
        }
        cc.loader.loadRes("prefabs/ui/RewardLayer", function (err, prefab) {
            let _node = cc.instantiate(prefab);
            _node.parent = parentNode;
 
            let rewardLayer = _node.getComponent("RewardLayer");
            rewardLayer.setEventNode(node);
 
            loading.active = false;
        });
    }
 
    //显示提示
    static showTip(str: string, delayTime = 0.6) {
        cc.loader.loadRes("prefabs/ui/TipPanel", function (err, prefab) {
            let tipNode = cc.instantiate(prefab);
            tipNode.parent = cc.find('Canvas');
 
            let tipPanel = tipNode.getComponent("TipPanel");
            tipPanel.showLabel(str, delayTime);
        });
    }
 
}