| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /** 签到提示 */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class SignTip extends cc.Component {
- @property(cc.Node)
- bg_tip: cc.Node = null;
- @property(cc.Label)
- lbl_tip: cc.Label = null;
- private tipArr = ['次日签到直接领取50元',
- '完成签到直接领取50元',
- '7日签到领取100元现金大奖',
- '7日签到领取100元现金大奖',
- '再登录2天领取100元现金大奖',
- '再登录1天领取100元现金大奖',
- '完成签到即可领取100元现金大奖']
- private curTipStr = ''
- private totalTime = 0;
- private showTime = 10;
- private hideTime = 30;
- private isShow = null;
- onLoad() {
- let index = 0;
- if (gData.gameData.gameData.loginDays <= 7) {
- index = gData.gameData.gameData.loginDays - 1;
- }
- else {
- index = 6;
- }
- this.curTipStr = this.tipArr[index];
- this.lbl_tip.string = this.curTipStr;
- if (!gData.sign.haveSignDay()) {
- return;
- }
- this.setShow(true);
- }
- update(dt) {
- if (!gData.sign.haveSignDay()) {
- return;
- }
- this.totalTime += dt;
- if (this.isShow) {
- if (this.totalTime >= this.showTime) {
- this.setShow(false);
- }
- }
- else {
- if (this.totalTime >= this.hideTime) {
- this.setShow(true);
- }
- }
- }
- setShow(state) {
- if (this.isShow == state) {
- return
- }
- this.totalTime = 0;
- this.isShow = state;
- if (state) {
- this.bg_tip.active = true;
- }
- else {
- this.bg_tip.active = false;
- }
- }
- lateUpdate() {
- this.bg_tip.width = this.lbl_tip.node.width + 24;
- }
- }
|