UEBattleView.ts 41 KB

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