123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { _decorator } from "cc";
- import ch_sign from "../../../ch/sign/sign";
- import { GameUILayers, gui } from "../../../core/ui/ui";
- import ui_base from "../../../core/ui/ui_base";
- import { UINotify } from "../../../module_basic/ui_notify/UINotify";
- import { Hall } from "../../../Scripts/Hall";
- import { ModuleDef } from "../../../Scripts/ModuleDef";
- import { ani_ui } from "../UI_Main/UI_Main";
- import { Layout_Sign } from "./Layout_Sign";
- const { ccclass, property } = _decorator;
- @ccclass('UI_Sign')
- export class UI_Sign extends ui_base {
- constructor() {
- super(ModuleDef.GAME, 'ui/UI_Sign/Sign', GameUILayers.HUD, Layout_Sign);
- }
- protected async onCreated() {
- const layout = this.getLayout<Layout_Sign>();
- ani_ui(layout.Return.node.parent.parent);
- this.onButtonEvent(layout.Return, () => {
- gui.close(UI_Sign);
- });
- this.onButtonEvent(layout.Free_Get,async () => {
- if(layout.Toggle.isChecked)
- {
- //看广告领双倍
- let ret = await chsdk.playRewardAd('领取双倍签到奖励');
- if(ret){
- this.Sign(true);
- }
- }else{
- //不看广告
- this.Sign(false);
- }
-
- });
- this.init_Sign();
- }
- private async init_Sign() {
- const layout = this.getLayout<Layout_Sign>();
- for (let i = 0; i < Hall.getInstance().player.get_sign(); i++) {
- layout.Sign_Reward[i].show(i + 1);
- }
- }
- private async Sign(flag: boolean) {
- const layout = this.getLayout<Layout_Sign>();
- let day = await ch_sign.getInstance().signIn();
- if (day == 0) {
- UINotify.show("签到失败");
- } else {
- //签到成功获取奖励
- layout.Sign_Reward[day - 1].show(day);
- layout.Sign_Reward[day - 1].add_Item(flag);
- Hall.getInstance().player.set_sign(day);
- Hall.getInstance().player.setDirty();
- Hall.getInstance().player.save();
- }
- }
- private async DoubleSign() {
- if (ch_sign.getInstance().checkReSigin() == 0) {
- return;
- }
- }
- }
|