CarSpace.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import { MONEY_TYPE } from "../datas/CommonData";
  8. import GameM, { AUDIO_TYPE, Game_Quality, VIDEO_TYPE } from "../manager/GameM";
  9. import UiM from "../manager/UiM";
  10. import Main from "../Main";
  11. import Sciencen_M from "../utils/Sciencen_M";
  12. import { Role } from "../other/item/Role";
  13. import MyExtends from "../tools/MyExtends";
  14. import EffectNode from "../ui/EffectNode";
  15. import { MateData } from "../datas/MateData";
  16. import Gift from "../ui/Gift";
  17. import WealthMng from "../manager/WealthMng";
  18. import Time from "../tools/Time";
  19. import { WealthData } from "../datas/WealthData";
  20. import { Utils } from "../utils/Utils";
  21. const { ccclass, property } = cc._decorator;
  22. @ccclass
  23. export default class CarSpace extends cc.Component {
  24. @property(cc.Node)
  25. chewei: cc.Node = null
  26. @property(cc.Node)
  27. green: cc.Node = null;
  28. @property(cc.Node)
  29. cheweihc: cc.Node = null
  30. @property(cc.Sprite)
  31. coinSlider: cc.Sprite = null;
  32. @property(cc.Node)
  33. car: cc.Node = null;
  34. @property(cc.Node)
  35. box: cc.Node = null;
  36. @property(cc.Node)
  37. boxHead: cc.Node = null;
  38. @property(cc.Node)
  39. xuhao: cc.Node = null
  40. @property(cc.Label)
  41. labLv: cc.Label = null
  42. @property(cc.Label)
  43. labNum: cc.Label = null
  44. @property(cc.Animation)
  45. boxShakeAni: cc.Animation = null
  46. @property(sp.Skeleton)
  47. lightAni: sp.Skeleton = null
  48. @property(sp.Skeleton)
  49. composeAni: sp.Skeleton = null
  50. @property(cc.Node)
  51. coinEft: cc.Node = null;
  52. @property(cc.Label)
  53. coinTxt: cc.Label = null;
  54. @property(cc.Node)
  55. strikeNode: cc.Node = null;
  56. @property(cc.Label)
  57. strikeTimerTxt: cc.Label = null;
  58. qipao: cc.Node = null
  59. boatTween = null
  60. //位置
  61. index: number = 0
  62. //类型
  63. //被其他占用
  64. /*
  65. 10001:金币
  66. 10002:红包币
  67. 10003:时间段收益(当前的每秒收益*时间段)
  68. 10004:惊喜礼包(打开后获得对应等级的汽车)
  69. */
  70. type: number = 0
  71. /** 数量 */
  72. num: number = 0
  73. // LIFE-CYCLE CALLBACKS:
  74. //西游
  75. role: Role = null;
  76. /**是否金币孵化 对应addRunCar 生产金币*/
  77. isSpawn: boolean = false;
  78. /**产生一次金币所花时间*/
  79. moneyTime: number = 0;
  80. /**产生一次金币计时器*/
  81. moneyTimer: number = 0;
  82. /**对应时间内产生金币数*/
  83. moneyDelta: string = '';
  84. main = null;
  85. onLoad() {
  86. this.qipao = this.box.getChildByName('main_icon_qipao')
  87. this.main = UiM.Instance.hallNode.getComponent(Main)
  88. this.box.active = false
  89. this.composeAni.node.active = false;
  90. this.labNum.node.active = false
  91. this.xuhao.active = false
  92. this.labLv.string = ''
  93. cc.loader.loadRes("prefabs/item/MasterSwimEft",cc.Prefab);
  94. }
  95. start() {
  96. }
  97. update(dt) {
  98. this.AddCoinRunner(dt);
  99. this.AttackRunner(dt);
  100. }
  101. /** 初始化
  102. * @param drop true 掉落
  103. */
  104. init(drop = false, num = 1) {
  105. this.unschedule(this.playBoxShakeDown); //停止播放左右抖动动画
  106. this.boxShakeAni.stop()
  107. this.boxOpen = false
  108. let self = this
  109. this.cheweihc.active = false
  110. this.green.active = false;
  111. this.num = num
  112. this.lightAni.node.active = false
  113. this.composeAni.node.active = false;
  114. this.qipao.active = false
  115. if (this.boatTween) {
  116. this.boatTween.stop()
  117. }
  118. // console.log('this.type ', this.type)
  119. if (this.type == 0) {
  120. this.coinSlider.node.active = false;
  121. this.car.active = false
  122. this.xuhao.active = false
  123. this.labLv.string = ''
  124. this.labNum.node.active = false
  125. this.boxHead.active = false
  126. this.box.active = false
  127. }
  128. else {
  129. this.coinSlider.node.active = this.type < 10000;
  130. if (this.type < 10000) {
  131. self.car.scale = 0;
  132. this.boxHead.active = false
  133. this.car.active = true
  134. this.box.active = false
  135. this.labNum.node.active = false
  136. this.xuhao.active = true
  137. cc.loader.loadRes('carPic/side/side_' + this.type, cc.SpriteFrame, (err, assets) => {
  138. if (err) {
  139. cc.error(err);
  140. return;
  141. }
  142. self.car.getComponent(cc.Sprite).spriteFrame = assets;
  143. if (cc.sys.platform != cc.sys.WECHAT_GAME) {
  144. self.car.scale = 1.1;
  145. // cc.tween(self.car).to(0.15, { scale: 1.1 }).start();
  146. if (drop) {
  147. self.car.y = 1300
  148. cc.tween(self.car)
  149. //.to(0.3, { y: -60 })
  150. .to(0.3, { y: -75 })
  151. .call(() => {
  152. if (GameM.commonData.quality > Game_Quality.medium) {
  153. //航海
  154. //this.shuihua.setAnimation(0, 'animation', false);
  155. //this.shuihua.node.active = true
  156. }
  157. })
  158. //.to(0.3, { y: -50 })
  159. .to(0.3, { y: -68.5 })
  160. .call(() => {
  161. this.boatWave()
  162. })
  163. .start()
  164. }
  165. else {
  166. //self.car.y = -54
  167. self.car.y = -68.5
  168. this.boatWave()
  169. }
  170. }
  171. else {
  172. self.car.scale = 1.1
  173. if (GameM.commonData.quality > Game_Quality.medium) {
  174. if (drop) {
  175. self.car.y = 1300
  176. cc.tween(self.car)
  177. //.to(0.3, { y: -60 })
  178. .to(0.3, { y: -75 })
  179. .call(() => {
  180. if (GameM.commonData.quality > Game_Quality.medium) {
  181. //航海
  182. //this.shuihua.setAnimation(0, 'animation', false);
  183. //this.shuihua.node.active = true
  184. }
  185. })
  186. //.to(0.3, { y: -50 })
  187. .to(0.3, { y: -68.5 })
  188. .call(() => {
  189. this.boatWave()
  190. })
  191. .start()
  192. }
  193. else {
  194. //self.car.y = -54
  195. self.car.y = -68.5
  196. this.boatWave()
  197. }
  198. }
  199. else {
  200. //self.car.y = -54
  201. self.car.y = -68.5
  202. this.boatWave()
  203. }
  204. }
  205. })
  206. this.labLv.string = this.type.toString()
  207. }
  208. else {
  209. this.labNum.node.active = true
  210. this.labNum.string = Sciencen_M.instance.format(this.num.toString())
  211. this.xuhao.active = false
  212. this.labLv.string = ''
  213. this.car.active = false
  214. this.box.active = true
  215. //航海
  216. //this.qipao.active = true
  217. let str = ''
  218. if (this.type == MONEY_TYPE.gold) {
  219. str = 'gift/gold'
  220. this.boxHead.active = false
  221. this.green.active = true;
  222. if (!drop) {
  223. self.boxShakeAni.play("boxGoldAni");
  224. }
  225. }
  226. else if (this.type == MONEY_TYPE.redMoney) {
  227. str = 'gift/redMoney'
  228. this.boxHead.active = false
  229. this.green.active = true;
  230. this.labNum.string = this.num.toString()
  231. if (!drop) {
  232. self.boxShakeAni.play("boxRedMoneyAni");
  233. }
  234. }
  235. else if (this.type == MONEY_TYPE.box) {
  236. str = 'gift/box'
  237. this.boxHead.active = true
  238. this.labNum.node.active = false
  239. this.qipao.active = false
  240. this.boxShakeAni.setCurrentTime(0, 'boxShake')
  241. this.boxShakeAni.stop()
  242. }
  243. else if (this.type == MONEY_TYPE.speedCard) {
  244. str = 'gift/iconJiasuka'
  245. this.boxHead.active = false
  246. this.green.active = true;
  247. this.labNum.string = this.num.toString()
  248. if (!drop) {
  249. self.boxShakeAni.play("boxRedMoneyAni");
  250. }
  251. }
  252. else if (this.type == MONEY_TYPE.turnTableCard) {
  253. str = 'gift/iconZhuanpanka'
  254. this.boxHead.active = false
  255. this.green.active = true;
  256. this.labNum.string = this.num.toString()
  257. if (!drop) {
  258. self.boxShakeAni.play("boxRedMoneyAni");
  259. }
  260. }
  261. else if (this.type == MONEY_TYPE.treasureCard) {
  262. str = 'gift/iconDuobaoquan'
  263. this.boxHead.active = false
  264. this.green.active = true;
  265. this.labNum.string = this.num.toString()
  266. if (!drop) {
  267. self.boxShakeAni.play("boxRedMoneyAni");
  268. }
  269. }
  270. // console.log('str ', str)
  271. self.box.getComponent(cc.Sprite).spriteFrame = cc.loader.getRes(str, cc.SpriteFrame)
  272. if (drop) {
  273. if (GameM.commonData.quality > Game_Quality.medium) {
  274. self.box.setPosition(cc.v2(0, 1300))
  275. cc.tween(self.box)
  276. .to(0.3, { position: cc.v2(0, -7.5) })
  277. .call(() => {
  278. if (self.type == MONEY_TYPE.box) {
  279. self.scheduleOnce(self.playBoxShakeDown, 0.5);
  280. self.scheduleOnce(self.delayOpenBox, 5);
  281. }
  282. else if (self.type == MONEY_TYPE.redMoney) {
  283. self.boxShakeAni.play("boxRedMoneyAni");
  284. }
  285. else if (self.type == MONEY_TYPE.gold) {
  286. self.boxShakeAni.play("boxGoldAni");
  287. } else {
  288. self.boxShakeAni.play("boxGoldAni");
  289. }
  290. })
  291. .start()
  292. }
  293. else {
  294. self.box.setPosition(cc.v2(0, -7.5))
  295. if (self.type == MONEY_TYPE.box) {
  296. self.scheduleOnce(self.playBoxShakeDown, 0.5);
  297. self.scheduleOnce(self.delayOpenBox, 5);
  298. }
  299. else if (self.type == MONEY_TYPE.redMoney) {
  300. self.boxShakeAni.play("boxRedMoneyAni");
  301. }
  302. else if (self.type == MONEY_TYPE.gold) {
  303. self.boxShakeAni.play("boxGoldAni");
  304. } else {
  305. self.boxShakeAni.play("boxGoldAni");
  306. }
  307. }
  308. }
  309. }
  310. }
  311. this.CheckAttack();
  312. this.ClearSwimState();
  313. }
  314. playBoxShakeDown() {
  315. this.boxShakeAni.play("boxShakeDown");
  316. }
  317. /** 船上下晃动 */
  318. boatWave() {
  319. if (GameM.commonData.quality <= Game_Quality.medium) {
  320. return
  321. }
  322. this.boatTween = cc.tween(this.car)
  323. //.to(1, { y: -50 })
  324. //.to(1, { y: -54 })
  325. .to(1, { y: -68.5 })
  326. .to(1, { y: -64.5 })
  327. .union()
  328. .repeatForever()
  329. .start()
  330. }
  331. delayOpenBox() {
  332. this.openBox(Number(GameM.commonData.buyNumCfg[(GameM.commonData.buyTimeTotal + 1).toString()].box_car));
  333. }
  334. hideImg() {
  335. this.car.active = false
  336. }
  337. showImg() {
  338. if (this.type < 10000 && this.type != 0) {
  339. this.car.active = true
  340. }
  341. }
  342. showCanCompose() {
  343. this.cheweihc.active = true;
  344. //this.cheweihc.opacity = 255;
  345. cc.tween(this.cheweihc).repeatForever(cc.tween(this.cheweihc).to(0.5, { scale: 1.1 }).to(0.5, { scale: 1 })).start();
  346. }
  347. hideCanCompose() {
  348. this.cheweihc.active = false;
  349. cc.Tween.stopAllByTarget(this.cheweihc);
  350. }
  351. /** 改变车类型
  352. * @param type 类型 0 为空车位
  353. */
  354. changeType(type) {
  355. if (type != 0) {
  356. this.showImg()
  357. }
  358. if (this.type == type) {
  359. return
  360. }
  361. this.type = type
  362. this.init()
  363. }
  364. boxOpen = false
  365. /** 打开宝箱
  366. * @type 车等级
  367. */
  368. openBox(type) {
  369. if (this.boxOpen) {
  370. return
  371. }
  372. this.unschedule(this.delayOpenBox)
  373. GameM.audioM.playEffect(AUDIO_TYPE.giftOpen)
  374. this.boxOpen = true
  375. let self = this
  376. this.scheduleOnce(function () {
  377. self.scheduleOnce(function () {
  378. GameM.audioM.playEffect(AUDIO_TYPE.giftGetCar)
  379. self.changeType(type)
  380. self.boxOpen = false
  381. GameM.commonData.updateBagCarData(self.index.toString(), type)
  382. if (GameM.commonData.isUseXiYouAddCoin) {
  383. //西游
  384. UiM.Instance.hallNode.getComponent(Main).addRunRole(type, this, true);
  385. //self.AddCoinSpawn(true);
  386. }
  387. self.composeAni.node.active = true;
  388. self.composeAni.setAnimation(0, 'animation', false);
  389. self.scheduleOnce(() => { self.composeAni.node.active = false }, 1.5);
  390. UiM.Instance.hallNode.getComponent(Main).CheckNormalGuide();
  391. }, 0.3)
  392. }, 1.2)
  393. this.boxShakeAni.setCurrentTime(0, 'boxShake')
  394. this.boxShakeAni.play()
  395. }
  396. // update (dt) {}
  397. /**判断武将是否未罢工*/
  398. CheckIsStrike() {
  399. if (this.role != null && GameM.commonData.IsUnlockStrike()) {
  400. return !this.role.isStriking;
  401. }
  402. return false;
  403. }
  404. /**点击角色 加速获取金币*/
  405. ClickRole() {
  406. //弃用
  407. return;
  408. //console.log("you click park " + this.node.name);
  409. if (this.role != null && GameM.commonData.IsUnlockStrike()) {
  410. if (GameM.commonData.clickStrikeNum < GameM.commonData.clickStrikeMaxNum) {
  411. if (this.role.AddSpeed()) {
  412. GameM.commonData.clickStrikeNum++;
  413. GameM.commonData.addDailyFinishTimesDataByType(5);
  414. } else {
  415. if (GameM.commonData.maxCarLevel >= GameM.commonData.clearCoolTimeLVOpen) {
  416. UiM.Instance.giftNode.active = true
  417. let gift = UiM.Instance.giftNode.getComponent(Gift)
  418. gift.init(MONEY_TYPE.clearCooltime, "0", null, false, 0, VIDEO_TYPE.clearCoolTime, -1, false)
  419. } else {
  420. EffectNode.instance.PlayTip('你太贪心了,都不让我休息会');
  421. }
  422. }
  423. } else {
  424. EffectNode.instance.PlayTip('你太贪心了,今天加速次数已用完');
  425. }
  426. }
  427. GameM.audioM.playEffect(AUDIO_TYPE.button);
  428. }
  429. RoleInit(isStriking: boolean, time = 0) {
  430. if (isStriking) {
  431. this.strikeNode.active = true;
  432. this.strikeTimerTxt.string = MyExtends.TimeToFormat(time);
  433. } else {
  434. this.strikeNode.active = false;
  435. }
  436. }
  437. ClearRole() {
  438. this.role = null;
  439. this.strikeNode.active = false;
  440. }
  441. /**金币获取*/
  442. AddCoinRunner(dt) {
  443. if (this.role != null) {
  444. //加速金币
  445. this.role.moneyTimer += dt;
  446. this.coinSlider.fillRange = this.role.moneyTimer / this.role.moneyTime;
  447. if (this.role.moneyTimer >= this.role.moneyTime) {
  448. this.role.moneyTimer = 0;
  449. //console.log("Index:" + this.type + " Money:" + this.role.moneyDelta + " Talent:" + MateData.Ins.Mate1Talent1);
  450. //唐僧天赋1
  451. let num = Sciencen_M.instance.addition(this.role.moneyDelta, Sciencen_M.instance.accMul(this.role.moneyDelta, (MateData.Ins.Mate1Talent1 * 0.01).toString()));
  452. GameM.commonData.updateGold(num)
  453. //GameM.commonData.updateGold(this.role.moneyDelta);
  454. //this.main.addCarGoldTip(this.role.moneyDelta);
  455. //this.PlayCoinAni(this.role.moneyDelta);
  456. if (this.isCanOperate)
  457. this.PlayCoinAni(num);
  458. //console.log("Add Coin "+this.role.moneyDelta);
  459. }
  460. //罢工计时
  461. if (this.role.isStriking) {
  462. this.role.strikeTimeNum -= dt;
  463. //if(this.role.strikeTimeNum<=0)this.role.strikeTimeNum=0;
  464. this.strikeTimerTxt.string = MyExtends.TimeToFormat(this.role.strikeTimeNum);
  465. if (this.role.strikeTimeNum <= 0) {
  466. console.log("-->Space " + this.index);
  467. this.role.RemoveStrike();
  468. this.strikeNode.active = false;
  469. }
  470. }
  471. }
  472. }
  473. PlayCoinAni(coinStr: string) {
  474. //this.coinEft.active = true;
  475. //this.coinEft.stopAllActions();
  476. this.coinEft.opacity = 255;
  477. this.coinEft.setPosition(0, 0);
  478. this.coinTxt.string = Sciencen_M.instance.format(coinStr);
  479. let copy = cc.instantiate(this.coinEft);
  480. copy.parent = this.coinEft.parent;
  481. copy.active = true;
  482. let a = cc.moveTo(0.5, cc.v2(0, 100));
  483. let b1 = cc.delayTime(0.4);
  484. let b2 = cc.fadeOut(0.1);
  485. let b3 = cc.callFunc(() => { copy.destroy(); });
  486. let b = cc.sequence(b1, b2, b3);
  487. copy.runAction(cc.spawn(a, b));
  488. }
  489. private isWealthing: boolean = false;
  490. private isCanAttack: boolean = false;
  491. private attackTimer: number = 0;
  492. private attackTime: number = 0.5;
  493. private swinEftNode: cc.Node = null;
  494. /**是否可以操作 false 座位被财神站住时 不可以被合成*/
  495. isCanOperate: boolean = true;
  496. CheckAttack() {
  497. if (WealthMng.Ins.isWealthing) {
  498. if (this.type > 0 && this.type < 10000) {
  499. if (this.isCanOperate) {
  500. this.attackTime = WealthData.Ins.GetMasterAttackTime(this.type);
  501. this.attackTimer = 0;
  502. if (!this.isWealthing) {
  503. this.isWealthing = true;
  504. this.isCanAttack = true;
  505. this.CheckAttackAni(true);
  506. WealthMng.Ins.Shoot(this.node, this.type);
  507. }
  508. } else {
  509. this.AttackEnd();
  510. }
  511. } else {
  512. this.AttackEnd();
  513. }
  514. } else {
  515. this.AttackEnd();
  516. }
  517. }
  518. /**检查车位可操作状态*/
  519. CheckSpaceState(active: boolean) {
  520. this.isCanOperate = active;
  521. if (this.type != 0) {
  522. if (active) {
  523. if (this.type < 10000) {
  524. cc.Tween.stopAllByTarget(this.car);
  525. cc.tween(this.car)
  526. .to(0.2, { scaleY: 1.1 })
  527. .call(() => this.boatWave())
  528. .start();
  529. //this.car.scale=1.1;
  530. //this.boatWave();
  531. }
  532. this.box.opacity = 255;
  533. this.car.opacity = 255;
  534. this.coinSlider.node.opacity = 255;
  535. this.xuhao.opacity = 255;
  536. this.labLv.node.opacity = 255;
  537. this.labNum.node.opacity = 255;
  538. this.strikeNode.opacity = 255;
  539. this.cheweihc.opacity = 255;
  540. } else {
  541. if (this.type < 10000) {
  542. cc.Tween.stopAllByTarget(this.car);
  543. cc.tween(this.car)
  544. .to(0.2, { scaleY: 0 })
  545. .call(() => this.car.opacity = 0)
  546. .start();
  547. }
  548. this.box.opacity = 0;
  549. //this.car.opacity = 0;
  550. this.coinSlider.node.opacity = 0;
  551. this.xuhao.opacity = 0;
  552. this.labLv.node.opacity = 0;
  553. this.labNum.node.opacity = 0;
  554. this.strikeNode.opacity = 0;
  555. this.cheweihc.opacity = 0;
  556. }
  557. }
  558. }
  559. CheckAttackAni(isAttack: boolean) {
  560. if (isAttack) {
  561. cc.tween(this.car)
  562. .to(0.07, { angle: 10 })
  563. .to(0.14, { angle: -10 })
  564. .to(0.07, { angle: 0 })
  565. .start();
  566. } else {
  567. //cc.Tween.stopAllByTarget(this.car);
  568. this.car.angle = 0;
  569. }
  570. }
  571. MasterEffect() {
  572. this.isCanAttack = false;
  573. if (this.type > 0 && this.type < 10000) {
  574. if (this.isCanOperate) {
  575. this.CheckAttackAni(false);
  576. this.CreateEffect();
  577. } else {
  578. if (this.swinEftNode != null) {
  579. this.swinEftNode.destroy();
  580. this.swinEftNode = null;
  581. }
  582. }
  583. }
  584. }
  585. async CreateEffect() {
  586. this.node.stopAllActions();
  587. let eftdmg = cc.instantiate(await Utils.loadResPromise("prefabs/item/MasterDmgEft"));
  588. eftdmg.parent = this.node;
  589. let a1 = cc.delayTime(0.5);
  590. let a2 = cc.callFunc(() => {
  591. eftdmg.destroy();
  592. if (this.swinEftNode != null) {
  593. this.swinEftNode.destroy();
  594. this.swinEftNode = null;
  595. }
  596. this.swinEftNode = cc.instantiate(cc.loader.getRes("prefabs/item/MasterSwimEft"));
  597. this.swinEftNode.parent = this.node;
  598. this.swinEftNode.setPosition(0, 40);
  599. });
  600. let a3 = cc.delayTime(WealthData.Ins.skill1Time);
  601. let a4 = cc.callFunc(() => {
  602. if (this.swinEftNode != null) {
  603. this.swinEftNode.destroy();
  604. this.swinEftNode = null;
  605. }
  606. this.isCanAttack = true;
  607. this.CheckAttack();
  608. });
  609. this.node.runAction(cc.sequence(a1, a2, a3, a4));
  610. //this.isCanAttack = false;
  611. //let eftdmg = cc.instantiate(cc.loader.getRes("prefabs/item/MasterDmgEft"));
  612. //eftdmg.parent = this.node;
  613. //await Time.WaitForSeconds(0.5);
  614. //eftdmg.destroy();
  615. //if (this.swinEftNode != null) {
  616. // this.swinEftNode.destroy();
  617. // this.swinEftNode = null;
  618. //}
  619. //
  620. //this.swinEftNode = cc.instantiate(cc.loader.getRes("prefabs/item/MasterSwimEft"));
  621. //this.swinEftNode.parent = this.node;
  622. //this.swinEftNode.setPosition(0, 40);
  623. //await Time.WaitForSeconds(WealthData.Ins.skill1Time);
  624. //if (this.swinEftNode != null) {
  625. // this.swinEftNode.destroy();
  626. // this.swinEftNode = null;
  627. //}
  628. //this.isCanAttack = true;
  629. //this.CheckAttack();
  630. }
  631. ClearSwimState() {
  632. if (this.swinEftNode != null) {
  633. this.swinEftNode.destroy();
  634. this.swinEftNode = null;
  635. }
  636. this.isCanAttack = true;
  637. }
  638. AttackRunner(dt) {
  639. if (this.isWealthing && this.isCanAttack) {
  640. this.attackTimer += dt;
  641. if (this.attackTimer >= this.attackTime) {
  642. this.attackTimer = 0;
  643. this.CheckAttackAni(true);
  644. WealthMng.Ins.Shoot(this.node, this.type);
  645. }
  646. }
  647. }
  648. AttackEnd() {
  649. this.isWealthing = false;
  650. this.isCanAttack = false;
  651. this.attackTimer = 0;
  652. this.CheckAttackAni(false);
  653. }
  654. }