Props3Action.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import { _decorator, Component, Label, Node, tween, Vec2, Vec3,sys } from 'cc';
  2. import { Global } from './Global';
  3. import { PropsAction } from './PropsAction';
  4. import { Clips, DJ, DJ_TYPE } from './Enums';
  5. import { AudioMgr } from './AudioMgr';
  6. import { Tools } from './Tools';
  7. import { AdManger } from './ad/AdManger';
  8. import { DjManger } from './DjManger';
  9. import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
  10. import AAJS2 from "./utils/ATAndroidJS2";
  11. import ATJSSDK from "./AnyThinkAds/ATJSSDK";
  12. import { CoinsAction } from './CoinsAction';
  13. //import { EncryptUtil } from './utils/EncryptUtil';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('Props3Action')
  16. export class Props3Action extends Component {
  17. @property([Node])
  18. pin_img_arr:Node[] = [];
  19. @property(Node)
  20. bucket:Node = null;
  21. pos_pin = [];
  22. @property({ type: Label })
  23. conis_label: Label;
  24. start() {
  25. this.conis_label.string = Global.get_need_coins() + "";
  26. if(this.pin_img_arr){
  27. this.pin_img_arr.forEach((ele)=>{
  28. if(ele){
  29. this.pos_pin.push({pos:ele.getPosition().clone(),pin:ele});
  30. }
  31. });
  32. }
  33. this.initAdForPage();
  34. }
  35. initAdForPage(){
  36. console.log('zh:initAdForPage foir props3Action.ts')
  37. if(sys.os===sys.OS.ANDROID){
  38. let deviceId = AAJS2.getDeviceUserId();
  39. //console.log("checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
  40. var setting = {};
  41. setting[ATRewardedVideoSDK.userIdKey] = deviceId;
  42. ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
  43. }
  44. }
  45. //电子邮件puhalskijsemen@gmail.com
  46. //源码网站 开vpn打开 http://web3incubators.com/
  47. //电报https://t.me/gamecode999
  48. dt:number = 0;
  49. times:number = 0;
  50. update(deltaTime: number) {
  51. if(!this.node.active){
  52. return;
  53. }
  54. if(this.times==0){
  55. this.times++;
  56. this.show_tween();
  57. }else{
  58. this.dt+=deltaTime;
  59. if(this.dt>=1.5){
  60. this.dt = 0;
  61. this.show_tween();
  62. }
  63. }
  64. }
  65. private show_tween(){
  66. this.pos_pin.forEach((ele)=>{
  67. this.play_tween(ele.pos,ele.pin);
  68. });
  69. }
  70. private play_tween(pos:Vec3,pin:Node){
  71. {
  72. //set pos default
  73. pin.setPosition(pos.x,pos.y,pos.z);
  74. }
  75. let target_pos = this.bucket.position.clone();
  76. target_pos.x = target_pos.x+ Tools.random_between(-20,20);
  77. target_pos.y = target_pos.y+ Tools.random_between(-20,20);
  78. tween(pin)
  79. .to(0.75, { position: target_pos },Global.our_easing)
  80. .call(() => {
  81. }).delay(0.3)
  82. .start();
  83. }
  84. clear_pins_coins(){
  85. AudioMgr.ins.playSound(Clips.btn_1);
  86. if (Global.cur_coins < Global.get_need_coins()) {
  87. Global.tips_action.show("Diamond Quantity Insufficient");//钻石数量不够
  88. return;
  89. }
  90. let pin_arr = Global.layer_empty_action.get_pin_arr();
  91. if (pin_arr.length == 0) {
  92. Global.tips_action.show("No Screws to Clear");//没有可清理的钉子
  93. return;
  94. }
  95. if (!DjManger.use_dj(DJ.Btn_3,DJ_TYPE.Type_coin)) {
  96. Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完
  97. return;
  98. }
  99. //消耗
  100. Global.use_coins(Global.get_need_coins());
  101. Global.bucket_action.put_pins(pin_arr);
  102. Global.coins_action.refrush_coins();
  103. this.node.parent.getComponent(PropsAction)?.close();
  104. }
  105. clear_pins_videos(){
  106. console.log('zh:clear_pins_videos333')
  107. AudioMgr.ins.playSound(Clips.btn_1);
  108. let pin_arr = Global.layer_empty_action.get_pin_arr();
  109. if (pin_arr.length == 0) {
  110. Global.tips_action.show("No Screws to Clear");//没有可清理的钉子
  111. return;
  112. }
  113. if (!DjManger.use_dj(DJ.Btn_3,DJ_TYPE.Type_video)) {
  114. Global.tips_action.show("Current Level: Props Exhausted");//当前关卡次数已经用完
  115. return;
  116. }
  117. console.log('zh:clear_pins_videos333 111')
  118. if(sys.os == sys.OS.ANDROID){
  119. if(ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())){
  120. console.log('zh:clear_pins_videos ad ok')
  121. //sys.localStorage.setItem("adtype","2");
  122. ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
  123. }else{
  124. console.log('zh:clear_pins_videos ad no ok')
  125. }
  126. }
  127. AdManger.show_video((data) => {
  128. if (data == 1) {
  129. console.log("clear_pins_videos 获取奖励成功");
  130. this.node.parent.getComponent(PropsAction)?.close();
  131. //解锁
  132. Global.bucket_action.put_pins(pin_arr);
  133. } else {
  134. Global.tips_action.show("Gain reward failure");//获取奖励失败
  135. //退款
  136. DjManger.return_used_dj(DJ.Btn_3,DJ_TYPE.Type_video);
  137. }
  138. })
  139. }
  140. open(){
  141. this.conis_label.string = Global.get_need_coins() + "";
  142. }
  143. }