a2b2a434-387b-4818-85b4-4626c8ca3b64.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. "use strict";
  2. cc._RF.push(module, 'a2b2aQ0OHtIGIW0RibIyjtk', 'UITurntablePage');
  3. // scripts/UI/UITurntablePage.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  25. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  26. return new (P || (P = Promise))(function (resolve, reject) {
  27. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  28. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  29. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  30. step((generator = generator.apply(thisArg, _arguments || [])).next());
  31. });
  32. };
  33. var __generator = (this && this.__generator) || function (thisArg, body) {
  34. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  35. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  36. function verb(n) { return function (v) { return step([n, v]); }; }
  37. function step(op) {
  38. if (f) throw new TypeError("Generator is already executing.");
  39. while (_) try {
  40. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  41. if (y = 0, t) op = [op[0] & 2, t.value];
  42. switch (op[0]) {
  43. case 0: case 1: t = op; break;
  44. case 4: _.label++; return { value: op[1], done: false };
  45. case 5: _.label++; y = op[1]; op = [0]; continue;
  46. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  47. default:
  48. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  49. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  50. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  51. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  52. if (t[2]) _.ops.pop();
  53. _.trys.pop(); continue;
  54. }
  55. op = body.call(thisArg, _);
  56. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  57. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  58. }
  59. };
  60. Object.defineProperty(exports, "__esModule", { value: true });
  61. var Utils_1 = require("../../common-plugin/Scripts/Utils");
  62. var CocosZ_1 = require("../Framework/CocosZ");
  63. var Constant_1 = require("../Framework/Constant");
  64. var Msg_1 = require("../Framework/Msg");
  65. var UIPage_1 = require("../Framework/UIPage");
  66. var gameDate_1 = require("../Game/gameDate");
  67. var weapon_1 = require("../Game/weapon");
  68. // @ts-ignore
  69. var i18n = require('LanguageData');
  70. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  71. var UITurntablePanel = /** @class */ (function (_super) {
  72. __extends(UITurntablePanel, _super);
  73. function UITurntablePanel() {
  74. var _this = _super.call(this, Constant_1.PanelName.UITurntablePanel) || this;
  75. _this._panel = null;
  76. _this._rewardList = null;
  77. _this._totalLabel = null;
  78. _this._btnCJ = null;
  79. _this._btnAD = null;
  80. _this.startNum = 0;
  81. _this.startIntervalTime = 10;
  82. _this.addTime = 1;
  83. _this.isCJ = false;
  84. _this.isValid() && _this.onLoad();
  85. return _this;
  86. }
  87. UITurntablePanel.prototype.onLoad = function () {
  88. this._panel = this._page.getChildByName("panel");
  89. this._rewardList = this._panel.getChildByName("rewardList");
  90. this._totalLabel = this._panel.getChildByName("totalLabel").getComponent(cc.Label);
  91. var btnNames = ["BtnBack", "BtnCJ", "BtnAD"];
  92. for (var i = 0; i < btnNames.length; i++) {
  93. var btn = this._panel.getChildByName(btnNames[i]);
  94. if (btn) {
  95. btn.on(cc.Node.EventType.TOUCH_END, this._onBtnClickHandler, this);
  96. if (btnNames[i] == "BtnCJ") {
  97. this._btnCJ = btn;
  98. }
  99. else if (btnNames[i] == "BtnAD") {
  100. this._btnAD = btn;
  101. }
  102. }
  103. }
  104. };
  105. UITurntablePanel.prototype.onOpen = function () {
  106. // 上报 首页抽奖
  107. Utils_1.utils.umaEvent("gamechoujiang");
  108. Utils_1.utils.SendEvent("页面-抽奖");
  109. this._panel.scale = 0;
  110. cc.tween(this._panel).to(0.3, { scale: 0.8 }, { easing: "backOut" }).start();
  111. // TweenEffect.panel_open_scale(this._panel);
  112. cc.tween(this._page.getChildByName("guang"))
  113. .by(0.5, { angle: 60, opacity: -150 })
  114. .by(0.5, { angle: 60, opacity: 150 })
  115. .union()
  116. .repeatForever()
  117. .start();
  118. this._totalLabel.string = (CocosZ_1.cocosz.totalCJTimes > 30 ? 30 : CocosZ_1.cocosz.totalCJTimes) + "/30";
  119. if (CocosZ_1.cocosz.totalCJTimes > 30 || CocosZ_1.cocosz.dataMgr.getGunInfo(10).State > 0) {
  120. this._panel.getChildByName("w_nnp").color = cc.Color.GRAY;
  121. }
  122. this.updateReward();
  123. this.updateBtn();
  124. };
  125. UITurntablePanel.prototype.updateReward = function () {
  126. for (var i = 0; i < 12; i++) {
  127. var str = "reward" + (i + 1);
  128. var reward = this._rewardList.getChildByName(str);
  129. if (gameDate_1.default.TurntableReward[i].type == gameDate_1.RewardType.Gold) {
  130. var gold = reward.getChildByName("gold");
  131. if (gold) {
  132. gold.active = true;
  133. // gold.setPosition(reward.x + gold.x, reward.y + gold.y);
  134. // gold.setParent(this._rewardList);
  135. }
  136. var label = reward.getChildByName("label");
  137. if (label) {
  138. label.active = true;
  139. label.zIndex = 2;
  140. label.setPosition(reward.x + label.x, reward.y + label.y);
  141. label.setParent(this._rewardList);
  142. label.getComponent(cc.Label).string = "+" + gameDate_1.default.TurntableReward[i].num;
  143. }
  144. }
  145. else if (gameDate_1.default.TurntableReward[i].type == gameDate_1.RewardType.Diamond) {
  146. var diamond = reward.getChildByName("diamond");
  147. if (diamond) {
  148. diamond.active = true;
  149. // diamond.setPosition(reward.x + diamond.x, reward.y + diamond.y);
  150. // diamond.setParent(this._rewardList);
  151. }
  152. var label = reward.getChildByName("label");
  153. if (label) {
  154. label.active = true;
  155. label.zIndex = 2;
  156. label.setPosition(reward.x + label.x, reward.y + label.y);
  157. label.setParent(this._rewardList);
  158. label.getComponent(cc.Label).string = "+" + gameDate_1.default.TurntableReward[i].num;
  159. }
  160. }
  161. else if (gameDate_1.default.TurntableReward[i].type == gameDate_1.RewardType.Skin) {
  162. var ani = cc.instantiate(CocosZ_1.cocosz.resMgr.getRes("skin" + gameDate_1.default.TurntableReward[i].num, cc.Prefab));
  163. if (ani) {
  164. ani.scale = 0.5;
  165. ani.zIndex = 1;
  166. ani.setParent(this._rewardList);
  167. ani.setPosition(reward.x, reward.y - 65);
  168. }
  169. var nameSpr = reward.getChildByName("nameSpr");
  170. if (nameSpr) {
  171. nameSpr.active = true;
  172. nameSpr.zIndex = 2;
  173. nameSpr.setPosition(reward.x + nameSpr.x, reward.y + nameSpr.y);
  174. nameSpr.setParent(this._rewardList);
  175. nameSpr.getComponent(cc.Sprite).spriteFrame = CocosZ_1.cocosz.resMgr.getRes("p_" + gameDate_1.default.TurntableReward[i].num, cc.SpriteFrame);
  176. }
  177. if (CocosZ_1.cocosz.dataMgr.getSkinInfo(gameDate_1.default.TurntableReward[i].num - 1).State != 0) {
  178. var mask = this._rewardList.getChildByName("mask" + (i + 1));
  179. if (mask) {
  180. mask.active = true;
  181. mask.zIndex = 3;
  182. }
  183. }
  184. }
  185. else if (gameDate_1.default.TurntableReward[i].type == gameDate_1.RewardType.Weapon) {
  186. var node = new cc.Node;
  187. var str_1 = "w_" + weapon_1.default.WeaponName[gameDate_1.default.TurntableReward[i].num];
  188. node.addComponent(cc.Sprite).spriteFrame = CocosZ_1.cocosz.resMgr.getRes(str_1, cc.SpriteFrame);
  189. node.setParent(this._rewardList);
  190. node.setPosition(reward.x, reward.y);
  191. var nameSpr = reward.getChildByName("nameSpr");
  192. if (nameSpr) {
  193. nameSpr.active = true;
  194. nameSpr.zIndex = 2;
  195. nameSpr.setPosition(reward.x + nameSpr.x, reward.y + nameSpr.y);
  196. nameSpr.setParent(this._rewardList);
  197. nameSpr.getComponent(cc.Sprite).spriteFrame = CocosZ_1.cocosz.resMgr.getRes("w_" + (gameDate_1.default.TurntableReward[i].num + 1), cc.SpriteFrame);
  198. }
  199. if (CocosZ_1.cocosz.dataMgr.getGunInfo(gameDate_1.default.TurntableReward[i].num).State != 0) {
  200. var mask = this._rewardList.getChildByName("mask" + (i + 1));
  201. if (mask) {
  202. mask.active = true;
  203. mask.zIndex = 3;
  204. }
  205. }
  206. }
  207. }
  208. };
  209. UITurntablePanel.prototype.CJ = function () {
  210. var _this = this;
  211. // 上报 首页抽奖
  212. Utils_1.utils.umaEvent("gamechoujiang" + CocosZ_1.cocosz.useCJTimes);
  213. this.isCJ = true;
  214. var num = 20;
  215. num += Math.floor(Math.random() * 12);
  216. var count = 0;
  217. var lastNum = this.startNum;
  218. var cur = 0;
  219. CocosZ_1.cocosz.audioMgr.playEffect("turntable");
  220. var timeCount = setInterval(function () {
  221. count++;
  222. if (_this.getTimeCount(count, cur) == 0) {
  223. _this._rewardList.children[lastNum].children[0].opacity = 0;
  224. lastNum++;
  225. if (lastNum >= 12) {
  226. lastNum = 0;
  227. }
  228. if (gameDate_1.default.TurntableReward[lastNum].type == gameDate_1.RewardType.Skin) {
  229. if (CocosZ_1.cocosz.dataMgr.getSkinInfo(gameDate_1.default.TurntableReward[lastNum].num - 1).State != 0) {
  230. lastNum++;
  231. if (lastNum >= 12) {
  232. lastNum = 0;
  233. }
  234. }
  235. }
  236. else if (gameDate_1.default.TurntableReward[lastNum].type == gameDate_1.RewardType.Weapon) {
  237. if (CocosZ_1.cocosz.dataMgr.getGunInfo(gameDate_1.default.TurntableReward[lastNum].num).State != 0) {
  238. lastNum++;
  239. if (lastNum >= 12) {
  240. lastNum = 0;
  241. }
  242. }
  243. }
  244. cur++;
  245. _this._rewardList.children[lastNum].children[0].opacity = 255;
  246. if (cur >= num) {
  247. _this.startNum = lastNum;
  248. clearInterval(timeCount);
  249. if (gameDate_1.default.TurntableReward[lastNum].type == gameDate_1.RewardType.Gold) {
  250. Msg_1.default.Show(i18n.t("msg.gxhdjb") + gameDate_1.default.TurntableReward[lastNum].num);
  251. CocosZ_1.cocosz.dataMgr.CoinCount += gameDate_1.default.TurntableReward[lastNum].num;
  252. }
  253. else if (gameDate_1.default.TurntableReward[lastNum].type == gameDate_1.RewardType.Diamond) {
  254. Msg_1.default.Show(i18n.t("msg.gxhdzs") + gameDate_1.default.TurntableReward[lastNum].num);
  255. CocosZ_1.cocosz.dataMgr.DiamondCount += gameDate_1.default.TurntableReward[lastNum].num;
  256. }
  257. else if (gameDate_1.default.TurntableReward[lastNum].type == gameDate_1.RewardType.Skin) {
  258. Msg_1.default.Show(i18n.t("msg.gxhdxjs"));
  259. CocosZ_1.cocosz.dataMgr.CurSkinId = gameDate_1.default.TurntableReward[lastNum].num - 1;
  260. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_CJ_SKIN });
  261. _this._rewardList.children[lastNum].children[0].opacity = 0;
  262. _this._rewardList.getChildByName("mask6").active = true;
  263. _this._rewardList.getChildByName("mask6").zIndex = 3;
  264. }
  265. else {
  266. Msg_1.default.Show(i18n.t("msg.gxhdxwq"));
  267. CocosZ_1.cocosz.dataMgr.curWeapon = gameDate_1.default.TurntableReward[lastNum].num;
  268. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_CJ_Weapon });
  269. _this._rewardList.children[lastNum].children[0].opacity = 0;
  270. _this._rewardList.getChildByName("mask12").active = true;
  271. _this._rewardList.getChildByName("mask12").zIndex = 3;
  272. }
  273. _this.isCJ = false;
  274. CocosZ_1.cocosz.useCJTimes++;
  275. CocosZ_1.cocosz.totalCJTimes++;
  276. _this._totalLabel.string = (CocosZ_1.cocosz.totalCJTimes > 30 ? 30 : CocosZ_1.cocosz.totalCJTimes) + "/30";
  277. if (CocosZ_1.cocosz.totalCJTimes == 30 && CocosZ_1.cocosz.dataMgr.getGunInfo(10).State == 0) {
  278. Msg_1.default.Show(i18n.t("msg.gxhdnnp")); //恭喜获得武器鸟鸟炮
  279. CocosZ_1.cocosz.dataMgr.curWeapon = 10;
  280. _this._panel.getChildByName("w_nnp").color = cc.Color.GRAY;
  281. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_CJ_Weapon });
  282. }
  283. _this.updateBtn();
  284. }
  285. }
  286. }, 10);
  287. };
  288. UITurntablePanel.prototype.getTimeCount = function (num1, num2) {
  289. var num = 0;
  290. for (var i = 0; i < num2; i++) {
  291. num += i * this.addTime;
  292. }
  293. return (num1 - num) % (this.startIntervalTime + num2 * this.addTime);
  294. };
  295. UITurntablePanel.prototype.updateBtn = function () {
  296. if (CocosZ_1.cocosz.isADON && CocosZ_1.cocosz.useCJTimes >= Constant_1.default.commonCJTimes /* + cocosz.getCJTimes */) {
  297. this._btnCJ.active = false;
  298. this._btnAD.active = true;
  299. }
  300. else {
  301. this._btnCJ.active = true;
  302. this._btnAD.active = false;
  303. }
  304. };
  305. UITurntablePanel.prototype._onBtnClickHandler = function (event) {
  306. return __awaiter(this, void 0, void 0, function () {
  307. var _this = this;
  308. return __generator(this, function (_a) {
  309. switch (_a.label) {
  310. case 0: return [4 /*yield*/, CocosZ_1.cocosz.audioMgr.playBtnEffect().catch()];
  311. case 1:
  312. _a.sent();
  313. if (this.isCJ)
  314. return [2 /*return*/];
  315. switch (event.target.name) {
  316. case "BtnBack": {
  317. CocosZ_1.cocosz.uiMgr.closePanel(Constant_1.PanelName.UITurntablePanel);
  318. break;
  319. }
  320. case "BtnCJ": {
  321. this.CJ();
  322. break;
  323. }
  324. case "BtnAD": {
  325. Utils_1.utils.SendEvent("视频-抽奖-播放");
  326. CocosZ_1.cocosz.watchAD(function () {
  327. Utils_1.utils.SendEvent("视频-抽奖-成功");
  328. _this.CJ();
  329. }, function () {
  330. Utils_1.utils.SendEvent("视频-抽奖-失败");
  331. });
  332. break;
  333. }
  334. }
  335. return [2 /*return*/];
  336. }
  337. });
  338. });
  339. };
  340. UITurntablePanel = __decorate([
  341. ccclass
  342. ], UITurntablePanel);
  343. return UITurntablePanel;
  344. }(UIPage_1.default));
  345. exports.default = UITurntablePanel;
  346. cc._RF.pop();