UEBattleView.ts 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. import { ActFightStart, ActionType, fightLogList, fightLogOne } from "../../common/Xys";
  2. import { BattleTeamId, FightType } from "../../data/const/TypeConst";
  3. import GameDataCenter from "../../data/GameDataCenter";
  4. import UEBase from "../../frameWork/compment/UEBase";
  5. import { eg } from "../../frameWork/eg";
  6. import AssetMgr from "../../utils/AssetMgr";
  7. import { BattleGridConstant } from "./BattleGridConstant";
  8. import UEBattleRole from "./UEBattleRole";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class UEBattleView extends UEBase {
  12. @property(cc.Prefab)
  13. rolePrefab: cc.Prefab = null;
  14. @property(cc.Prefab)
  15. subHpPrefab: cc.Prefab = null;
  16. @property(cc.Prefab)
  17. cellPrefab: cc.Prefab = null!;
  18. @property(cc.Node)
  19. roleContent: cc.Node = null;
  20. @property(cc.Node)
  21. hpLayer: cc.Node = null
  22. @property(cc.Node)
  23. cellLayer: cc.Node = null;
  24. fightStart: ActFightStart;
  25. fightLogList: fightLogList;
  26. static readonly BundleKey: string = "battle";
  27. static readonly PrefabUrl: string = "UEBattleView";
  28. static readonly CLS: string = "UEBattleView";
  29. type: FightType;
  30. huihe: number;
  31. curIndex: number;
  32. static s_ins: UEBattleView;
  33. TxtRound: cc.Label;
  34. static getInstance() {
  35. return this.s_ins
  36. }
  37. Init() {
  38. UEBattleView.s_ins = this;
  39. this.fightStart = {
  40. "from": "pve",
  41. "seed": 29576,
  42. "teams": {
  43. "10": {
  44. "fid": "106364",
  45. "zhanwei": 0,
  46. "level": 0,
  47. },
  48. "20": {
  49. "fid": "1022",
  50. "zhanwei": 0,
  51. "level": 0,
  52. }
  53. }
  54. };
  55. this.fightLogList = {
  56. "win": 1,
  57. "log": {
  58. "1": [{
  59. "aType": ActionType.round,
  60. "atker": {
  61. "fid": "",
  62. "iid": "",
  63. "hp": 0,
  64. "nuqi": 0,
  65. "buff": [],
  66. "effect": [],
  67. "status": 0
  68. },
  69. "target": [{
  70. "fid": "106364",
  71. "iid": "10",
  72. "hp": 943267,
  73. "nuqi": 0,
  74. "buff": [],
  75. "effect": [
  76. [
  77. "huifu",
  78. 2100
  79. ]
  80. ],
  81. "status": 0
  82. }],
  83. },
  84. {
  85. "aType": ActionType.buff,
  86. "atker": {
  87. "fid": "1022",
  88. "iid": "20",
  89. "hp": 707156,
  90. "nuqi": 0,
  91. "buff": [],
  92. "effect": [],
  93. "status": 0
  94. },
  95. "target": []
  96. },
  97. {
  98. "aType": ActionType.atk,
  99. "atker": {
  100. "fid": "1022",
  101. "iid": "20",
  102. "hp": 707156,
  103. "nuqi": 1819,
  104. "buff": [],
  105. "effect": [
  106. [
  107. "xixue",
  108. 11400
  109. ]
  110. ],
  111. "status": 0
  112. },
  113. "target": [{
  114. "fid": "106364",
  115. "iid": "10",
  116. "hp": 883267,
  117. "nuqi": 659,
  118. "buff": [
  119. [
  120. "jiyun",
  121. 1
  122. ]
  123. ],
  124. "effect": [
  125. [
  126. "hp", -60000
  127. ]
  128. ],
  129. "status": 0
  130. }]
  131. },
  132. {
  133. "aType": ActionType.over,
  134. "atker": {
  135. "fid": "1022",
  136. "iid": "20",
  137. "hp": 707156,
  138. "nuqi": 1819,
  139. "buff": [],
  140. "effect": [],
  141. "status": 0
  142. },
  143. "target": []
  144. },
  145. {
  146. "aType": ActionType.buff,
  147. "atker": {
  148. "fid": "106364",
  149. "iid": "10",
  150. "hp": 883267,
  151. "nuqi": 659,
  152. "buff": [
  153. [
  154. "jiyun",
  155. 1
  156. ]
  157. ],
  158. "effect": [
  159. [
  160. "jiyun",
  161. 1
  162. ]
  163. ],
  164. "status": 0
  165. },
  166. "target": []
  167. },
  168. {
  169. "aType": ActionType.over,
  170. "atker": {
  171. "fid": "106364",
  172. "iid": "10",
  173. "hp": 883267,
  174. "nuqi": 659,
  175. "buff": [],
  176. "effect": [],
  177. "status": 0
  178. },
  179. "target": []
  180. }
  181. ],
  182. "2": [{
  183. "aType": ActionType.round,
  184. "atker": {
  185. "fid": "",
  186. "iid": "",
  187. "hp": 0,
  188. "nuqi": 0,
  189. "buff": [],
  190. "effect": [],
  191. "status": 0
  192. },
  193. "target": [{
  194. "fid": "106364",
  195. "iid": "10",
  196. "hp": 885367,
  197. "nuqi": 659,
  198. "buff": [],
  199. "effect": [
  200. [
  201. "huifu",
  202. 2100
  203. ]
  204. ],
  205. "status": 0
  206. }]
  207. },
  208. {
  209. "aType": ActionType.buff,
  210. "atker": {
  211. "fid": "1022",
  212. "iid": "20",
  213. "hp": 707156,
  214. "nuqi": 1819,
  215. "buff": [],
  216. "effect": [],
  217. "status": 0
  218. },
  219. "target": []
  220. },
  221. {
  222. "aType": ActionType.atk,
  223. "atker": {
  224. "fid": "1022",
  225. "iid": "20",
  226. "hp": 707156,
  227. "nuqi": 3733,
  228. "buff": [],
  229. "effect": [
  230. [
  231. "xixue",
  232. 22121
  233. ]
  234. ],
  235. "status": 0
  236. },
  237. "target": [{
  238. "fid": "106364",
  239. "iid": "10",
  240. "hp": 768942,
  241. "nuqi": 1355,
  242. "buff": [],
  243. "effect": [
  244. [
  245. "baoji", -116425
  246. ]
  247. ],
  248. "status": 0
  249. }]
  250. },
  251. {
  252. "aType": ActionType.over,
  253. "atker": {
  254. "fid": "1022",
  255. "iid": "20",
  256. "hp": 707156,
  257. "nuqi": 3733,
  258. "buff": [],
  259. "effect": [],
  260. "status": 0
  261. },
  262. "target": []
  263. },
  264. {
  265. "aType": ActionType.buff,
  266. "atker": {
  267. "fid": "106364",
  268. "iid": "10",
  269. "hp": 768942,
  270. "nuqi": 1355,
  271. "buff": [],
  272. "effect": [],
  273. "status": 0
  274. },
  275. "target": []
  276. },
  277. {
  278. "aType": ActionType.atk,
  279. "atker": {
  280. "fid": "106364",
  281. "iid": "10",
  282. "hp": 768942,
  283. "nuqi": 3227,
  284. "buff": [],
  285. "effect": [],
  286. "status": 0
  287. },
  288. "target": [{
  289. "fid": "1022",
  290. "iid": "20",
  291. "hp": 605306,
  292. "nuqi": 4474,
  293. "buff": [],
  294. "effect": [
  295. [
  296. "hp", -101850
  297. ]
  298. ],
  299. "status": 0
  300. }]
  301. },
  302. {
  303. "aType": ActionType.atk,
  304. "atker": {
  305. "fid": "106364",
  306. "iid": "10",
  307. "hp": 832958,
  308. "nuqi": 3227,
  309. "buff": [],
  310. "effect": [
  311. [
  312. "huifu",
  313. 64016
  314. ]
  315. ],
  316. "status": 0
  317. },
  318. "target": [{
  319. "fid": "1022",
  320. "iid": "20",
  321. "hp": 507489,
  322. "nuqi": 4474,
  323. "buff": [],
  324. "effect": [
  325. [
  326. "lianji", -97817
  327. ]
  328. ],
  329. "status": 0
  330. }]
  331. },
  332. {
  333. "aType": ActionType.over,
  334. "atker": {
  335. "fid": "106364",
  336. "iid": "10",
  337. "hp": 832958,
  338. "nuqi": 3227,
  339. "buff": [],
  340. "effect": [],
  341. "status": 0
  342. },
  343. "target": []
  344. }
  345. ],
  346. "3": [{
  347. "aType": ActionType.round,
  348. "atker": {
  349. "fid": "",
  350. "iid": "",
  351. "hp": 0,
  352. "nuqi": 0,
  353. "buff": [],
  354. "effect": [],
  355. "status": 0
  356. },
  357. "target": [{
  358. "fid": "106364",
  359. "iid": "10",
  360. "hp": 835058,
  361. "nuqi": 3227,
  362. "buff": [],
  363. "effect": [
  364. [
  365. "huifu",
  366. 2100
  367. ]
  368. ],
  369. "status": 0
  370. }]
  371. },
  372. {
  373. "aType": ActionType.buff,
  374. "atker": {
  375. "fid": "1022",
  376. "iid": "20",
  377. "hp": 507489,
  378. "nuqi": 4474,
  379. "buff": [],
  380. "effect": [],
  381. "status": 0
  382. },
  383. "target": []
  384. },
  385. {
  386. "aType": ActionType.atk,
  387. "atker": {
  388. "fid": "1022",
  389. "iid": "20",
  390. "hp": 518778,
  391. "nuqi": 6374,
  392. "buff": [],
  393. "effect": [
  394. [
  395. "xixue",
  396. 11289
  397. ]
  398. ],
  399. "status": 0
  400. },
  401. "target": [{
  402. "fid": "106364",
  403. "iid": "10",
  404. "hp": 775646,
  405. "nuqi": 3916,
  406. "buff": [],
  407. "effect": [
  408. [
  409. "hp", -59412
  410. ]
  411. ],
  412. "status": 0
  413. }]
  414. },
  415. {
  416. "aType": ActionType.over,
  417. "atker": {
  418. "fid": "1022",
  419. "iid": "20",
  420. "hp": 518778,
  421. "nuqi": 6374,
  422. "buff": [],
  423. "effect": [],
  424. "status": 0
  425. },
  426. "target": []
  427. },
  428. {
  429. "aType": ActionType.buff,
  430. "atker": {
  431. "fid": "106364",
  432. "iid": "10",
  433. "hp": 775646,
  434. "nuqi": 3916,
  435. "buff": [],
  436. "effect": [],
  437. "status": 0
  438. },
  439. "target": []
  440. },
  441. {
  442. "aType": ActionType.atk,
  443. "atker": {
  444. "fid": "106364",
  445. "iid": "10",
  446. "hp": 775646,
  447. "nuqi": 5767,
  448. "buff": [],
  449. "effect": [],
  450. "status": 0
  451. },
  452. "target": [{
  453. "fid": "1022",
  454. "iid": "20",
  455. "hp": 415919,
  456. "nuqi": 7039,
  457. "buff": [],
  458. "effect": [
  459. [
  460. "hp", -102859
  461. ]
  462. ],
  463. "status": 0
  464. }]
  465. },
  466. {
  467. "aType": ActionType.over,
  468. "atker": {
  469. "fid": "106364",
  470. "iid": "10",
  471. "hp": 775646,
  472. "nuqi": 5767,
  473. "buff": [],
  474. "effect": [],
  475. "status": 0
  476. },
  477. "target": []
  478. }
  479. ],
  480. "4": [{
  481. "aType": ActionType.round,
  482. "atker": {
  483. "fid": "",
  484. "iid": "",
  485. "hp": 0,
  486. "nuqi": 0,
  487. "buff": [],
  488. "effect": [],
  489. "status": 0
  490. },
  491. "target": [{
  492. "fid": "106364",
  493. "iid": "10",
  494. "hp": 777746,
  495. "nuqi": 5767,
  496. "buff": [],
  497. "effect": [
  498. [
  499. "huifu",
  500. 2100
  501. ]
  502. ],
  503. "status": 0
  504. }]
  505. },
  506. {
  507. "aType": ActionType.buff,
  508. "atker": {
  509. "fid": "1022",
  510. "iid": "20",
  511. "hp": 415919,
  512. "nuqi": 7039,
  513. "buff": [],
  514. "effect": [],
  515. "status": 0
  516. },
  517. "target": []
  518. },
  519. {
  520. "aType": ActionType.atk,
  521. "atker": {
  522. "fid": "1022",
  523. "iid": "20",
  524. "hp": 427319,
  525. "nuqi": 8850,
  526. "buff": [],
  527. "effect": [
  528. [
  529. "xixue",
  530. 11400
  531. ]
  532. ],
  533. "status": 0
  534. },
  535. "target": [{
  536. "fid": "106364",
  537. "iid": "10",
  538. "hp": 717746,
  539. "nuqi": 6414,
  540. "buff": [],
  541. "effect": [
  542. [
  543. "hp", -60000
  544. ]
  545. ],
  546. "status": 0
  547. }]
  548. },
  549. {
  550. "aType": ActionType.over,
  551. "atker": {
  552. "fid": "1022",
  553. "iid": "20",
  554. "hp": 427319,
  555. "nuqi": 8850,
  556. "buff": [],
  557. "effect": [],
  558. "status": 0
  559. },
  560. "target": []
  561. },
  562. {
  563. "aType": ActionType.buff,
  564. "atker": {
  565. "fid": "106364",
  566. "iid": "10",
  567. "hp": 717746,
  568. "nuqi": 6414,
  569. "buff": [],
  570. "effect": [],
  571. "status": 0
  572. },
  573. "target": []
  574. },
  575. {
  576. "aType": ActionType.atk,
  577. "atker": {
  578. "fid": "106364",
  579. "iid": "10",
  580. "hp": 717746,
  581. "nuqi": 8377,
  582. "buff": [],
  583. "effect": [],
  584. "status": 0
  585. },
  586. "target": [{
  587. "fid": "1022",
  588. "iid": "20",
  589. "hp": 323452,
  590. "nuqi": 9529,
  591. "buff": [],
  592. "effect": [
  593. [
  594. "hp", -103867
  595. ]
  596. ],
  597. "status": 0
  598. }]
  599. },
  600. {
  601. "aType": ActionType.atk,
  602. "atker": {
  603. "fid": "106364",
  604. "iid": "10",
  605. "hp": 781762,
  606. "nuqi": 8377,
  607. "buff": [],
  608. "effect": [
  609. [
  610. "huifu",
  611. 64016
  612. ]
  613. ],
  614. "status": 0
  615. },
  616. "target": [{
  617. "fid": "1022",
  618. "iid": "20",
  619. "hp": 222610,
  620. "nuqi": 9529,
  621. "buff": [],
  622. "effect": [
  623. [
  624. "lianji", -100842
  625. ]
  626. ],
  627. "status": 0
  628. }]
  629. },
  630. {
  631. "aType": ActionType.over,
  632. "atker": {
  633. "fid": "106364",
  634. "iid": "10",
  635. "hp": 781762,
  636. "nuqi": 8377,
  637. "buff": [],
  638. "effect": [],
  639. "status": 0
  640. },
  641. "target": []
  642. }
  643. ],
  644. "5": [{
  645. "aType": ActionType.round,
  646. "atker": {
  647. "fid": "",
  648. "iid": "",
  649. "hp": 0,
  650. "nuqi": 0,
  651. "buff": [],
  652. "effect": [],
  653. "status": 0
  654. },
  655. "target": [{
  656. "fid": "106364",
  657. "iid": "10",
  658. "hp": 783862,
  659. "nuqi": 8377,
  660. "buff": [],
  661. "effect": [
  662. [
  663. "huifu",
  664. 2100
  665. ]
  666. ],
  667. "status": 0
  668. }]
  669. },
  670. {
  671. "aType": ActionType.buff,
  672. "atker": {
  673. "fid": "1022",
  674. "iid": "20",
  675. "hp": 222610,
  676. "nuqi": 9529,
  677. "buff": [],
  678. "effect": [],
  679. "status": 0
  680. },
  681. "target": []
  682. },
  683. {
  684. "aType": ActionType.atk,
  685. "atker": {
  686. "fid": "1022",
  687. "iid": "20",
  688. "hp": 233675,
  689. "nuqi": 11455,
  690. "buff": [],
  691. "effect": [
  692. [
  693. "xixue",
  694. 11065
  695. ]
  696. ],
  697. "status": 0
  698. },
  699. "target": [{
  700. "fid": "106364",
  701. "iid": "10",
  702. "hp": 725626,
  703. "nuqi": 9055,
  704. "buff": [],
  705. "effect": [
  706. [
  707. "hp", -58236
  708. ]
  709. ],
  710. "status": 0
  711. }]
  712. },
  713. {
  714. "aType": ActionType.over,
  715. "atker": {
  716. "fid": "1022",
  717. "iid": "20",
  718. "hp": 233675,
  719. "nuqi": 11455,
  720. "buff": [],
  721. "effect": [],
  722. "status": 0
  723. },
  724. "target": []
  725. },
  726. {
  727. "aType": ActionType.buff,
  728. "atker": {
  729. "fid": "106364",
  730. "iid": "10",
  731. "hp": 725626,
  732. "nuqi": 9055,
  733. "buff": [],
  734. "effect": [],
  735. "status": 0
  736. },
  737. "target": []
  738. },
  739. {
  740. "aType": ActionType.atk,
  741. "atker": {
  742. "fid": "106364",
  743. "iid": "10",
  744. "hp": 725626,
  745. "nuqi": 10940,
  746. "buff": [],
  747. "effect": [],
  748. "status": 0
  749. },
  750. "target": [{
  751. "fid": "1022",
  752. "iid": "20",
  753. "hp": 129808,
  754. "nuqi": 12088,
  755. "buff": [],
  756. "effect": [
  757. [
  758. "hp", -103867
  759. ]
  760. ],
  761. "status": 0
  762. }]
  763. },
  764. {
  765. "aType": ActionType.over,
  766. "atker": {
  767. "fid": "106364",
  768. "iid": "10",
  769. "hp": 725626,
  770. "nuqi": 10940,
  771. "buff": [],
  772. "effect": [],
  773. "status": 0
  774. },
  775. "target": []
  776. }
  777. ],
  778. "6": [{
  779. "aType": ActionType.round,
  780. "atker": {
  781. "fid": "",
  782. "iid": "",
  783. "hp": 0,
  784. "nuqi": 0,
  785. "buff": [],
  786. "effect": [],
  787. "status": 0
  788. },
  789. "target": [{
  790. "fid": "106364",
  791. "iid": "10",
  792. "hp": 727726,
  793. "nuqi": 10940,
  794. "buff": [],
  795. "effect": [
  796. [
  797. "huifu",
  798. 2100
  799. ]
  800. ],
  801. "status": 0
  802. }]
  803. },
  804. {
  805. "aType": ActionType.buff,
  806. "atker": {
  807. "fid": "1022",
  808. "iid": "20",
  809. "hp": 129808,
  810. "nuqi": 12088,
  811. "buff": [],
  812. "effect": [],
  813. "status": 0
  814. },
  815. "target": []
  816. },
  817. {
  818. "aType": ActionType.atk,
  819. "atker": {
  820. "fid": "1022",
  821. "iid": "20",
  822. "hp": 140761,
  823. "nuqi": 13934,
  824. "buff": [],
  825. "effect": [
  826. [
  827. "xixue",
  828. 10953
  829. ]
  830. ],
  831. "status": 0
  832. },
  833. "target": [{
  834. "fid": "106364",
  835. "iid": "10",
  836. "hp": 670079,
  837. "nuqi": 11638,
  838. "buff": [],
  839. "effect": [
  840. [
  841. "hp", -57647
  842. ]
  843. ],
  844. "status": 0
  845. }]
  846. },
  847. {
  848. "aType": ActionType.over,
  849. "atker": {
  850. "fid": "1022",
  851. "iid": "20",
  852. "hp": 140761,
  853. "nuqi": 13934,
  854. "buff": [],
  855. "effect": [],
  856. "status": 0
  857. },
  858. "target": []
  859. },
  860. {
  861. "aType": ActionType.buff,
  862. "atker": {
  863. "fid": "106364",
  864. "iid": "10",
  865. "hp": 670079,
  866. "nuqi": 11638,
  867. "buff": [],
  868. "effect": [],
  869. "status": 0
  870. },
  871. "target": []
  872. },
  873. {
  874. "aType": ActionType.skill,
  875. "atker": {
  876. "fid": "106364",
  877. "iid": "10",
  878. "hp": 670079,
  879. "nuqi": 0,
  880. "buff": [],
  881. "effect": [
  882. [
  883. "huifu",
  884. 35855
  885. ]
  886. ],
  887. "status": 0
  888. },
  889. "target": []
  890. },
  891. {
  892. "aType": ActionType.atk,
  893. "atker": {
  894. "fid": "106364",
  895. "iid": "10",
  896. "hp": 705934,
  897. "nuqi": 1813,
  898. "buff": [],
  899. "effect": [],
  900. "status": 0
  901. },
  902. "target": [{
  903. "fid": "1022",
  904. "iid": "20",
  905. "hp": 37902,
  906. "nuqi": 14627,
  907. "buff": [],
  908. "effect": [
  909. [
  910. "hp", -102859
  911. ]
  912. ],
  913. "status": 0
  914. }]
  915. },
  916. {
  917. "aType": ActionType.atk,
  918. "atker": {
  919. "fid": "106364",
  920. "iid": "10",
  921. "hp": 779552,
  922. "nuqi": 1813,
  923. "buff": [],
  924. "effect": [
  925. [
  926. "huifu",
  927. 73618
  928. ]
  929. ],
  930. "status": 0
  931. },
  932. "target": [{
  933. "fid": "1022",
  934. "iid": "20",
  935. "hp": 0,
  936. "nuqi": 14627,
  937. "buff": [],
  938. "effect": [
  939. [
  940. "lianji", -216709
  941. ]
  942. ],
  943. "status": 0
  944. }]
  945. },
  946. {
  947. "aType": ActionType.over,
  948. "atker": {
  949. "fid": "106364",
  950. "iid": "10",
  951. "hp": 779552,
  952. "nuqi": 1813,
  953. "buff": [],
  954. "effect": [],
  955. "status": 0
  956. },
  957. "target": []
  958. }
  959. ]
  960. }
  961. }
  962. this.TxtRound = this.node.getChildByName("ImgDi").getChildByName("TxtRound").getComponent(cc.Label);
  963. this.initEvent();
  964. this.LoadCell();
  965. }
  966. initEvent(): void {
  967. }
  968. //关闭界面
  969. onDisable(): void {
  970. this.node.destroy();
  971. }
  972. /** 加载地图数据 */
  973. private LoadCell() {
  974. for (let i = 0; i < BattleGridConstant.COL; i++) {
  975. for (let j = 0; j < BattleGridConstant.ROW; j++) {
  976. this.CreateCell(i, j);
  977. }
  978. }
  979. }
  980. /** 创建格子 */
  981. private CreateCell(i: number, j: number) {
  982. let cell = cc.instantiate(this.cellPrefab);
  983. this.cellLayer.addChild(cell);
  984. cell.width = BattleGridConstant.CELL_WIDTH;
  985. cell.height = BattleGridConstant.CELL_HEIGHT;
  986. let pos = this.GetPosByIdx(i, j);
  987. cell.setPosition(pos);
  988. cell.name = `${(i + 1) * 10 + (j + 1)}`;
  989. cell.getChildByName("txtIndex").getComponent(cc.Label).string = `${(i + 1) * 10 + (j + 1)}`;
  990. return cell;
  991. }
  992. /** 根据索引获取实际像素坐标 */
  993. private GetPosByIdx(i: number, j: number): cc.Vec3 {
  994. const startX = -(BattleGridConstant.ROW * BattleGridConstant.CELL_WIDTH) / 2;
  995. const startY = (BattleGridConstant.COL * BattleGridConstant.CELL_HEIGHT) / 2;
  996. return cc.v3(
  997. startX + j * BattleGridConstant.CELL_WIDTH + BattleGridConstant.CELL_WIDTH / 2,
  998. startY - i * BattleGridConstant.CELL_HEIGHT - BattleGridConstant.CELL_HEIGHT / 2
  999. )
  1000. }
  1001. /** 获取扣血飘字表现层 */
  1002. GetHpLayer() {
  1003. return this.hpLayer;
  1004. }
  1005. /** 获取扣血飘字预制体 */
  1006. GetSubHpPrefab() {
  1007. return this.subHpPrefab;
  1008. }
  1009. //开始战斗
  1010. async onStartFight() {
  1011. eg.poolManager.GetPool("subHPPool").clear();
  1012. await this.produceRole();
  1013. this.huihe = 1;
  1014. this.curIndex = 0;
  1015. this.playLog();
  1016. }
  1017. async produceRole() {
  1018. let role1 = this.fightStart.teams[BattleTeamId.role1]
  1019. let role2 = this.fightStart.teams[BattleTeamId.role2]
  1020. let roleZhanwei1: string = "61"
  1021. let roleZhanwei2: string = "66"
  1022. let fightType: FightType = this.type;
  1023. let roleNode1 = AssetMgr.instantiate(this.cellLayer, this.rolePrefab);
  1024. roleNode1.getComponent(UEBattleRole).setRole(this.cellLayer.getChildByName(roleZhanwei1).position, role1, fightType);
  1025. roleNode1.scaleX = 1;
  1026. GameDataCenter.battle.addRole(role1?.fid, roleNode1.getComponent(UEBattleRole));
  1027. let roleNode2 = AssetMgr.instantiate(this.cellLayer, this.rolePrefab);
  1028. roleNode2.getComponent(UEBattleRole).setRole(this.cellLayer.getChildByName(roleZhanwei2).position, role2, fightType);
  1029. roleNode2.scaleX = -1;
  1030. GameDataCenter.battle.addRole(role2?.fid, roleNode2.getComponent(UEBattleRole));
  1031. }
  1032. //播放战斗日志
  1033. playLog() {
  1034. this.TxtRound.string = "第" + this.huihe + "回合";
  1035. let curLog = this.fightLogList.log[this.huihe][this.curIndex];
  1036. // console.error("curLog:", curLog)
  1037. let actionType: ActionType = curLog.aType;
  1038. switch (actionType) {
  1039. case ActionType.round:
  1040. case ActionType.buff:
  1041. this.nextLog();
  1042. break;
  1043. case ActionType.atk:
  1044. this.playAtk(curLog);
  1045. break;
  1046. case ActionType.skill:
  1047. this.playAtk(curLog);
  1048. break;
  1049. case ActionType.over:
  1050. this.nextLog();
  1051. break;
  1052. default:
  1053. break;
  1054. }
  1055. }
  1056. //播放下一条日志
  1057. nextLog() {
  1058. this.curIndex++;
  1059. if (this.fightLogList.log[this.huihe][this.curIndex] == null) {
  1060. this.huihe++;
  1061. if (this.fightLogList.log[this.huihe] != null) {
  1062. this.curIndex = 0;
  1063. this.playLog();
  1064. } else {
  1065. this.scheduleOnce(() => {
  1066. console.log("战斗结束");
  1067. }, 1);
  1068. }
  1069. } else {
  1070. this.playLog();
  1071. }
  1072. }
  1073. playAtk(curLog: fightLogOne) {
  1074. let atker = GameDataCenter.battle.battleRoleList[curLog.atker.fid];
  1075. let target0 = curLog.target.length > 0 ? GameDataCenter.battle.battleRoleList[curLog.target[0].fid]
  1076. : Object.values(GameDataCenter.battle.battleRoleList)[0] //没有target 默认取一个防错
  1077. let delay = 0.5;
  1078. let hitX = 150; //近战偏移量
  1079. cc.tween(atker.node)
  1080. .delay(0.15 / GameDataCenter.battle.realBattleSpeed)
  1081. .to(delay / GameDataCenter.battle.realBattleSpeed, { x: atker.posX < 0 ? target0.node.x - hitX : target0.node.x + hitX })
  1082. .call(() => {
  1083. if (curLog.atker.fid == "1022") {
  1084. atker.playAni("atk", false);
  1085. } else {
  1086. atker.playAni("atk1", false);
  1087. }
  1088. // GameDataCenter.audio.playEffect(atker.atkAudio);
  1089. })
  1090. .delay((delay + 0.3) / GameDataCenter.battle.realBattleSpeed)
  1091. .call(() => {
  1092. //飘血
  1093. let effectList = curLog.target?.[0]?.effect;
  1094. for (let i = 0; i < effectList?.length; i++) {
  1095. let effect = effectList[i];
  1096. console.log("effect:", effect);
  1097. target0.ShowSubHp(effect);
  1098. }
  1099. })
  1100. .delay(0.1 / GameDataCenter.battle.realBattleSpeed)
  1101. .call(() => {
  1102. //显示特效以及连击等特殊效果
  1103. })
  1104. .delay(0.1 / GameDataCenter.battle.realBattleSpeed)
  1105. .call(() => {
  1106. if (curLog.atker.fid != "1022") {
  1107. atker.playAni("walk", true);
  1108. }
  1109. // GameDataCenter.audio.playEffect(atker.atkAudio);
  1110. })
  1111. .to(delay / GameDataCenter.battle.realBattleSpeed, { x: atker.posX })//回到初始位置
  1112. .call(() => {
  1113. if (curLog.atker.fid != "1022") {
  1114. atker.playAni("stand", true);
  1115. }
  1116. let atkerEffectList = curLog.atker?.effect;
  1117. for (let i = 0; i < atkerEffectList?.length; i++) {
  1118. let effect = atkerEffectList[i];
  1119. console.log("atkerEffect:", effect);
  1120. atker.ShowSubHp(effect);
  1121. }
  1122. // GameDataCenter.audio.playEffect(atker.atkAudio);
  1123. })
  1124. .delay(0.3 / GameDataCenter.battle.realBattleSpeed)
  1125. .call(() => {
  1126. this.nextLog();
  1127. })
  1128. .start();
  1129. }
  1130. }