1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import { _decorator, Component, Node } from 'cc';
- import ui_base from '../../../core/ui/ui_base';
- import { Layout_LatticeFull } from './Layout_LatticeFull';
- import { GameUILayers, gui } from '../../../core/ui/ui';
- import { ModuleDef } from '../../../Scripts/ModuleDef';
- import { Hall } from '../../hall/Hall';
- import { UI_Fail } from '../UI_Fail/UI_Fail';
- import { ani_ui, UI_Main } from '../UI_Main/UI_Main';
- const { ccclass, property } = _decorator;
- @ccclass('UI_LatticeFull')
- export class UI_LatticeFull extends ui_base {
- constructor() {
- super(ModuleDef.GAME, 'ui/UI_LatticeFull/LatticeFull', GameUILayers.HUD, Layout_LatticeFull);
- }
- protected async onCreated() {
- const layout = this.getLayout<Layout_LatticeFull>();
- ani_ui(layout.Close_Btn.node.parent);
- let num1 = Hall.getInstance().player.get_item(1);
- if (num1 > 0) {
- layout.Empty_Ad.node.active = false;
- layout.Empty_RedPoint_num.node.parent.active = true;
- layout.Empty_RedPoint_num.string = num1.toString();
- } else {
- layout.Empty_Ad.node.active = true;
- layout.Empty_RedPoint_num.node.parent.active = false;
- }
- let num2 = Hall.getInstance().player.get_item(3);
- if (num2 > 0) {
- layout.Eliminate_Ad.node.active = false;
- layout.Eliminate_RedPoint_num.node.parent.active = true;
- layout.Eliminate_RedPoint_num.string = num2.toString();
- } else {
- layout.Eliminate_Ad.node.active = true;
- layout.Eliminate_RedPoint_num.node.parent.active = false;
- }
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.pause);
- this.onButtonEvent(layout.Close_Btn, () => {
- gui.close(UI_LatticeFull);
- gui.show(UI_Fail);
- });
- this.onButtonEvent(layout.Eliminate, async () => {
- if (num1 <= 0) {
- const ret = await chsdk.playRewardAd('获得道具' + 1);
- if (ret) {
- Hall.getInstance().player.add_item(1, 1);
- Hall.getInstance().player.use_item(1);
- gui.close(UI_LatticeFull);
- //直接使用道具
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- }
- else {
- Hall.getInstance().player.use_item(1);
- gui.close(UI_LatticeFull);
- //直接使用道具
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- });
- this.onButtonEvent(layout.Empty, async () => {
- if (num2 <= 0) {
- const ret = await chsdk.playRewardAd('获得道具' + 3);
- if (ret) {
- Hall.getInstance().player.add_item(3, 1);
- Hall.getInstance().player.use_item(3);
- gui.close(UI_LatticeFull);
- //直接使用道具
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- }
- else {
- Hall.getInstance().player.use_item(3);
- gui.close(UI_LatticeFull);
- //直接使用道具
- gui.get(UI_Main).evt.emit(gui.get(UI_Main).evt.key.resume);
- }
- });
- this.onButtonEvent(layout.Click, () => {
- gui.close(UI_LatticeFull);
- //放弃此局,跳至结算界面
- gui.show(UI_Fail);
- });
- }
- }
|