Props1Action.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { _decorator, Component, Label, Node, tween, Vec3 } from 'cc';
  2. import { Clips, DJ, DJ_TYPE } from './Enums';
  3. import { AudioMgr } from './AudioMgr';
  4. import { Global } from './Global';
  5. import { PropsAction } from './PropsAction';
  6. import { AdManger } from './ad/AdManger';
  7. import { DjManger } from './DjManger';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('Props1Action')
  10. export class Props1Action extends Component {
  11. @property(Node)
  12. lock_img:Node ;
  13. @property({ type: Label })
  14. conis_label: Label;
  15. start() {
  16. this.conis_label.string = Global.get_need_coins() + "";
  17. }
  18. dt:number = 0;
  19. times:number = 0;
  20. update(deltaTime: number) {
  21. if(!this.node.active){
  22. return;
  23. }
  24. if(this.times==0){
  25. this.times++;
  26. this.show_tween();
  27. }else{
  28. this.dt+=deltaTime;
  29. if(this.dt>=1.5){
  30. this.dt = 0;
  31. this.show_tween();
  32. }
  33. }
  34. }
  35. private show_tween(){
  36. if(this.lock_img){
  37. this.lock_img.active = true;
  38. tween(this.lock_img)
  39. .to(0.25,{scale:new Vec3(1.2,1.2,1)},Global.our_easing)
  40. .to(0.35,{scale:new Vec3(0.8,0.8,1)},Global.our_easing)
  41. .to(0.15,{scale:new Vec3(1,1,1)},Global.our_easing)
  42. .call(()=>{
  43. this.lock_img.scale = new Vec3(1,1,1);
  44. this.lock_img.active = false;
  45. }).delay(0.3)
  46. .start();
  47. }
  48. }
  49. add_hole_coins(){
  50. console.log('zh:add_hole_coins111')
  51. AudioMgr.ins.playSound(Clips.btn_1);
  52. if (Global.layer_empty_action.get_unlock_num() <= 0) {
  53. Global.tips_action.show("没有空位了");
  54. return;
  55. }
  56. if (Global.cur_coins < Global.get_need_coins()) {
  57. Global.tips_action.show("Diamond Quantity Insufficient");//钻石数量不够
  58. return;
  59. }
  60. if (!DjManger.use_dj(DJ.Btn_1,DJ_TYPE.Type_coin)) {
  61. Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完
  62. return;
  63. }
  64. //消耗
  65. Global.use_coins(Global.get_need_coins());
  66. Global.layer_empty_action.unlock_empty_hole();
  67. Global.coins_action.refrush_coins();
  68. this.node.parent.getComponent(PropsAction)?.close();
  69. }
  70. add_hole_videos(){
  71. console.log('zh:add_hole_videos222')
  72. AudioMgr.ins.playSound(Clips.btn_1);
  73. if (Global.layer_empty_action.get_unlock_num() <= 0) {
  74. Global.tips_action.show("没有空位了");
  75. return;
  76. }
  77. if (!DjManger.use_dj(DJ.Btn_1,DJ_TYPE.Type_video)) {
  78. Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完
  79. return;
  80. }
  81. AdManger.show_video((data) => {
  82. if (data == 1) {
  83. console.log("add_hole_videos 获取奖励成功");
  84. this.node.parent.getComponent(PropsAction)?.close();
  85. //解锁
  86. Global.layer_empty_action.unlock_empty_hole();
  87. } else {
  88. Global.tips_action.show("Gain reward failure");//获取奖励失败
  89. //退款
  90. DjManger.return_used_dj(DJ.Btn_1,DJ_TYPE.Type_video);
  91. }
  92. })
  93. }
  94. open(){
  95. this.conis_label.string = Global.get_need_coins() + "";
  96. }
  97. }