14607736-34f1-4b5e-b383-6dff53f0a9bc.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. cc._RF.push(module, '14607c2NPFLXrODbf9T8Km8', 'jingyan');
  3. // scripts/Game/jingyan.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 YZ_Constant_1 = require("../../common-plugin/Scripts/YZ_Constant");
  26. var CocosZ_1 = require("../Framework/CocosZ");
  27. var Constant_1 = require("../Framework/Constant");
  28. var gameMgr_1 = require("./gameMgr");
  29. var UpgradeMgr_1 = require("./UpgradeMgr");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var Jingyan = /** @class */ (function (_super) {
  32. __extends(Jingyan, _super);
  33. function Jingyan() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this.isRun = false;
  36. // 成功距离
  37. _this.moveSpeed = 1000;
  38. _this._time = -1;
  39. return _this;
  40. }
  41. Jingyan.prototype.onLoad = function () { };
  42. Jingyan.prototype.start = function () { };
  43. Jingyan.prototype.init = function () {
  44. var _this = this;
  45. this.isRun = false;
  46. cc.game.on(Constant_1.default.E_Skill_Citie, function (e) { _this.isRun = true; }, this);
  47. };
  48. Jingyan.prototype.finish = function () {
  49. UpgradeMgr_1.upgradeMgr.curJingyan += 1;
  50. cc.game.emit(Constant_1.default.E_GAME_LOGIC, { type: Constant_1.default.E_Jingyan_Finish });
  51. if (!CocosZ_1.cocosz.isPause) {
  52. gameMgr_1.gameMgr.playEffect("jingyan");
  53. gameMgr_1.gameMgr.shakeEffect(0, 0, true, YZ_Constant_1.VibrateType.Long);
  54. }
  55. // 回收
  56. cc.game.targetOff(this);
  57. gameMgr_1.gameMgr && gameMgr_1.gameMgr.isValid && gameMgr_1.gameMgr.nodePut("jingyan", this.node);
  58. };
  59. Jingyan.prototype.update = function (dt) {
  60. if (this.isRun == false) {
  61. if (++this._time % 10 == 0) {
  62. this.activating();
  63. }
  64. }
  65. else {
  66. this.followTo(dt);
  67. }
  68. };
  69. Jingyan.prototype.activating = function () {
  70. if (UpgradeMgr_1.upgradeMgr && UpgradeMgr_1.upgradeMgr.isValid && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.isValid) {
  71. var from = this.node.getPosition();
  72. var to = gameMgr_1.gameMgr.playerTs.node.getPosition();
  73. if (from.sub(to).mag() < UpgradeMgr_1.upgradeMgr.jingyanRange) {
  74. this.isRun = true;
  75. }
  76. }
  77. };
  78. Jingyan.prototype.followTo = function (dt) {
  79. if (UpgradeMgr_1.upgradeMgr && UpgradeMgr_1.upgradeMgr.isValid && gameMgr_1.gameMgr && gameMgr_1.gameMgr.playerTs && gameMgr_1.gameMgr.playerTs.isValid) {
  80. var from = this.node.getPosition();
  81. var to = gameMgr_1.gameMgr.playerTs.node.getPosition();
  82. var div = to.subSelf(from);
  83. var moveDis = this.moveSpeed * dt;
  84. // 成功到达
  85. if (div.mag() < moveDis) {
  86. this.finish();
  87. }
  88. else {
  89. this.node.setPosition(from.addSelf(div.normalizeSelf().mulSelf(moveDis)));
  90. }
  91. }
  92. };
  93. Jingyan = __decorate([
  94. ccclass
  95. ], Jingyan);
  96. return Jingyan;
  97. }(cc.Component));
  98. exports.default = Jingyan;
  99. cc._RF.pop();