| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import { _decorator, Button, Component, Node } from 'cc';
- import { BasePanel } from './BasePanel';
- import { Sign_Reward } from './Sign_Reward';
- import ch_sign from '../../ch/sign/sign';
- import { MyGame } from '../Game/MyGame';
- const { ccclass, property } = _decorator;
- @ccclass('SignPanel')
- export class SignPanel extends BasePanel {
- @property(Button)
- private Sign_Btn: Button;
- @property(Button)
- private Double_Get_Btn: Button;
- @property({ type: [Sign_Reward] })
- sigin_rewards: Sign_Reward[] = [];
- start() {
- this.Sign_Btn = this.node.getChildByName("Sign_Btn").getComponent(Button);
- this.Double_Get_Btn = this.node.getChildByName("Double_Get_Btn").getComponent(Button);
- this.show_info();
- this.Sign_Btn.node.on(Button.EventType.CLICK, this.onSigin, this);
- this.Double_Get_Btn.node.on(Button.EventType.CLICK, this.onDoubleSigin, this);
- }
- update(deltaTime: number) {
- }
- private async show_info() {
- await ch_sign.getInstance().getSignData();
- const rewards = this.sigin_rewards;
- for (let i = 0; i < rewards.length; i++) {
- rewards[i].show(i + 1);
- }
-
- }
- private async onSigin() {
- let day = await ch_sign.getInstance().signIn();
- if (day == 0) {
- console.log("签到失败");
- } else {
- //签到成功获取奖励
- console.log("签到成功");
- this.sigin_rewards[day-1].show(day);
- MyGame.getInstance().setSignData(ch_sign.getInstance().getSignData());
- MyGame.getInstance().saveData();
- }
- }
- //
- private async onDoubleSigin() {
- if (ch_sign.getInstance().checkReSigin() == 0) {
- console.log("无需补签");
- return;
- }
- //可以补签
- }
- onEnter() {
- super.onEnter();
- this.show_info();
- }
- onClose() {
- super.onClose(null);
- }
- }
|