96bb687c-1987-4e5b-8edc-8f230f8c78e5.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. "use strict";
  2. cc._RF.push(module, '96bb6h8GYdOW47cjyMPjHjl', 'CoinBord');
  3. // scripts/UI/CoinBord.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. Object.defineProperty(exports, "__esModule", { value: true });
  25. var Constant_1 = require("../Framework/Constant");
  26. var CocosZ_1 = require("../Framework/CocosZ");
  27. var Msg_1 = require("../Framework/Msg");
  28. // @ts-ignore
  29. var i18n = require('LanguageData');
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var CoinBord = /** @class */ (function (_super) {
  32. __extends(CoinBord, _super);
  33. function CoinBord() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this._label = null;
  36. _this._icon = null;
  37. _this._adBtn = null;
  38. _this.isDiamond = false;
  39. return _this;
  40. }
  41. CoinBord.prototype.onLoad = function () {
  42. var _this = this;
  43. this._label = this.node.getChildByName("Label").getComponent(cc.Label);
  44. this._icon = this.node.getChildByName("Icon");
  45. this._adBtn = this.node.getChildByName("BtnAD");
  46. if (this._adBtn) {
  47. this._adBtn.on(cc.Node.EventType.TOUCH_END, (function () {
  48. var node = cc.instantiate(CocosZ_1.cocosz.resMgr.getRes("UIADPanel", cc.Prefab));
  49. cc.find("Canvas").addChild(node);
  50. if (_this.isDiamond) {
  51. node.getComponent("UIADPanel").setDiamond();
  52. }
  53. }));
  54. this._adBtn.active = CocosZ_1.cocosz.isADON;
  55. }
  56. };
  57. CoinBord.prototype.onEnable = function () {
  58. cc.game.on(Constant_1.default.E_GAME_LOGIC, this._onGameMessageHandler, this);
  59. this._updateLabel();
  60. };
  61. CoinBord.prototype.onDisable = function () {
  62. cc.game.targetOff(this);
  63. };
  64. CoinBord.prototype._onGameMessageHandler = function (event) {
  65. switch (event.type) {
  66. case Constant_1.default.E_COIN_CHANGE: {
  67. this._updateLabel();
  68. break;
  69. }
  70. case Constant_1.default.E_Diamond_CHANGE: {
  71. this._updateLabel();
  72. break;
  73. }
  74. }
  75. };
  76. CoinBord.prototype._updateLabel = function () {
  77. if (this.isDiamond) {
  78. this._label.string = CocosZ_1.cocosz.dataMgr.DiamondCount + "";
  79. }
  80. else {
  81. this._label.string = CocosZ_1.cocosz.dataMgr.CoinCount + "";
  82. }
  83. };
  84. /**
  85. * 获取Icon的世界坐标位置(金币动画飞入使用)
  86. */
  87. CoinBord.prototype.getLocation = function () {
  88. var pos = this._icon.convertToWorldSpaceAR(cc.Vec3.ZERO);
  89. // let temp = cc.v2(pos.x, cc.winSize.height - 76)
  90. return pos;
  91. };
  92. CoinBord.prototype._addGold = function () {
  93. CocosZ_1.cocosz.dataMgr.CoinCount += 200;
  94. Msg_1.default.Show(i18n.t("msg.gxhdjb") + "200"); //恭喜获得金币
  95. };
  96. __decorate([
  97. property
  98. ], CoinBord.prototype, "isDiamond", void 0);
  99. CoinBord = __decorate([
  100. ccclass
  101. ], CoinBord);
  102. return CoinBord;
  103. }(cc.Component));
  104. exports.default = CoinBord;
  105. cc._RF.pop();