UI_Main.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { _decorator, Component, Node } from 'cc';
  2. import { GameUILayers, gui } from 'db://assets/core/ui/ui';
  3. import ui_base from 'db://assets/core/ui/ui_base';
  4. import { ModuleDef } from 'db://assets/Scripts/ModuleDef';
  5. import { Layout_Main } from './Layout_Main';
  6. import { UI_Settings } from '../UI_Settings/UI_Settings';
  7. import { UI_GameRules } from '../UI_GameRules/UI_GameRules';
  8. import { ch } from 'db://assets/ch/ch';
  9. import { GameCtl } from 'db://assets/Scripts/GameCtl';
  10. import { Container_Manager } from 'db://assets/Scripts/Container_Manager';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('UI_Main')
  13. export class UI_Main extends ui_base {
  14. constructor() {
  15. super(ModuleDef.GAME, 'ui/UI_Main/Main', GameUILayers.GAME, Layout_Main);
  16. }
  17. protected async onCreated() {
  18. const layout = this.getLayout<Layout_Main>();
  19. this.onButtonEvent(layout.Pause_Btn, async (button: any) => {
  20. //打开设置界面
  21. gui.show(UI_Settings);
  22. }, this);
  23. this.onButtonEvent(layout.Rules_Btn, async (button: any) => {
  24. //打开游戏说明
  25. gui.show(UI_GameRules);
  26. }, this);
  27. this.onButtonEvent(layout.Eliminate_Btn, async (button: any) => {
  28. //判断道具数量
  29. //清除
  30. Container_Manager.instance.eliminate();
  31. // const ret = await chsdk.playRewardAd('获得道具:清除');
  32. // if(ret)
  33. // {
  34. // ch.audio.resume();
  35. // }
  36. }, this);
  37. this.onButtonEvent(layout.Shuffle_Btn, async (button: any) => {
  38. //刷新
  39. Container_Manager.instance.shuffle();
  40. // const ret = await chsdk.playRewardAd('获得道具:刷新');
  41. // if(ret)
  42. // {
  43. // ch.audio.resume();
  44. // }
  45. }, this);
  46. this.onButtonEvent(layout.Empty_Btn, async (button: any) => {
  47. //清空
  48. Container_Manager.instance.Empty();
  49. // const ret = await chsdk.playRewardAd('获得道具:清空');
  50. // if(ret)
  51. // {
  52. // ch.audio.resume();
  53. // }
  54. }, this);
  55. }
  56. }
  57. export function ani_ui(node: Node, end: number = 1.0): void {
  58. gui.scale_elasticOut_anim(node, 1.2, 0.5, end);
  59. }
  60. export function repair_ani_ui(node: Node, end: number = 1.15): void {
  61. gui.scale_elasticOut_anim(node, 1.2, 0.5, end);
  62. }