GameOverAction.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { _decorator, Component, director, Node, Sprite, tween, Vec3, Widget } from 'cc';
  2. import { AudioMgr } from './AudioMgr';
  3. import { Clips, DJ, DJ_TYPE } from './Enums';
  4. import { Global } from './Global';
  5. import { BasePage } from './BasePage';
  6. import { AdManger } from './ad/AdManger';
  7. import { DjManger } from './DjManger';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('GameOverAction')
  10. export class GameOverAction extends BasePage {
  11. @property({ type: Node })
  12. fail_img: Node
  13. @property({ type: Node })
  14. fail_dou: Node
  15. @property({ type: Node })
  16. btn_continue: Node
  17. start() {
  18. super.start();
  19. }
  20. update(deltaTime: number) {
  21. }
  22. //show menu panel
  23. open() {
  24. if(this.node.position.x == 0 && this.node.position.y == 0){
  25. //console.log("打开中,跳过");
  26. return;
  27. }
  28. super.open();
  29. this.fail_img.scale = new Vec3(2, 2, 0);
  30. tween(this.fail_img)
  31. .to(0.3, { scale: new Vec3(1, 1, 0) },Global.our_easing)
  32. .call(() => {
  33. })
  34. .start();
  35. this.fail_dou.scale = new Vec3(0.1, 0.1, 0);
  36. tween(this.fail_dou)
  37. .to(0.3, { scale: new Vec3(1, 1, 0) },Global.our_easing)
  38. .call(() => {
  39. }).start();
  40. AudioMgr.ins.playSound(Clips.fail);
  41. }
  42. btn_go_home() {
  43. this.close();
  44. director.loadScene("home");
  45. AdManger.show_interstial();
  46. }
  47. btn_restart_game() {
  48. this.close();
  49. Global.main_action.restart_game();
  50. AdManger.show_interstial();
  51. }
  52. clear_pins_videos(){
  53. AudioMgr.ins.playSound(Clips.btn_1);
  54. let pin_arr = Global.layer_empty_action.get_pin_arr();
  55. if (pin_arr.length == 0) {
  56. Global.tips_action.show("No Screws to Clear");//没有可清理的钉子
  57. return;
  58. }
  59. if (!DjManger.use_dj(DJ.Btn_5,DJ_TYPE.Type_video)) {
  60. Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完
  61. return;
  62. }
  63. // Global.log_dj();
  64. // this.close();
  65. // Global.log_dj();
  66. AdManger.show_video((data) => {
  67. if (data == 1) {
  68. console.log("clear_pins_videos 获取奖励成功");
  69. this.close();
  70. //解锁
  71. Global.bucket_action.put_pins(pin_arr);
  72. } else {
  73. Global.tips_action.show("Gain reward failure");//获取奖励失败
  74. //退款
  75. DjManger.return_used_dj(DJ.Btn_5,DJ_TYPE.Type_video);
  76. }
  77. })
  78. }
  79. }