difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
"use strict";
cc._RF.push(module, '046a3v0XBJHTaPPjX3IPd0Q', 'battle_model');
// Scripts/mod/battle/battle_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      战战斗数据控制器,其中包括了战斗场景的创建
//      flyItem attack hideUI showUI fadeOut fadeIn moveBack moveTo noActAttack  暂时实现的播报动作只有这一些
//      blackScreen blackScreen2 blackScreen3 hide show shadow 这一些已经废弃的
// <br/>Create: 2018-11-28 19:19:19
// --------------------------------------------------------------------
var BattleData = require("battle_data");
 
var BattleConst = require("battle_const");
 
var LoaderManager = require("loadermanager");
 
var BattleResPool = require("battle_res_pool");
 
var AniRes = ["hit_effect_list", // 受击点特效
"area_effect_list", // 范围特效
"act_effect_list", // 出手点特效
"bact_effect_list", // 施法特效
"trc_effect_list" // 弹道特效
];
var BattleModel = cc.Class({
  ctor: function ctor() {},
  properties: {
    init_fight_status: false
  },
  initConfig: function initConfig() {
    this.battle_controller = require("battle_controller").getInstance();
    this.hook_model = this.battle_controller.getHookModel();
    this.skill_act = require("skill_act");
    this.battle_pools = require("battle_role_pool").getInstance(); // 现在这个对象池主要是存放buff飘字以及主动技能飘字等,退出战斗没有移除掉这个对象池
 
    this.battle_dmg_cache_list = {}; // 战斗伤害数字的缓存纹理数据,现在退出战斗没有移除掉
 
    this.battle_effect_list = {}; // 当前战斗存在的非挂接角色的特效,这里存放的,退出战斗就会移除掉
 
    this.battle_effect_pool = {}; // 已经播放过的特效缓存对象,退出战斗就会移除掉
 
    this.role_time_scale = 1.1; // 二倍速下面的模型动作速率
 
    this.battle_speed = 1; // 当前战斗速率,服务端速率
 
    this.button_list_panel_time = 0; // 假战斗详情面板关闭的时间戳
 
    this.form_panel_time = 0; // 真战斗对战面板关闭的时间戳
 
    this.is_clear = true;
    this.resetInitData();
  },
  // 重设初始化数据
  resetInitData: function resetInitData() {
    this.my_group = 0; // 战斗中我自己的分组,主要区分是否是己方
 
    this.init_fight_status = false; // 是否是初始化进詹欧的,主要是做进场
 
    this.alive_num = 0; // 存活单位
 
    this.create_over_num = 0; // 已经创建完成的单位数量
 
    this.skill_plays_order_list = []; // 当前播放列表
 
    this.round_data_temp = {};
    this.order_list = [];
    this.round_data = {};
    this.cur_round_data = {};
    this.actor_sum = 0;
    this.actor_play_sum = 0;
    this.act_playing = false;
    this.is_play_round_start = false;
    this.cur_round = null;
    this.next_round = null;
    this.battle_data = null;
    this.combat_type = BattleConst.Fight_Type.Nil; // 当前战斗类型
 
    this.real_role_list = {}; // 真是战斗单位列表
 
    this.cur_fight_type = 0; // 当前战斗类型,如果是0:没有战斗 1:假战斗 2:真战斗
 
    this.buffs = {}; // 重连buff
 
    this.hallows_list = {}; // 神器数据
 
    this.scene_buff_effect_list = {}; // 场景buff特效缓存对象
  },
  // 创建一个场景特效,主要是群攻之类的,这类特效在退出战斗的时候会移除掉
  addBattleEfffect: function addBattleEfffect(parent, scene_pos, reverse, effect_id, action_name) {
    var BattleEffect = require("battle_effect");
 
    var battle_effect = null;
    var effect_key = Utils.getNorKey(effect_id, action_name);
 
    if (this.battle_effect_pool[effect_key] != null) {
      if (this.battle_effect_pool[effect_key].length > 0) {
        battle_effect = this.battle_effect_pool[effect_key].shift(); // 从头取出一个
      }
    }
 
    if (battle_effect == null) {
      battle_effect = new BattleEffect();
      battle_effect.createEffect(parent, scene_pos, reverse, effect_id);
    } else {
      battle_effect.resetScenePos(scene_pos);
      battle_effect.resetReverse(reverse);
      battle_effect.setTimeScale(this.role_time_scale);
      battle_effect.setActiveEffect(true);
    }
 
    if (this.battle_effect_list[effect_key] == null) {
      this.battle_effect_list[effect_key] = [];
    }
 
    this.battle_effect_list[effect_key].push(battle_effect);
    return battle_effect;
  },
  // 移除一个场景战斗特效
  delBattleEffect: function delBattleEffect(battle_effect) {
    var effect_key = battle_effect.getEffectKey();
    if (effect_key == "_") return;
 
    if (this.battle_effect_pool[effect_key] == null) {
      this.battle_effect_pool[effect_key] = [];
    }
 
    var array = this.battle_effect_list[effect_key];
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
 
      if (element == battle_effect) {
        array.splice(index, 1);
        battle_effect.setActiveEffect(false);
        this.battle_effect_pool[effect_key].push(battle_effect);
        break;
      }
    }
  },
  // 获取伤害数字的缓存纹理数据
  getDmgFontCacheObject: function getDmgFontCacheObject(type, callback) {
    var res_path = PathTool.getPlistPath("num", "type" + type);
    var res_object = this.battle_dmg_cache_list[res_path];
 
    if (res_object == null) {
      LoaderManager.getInstance().loadRes(res_path, function (res_object) {
        this.battle_dmg_cache_list[res_path] = res_object;
        callback(res_object);
      }.bind(this));
    } else {
      callback(res_object);
    }
  },
  // 释放掉战斗资源,退出战斗场景之后释放掉吧,但是这里可能存在一个问题就是退出战斗场景是即时的,但是伤害数字还在处于动作中,这个时候还是释放不掉,战斗艺术字不是特别大,暂时考虑不清除
  releaseDmgFont: function releaseDmgFont() {
    for (var path in this.battle_dmg_cache_list) {
      LoaderManager.getInstance().releaseRes(path);
    }
 
    this.battle_dmg_cache_list = {};
  },
  // 获取一个普通文字.带背景的,暂时退出战斗没有移除对象池
  getNormalFont: function getNormalFont() {
    var pools = this.battle_pools.getFontPools();
    var node = null;
 
    if (pools.size() > 0) {
      node = pools.get();
    } else {
      node = new cc.Node();
      node.setAnchorPoint(0.5, 0.5);
      node.width = 176;
      node.height = 44;
      var bg_node = new cc.Node();
      bg_node.addComponent(cc.Sprite);
      node.addChild(bg_node);
      var font_node = new cc.Node();
      var font_label = font_node.addComponent(cc.Label);
      font_label.lineHeight = 20;
      font_label.fontSize = 20;
      font_node.addComponent(cc.LabelOutline);
      font_node.name = "font_label";
      node.addChild(font_node);
      var bg_path = PathTool.getUIIconPath("battle", "battle_buff_name_bg");
      LoaderManager.getInstance().loadRes(bg_path, function (bg_node, res_object) {
        bg_node.getComponent(cc.Sprite).spriteFrame = res_object;
      }.bind(this, bg_node));
    }
 
    return node;
  },
 
  /**
   * 回收对象池
   * @param {*} font 
   */
  pushBackBattleFont: function pushBackBattleFont(font) {
    this.battle_pools.pushBackFont(font);
  },
 
  /**
   * 真是战斗的初始化数据.战斗单位可能存在hp为0的时候,这个时候需要特殊处理
   */
  updateCurBattleData: function updateCurBattleData(data, is_init) {
    this.deleteCurBattleData();
    this.init_fight_status = is_init;
 
    if (this.battle_data == null) {
      this.battle_data = new BattleData();
    }
 
    this.battle_data.updateData(data); // 保存战斗速度
 
    this.saveSpeed(data.play_speed); // 更新神器数据
 
    for (var index = 0; index < data.hallows_list.length; index++) {
      var element = data.hallows_list[index];
      this.hallows_list[element.group] = element;
    } // 先判断对战列表中是否有自己的
 
 
    var RoleController = require("role_controller");
 
    var role_vo = RoleController.getInstance().getRoleVo();
 
    for (var key in this.battle_data.fight_object_list) {
      var role_data = this.battle_data.fight_object_list[key];
 
      if (Utils.getNorKey(role_data.owner_id, role_data.owner_srv_id) == Utils.getNorKey(role_vo.rid, role_vo.srv_id) && this.my_group == 0) {
        this.my_group = role_data.group;
      }
 
      if (role_data.hp > 0) {
        this.alive_num += 1;
      } // 处理神器的
 
 
      if (role_data.object_type == BattleConst.Unit_Type.Hallows) {
        var hallows_data = this.hallows_list[role_data.group];
        hallows_data.pos = role_data.pos;
        role_data.hallows_val = hallows_data.val;
        role_data.hallows_max = hallows_data.max;
      }
    }
 
    if (this.my_group == 0) {
      this.my_group = 1;
    }
  },
 
  /**
   * 创建完成之后通知服务端准备报了
   */
  addReadySum: function addReadySum() {
    this.create_over_num += 1;
 
    if (this.create_over_num >= this.alive_num) {
      this.battle_controller.csReadyFightStart();
    }
  },
  // 获取所有战斗单位
  getAllObject: function getAllObject() {
    return this.real_role_list;
  },
  // 设置战斗场景可见与否
  handleBattleSceneStatus: function handleBattleSceneStatus(status) {
    if (this.battle_scene) {
      this.battle_scene.changeVisible(status); // this.battle_scene.setVisible(status)
    }
  },
  // 是否在战斗中
  getFightStatus: function getFightStatus() {
    return this.is_real_combat;
  },
  // 返回战斗场景
  getBattleScene: function getBattleScene() {
    return this.battle_scene;
  },
  // 是否在真战斗中
  isInRealBattle: function isInRealBattle() {
    return this.is_real_combat;
  },
 
  /**
   * 创建战斗场景,这里是唯一的入口,这里需要判断真假战斗切换,等
   * @param {*} in_fight_type 0:没有战斗 1:假战斗 2:真战斗
   */
  createBattleScene: function createBattleScene(in_fight_type, combat_type) {
    // 不同类的战斗或者不同类的战斗状态类型,都清掉单位
    if (this.combat_type != combat_type || this.cur_fight_type != in_fight_type || in_fight_type == 1) {
      // 假战斗也移除掉单位重新创建吧
      this.clearRealRole();
      this.hook_model.clearRealRole();
    }
 
    this.combat_type = combat_type; // 储存当前战斗类型
 
    this.cur_fight_type = in_fight_type; // 保存当前之战斗状态类型
 
    this.is_real_combat = in_fight_type == BattleConst.Battle_In_Type.Real;
 
    if (this.battle_scene == null) {
      this.battle_scene = Utils.createClass("battle_scene");
    }
 
    this.battle_scene.updateBattleScene(this.is_real_combat); // 只有剧情战斗的时候才需要显示战斗ui
 
    var is_show = combat_type == BattleConst.Fight_Type.Darma;
    this.openDramaFightUI(is_show); // 只有真战斗才需要显示
 
    this.openFormViewUI(this.is_real_combat, combat_type);
    this.battle_controller.setIsNormaBattle(this.is_real_combat); // 这里把主城设置不可见
 
    require("mainscene_controller").getInstance().handleSceneStatus(false);
 
    this.is_clear = false;
  },
  // 剧情战斗的ui部分
  openDramaFightUI: function openDramaFightUI(status) {
    if (this.show_fight_ui_status == status && this.fight_ui_combat == this.is_real_combat) {
      return;
    }
 
    this.show_fight_ui_status = status;
    this.fight_ui_combat = this.is_real_combat;
 
    if (!status) {
      if (this.drama_fight_ui) {
        this.drama_fight_ui.hide();
        this.button_list_panel_time = gcore.SmartSocket.getTime();
      }
    } else {
      if (this.drama_fight_ui == null) {
        this.drama_fight_ui = Utils.createClass("battle_button_list_panel");
        var partner = ViewManager.getInstance().getSceneNode(SCENE_TAG.ui);
        this.drama_fight_ui.setParent(partner);
        this.drama_fight_ui.show(this.is_real_combat);
        this.drama_fight_ui.setZIndex(-2);
      } else {
        if (this.drama_fight_ui.is_onshow == false) {
          this.drama_fight_ui.show(this.is_real_combat);
        } else {
          this.drama_fight_ui.changeBattleStatus(this.is_real_combat);
        }
      }
 
      this.button_list_panel_time = 0;
    }
 
    this.battle_controller.setIsNormaBattle(this.is_real_combat);
    this.startCountDownToDelete();
  },
  // 真战斗中的阵型以及其他相关显示部分
  openFormViewUI: function openFormViewUI(status, combat_type) {
    if (!status) {
      if (this.form_fight_ui) {
        this.form_fight_ui.hide();
        this.form_panel_time = gcore.SmartSocket.getTime();
      }
    } else {
      if (this.form_fight_ui) {
        this.form_fight_ui.show(combat_type);
      } else {
        this.form_fight_ui = Utils.createClass("battle_form_panel");
        var partner = ViewManager.getInstance().getSceneNode(SCENE_TAG.ui);
        this.form_fight_ui.setAnchorPoint(0, 0);
        this.form_fight_ui.setPosition(-partner.width * 0.5, -partner.height * 0.5);
        this.form_fight_ui.setParent(partner);
        this.form_fight_ui.show(combat_type);
        this.form_fight_ui.setZIndex(-1);
      }
 
      this.form_panel_time = 0;
    }
 
    this.startCountDownToDelete();
  },
  // 关闭面板的倒计时
  startCountDownToDelete: function startCountDownToDelete() {
    if (this.form_panel_time == 0 && this.button_list_panel_time == 0) {
      if (this.close_panel_timer) {
        gcore.Timer.del(this.close_panel_timer);
        this.close_panel_timer = null;
      }
    } else {
      if (this.close_panel_timer == null) {
        this.close_panel_timer = gcore.Timer.set(function () {
          this.waitDeletePanel();
        }.bind(this), 1000, -1);
      }
    }
  },
  // 倒计时准备清楚面板
  waitDeletePanel: function waitDeletePanel() {
    if (this.form_panel_time == 0 && this.button_list_panel_time == 0) {
      this.startCountDownToDelete(); // 移除掉定时器
    } else {
      if (this.button_list_panel_time != 0) {
        var button_pass_time = gcore.SmartSocket.getTime() - this.button_list_panel_time;
 
        if (button_pass_time > 100) {
          if (this.drama_fight_ui) {
            this.drama_fight_ui.deleteMe();
            this.drama_fight_ui = null;
          }
 
          this.button_list_panel_time = 0;
        }
      }
 
      if (this.form_panel_time != 0) {
        var form_pass_time = gcore.SmartSocket.getTime() - this.form_panel_time;
 
        if (form_pass_time > 100) {
          if (this.form_fight_ui) {
            this.form_fight_ui.deleteMe();
            this.form_fight_ui = null;
          }
 
          this.form_panel_time = 0;
        }
      }
    }
  },
  // 引导需要
  getDramaFightUI: function getDramaFightUI() {
    if (this.drama_fight_ui) return this.drama_fight_ui.root_wnd;
    return null;
  },
 
  /**
   * 彻底移除一个战斗场景,比如说切换出战斗,或者非剧情战斗结束,这个结束
   */
  clearBattleScene: function clearBattleScene() {
    if (this.battle_scene && !this.is_clear) {
      // 先移除掉单位定时器
      var role_list = this.getAllBattleRoleList();
 
      for (var pos in role_list) {
        gcore.Timer.del("attackerActTimeout" + pos);
      }
 
      this.combat_type = BattleConst.Fight_Type.Nil;
      this.cur_fight_type = BattleConst.Battle_In_Type.Nil; // 移除掉战斗类型
 
      this.is_real_combat = false; // 战斗
      // 清楚掉场景单位
 
      this.clearRealRole();
      this.hook_model.clearRealRole(); // 假战斗模型资源
 
      this.battle_scene.deleteMe();
      this.battle_scene = null;
      this.openDramaFightUI(false);
      this.openFormViewUI(false); // 移除掉所有的战斗特效--,群攻类和子弹类
 
      this.cleanAllBattleEffect(); // 移除真实战斗场景的数据
 
      this.deleteCurBattleData(); // 这里切回主城音乐
 
      Utils.playMusic(AUDIO_TYPE.SCENE, "s_002", true);
      this.is_clear = true;
    }
  },
  // 清空所有的场景战斗特效
  cleanAllBattleEffect: function cleanAllBattleEffect() {
    // 回收掉场景特效资源
    for (var key in this.battle_effect_list) {
      var array = this.battle_effect_list[key];
 
      for (var index = 0; index < array.length; index++) {
        var element = array[index];
        element.deleEffect();
      }
    }
 
    this.battle_effect_list = {}; // 回收掉场景特效资源
 
    for (var key in this.battle_effect_pool) {
      var array = this.battle_effect_pool[key];
 
      for (var _index = 0; _index < array.length; _index++) {
        var _element = array[_index];
 
        _element.deleEffect();
      }
    }
 
    this.battle_effect_pool = {};
  },
 
  /**
   * 假战斗定帧移动地图处理,现在卸载gamestart 的update里面
   */
  mapMovescheduleUpdate: function mapMovescheduleUpdate() {
    if (this.battle_scene) {
      this.battle_scene.mapMovescheduleUpdate();
    }
  },
 
  /**
   * 切换战斗移动状态,比如真实剧情战斗切换到假战斗的时候,就需要开启地图移动
   * @param {*} status Bool
   */
  changeMoveMapStatus: function changeMoveMapStatus(status) {
    if (this.battle_scene) {
      this.battle_scene.changeMoveMapStatus(status);
    }
  },
 
  /**
   * 进入真实战斗时,是否需要播放进场动作,中途切进去的不需要处理,这个值针对初始化单位的时候需要,战斗创建一个单位不需要
   */
  needPlayEnterAction: function needPlayEnterAction() {
    return this.init_fight_status;
  },
 
  /**
   * 真实战斗中的单位是否是友方判断
   * @param {*} group BattleRoleData.group
   */
  isFriend: function isFriend(group) {
    return group == this.my_group;
  },
 
  /**
   * 当前真实战斗的初始化数据
   */
  getCurBattleData: function getCurBattleData() {
    return this.battle_data;
  },
  // 获取当前战斗类型
  getCombatType: function getCombatType() {
    return this.combat_type;
  },
 
  /**
   * 退出战斗,清空战斗数据,针对真实战斗
   */
  deleteCurBattleData: function deleteCurBattleData() {
    this.resetInitData();
  },
  // 判断是否可以改变战斗速度
  checkIsCanChangeBattleSpeed: function checkIsCanChangeBattleSpeed() {
    if (this.battle_data == null) {
      return false;
    }
 
    var next_speed = 1;
 
    if (this.battle_speed == 1) {
      next_speed = 2;
    }
 
    var speed_config = Config.combat_type_data.data_combat_speed[next_speed];
 
    if (speed_config == null) {
      return false;
    }
 
    var role_vo = require("role_controller").getInstance().getRoleVo();
 
    if (role_vo == null) {
      return false;
    }
 
    if (speed_config.limit_lev > role_vo.lev && speed_config.limit_vip_lev > role_vo.vip_lev) {
      var desc = cc.js.formatStr(Utils.TI18N("等级达到%s级或VIP%s开启"), speed_config.limit_lev, speed_config.limit_vip_lev);
      message(desc);
      return false;
    }
 
    var fight_config = Config.combat_type_data.data_fight_list[this.battle_data.combat_type];
 
    if (fight_config == null) {
      return false;
    }
 
    if (fight_config.is_pvp == 1) {
      message(cc.js.formatStr(Utils.TI18N("%s不能更改速度"), fight_config.desc));
      return false;
    }
 
    return true;
  },
 
  /**
   * 修改一下当前战斗速度
   */
  changeSpeed: function changeSpeed() {
    if (this.battle_speed == 1) {
      this.saveSpeed(2);
      this.battle_controller.csFightSpeed(2);
    } else {
      this.saveSpeed(1);
      this.battle_controller.csFightSpeed(1);
    }
  },
 
  /**
   * 当前战斗速度
   */
  getTimeScale: function getTimeScale() {
    var time_scale = 1;
 
    if (this.isInRealBattle() == true) {
      time_scale = this.role_time_scale;
    } // time_scale = 1.5
    // 要根据当前帧频调整播放速度
 
 
    return time_scale;
  },
  // 设置当前动作速度
  setBattleTimeScale: function setBattleTimeScale(is_reset) {
    if (this.battle_time_status == is_reset) return;
    this.battle_time_status = is_reset;
    var base_config = null;
 
    if (is_reset == true) {
      // 这个时候是1倍速
      base_config = Config.battle_act_data.data_get_act_data.base_speed_scale;
    } else {
      base_config = Config.battle_act_data.data_get_act_data.speed_scale;
    }
 
    if (base_config) {
      this.role_time_scale = base_config.val * 0.01;
    }
 
    this.setRoleTimeScale();
  },
  // 保存速率之后马上设置模型动作
  setRoleTimeScale: function setRoleTimeScale() {
    if (this.real_role_list) {
      for (var key in this.real_role_list) {
        var object = this.real_role_list[key];
 
        if (object) {
          object.setTimeScale(this.role_time_scale);
        }
      }
    } // 设置场景特效
 
 
    if (this.battle_effect_list) {
      for (var key in this.battle_effect_list) {
        var array = this.battle_effect_list[key];
 
        for (var index = 0; index < array.length; index++) {
          var element = array[index];
 
          if (element) {
            element.setTimeScale(this.role_time_scale);
          }
        }
      }
    }
  },
  // 保存当前战斗速度,这个速度只是为了改变显示
  saveSpeed: function saveSpeed(speed) {
    if (this.battle_speed == speed) return;
    this.battle_speed = speed;
 
    if (this.form_fight_ui) {
      this.form_fight_ui.setSpeed(speed);
    }
  },
  // 获取当前速度
  getSpeed: function getSpeed() {
    return this.battle_speed;
  },
 
  /**
   * 一个回合播报的动作计数,最后保证值为0就表示播完了当前动作
   * @param {*} attacker 
   */
  actStart: function actStart(attacker) {
    // 如果结算面板已经出来了,就不需要播报了
    if (this.checkoutIsRightFight(attacker) == true) {
      attacker.wait_act += 1;
      gcore.Timer.del("attackerActTimeout" + attacker.pos);
      gcore.Timer.set(function () {
        this.actTimeout(attacker);
      }.bind(this), 3000, 1, "attackerActTimeout" + attacker.pos);
    }
  },
 
  /**
   * 某一个动作播放完成之后,计数 -1,当为0的时候,就表示当前小回合播报结束
   * @param {*} attacker 
   */
  actFinish: function actFinish(attacker) {
    if (this.checkoutIsRightFight(attacker) == true) {
      if (attacker.wait_act > 0) {
        attacker.wait_act -= 1;
 
        if (attacker.wait_act <= 0) {
          if (attacker.is_real) {
            this.playOrder(attacker);
            gcore.Timer.del("attackerActTimeout" + attacker.pos);
          } else {
            this.hook_model.playOrder(attacker);
          }
        }
      }
    }
  },
 
  /**
  * 判断是都是正式战斗
  *
  */
  checkoutIsRightFight: function checkoutIsRightFight(attacker) {
    if (attacker.is_real == true) {
      if (this.battle_data && this.cur_round_data && this.battle_data.combat_type == this.cur_round_data.combat_type) {
        return true;
      }
    } else {
      var battle_data = this.hook_model.getUnrealBattleData();
 
      if (battle_data && battle_data.combat_type == BattleConst.Fight_Type.Darma) {
        return true;
      }
    }
 
    return false;
  },
 
  /**
   * 小回合播报超时处理
   * @param {*} attacker 
   */
  actTimeout: function actTimeout(attacker) {
    if (attacker == null) return;
    attacker.wait_act = 1;
    this.actFinish(attacker);
  },
 
  /**
   * 回合开始的播报,包括站位的初始化等,因为有一些是需要在回合开始的时候播放的播报  包含回合开始的buff
   * @param {*} data 协议 20002 的数据
   */
  playRoundStart: function playRoundStart(data) {
    if (this.getBattleScene() == null || this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
      return;
    }
 
    this.is_play_round_start = true; // 处理回合buff
 
    this.dealRoundBuff(data.round_buff); // 处理神器的回合进度
 
    if (data && data.hallows_list) {
      for (var index = 0; index < data.hallows_list.length; index++) {
        var element = data.hallows_list[index];
 
        if (element) {
          var hallows = this.hallows_list[element.group];
 
          if (hallows && hallows.pos) {
            var role = this.real_role_list[hallows.pos];
 
            if (role) {
              role.setHallowsRound(element.val);
            }
          }
        }
      }
    } // 回合开始也处理掉那些假死的模型
 
 
    if (data && data.all_alive) {
      var temp_list = {};
 
      for (var _index2 = 0; _index2 < data.all_alive.length; _index2++) {
        var _element2 = data.all_alive[_index2];
 
        if (_element2) {
          temp_list[_element2.pos] = true;
        }
      }
 
      for (var key in this.real_role_list) {
        if (!temp_list[key]) {
          var role = this.real_role_list[key];
 
          if (role && !role.is_die && role.role_data && role.role_data.object_type != BattleConst.Unit_Type.Hallows) {
            role.doDied();
          }
        }
      }
    } // 没有技能播报列表,直接通知服务端结束
 
 
    if (data == null || data.skill_plays.length == 0) {
      this.battle_controller.csRoundFightEnd(); // 初始化位置层级等相关信息
 
      this.handlePlayRoundStart(data);
    } else {
      this.addRoundData(data);
    }
 
    if (this.form_fight_ui) {
      this.form_fight_ui.updateRound(data.action_count);
    }
  },
 
  /**
   * 正常回合播报,回合开始播报结束之后,进入正常回合播报 包含回合结束buff和效果播报的buff
   * @param {*} data 协议 20004 的数据
   */
  playRoundIn: function playRoundIn(data) {
    this.is_play_round_start = false; // 回合结束后的buff可能需要处理的
 
    if (data.round_buff && data.round_buff.length > 0) {
      this.act_after_buff_list = data.round_buff;
    } else {
      this.act_after_buff_list = null;
    }
 
    this.addRoundData(data);
  },
  // 更新buff
  setBuffsList: function setBuffsList(data) {
    this.buffs = data;
  },
 
  /**
   * 更新下一波怪物的数据
   * @param {*} data 
   */
  upDateNextMon: function upDateNextMon(data) {
    if (this.real_role_list == null || data == null) return; // 清掉上一回合的死亡对象
 
    for (var key in this.real_role_list) {
      var role = this.real_role_list[key];
 
      if (role && role.is_die == true) {
        role.deleteRole();
        this.real_role_list[key] = null;
      }
    }
 
    this.setBuffsList(data.buffs);
 
    if (this.getBattleScene()) {
      for (var index = 0; index < data.objects.length; index++) {
        var element = data.objects[index];
        var role = this.real_role_list[element.pos];
 
        if (this.isFriend(element.group) && role) {
          role.updataNextBattleRole(element);
        } else {
          this.createRole(element, true, null, true);
        }
      }
    } // 更新战斗基本数据
 
 
    if (this.battle_data) {
      this.battle_data.updateData(data);
 
      if (this.form_fight_ui) {
        this.form_fight_ui.updateBaseInfo();
      }
    }
  },
 
  /**addReConnectReadySum
   * 
   * 处理回合开始的数据
   * @param {*} data 协议 20002 的数据
   */
  handlePlayRoundStart: function handlePlayRoundStart(data) {
    if (this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
      return;
    }
 
    if (this.battle_scene == null) {
      return;
    }
 
    this.resetBattleRoleBaseInfo();
  },
  // 处理回合buff
  dealRoundBuff: function dealRoundBuff(buff_list, attacker) {
    if (buff_list == null || buff_list.length == 0) return;
 
    for (var index = 0; index < buff_list.length; index++) {
      var element = buff_list[index];
      var battle_role = this.real_role_list[element.target];
      var buff_config = Config.skill_data.data_get_buff[element.buff_bid];
 
      if (battle_role && buff_config) {
        this.playRoundBuff(battle_role, element, attacker);
      }
    }
  },
 
  /**
   * 回合中的播报,这个是播报的主入口
   * @param {*} data 协议 20004 的数据 
   */
  addRoundData: function addRoundData(data) {
    if (this.getBattleScene() == null || this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
      return;
    } // 更新当前回合数
 
 
    if (this.form_fight_ui && data.action_count) {
      this.form_fight_ui.updateRound(data.action_count);
    } // 播报数据
 
 
    this.cur_round = null;
    this.next_round = null;
    this.cur_round_data = data;
    this.skill_plays_order_list = [];
    this.round_data_temp = {};
 
    if (this.form_fight_ui) {
      this.form_fight_ui.updateRound(data.action_count);
    } // 技能播报数据, 解析技能数据
 
 
    for (var j = 0; j < data.skill_plays.length; j++) {
      var skill_element = data.skill_plays[j];
 
      for (var i = 0; i < skill_element.effect_play.length; i++) {
        var effect_element = skill_element.effect_play[i];
 
        if (this.round_data_temp[skill_element.order] == null) {
          this.round_data_temp[skill_element.order] = [];
          this.skill_plays_order_list.push({
            skill_order: skill_element.order,
            priority: skill_element.order * 1000 + j
          });
        }
 
        effect_element.skill_bid = effect_element.skill_bid_of_effect;
        effect_element.talk_pos = skill_element.talk_pos;
        effect_element.talk_content = skill_element.talk_content;
        effect_element.index = i;
        effect_element.skill_order = skill_element.order;
        effect_element.priority = effect_element.order * 10000 + j * 100 + i;
        this.round_data_temp[skill_element.order].push(effect_element);
      }
    } // 对出手进行排序
 
 
    this.skill_plays_order_list.sort(function (a, b) {
      return a.priority - b.priority;
    }); // cc.log("HHHHHHHHHHHHHHHHHHHHH");
    // cc.log(this.skill_plays_order_list);
 
    this.preloadBattleRes(data, function () {
      this.analyseTempRoundData();
    }.bind(this));
  },
  // 分析当前播报数据
  analyseTempRoundData: function analyseTempRoundData() {
    this.order_list = [];
    this.round_data = {};
 
    if (Object.keys(this.round_data_temp).length > 0) {
      for (var index = 0; index < this.skill_plays_order_list.length; index++) {
        var element = this.skill_plays_order_list[index];
        var temp = this.round_data_temp[element.skill_order];
 
        for (var i = 0; i < temp.length; i++) {
          var one_temp = temp[i];
 
          if (this.round_data[one_temp.order] == null) {
            this.round_data[one_temp.order] = {};
            this.order_list.push({
              order: one_temp.order,
              priority: one_temp.priority
            });
          }
 
          if (this.round_data[one_temp.order][one_temp.actor] == null) {
            this.round_data[one_temp.order][one_temp.actor] = {
              order: one_temp.order,
              actor: one_temp.actor,
              skill_bid: one_temp.skill_bid,
              talk_content: one_temp.talk_content,
              talk_pos: one_temp.talk_pos,
              index: one_temp.index,
              target_list: []
            };
          }
 
          var object = this.round_data[one_temp.order][one_temp.actor];
          object.target_list.push(one_temp);
        }
      } // 对出售惊醒排序
 
 
      this.order_list.sort(function (a, b) {
        return a.priority - b.priority;
      });
      this.round_data_temp = {};
    } // cc.log("出售顺序HHHHH");
    // cc.log(Utils.deepCopy(this.order_list));
    // cc.log(Utils.deepCopy(this.round_data));
 
 
    this.round();
  },
  // 回合播报
  round: function round() {
    if (this.round_num && this.round_num > 0) return;
    this.round_num = 0;
    this.actor_sum = 0;
    this.actor_play_sum = 0;
    this.cur_round = null;
    this.next_round = null; // 回合播报之前重置掉所有单位受击状态
 
    if (this.battle_scene) {
      var role_list = this.getAllBattleRoleList();
 
      for (var key in role_list) {
        var role = role_list[key];
 
        if (role) {
          role.dmg_index = 0;
          role.dmg_aid_y_offset = 0;
          role.is_hurt_play = false;
          role.is_big_play = false;
        }
      }
    }
 
    if (this.order_list.length == 0) {
      this.cancleBlackScreen(); // 回合后的buff处理
 
      if (this.act_after_buff_list && this.act_after_buff_list.length > 0) {
        this.dealRoundBuff(this.act_after_buff_list);
        this.act_after_buff_list = null;
      } // 重置一些状态,可能是一些数值类的
 
 
      if (this.real_role_list) {
        for (var key in this.real_role_list) {
          var battle_role = this.real_role_list[key];
 
          if (battle_role) {
            battle_role.temp_skill_bid = 0;
          }
        }
      } // 通知服务端播报完成,区分回合开始和中间回合播报
 
 
      if (this.is_play_round_start == true) {
        this.battle_controller.csRoundFightEnd();
      } else {
        this.battle_controller.csSkillPlayEnd();
      } // 这个时候设置所有的单位初始状态
 
    } else {
      var first_data = this.order_list.shift();
      var round_data = this.round_data[first_data.order];
 
      if (this.order_list.length > 0) {
        var second_order = this.order_list[0].order;
        var second_data = this.round_data[second_order]; // 找到下一个回合播报,于当前回合播报做比较判断是不是多段攻击,从而在当前播报结束之后,是否需要重置
 
        for (var actor in second_data) {
          if (this.next_round == null) {
            this.next_round = second_data[actor];
            break;
          }
        }
      }
 
      this.round_num = Object.keys(round_data).length;
 
      for (var actor in round_data) {
        this.round_num -= 1;
        var round_one_temp = round_data[actor];
 
        if (this.cur_round == null) {
          this.cur_round = round_one_temp;
        }
 
        if (round_one_temp.target_list.length > 0) {
          var attacker = this.getBattleRoleByPos(round_one_temp.actor);
 
          if (attacker) {
            this.actor_sum = this.actor_sum + 1;
            this.initOrder(attacker, round_one_temp);
          } else {
            this.round();
          }
        } else {
          this.round();
        }
      }
    }
  },
  // 播放回合buff,可能是回合开始,效果播报结束,也可能是回合结束, 这个buff是协议数据来的
  playRoundBuff: function playRoundBuff(target, buff, attacker, effect_hit) {
    if (target == null || buff == null) return;
    this.addBuff(attacker, target, buff);
 
    if (buff.change_type == 1) {
      // 血量变化的时候
      this.battleRoleHPChange(target, buff.change_value, buff.is_dead, effect_hit, true);
    }
  },
  // buff类的气血上号
  battleRoleHPChange: function battleRoleHPChange(target, value, is_dead, effect_hit, is_buff, camp_restrain) {
    if (target == null) return;
    target.updateHP(value, is_dead, true, 0);
    this.mutiHurtNum(target, value, effect_hit, is_buff, camp_restrain);
  },
  // 初始化动作列表,准备开战了,初始化一些数据
  initOrder: function initOrder(attacker, one) {
    one.target_list.sort(function (a, b) {
      return a.priority - b.priority;
    }); // 这个后续再看看要不要动态设置层级
 
    if (this.cur_round && this.last_round_actor && this.cur_round.actor == this.last_round_actor) {} else {
      attacker.resetZOrder();
      attacker.targe_zorder = 9999;
    }
 
    var list = one.target_list;
    var col_target = list[0].target;
 
    if (col_target > GIRD_POS_OFFSET) {
      col_target = col_target - GIRD_POS_OFFSET;
    }
 
    var col = Pos_To_Col[col_target - 1];
    var target = this.getBattleRoleByPos(col_target);
 
    if (target) {
      target.resetZOrder();
      attacker.targe_zorder = target.getLocalZOrder();
    }
 
    attacker.col = col;
    attacker.is_round = false;
    attacker.attacker_info = one;
    attacker.skill_data = gdata('skill_data', 'data_get_skill', one.skill_bid);
    attacker.target_pos = attacker.grid_pos;
    attacker.play_order_index = one.target_list[0].effect_bid;
    this.calcTargetPos(attacker); // 如果没有效果id则不处理,所有播报驱动都是效果驱动
 
    if (attacker.play_order_index == null || attacker.play_order_index == 0) {
      this.actor_play_sum += 1;
      var effect_play = one.target_list[0];
 
      if (effect_play) {
        if (effect_play.sub_effect_play_list && effect_play.sub_effect_play_list.length > 0) {
          this.handleSubEffectPlaylist(effect_play, attacker);
        }
 
        this.dealRoundBuff(effect_play.buff_list, attacker);
      }
 
      this.round();
      return;
    }
 
    var effect_config = gdata('skill_data', 'data_get_effect', attacker.play_order_index);
 
    if (effect_config) {
      attacker.play_order = Utils.deepCopy(effect_config.action_list); // 动作列表
 
      attacker.shake_id = effect_config.shake_id; // 震屏ID
 
      attacker.effect_type = effect_config.effect_type; // 效果类型
 
      attacker.play_stand = effect_config.play_stand; // 是否收招
 
      attacker.anime_res = effect_config.anime_res; // 攻击动作资源
 
      attacker.split_hurt = effect_config.split_hurt;
      attacker.hit_action = effect_config.hit_action; // 受击处理
 
      attacker.effect_desc = effect_config.effect_desc; // 效果飘字
 
      attacker.is_must_die = effect_config.is_must_die; // 死亡的时候是否移除,这个主要是判断连击中的时候
 
      attacker.anime_user_atk = effect_config.anime_user_atk; // 攻击动作名
 
      attacker.attack_sound = effect_config.attack_sound; // 攻击音效
 
      attacker.ready_sound = effect_config.ready_sound; // 准备音效
 
      attacker.shout_trick = effect_config.shout_trick; // 喊招音效
 
      attacker.hit_sound = effect_config.hit_sound; // 受击音效
 
      attacker.hit_effect_list = Utils.deepCopy(this.getCurEffectList(effect_config.hit_effect_list)); // 记录打击特效列表
 
      attacker.area_effect_list = Utils.deepCopy(this.getCurEffectList(effect_config.area_effect_list)); // 记录范围人物特效
 
      attacker.act_effect_list = Utils.deepCopy(this.getCurEffectList(effect_config.act_effect_list)); // 记录出手点特效
 
      attacker.bact_effect_list = Utils.deepCopy(this.getCurEffectList(effect_config.bact_effect_list)); // 记录施法特效
 
      attacker.trc_effect_list = Utils.deepCopy(this.getCurEffectList(effect_config.trc_effect_list)); // 记录弹道特效
    } // 是否有群攻
 
 
    if (attacker.area_effect_list.length > 0) {
      attacker.attacker_info.is_calc = false;
      attacker.in_area_effect = true;
      attacker.area_hit_num = 1;
      attacker.area_hit_time = 0;
    } else {
      attacker.in_area_effect = false;
    }
 
    var start_attack = function () {
      this.playOrder(attacker);
    }.bind(this); // 主动技能和被动技能喊招处理
 
 
    var show_skill_nme = function () {
      var skill_type = attacker.skill_data.type;
 
      if (skill_type == BattleConst.Skill_Type.PASSIVE_SKILL && attacker.skill_data.passive_skill_show == 1) {
        this.playFontMessage(attacker, attacker.skill_data.name, null, null, null, null, null, function () {
          start_attack();
        }.bind(this));
      } else if (skill_type == BattleConst.Skill_Type.ACTIVE_SKILL) {
        if (this.form_fight_ui) {
          this.form_fight_ui.showActiveSkillName(attacker, function () {
            start_attack();
          });
        }
      } else {
        start_attack();
      }
    }.bind(this);
 
    if (attacker.skill_data == null) {
      this.talk(attacker, start_attack);
    } else {
      this.talk(attacker, show_skill_nme);
    }
 
    this.act_playing = true;
  },
 
  /**
   * 计算目标点
   * @param {*} attacker 
   * @param {*} object_list 
   */
  calcTargetPos: function calcTargetPos(attacker, object_list) {
    if (attacker == null || attacker.attacker_info == null) {
      return;
    }
 
    var target_list = attacker.attacker_info.target_list;
    var target = null;
 
    for (var index = 0; index < target_list.length; index++) {
      var element = target_list[index];
 
      if (object_list) {
        target = object_list[element.target];
      } else {
        target = this.getBattleRoleByPos(element.target);
      }
 
      if (target && target.obj_type != attacker.obj_type) {
        break;
      }
    }
 
    if (target) {
      attacker.target_pos = target.grid_pos;
      attacker.target_pos_base = target.grid_pos;
      attacker.target_name = target.role_data.object_name;
    }
  },
  // 效果列表
  getCurEffectList: function getCurEffectList(list) {
    var effect_list = [];
 
    for (var index = 0; index < list.length; index++) {
      var element = list[index];
      var effect_data = Config.skill_data.data_get_effect_data[element];
      effect_list.push(effect_data);
    }
 
    return effect_list;
  },
  // 单位喊话
  talk: function talk(attacker, callback) {
    var msg = attacker.attacker_info.talk_content || "";
    var actor = attacker.attacker_info.talk_pos;
 
    if (msg == "") {
      if (callback) {
        callback();
      }
 
      return;
    } // 然后播放气泡.....
 
 
    if (callback) {
      callback();
    }
  },
  // 获取播报动作
  singleAct: function singleAct(act_data, attacker) {
    if (act_data instanceof Array) {
      return this.mutiAct(act_data, attacker);
    } else {
      var act_config = Utils.deepCopy(Config.skill_data.data_get_act_data[act_data]);
 
      if (act_config) {
        var args = act_config.act_args;
        var funname = args[0];
 
        if (funname == null || this[funname] == null) {
          return;
        }
 
        if (this[funname] instanceof Function) {
          var params = args[1] || [];
          params.unshift(attacker);
          return this[funname].apply(this, params);
        } else {
          Log.info("动作错误,动作BID:" + act_data);
        }
      }
    }
  },
  // 获取多段播报动作
  mutiAct: function mutiAct(args, attacker) {
    var acts = [];
 
    for (var index = 0; index < args.length; index++) {
      var element = args[index];
      var act = this.singleAct(element, attacker);
      acts.push(act);
    }
 
    if (acts.length == 1) {
      return acts[0];
    } else {
      return cc.spawn.apply(null, acts);
    }
  },
 
  /**
   * 技能动作附带糊掉函数
   * @param {*} attacker 
   * @param {*} args 
   */
  callfun: function callfun(attacker, args) {
    var funname = "";
    var params = null;
 
    if (args instanceof Array) {
      funname = args[0];
      params = args[1] || [];
    } else {
      funname = args;
    }
 
    if (funname == "") {
      return;
    }
 
    if (this[funname] instanceof Function) {
      if (params == null) {
        params = [];
      }
 
      params.unshift(attacker);
      this[funname].apply(this, params);
    } else if (typeof funname == "number") {
      var act = this.singleAct(funname, attacker);
      attacker.runAction(act);
    }
  },
 
  /**
   * 普通近战攻击
   * @param {*} attack 
   * @param {*} delay_time 
   * @param {*} hit_fun 
   * @param {*} start_fun 攻击开始动作
   * @param {*} is_reverse 是否是移动到背面
   */
  attack: function attack(attacker, delay_time, hit_fun, start_fun, is_reverse) {
    if (attacker && attacker.anime_user_atk) {
      delay_time = delay_time || 0;
      is_reverse = is_reverse == 1;
 
      var start_callback = function () {
        this.callfun(attacker, start_fun);
      }.bind(this);
 
      var hit_callback = function () {
        this.callfun(attacker, hit_fun);
      }.bind(this);
 
      return this.skill_act.attack(attacker, delay_time, attacker.anime_user_atk, hit_callback, start_callback, is_reverse, null, attacker.anime_res);
    }
  },
 
  /**
   * 远程攻击子弹
   * @param {*} attacker 
   * @param {*} delay_time 
   * @param {*} move_time 
   * @param {*} is_back 
   * @param {*} funname 
   * @param {*} start_height 
   */
  flyItem: function flyItem(attacker, delay_time, move_time, is_back, funname, start_height) {
    if (this.checkIsInBattle(attacker) == false) {
      return;
    }
 
    var effect_list = attacker.trc_effect_list; // 这个效果可能有多个,这个时候主要取第一个吧
 
    if (effect_list == null || effect_list.length == 0) {
      Log.info("播放远程攻击效果失败,不存在远程的效果,效果id为:  " + attacker.play_order_index);
      this.actStart(attacker);
      return;
    }
 
    var effect_object = effect_list[0]; // 主要第一个
 
    var is_friend = attacker.is_friend; // 是否是友方
 
    var res_up = effect_object.res_up; //
 
    if (is_friend == true && effect_object.spec_res_up != "") {
      res_up = effect_object.spec_res_up;
    }
 
    var scale = effect_object.scale * 0.001;
    var x_fix = effect_object.x_fix * attacker.obj_type;
    var y_fix = effect_object.y_fix == 0 ? 50 : effect_object.y_fix;
    var anima_name = attacker.anime_user_atk || PlayerAction.action_2;
 
    var attack_func = function () {
      var target_list = attacker.attacker_info.target_list;
 
      if (target_list.length <= 1) {
        // 只有一个攻击对象的时候
        var target_pos = this.center_pos(attacker, y_fix);
        return this.item(attacker, delay_time, res_up, move_time, funname, start_height, target_pos, scale, effect_object.bid, x_fix, y_fix);
      } else {
        this.playSelfEffect();
        var act_list = []; // 动作列表
 
        var array = attacker.attacker_info.target_list;
 
        for (var index = 0; index < array.length; index++) {
          var element = array[index];
          var target = this.getBattleRoleByPos(element.target);
 
          if (target) {
            // 目标
            var target_pos = {
              x: target.scene_pos.x,
              y: target.scene_pos.y + y_fix
            };
 
            if (target.group != attacker.group) {
              var func = this.getItem(attacker, delay_time, res_up, move_time, "hurtOne", start_height, target_pos, scale, effect_object.bid, x_fix, y_fix);
              act_list.push(func);
            }
          }
        } // 关键数据
 
 
        var finish_func = cc.callFunc(function () {
          if (attacker.attacker_info.last_effect) {
            for (var _index3 = 0; _index3 < attacker.attacker_info.last_effect.length; _index3++) {
              var _element3 = attacker.attacker_info.last_effect[_index3];
 
              if (attacker.is_real) {
                this.playMagic(attacker, _element3);
              } else {
                this.hook_model.playMagic(attacker, _element3);
              }
            }
          }
        }.bind(this));
 
        if (act_list.length > 0) {
          var act_start = this.skill_act.normalStart(attacker);
          var act_finish = this.skill_act.normalFinish(attacker);
          var act = cc.sequence(act_start, cc.spawn.apply(null, act_list), act_finish);
          attacker.runAction(act);
        }
      }
    }.bind(this);
 
    return this.skill_act.attack(attacker, delay_time, anima_name, null, null, false, attack_func, attacker.anime_res);
  },
  // 渐隐掉的播报
  fadeOut: function fadeOut(attacker, delay_time, time) {
    time = time || 10;
    return this.skill_act.fadeOut(attacker, delay_time, time);
  },
  // 渐现出来
  fadeIn: function fadeIn(attacker, delay_time, time) {
    time = time || 1;
    return this.skill_act.fadeIn(attacker, delay_time, time);
  },
  // 处理友方特效
  playSelfEffect: function playSelfEffect(attacker) {
    if (attacker == null || attacker.attacker_info == null || attacker.attacker_info.target_list == null) return;
    var last_effect = [];
    var target = null;
 
    for (var index = 0; index < attacker.attacker_info.target_list.length; index++) {
      var element = attacker.attacker_info.target_list[index];
      target = this.getBattleRoleByPos(element.target);
 
      if (target && attacker.group == target.group) {
        last_effect.push(element);
      }
    }
 
    attacker.attacker_info.effect_play = last_effect;
    attacker.attacker_info.last_effect = last_effect;
  },
  // 回合播报结束设置施法者战力动作
  resetAttackerStandStatus: function resetAttackerStandStatus(attacker) {
    if (this.battle_scene == null || attacker == null) {
      return;
    }
 
    var next_round_actor = 0;
 
    if (this.next_round) {
      next_round_actor = this.next_round.actor;
    }
 
    if (this.cur_round) {
      this.last_round_actor = this.cur_round.actor;
    }
 
    if (next_round_actor == 0 || this.cur_round && this.cur_round.actor != next_round_actor) {
      this.skill_act.setAnimation(attacker, PlayerAction.battle_stand, true);
      this.cancleBlackScreen();
      attacker.resetZOrder();
    }
  },
 
  /**
   * 实例化远程子弹动作
   * @param {*} attacker 
   * @param {*} delay_time 
   * @param {*} effect_name 
   * @param {*} move_time 
   * @param {*} funname 
   * @param {*} start_height 
   * @param {*} target_pos 
   * @param {*} scale 
   * @param {*} bid 
   * @param {*} x_fix 
   * @param {*} y_fix 
   */
  item: function item(attacker, delay_time, effect_name, move_time, funname, start_height, target_pos, scale, bid, x_fix, y_fix) {
    if (attacker == null || this.battle_scene == null) {
      return;
    }
 
    start_height = (start_height || 0) * attacker.model_height * 0.01;
    move_time = move_time || 10;
 
    var hit_callback = function () {
      this.callfun(attacker, funname); // 这里暂时注释掉不知道有没有问题
      // if(attacker.attacker_info.target_list.length > 0){
      //     attacker.attacker_info.target_list.unshift();
      // }
    }.bind(this);
 
    if (!attacker.is_real) {
      hit_callback();
    } else {
      attacker.runAction(this.skill_act.flyItem(attacker, delay_time, effect_name, move_time, hit_callback, start_height, target_pos, scale, bid, x_fix, y_fix));
    }
  },
 
  /**
   * 获取移动动作
   * @param {*} attacker 
   * @param {*} delay_time 
   * @param {*} effect_name 
   * @param {*} move_time 
   * @param {*} funname 
   * @param {*} start_height 
   * @param {*} target_pos 
   * @param {*} scale 
   * @param {*} bid 
   * @param {*} x_fix 
   * @param {*} y_fix 
   */
  getItem: function getItem(attacker, delay_time, effect_name, move_time, funname, start_height, target_pos, scale, bid, x_fix, y_fix) {
    start_height = start_height || 60;
    move_time = move_time || 10;
 
    var hit_callback = function () {
      this.callfun(attacker, funname); // 这里暂时注释掉不知道有没有问题
      // if(attacker.attacker_info.target_list.length > 0){
      //     attacker.attacker_info.target_list.unshift();
      // }
    }.bind(this);
 
    var act = this.skill_act.flyItem(attacker, delay_time, effect_name, move_time, hit_callback, start_height, target_pos, scale, bid, x_fix, y_fix);
    return act;
  },
  // 播报,动作施法者
  playOrder: function playOrder(attacker) {
    if (attacker == null) return;
    if (attacker.wait_act && attacker.wait_act != 0) return; // 没有技能效果的时候,直接移除掉
 
    if (attacker.play_order_index == null || attacker.play_order_index == 0) return; // 每个动作的计数器,当一个动作开始之后开始计数,为0标识这个动作做完了
 
    attacker.wait_act = 0;
 
    if (attacker.play_order == null || attacker.play_order.length == 0) {
      this.actor_play_sum += 1;
 
      if (!attacker.is_die) {
        this.resetAttackerStandStatus(attacker);
      }
 
      if (!attacker.is_round) {
        this.act_playing = false;
 
        if (this.actor_play_sum >= this.actor_sum) {
          this.round();
        }
      }
    } else {
      var index = attacker.play_order.shift();
      var act = this.singleAct(index, attacker);
 
      if (act) {
        attacker.runAction(act);
      }
    }
  },
  // 处理群攻效果,比如说音效不要播太多
  batchPlayHurt: function batchPlayHurt(attacker) {
    if (attacker == null || attacker.attacker_info == null || attacker.attacker_info.target_list == null) {
      return;
    }
 
    var target_list = attacker.attacker_info.target_list;
 
    if (target_list.length == 0) {
      return;
    }
 
    var had_play = false; // 多个受击音效只需要播放一次
 
    for (var index = 0; index < target_list.length; index++) {
      var element = target_list[index];
 
      if (attacker.is_real) {
        var play_effect = false;
 
        if (element.hp_changed && element.hp_changed < 0 && had_play == false) {
          had_play = true;
          play_effect = true;
        }
 
        this.playMagic(attacker, element, play_effect);
      } else {
        this.hook_model.playMagic(attacker, element, play_effect);
      }
    }
  },
 
  /**
   * 播放普通战斗飘字
   * @param {*} target 战斗目标单位
   * @param {*} desc 当前文本
   * @param {*} parent 父节点,如果没有,则默认是战斗场景特效层1
   * @param {*} x x方向的偏移值
   * @param {*} y y方向的偏移值
   * @param {*} color 文字颜色
   * @param {*} outline 文字描边色
   */
  playFontMessage: function playFontMessage(target, desc, parent, x, y, color, outline, callback) {
    if (this.checkIsInBattle(target) == false) {
      return;
    }
 
    if (parent == null) {
      parent = this.battle_scene.getBattleEffectLayer(1); // 默认放在特效1层上面
    }
 
    x = x || 0;
    y = y || 0;
    var target_x = target.scene_pos.x + x;
    var target_y = target.scene_pos.y + y + target.model_height / 2;
 
    if (color == null) {
      color = 217;
    }
 
    if (outline == null) {
      outline = 218;
    } // 设置字体默认颜色
 
 
    var normal_node = this.getNormalFont();
    normal_node.setPosition(target_x, target_y);
    var font_node = normal_node.getChildByName("font_label");
    var hex = Config.color_data.data_color16[color];
    var _color = font_node.color;
 
    _color.fromHEX(hex);
 
    font_node.color = _color; // 设置描边颜色
 
    var out_hex = Config.color_data.data_color16[outline];
    var out_line = font_node.getComponent(cc.LabelOutline);
    var _color1 = out_line.color;
 
    _color1.fromHEX(out_hex);
 
    out_line.color = _color1; // 设置字体
 
    var label = font_node.getComponent(cc.Label);
    label.string = desc;
    parent.addChild(normal_node);
 
    if (target.buff_show_index == null) {
      target.buff_show_index = 0;
    }
 
    target.buff_show_index = target.buff_show_index + 1;
    var show = cc.show();
    var delay = cc.delayTime(0.3 * target.buff_show_index);
    var delay_over = cc.callFunc(function () {
      target.buff_show_index -= 1;
    }.bind(this));
    var scale_to_1 = cc.scaleTo(0.4, 1.2);
    var move_by_1 = cc.moveBy(0.4, 0, 50);
    var fade_in = cc.fadeIn(0.4);
    var scale_to_2 = cc.scaleTo(0.6, 0.9);
    var fade_out = cc.fadeOut(0.6);
    var move_by_2 = cc.moveBy(0.6, 0, 25);
    var hide = cc.hide();
    normal_node.runAction(cc.sequence(show, delay, delay_over, cc.spawn(scale_to_1, move_by_1, fade_in), cc.spawn(scale_to_2, fade_out, move_by_2), hide, cc.callFunc(function () {
      if (callback) {
        callback();
      }
 
      this.pushBackBattleFont(normal_node);
    }.bind(this))));
  },
 
  /**
   * 播放魔法特效
   * @param {*} attacker 
   * @param {*} effect_play 
   * @param {*} no_die 
   * @param {*} play_effect 
   */
  playMagic: function playMagic(attacker, effect_play, play_effect) {
    if (this.battle_scene == null) {
      return;
    }
 
    if (effect_play.target == null) {
      return;
    }
 
    if (attacker == null) {
      return;
    }
 
    if (effect_play.play_num != null && effect_play.play_num <= 0) {
      return;
    }
 
    if (effect_play.play_num == null && attacker.split_hurt) {
      effect_play.play_num = attacker.split_hurt || 1;
 
      if (effect_play.play_num > 1) {
        effect_play.avg_hp_changed = Math.ceil(effect_play.hp_changed / effect_play.play_num);
      }
    }
 
    effect_play.play_num = effect_play.play_num || 1;
    effect_play.play_num -= 1;
    var effect_hit = 1;
    var target = this.getBattleRoleByPos(effect_play.target);
 
    if (target) {
      if (effect_play.is_hit == 0 || effect_play.is_blind == 1) {
        // 闪躲或者未命中
        effect_hit = 0;
        var desc = Utils.TI18N("闪躲");
 
        if (effect_play.is_blind == 1) {
          desc = Utils.TI18N("未命中");
        }
 
        if (effect_play.is_dead == 0) {
          // 非死亡情况下才飘字
          this.playFontMessage(target, desc, null, null, null, 227, 228);
        }
      }
 
      var hp_changed = effect_play.avg_hp_changed || effect_play.hp_changed || 0;
      var dmg = Math.floor(hp_changed);
 
      if (effect_play.is_crit == 1) {
        // 暴击
        effect_hit = 2;
      }
 
      var is_dead = effect_play.is_dead;
 
      if (effect_play.play_num > 0) {
        // 多次伤害的话第一次不能死
        is_dead = 0;
      } // 处理召唤列表
 
 
      if (effect_play.summon_list.length > 0) {
        this.addRoleList(effect_play.summon_list, attacker);
      } // 处理子效果
 
 
      if (effect_play.sub_effect_play_list.length > 0) {
        this.handleSubEffectPlaylist(effect_play, attacker);
      } // 副本中需要的特殊处理
 
 
      this.handleExtendDungeon(effect_play); // 处理援护
 
      if (effect_play.aid_actor != 0) {
        this.handleAidActor(effect_play, attacker, effect_hit, target);
      } // 播放受击处理
 
 
      this.playBattleRoleHurt(attacker, target, dmg, play_effect); // 飘字处理
 
      if (attacker.effect_desc != "" && effect_play.is_hit != 0 && effect_play.play_num <= 0) {
        this.showbuffName(target, attacker.effect_desc, 229, 230, attacker.play_order_index);
      } // 把扣血放到最后,因为有死亡动作
 
 
      this.updateTargetHp(attacker, target, dmg, is_dead, effect_hit, effect_play); // 处理buff列表,非死亡的时候才处理,如果上面播报已经说死了,不需要处理buff了
 
      if (effect_play.play_num <= 0 && effect_play.buff_list.length > 0) {
        this.handleBufflist(attacker, effect_play.buff_list, 1);
      }
    }
  },
  // 播放受击处理
  playBattleRoleHurt: function playBattleRoleHurt(attacker, target, dmg, play_effect) {
    if (attacker == null || target == null) return;
    if (target.is_hurt_play == true) return;
    target.is_hurt_play = true;
 
    if (!target.is_big_play) {
      target.is_big_play = true;
      this.playHurtEffect(attacker, target);
    }
 
    if (attacker.pos != target.pos && dmg < 0 && attacker.group != target.group) {
      // 播放受击动作
      if (attacker.hit_action != "no-hurt") {
        this.skill_act.hurt(attacker, target, attacker.hit_action, play_effect);
      }
    }
  },
 
  /**
   * 更新血条处理
   * @param {*} attacker 
   * @param {*} target 
   * @param {*} dmg 
   * @param {*} is_die 
   * @param {*} effect_hit 1是是普通, 2是暴击
   * @param {*} is_yuanhu 
   * @param {*} is_normal 
   * @param {*} effect_play 
   */
  updateTargetHp: function updateTargetHp(attacker, target, dmg, is_die, effect_hit, effect_play) {
    if (target == null) return;
    if (attacker == null) return;
    if (dmg == 0) return;
    effect_hit = effect_hit || 1;
    this.mutiHurtNum(target, dmg, effect_hit, false, effect_play.camp_restrain); // 储存具体数据
 
    target.updateHP(dmg, is_die, false, attacker.is_must_die);
  },
 
  /**
   * 播放伤害飘血
   * @param {*} tatget 
   * @param {*} dmg 
   * @param {*} effect_hit 1是是普通, 2是暴击
   * @param {*} is_normal 
   * @param {*} is_buff 
   * @param {*} camp_restrain 
   */
  mutiHurtNum: function mutiHurtNum(target, dmg, effect_hit, is_buff, camp_restrain) {
    if (this.checkIsInBattle(target) == false || dmg == 0 || target.is_real == false) {
      return;
    } // 这个数值用于处理飘血高度的...放置叠加到一起
 
 
    if (target.dmg_index == null) {
      target.dmg_index = 0;
    }
 
    target.dmg_index += 1;
    this.skill_act.playDmgMessage(target, dmg, effect_hit, is_buff, camp_restrain);
  },
 
  /**
   * 处理buff效果
   * @param {*} attacker 
   * @param {*} list 
   * @param {*} effect_hit 是否是暴击
   */
  handleBufflist: function handleBufflist(attacker, list, effect_hit) {
    if (this.checkIsInBattle(attacker) == false) {
      return;
    }
 
    for (var index = 0; index < list.length; index++) {
      var buff = list[index];
      var target = this.getBattleRoleByPos(buff.target);
 
      if (target) {
        this.playRoundBuff(target, buff, attacker, effect_hit);
      }
    }
  },
 
  /**
   * 添加一个buf
   * @param {*} attacker buff的发起者.可能没有
   * @param {*} target 
   * @param {*} buff 
   */
  addBuff: function addBuff(attacker, target, buff) {
    if (target == null || buff == null) return;
    var buff_data = Config.skill_data.data_get_buff[buff.buff_bid];
    if (buff_data == null) return;
 
    if (buff_data.is_passive == 1) {
      this.playBuffEffect(attacker, target, buff, buff_data);
    }
 
    if (buff.action_type == 4) return;
 
    if (buff.action_type == 2) {
      this.removeBuff(target, buff, buff_data);
    } else {
      if (buff_data.is_passive == 1 || buff_data.group == 3211) {
        // 不可复活组的buff额外处理
        if (buff.action_type == 1 || buff.action_type == 3) {
          // 主处理新增或者是展示的buff
          if (buff_data.group != 3211) {
            if (buff_data.buff_spine && buff_data.buff_data != "") {
              // 存在变身的buff
              target.changeSpine(true, buff_data.buff_spine, PlayerAction.battle_stand);
            }
 
            if (buff_data.group == 3703) {
              // 隐身buff
              target.setOpacity(true, 155);
            }
          }
 
          if (buff.action_type == 1 && buff.remain_round != 0) {
            // 新增buff才处理,这里主要是开始增加血条下面的bufficon
            target.updateBuffList(buff, buff_data);
          }
        }
      }
    }
  },
  // 移除一个buff,包含移除一个对象的特效和移除一个buff图标
  removeBuff: function removeBuff(target, buff, buff_data) {
    if (this.getBattleScene() == null || target == null) return;
    if (buff == null || buff_data == null) return;
    var had_buff = target.hadBuff(buff.id);
 
    if (had_buff == true) {
      target.removeBuffList(buff.id); // 移除一个buff,并且包含移除buff图标
 
      if (buff_data.group == 3703) {
        // 隐身buff
        target.setOpacity(false);
      }
 
      if (buff_data.buff_spine && buff_data.buff_spine != "") {
        // 移除变身效果
        target.changeSpine(false);
      } // 如果是场景buff,则移除
 
 
      var effect_config = Config.skill_data.data_get_effect_data[buff_data.res];
 
      if (effect_config && effect_config.play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
        this.removeSceneBuffEffect(target.group, effect_config.bid);
      } // 移除buff存在的特效绑在自身上的
 
 
      if (effect_config) {
        this.removeBattleSpineEffect(target, effect_config);
      }
    }
  },
  // 添加一个场景buff特效
  addSceneBuffEffect: function addSceneBuffEffect(group, bid, effect_res, effect) {
    if (group == null || bid == null || effect_res == null || effect == null) return;
    var key = Utils.getNorKey(group, bid);
 
    if (this.scene_buff_effect_list[key] == null) {
      this.scene_buff_effect_list[key] = {};
    } // 如果存在的话,先丢到对象池里面去
 
 
    if (this.scene_buff_effect_list[key][effect_res]) {
      this.delBattleEffect(this.scene_buff_effect_list[key][effect_res]);
    }
 
    this.scene_buff_effect_list[key][effect_res] = effect;
  },
  // 移除一个场景buff特效
  removeSceneBuffEffect: function removeSceneBuffEffect(group, effect_bid) {
    if (group == null || effect_bid == null) {
      if (this.scene_buff_effect_list) {
        for (var key in this.scene_buff_effect_list) {
          for (var res in this.scene_buff_effect_list[key]) {
            var effect = this.scene_buff_effect_list[key][res];
            this.delBattleEffect(this.scene_buff_effect_list[key][effect]);
          }
        }
 
        this.scene_buff_effect_list = {};
      }
    } else {
      var key = Utils.getNorKey(group, effect_bid);
      var effect_list = this.scene_buff_effect_list[key];
 
      if (effect_list) {
        for (var key in effect_list) {
          this.delBattleEffect(effect_list[key]);
        }
      }
 
      this.scene_buff_effect_list[key] = null;
    }
  },
  // 移除一个绑在单位身上的buff特效,这里会根据特效配置去判断上下层特效资源
  removeBattleSpineEffect: function removeBattleSpineEffect(target, effect_config) {
    if (target == null || effect_config == null) return;
    var action_name = PlayerAction.action;
 
    if (effect_config.up_action_name != "") {
      action_name = effect_config.up_action_name;
    }
 
    target.delBattleEffect(effect_config.res_up, action_name); // 移除上层特效
 
    action_name = PlayerAction.action;
 
    if (effect_config.down_action_name != "") {
      action_name = effect_config.down_action_name;
    }
 
    target.delBattleEffect(effect_config.res_down, action_name); // 移除下层特效
  },
  // 播放buff效果,以及添加bufficon等
  playBuffEffect: function playBuffEffect(attacker, target, buff, buff_data) {
    if (buff == null || buff_data == null) return;
    var text_color = null;
    var outline_color = null;
 
    if (buff_data.client_desc != "") {
      if (buff.action_type == 1 || buff.action_type == 4) {
        // 增益
        if (buff_data.positive_or_negative == 1) {
          text_color = 221;
          outline_color = 222;
        } else if (buff_data.positive_or_negative == 2) {
          // 减益
          text_color = 223;
          outline_color = 224;
        } else if (buff_data.positive_or_negative == 3) {
          // 控制
          text_color = 225;
          outline_color = 226;
        }
 
        this.showbuffName(target, buff_data.client_desc, text_color, outline_color, buff.buff_bid);
      }
    }
 
    if (attacker == null) return;
    var hadbuff = target.hadBuff(buff.id);
 
    if (!hadbuff && buff.action_type == 1 && buff_data.res != 0) {
      // 不存在的buff才需要处理
      var config = Config.skill_data.data_get_effect_data[buff_data.res];
 
      if (config) {
        if (config.play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
          var key = Utils.getNorKey(target.group, buff_data.res);
 
          if (this.scene_buff_effect_list[key] == null || Utils.next(this.scene_buff_effect_list[key]) == false) {
            this.effectArea(attacker, [config.res_up, config.res_down], 0, null, config.play_type, config.x_fix, config.y_fix, buff_data.res, config.is_col_effect, false);
          }
        } else {
          this.effectSpineUser(attacker, buff_data.is_release == 1, config.x_fix * target.obj_type, config.y_fix, [config.res_up, config.res_down], target, 1, null, buff_data.bid, buff_data.res);
        }
      }
    } // 一次效果
 
 
    if (buff.action_type == 3 && buff_data.efftive_effect != 0) {
      var config = Config.skill_data.data_get_effect_data[buff_data.efftive_effect];
 
      if (config) {
        this.effectSpineUser(attacker, true, config.x_fix * target.obj_type, config.y_fix, [config.res_up, config.res_down], target, 1, null, buff_data.bid, buff_data.res);
      }
    }
  },
  // 播放buff描述文字,这里需要对这个对象做判断,如果bid的飘字存在,则不处理了...
  showbuffName: function showbuffName(target, desc, color, outline_color, bid) {
    if (target == null || bid == null) return;
    if (target.tips_list[bid]) return;
    target.addTips(bid);
 
    var callback = function () {
      target.removeTips(bid);
    }.bind(this);
 
    this.playFontMessage(target, desc, null, null, null, color, outline_color, callback);
  },
 
  /**
   * 添加召唤列表
   * @param {*} list 
   * @param {*} attacker 
   */
  addRoleList: function addRoleList(list, attacker) {
    if (list == null || list.length == 0) return;
  },
 
  /**
   * 处理子效果
   * @param {*} effect_play 
   * @param {*} attacker 
   */
  handleSubEffectPlaylist: function handleSubEffectPlaylist(effect_play, attacker) {
    if (effect_play == null || effect_play.sub_effect_play_list == null || effect_play.sub_effect_play_list.length == 0) return;
 
    for (var index = 0; index < effect_play.sub_effect_play_list.length; index++) {
      var element = effect_play.sub_effect_play_list[index];
      var sub_target = this.real_role_list[element.sub_target];
 
      if (sub_target) {
        // 播放气血变化的
        this.battleRoleHPChange(sub_target, element.sub_hp_changed, false, 1, true);
 
        if (element.extra_effect && element.extra_effect.length > 0) {
          for (var n = 0; n < element.extra_effect.length; n++) {
            var extra = element.extra_effect[n];
 
            if (extra.extra_key == 2) {
              // 护盾吸收
              this.skill_act.playBuffAbsorbHurt(sub_target, extra.extra_param);
            }
          }
        } // 技能效果是否飘字
 
 
        var effect_config = gdata('skill_data', 'data_get_effect', element.sub_effect_id);
 
        if (effect_config && effect_config.effect_desc != "" && element.sub_is_hit != 0) {
          this.showbuffName(sub_target, effect_config.effect_desc, 229, 230, element.sub_effect_id);
        } // 被动技能是否飘字
 
 
        var skill_config = gdata('skill_data', 'data_get_skill', element.sub_skill_id);
 
        if (skill_config && skill_config.passive_skill_show == 1) {
          this.showbuffName(sub_target, skill_config.name, 217, 218, element.sub_skill_id);
        } // 闪躲处理
 
 
        if (element.sub_is_hit == 0 && effect_play.is_dead == 0) {
          this.showbuffName(sub_target, Utils.TI18N("躲闪"), 227, 228, element.sub_effect_id);
        }
      }
    }
  },
 
  /**
   * 副本数据特殊处理
   * @param {*} effect_play 
   */
  handleExtendDungeon: function handleExtendDungeon(effect_play) {
    if (this.battle_data == null || this.battle_data.combat_type != BattleConst.Fight_Type.GuildDun) return;
 
    if (this.form_fight_ui) {
      this.form_fight_ui.addGuildBossUI(effect_play.total_hurt);
    }
  },
 
  /**
   * 处理援护
   * @param {*} effect_play 
   * @param {*} attacker 
   * @param {*} effect_hit 是否暴击
   * @param {*} target
   */
  handleAidActor: function handleAidActor(effect_play, attacker, effect_hit, target) {
    if (effect_play == null || effect_play.aid_actor == 0) return;
    var aid_target = this.real_role_list[effect_play.aid_actor];
 
    if (aid_target) {
      var aid_dmg = effect_play.actor_hp_changed; // 援护者血量变化
 
      var friend_pos = target.scene_pos; // 
 
      var role_width = target.model_width * target.obj_type;
      var camp_restrain = effect_play.camp_restrain; // 是否是阵营压制
 
      aid_target.setLocalZOrder(target.getLocalZOrder() + 1); // 层级放到上面来
 
      aid_target.setScenePos(cc.v2(friend_pos.x + role_width, friend_pos.y)); // 设置援护坐标
 
      this.actStart(attacker);
      this.skill_act.aid_hurt(attacker, aid_target, "hurt");
      this.battleRoleHPChange(aid_target, aid_dmg, effect_play.actor_is_dead, effect_hit, false, camp_restrain);
      this.playHurtEffect(attacker, aid_target);
    }
  },
 
  /**
   * 播放伤害特效
   * @param {*} attacker 
   * @param {*} target 
   */
  playHurtEffect: function playHurtEffect(attacker, target) {
    if (this.battle_scene == null || attacker == null || attacker.hit_effect_list == null || attacker.hit_effect_list.length == 0) {
      return;
    }
 
    var array = attacker.hit_effect_list;
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
      this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [element.res_up, element.res_down], target, element.scale * 0.001, null, element.bid);
    }
  },
 
  /**
   * 出手前动作
   * @param {*} attacker 
   */
  attackReady: function attackReady(attacker) {
    if (attacker == null) {
      return;
    }
 
    if (attacker.bact_effect_list == null || attacker.bact_effect_list.length == 0) {
      return;
    } // 播放出手前音效
 
 
    if (attacker.ready_sound && attacker.ready_sound != "" && attacker.is_real == true) {
      Utils.playEffectSound(AUDIO_TYPE.BATTLE, attacker.ready_sound);
    }
 
    var array = attacker.bact_effect_list;
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
 
      if (element && element.play_type == BattleConst.Effect_Play_Type.ROLE) {
        if (element.res_up != "" || element.res_down != "") {
          this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [element.res_up, element.res_down], attacker, element.scale * 0.001, null, element.bid);
        }
      }
    }
  },
 
  /**
   * 创建单位跟随特效
   * @param {*} attacker 
   * @param {*} is_release 
   * @param {*} x_fix 
   * @param {*} height 
   * @param {*} effect_list
   * @param {*} target 目标对象,也可能是自己,也可能是被攻击者 
   * @param {*} scale 
   * @param {*} callback 
   * @param {*} bid 
   * @param {*} buff_bid 如果这个值不为0,即最终值
   */
  effectSpineUser: function effectSpineUser(attacker, is_release, x_fix, height, effect_list, target, scale, callback, bid, buff_bid) {
    if (buff_bid && buff_bid != 0) {
      bid = buff_bid;
    }
 
    var obj_type = BattleConst.Battle_Type_Conf.TYPE_ROLE;
 
    if (attacker) {
      obj_type = attacker.obj_type;
    }
 
    this.skill_act.effectSpineUser(attacker, is_release, x_fix, height, effect_list, target, scale, callback, bid, obj_type);
  },
  // 群攻
  areaHurt: function areaHurt(attacker) {
    var hurt_func = function () {
      if (this.battle_scene) {
        var role_list = this.getAllBattleRoleList();
 
        for (var key in role_list) {
          var role = role_list[key];
 
          if (role) {
            role.is_hurt_play = false;
            role.is_big_play = false;
          }
        }
      }
 
      this.batchPlayHurt(attacker);
    }.bind(this);
 
    this.playSceneAreaEffect(attacker, hurt_func);
  },
  // 播放范围特效
  playSceneAreaEffect: function playSceneAreaEffect(attacker, callback) {
    if (attacker == null || attacker.play_order_index == null || attacker.area_effect_list == null || attacker.area_effect_list.length == 0) {
      return;
    }
 
    var array = attacker.area_effect_list;
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
 
      if (element && (element.res_down != "" || element.res_up != "")) {
        this.effectArea(attacker, [element.res_up, element.res_down], 0, callback, element.play_type, element.x_fix, element.y_fix, element.bid, element.is_col_effect);
      }
    }
  },
 
  /**
   * 播放范围特效
   * @param {*} attacker 
   * @param {*} effect_list
   * @param {*} height 
   * @param {*} is_reverse 
   * @param {*} hit_callback 
   * @param {*} play_type 
   * @param {*} x_fix 
   * @param {*} y_fix 
   * @param {*} bid 
   * @param {*} is_col_effect
   * @param {*} is_release 播完是否释放
   */
  effectArea: function effectArea(attacker, effect_list, height, hit_callback, play_type, x_fix, y_fix, bid, is_col_effect, is_release) {
    height = height || 0;
    var reverse = attacker.obj_type;
    var is_left = attacker.is_friend;
    var scene_pos = null;
 
    if (is_col_effect == 1) {
      var temp_list = null;
 
      if (is_left) {
        temp_list = [{
          x: 34,
          y: 17
        }, {
          x: 34,
          y: 23
        }, {
          x: 34,
          y: 29
        }];
      } else {
        temp_list = [{
          x: 44,
          y: 17
        }, {
          x: 44,
          y: 23
        }, {
          x: 44,
          y: 29
        }];
      }
 
      var pos = temp_list[attacker.col];
 
      if (pos) {
        var temp_pos = this.skill_act.gridPosToScreenPos(pos);
        scene_pos = {
          x: temp_pos.x + x_fix,
          y: temp_pos.y + y_fix
        };
      }
    } else {
      if (play_type == BattleConst.Effect_Play_Type.SCENE) {
        // 暂时看到是作废的
        scene_pos = {
          x: SCREEN_WIDTH * 0.5,
          y: SCREEN_HEIGHT * 0.5
        };
      } else if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE || play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
        x_fix = attacker.obj_type * x_fix;
 
        if (is_left) {
          if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
            //  友方阵型
            scene_pos = {
              x: SCREEN_WIDTH * 22 / 100 + x_fix,
              y: SCREEN_HEIGHT * 1 / 4 + y_fix
            };
          } else {
            // 敌方阵型
            scene_pos = {
              x: SCREEN_WIDTH * 78 / 100 + x_fix,
              y: SCREEN_HEIGHT * 1 / 4 + y_fix
            };
          }
        } else {
          if (play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
            scene_pos = {
              x: SCREEN_WIDTH * 22 / 100 + x_fix,
              y: SCREEN_HEIGHT * 1 / 4 + y_fix
            };
          } else {
            scene_pos = {
              x: SCREEN_WIDTH * 78 / 100 + x_fix,
              y: SCREEN_HEIGHT * 1 / 4 + y_fix
            };
          }
        }
      } else {
        scene_pos = this.center_pos(attacker);
      }
    }
 
    if (scene_pos) {
      scene_pos.y = scene_pos.y + height;
      this.skill_act.effectArea(attacker, effect_list, reverse, is_release, scene_pos, hit_callback, bid);
    }
  },
  // 获取施法者目标对象的中心位置
  center_pos: function center_pos(attacker, height_fix) {
    height_fix = height_fix || 0;
    var scene_pos = {
      x: 0,
      y: 0
    };
 
    if (this.battle_scene && attacker && attacker.attacker_info && attacker.attacker_info.target_list && attacker.attacker_info.target_list.length > 0) {
      var array = attacker.attacker_info.target_list;
 
      for (var index = 0; index < array.length; index++) {
        var element = array[index];
        var target = this.getBattleRoleByPos(element.target);
 
        if (target && target.scene_pos) {
          scene_pos.x = target.scene_pos.x;
          scene_pos.y = target.scene_pos.y + target.model_height * height_fix * 0.01; // 这个计算位置好奇葩..竟然不是直接用偏移高度去算..
 
          break;
        }
      }
    }
 
    return scene_pos;
  },
  // 播放攻击动作之类的
  actHurt: function actHurt(attacker, is_big) {
    if (attacker == null || attacker.attacker_info == null || attacker.attacker_info.target_list == null) return;
    var had_play = false;
 
    for (var index = 0; index < attacker.attacker_info.target_list.length; index++) {
      var effect_list = attacker.attacker_info.target_list[index];
      var play_effect = false;
 
      if (effect_list.hp_changed && effect_list.hp_changed < 0 && had_play == false) {
        had_play = true;
        play_effect = true;
      }
 
      this.playMagic2(attacker, effect_list, is_big, play_effect);
    }
  },
  // 提前播放受击特效,回播受击动作
  playMagic2: function playMagic2(attacker, effect_play, is_big, play_effect) {
    if (attacker == null || effect_play == null) return;
    var target = this.real_role_list[effect_play.target];
    if (target == null) return;
 
    if (is_big == true) {
      if (!target.is_big_play) {
        target.is_big_play = true;
        this.playHurtEffect(attacker, target);
      }
    } else {
      if (attacker.pos != target.pos && attacker.group != target.group) {
        this.skill_act.hurt(attacker, target, PlayerAction.hurt, play_effect);
      }
    }
  },
  // 攻击上层特效处理
  attackPoint: function attackPoint(attacker) {
    if (attacker && attacker.attack_sound != "" && attacker.is_real == true) {
      Utils.playEffectSound(AUDIO_TYPE.BATTLE, attacker.attack_sound);
    }
 
    if (attacker.act_effect_list == null || attacker.act_effect_list.length == 0) {
      return;
    }
 
    var is_friend = attacker.is_friend;
    var array = attacker.act_effect_list;
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
      var anime_res_up = element.res_up;
 
      if (element.spec_res_up != "" && is_friend == true) {
        anime_res_up = element.spec_res_up;
      }
 
      if (anime_res_up != "" || element.res_down != "") {
        this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [anime_res_up, element.res_down], attacker, element.scale * 0.001, null, element.bid);
      }
    }
  },
 
  /**
   * 处理普通伤害
   * @param {*} attacker 
   * @param {*} role_list 
   */
  hurt: function hurt(attacker, object_list) {
    if (this.battle_scene == null || attacker == null) {
      return;
    }
 
    if (attacker.area_effect_list.length == 0) {
      var hit_num = !attacker.in_area_effect ? attacker.hit_num : attacker.area_hit_num || 1;
      var split_hurt = attacker.split_hurt || 1;
 
      if (hit_num == 1 || split_hurt > 1) {} else {
        var role_list = object_list || this.getAllBattleRoleList();
 
        for (var key in role_list) {
          var role = role_list[key];
 
          if (role) {
            role.is_hurt_play = false;
            role.is_big_play = false;
          }
        }
      }
 
      this.batchPlayHurt(attacker);
    }
  },
 
  /**
   * 伤害一个人的时候
   * @param {*} attacker 
   */
  hurtOne: function hurtOne(attacker) {
    if (this.checkIsInBattle(attacker) == false) {
      return;
    }
 
    var effect_play_num = attacker.attacker_info.target_list.length;
 
    if (effect_play_num > 0) {
      if (attacker.is_real) {
        this.playMagic(attacker, attacker.attacker_info.target_list[0]);
      } else {
        this.hook_model.playMagic(attacker, attacker.attacker_info.target_list[0]);
      }
    }
  },
  // 隐藏血条
  hideUI: function hideUI(attacker, delay_time) {
    if (attacker) {
      return this.skill_act.hideUI(attacker, delay_time);
    }
  },
  // 无动作并行攻击
  noActAttack: function noActAttack(attacker, delay_time, hit_fun, start_fun, next_delay_time) {
    if (!this.getBattleScene()) return;
    if (!attacker) return;
 
    var start_callback = function () {
      this.callfun(attacker, start_fun);
    }.bind(this);
 
    var hit_callback = function () {
      this.callfun(attacker, hit_fun);
    }.bind(this);
 
    return this.skill_act.noActAttack(attacker, delay_time, hit_callback, start_callback, next_delay_time);
  },
  // 显示血条
  showUI: function showUI(attacker, delay_time) {
    if (attacker) {
      return this.skill_act.showUI(attacker, delay_time);
    }
  },
  // 判断是否存在反击buff
  getBuffTag: function getBuffTag(attacker) {
    if (attacker == null || attacker.buff_list == null || attacker.buff_list.length == null) {
      return false;
    }
 
    var array = attacker.buff_list;
 
    for (var index = 0; index < array.length; index++) {
      var element = array[index];
      var config = Config.skill_data.data_get_buff[element.bid];
 
      if (config && config.group == 3108) {
        return true;
      }
    }
 
    return false;
  },
  // 近战移动归位
  moveBack: function moveBack(attacker, delay_time, move_time, grid_pos_x, action_name, is_jump, is_jump_delay, is_get_point, is_move, is_reverse) {
    if (!this.getBattleScene()) return;
    if (!attacker) return;
    var target_pos = attacker.scene_pos;
    var skill_act = this.skill_act.move(attacker, target_pos, delay_time, move_time);
    attacker.runAction(skill_act);
  },
  // 移动到指定区域
  moveToArea: function moveToArea(attacker, config) {
    if (!this.getBattleScene()) return;
    if (!attacker) return;
    if (!config) return;
    var grid_pos_x = config.move_model_x * this.skill_act.gridSizeX();
    var grid_pos_y = config.move_model_y * this.skill_act.gridSizeY();
    var target_pos = {
      x: SCREEN_WIDTH * 32 / 64 + grid_pos_x * attacker.obj_type,
      y: SCREEN_HEIGHT * 11 / 36 + grid_pos_y
    };
    var skill_act = this.skill_act.move(attacker, target_pos, config.move_delay_time, config.move_time);
    attacker.runAction(skill_act);
  },
  // act_args={ [[moveTo]],{ 0, 10,- 7, 0, [[run]], 0, 0, 0, 1, 1}}},
  // 移动到目标处
  moveTo: function moveTo(attacker, delay_time, move_time, grid_pos_x, grid_pos_y, action_name, is_jump, is_jump_delay, is_get_point, is_move, is_reverse, is_col_act) {
    if (!this.getBattleScene()) return;
    if (!attacker) return;
    move_time = move_time || 30;
 
    if (grid_pos_x == null) {
      grid_pos_x = 0;
    }
 
    if (grid_pos_y == null) {
      grid_pos_y = 0;
    }
 
    var direct = is_reverse == 1 ? -1 : 1;
    var target_pos = null;
    var scene_pos = attacker.scene_pos;
 
    if (is_col_act == 1) {
      var is_left = attacker.is_friend; // 是否是己方,己方就是在左边
 
      var temp_list = null;
 
      if (is_left) {
        temp_list = [{
          x: 34,
          y: 17
        }, {
          x: 34,
          y: 23
        }, {
          x: 34,
          y: 29
        }];
      } else {
        temp_list = [{
          x: 44,
          y: 17
        }, {
          x: 44,
          y: 23
        }, {
          x: 44,
          y: 29
        }];
      }
 
      var pos = temp_list[attacker.col];
 
      if (pos) {
        var temp_pos = this.skill_act.gridPosToScreenPos(pos);
        target_pos = {
          x: temp_pos.x + grid_pos_x,
          y: temp_pos.y + grid_pos_y
        };
      }
    } else if (grid_pos_x > 0) {
      target_pos = {
        x: scene_pos.x + grid_pos_x * attacker.obj_type * direct,
        y: scene_pos.y + grid_pos_y
      };
    } else {
      if (is_reverse == 1 && attacker.target_pos_base) {
        // 反转
        target_pos = this.skill_act.gridPosToScreenPos({
          x: attacker.target_pos_base.x + grid_pos_x * attacker.obj_type * direct,
          y: attacker.target_pos_base.y + grid_pos_y * attacker.obj_type * direct
        });
      } else {
        target_pos = this.skill_act.gridPosToScreenPos({
          x: attacker.target_pos.x + grid_pos_x * attacker.obj_type * direct,
          y: attacker.target_pos.y + grid_pos_y
        });
      }
    }
 
    if (is_get_point == null || is_get_point == 0) {
      var skill_act = this.skill_act.move(attacker, target_pos, delay_time, move_time);
      attacker.runAction(skill_act);
    } else {
      return this.skill_act.move(attacker, target_pos, delay_time, move_time);
    }
  },
  // 一些播报判断
  checkIsInBattle: function checkIsInBattle(attacker) {
    if (this.battle_scene == null || attacker == null) {
      return false;
    }
 
    return true;
  },
  // -------------------------------创景单位这一块,真是战斗单位
  createRoleList: function createRoleList() {
    var battle_data = this.battle_data;
    var need_enter = this.needPlayEnterAction();
 
    for (var key in battle_data.fight_object_list) {
      var role_data = battle_data.fight_object_list[key];
      this.createRole(role_data, need_enter, true, true);
    }
  },
  // 创建具体单位
  createRole: function createRole(role_data, enter_run, talk_back, is_real) {
    if (this.battle_scene == null) return;
    if (role_data == null || role_data.hp == 0) return;
    var role_layer = this.battle_scene.getBattleRoleLayer();
    if (role_layer == null) return;
    if (this.real_role_list[role_data.pos] != null) return;
    var role = Utils.createClass("battle_role");
    role.createRole(role_layer, role_data, enter_run, talk_back, is_real);
    this.real_role_list[role_data.pos] = role;
  },
  // 重置战斗单位初始化信息,比如位置层级和动作状态
  resetBattleRoleBaseInfo: function resetBattleRoleBaseInfo() {
    for (var key in this.real_role_list) {
      var battle_role = this.real_role_list[key];
 
      if (battle_role) {
        battle_role.resetBaseInfo();
      }
    }
  },
  // 清楚掉单位
  clearRealRole: function clearRealRole() {
    if (Object.keys(this.real_role_list).length == 0) {
      return;
    }
 
    for (var key in this.real_role_list) {
      // 清楚掉定时器
      gcore.Timer.del("attackerActTimeout" + key);
      var battle_role = this.real_role_list[key];
 
      if (battle_role) {
        battle_role.deleteRole();
        battle_role = null;
      }
    }
 
    this.real_role_list = {};
  },
  // 当前所有单位
  getAllBattleRoleList: function getAllBattleRoleList() {
    return this.real_role_list;
  },
  // 指定单位上的对象
  getBattleRoleByPos: function getBattleRoleByPos(pos) {
    if (this.real_role_list[pos]) {
      return this.real_role_list[pos];
    }
  },
  // 魅魔技能黑屏,暂时也没配置了
  blackScreen: function blackScreen(attacker) {},
  // 只显示攻击于被攻击放,暂时都没有配置
  blackScreen2: function blackScreen2(attacker) {},
  // 黑屏------后续一律使用这个黑屏
  blackScreen3: function blackScreen3(attacker, delay_time, time, alpha) {
    if (time == null) {
      time = 15;
    }
 
    var begin_fun = function () {
      if (this.battle_scene) {
        this.battle_scene.setBlack(true, alpha);
      }
 
      this.is_black = true;
    }.bind(this);
 
    var end_fun = function () {}.bind(this);
 
    return this.skill_act.blackScreen(attacker, delay_time, time, begin_fun, end_fun);
  },
  // 取消黑屏
  cancleBlackScreen: function cancleBlackScreen() {
    this.is_black = false;
 
    if (this.battle_scene) {
      this.battle_scene.setBlack(false);
    }
  },
  // 震屏
  playShakeScreen: function playShakeScreen(shake_id) {
    if (shake_id == null || shake_id == 0) return;
 
    if (this.battle_scene) {
      this.battle_scene.shakeScreen(shake_id);
    }
  },
  // 隐身,暂时没有配置了
  hide: function hide(attacker) {},
  // 显示,暂时也没有配置了
  show: function show(attacker) {},
  // 残影,也是没有配置了
  shadow: function shadow(attacker) {},
  // 返回主界面控制器
  getMainUICtrl: function getMainUICtrl() {
    if (this.mainui_ctrl == null) {
      this.mainui_ctrl = require("mainui_controller").getInstance();
    }
 
    return this.mainui_ctrl;
  },
  // -------------------------战斗结束
  //结算界面
  showWin: function showWin(data, is_replay) {
    if (data.show_panel_type == null || data.combat_type == null) return;
 
    if (data.show_panel_type == 1) {
      // 显示战斗结算界面,这个时候不要立即清除掉,
      if (data.combat_type == this.combat_type && this.battle_controller.getWatchReplayStatus() || is_replay == true) {} // 这个时候都需要显示结算界面
 
 
      this.setBattleTimeScale(true);
      this.showWinView(data);
    } else {
      if (data.combat_type == this.combat_type) {
        // 
        if (is_replay == true) {
          this.clearView();
        } else {
          this.clearBattleScene();
          gcore.GlobalEvent.fire(EventId.EXIT_FIGHT, data.combat_type);
        }
      }
    }
  },
  //游戏退出结算
  showWinView: function showWinView(data) {
    if (data == null) return;
    this.battle_controller.openFinishView(true, data.combat_type, data);
  },
  //战斗结果
  result: function result(data, is_self_exit) {
    if (data == null) return;
 
    if (this.cur_fight_type == 2 && this.combat_type == data.combat_type) {
      this.clearView();
    }
  },
  clearView: function clearView() {
    this.setBattleTimeScale(true); // 还原动作速率
 
    if (this.battle_controller.getWatchReplayStatus() == true) {
      // 如果是录像状态下,退出录像
      this.battle_controller.setWatchReplayStatus(false);
    } // 派发退出战斗事件,通知各个系统处理
 
 
    gcore.GlobalEvent.fire(EventId.EXIT_FIGHT, this.combat_type);
 
    var MainuiController = require("mainui_controller");
 
    if (this.combat_type == BattleConst.Fight_Type.Darma) {
      if (MainuiController.getInstance().checkIsInDramaUIFight()) {
        // 剧情副本中结束战斗,则切到假战斗
        this.battle_controller.send20060(BattleConst.Fight_Type.Darma);
      }
    } else {
      if (this.battle_controller.getWatchReplayStatus() == true || this.combat_type == BattleConst.Fight_Type.PK || this.combat_type == BattleConst.Fight_Type.HeroTestWar) {
        if (MainuiController.getInstance().checkIsInDramaUIFight()) {
          // 剧情副本中结束战斗,则切到假战斗
          this.battle_controller.send20060(BattleConst.Fight_Type.Darma);
        } else {
          this.clearBattleScene();
        }
      } else {
        this.clearBattleScene();
      }
    }
  },
  // 播放资产掉落的动作
  playResourceCollect: function playResourceCollect(x, y, pos) {
    if (this.drama_fight_ui) {
      this.drama_fight_ui.playResourceCollect(x, y, pos);
    }
  },
  //获取group
  getGroup: function getGroup() {
    return this.my_group;
  },
  getCampIconConfigByIds: function getCampIconConfigByIds(id_list) {
    if (!id_list || Utils.next(id_list) == null) return;
 
    if (id_list.length == 1) {
      var id = id_list[0];
      return Config.combat_halo_data.data_halo_icon[id];
    } else {
      var min_id = Math.min(id_list[0], id_list[1]);
      var max_id = Math.max(id_list[0], id_list[1]);
 
      var _id = min_id * 100 + max_id;
 
      return Config.combat_halo_data.data_halo_icon[_id];
    }
  },
  getEffectRes: function getEffectRes(effect_id) {},
  // 开始准备战斗资源
  preloadBattleRes: function preloadBattleRes(data, finish_cb) {
    // skill_plays
    var battle_res = {};
 
    for (var skill_i in data.skill_plays) {
      var skill_data = data.skill_plays[skill_i];
 
      for (var effect_i in skill_data.effect_play) {
        var effect_data = skill_data.effect_play[effect_i];
        if (!effect_data.effect_bid) continue;
        var effect_config = gdata('skill_data', 'data_get_effect', effect_data.effect_bid);
 
        if (!effect_config) {
          continue;
        }
 
        var actor = this.real_role_list[effect_data.actor];
        var target = this.real_role_list[effect_data.target]; // 攻击动作资源
 
        if (effect_config.anime_res && actor) {
          var anime_res_path = actor.getResPath(effect_config.anime_res);
 
          if (anime_res_path) {
            battle_res[anime_res_path] = true;
          }
        } // 受击动作资源
 
 
        if (effect_config.hit_action && target) {
          if (effect_config.hit_action != "no-hurt") {
            var hit_action_path = target.getResPath(effect_config.hit_action);
 
            if (hit_action_path) {
              battle_res[hit_action_path] = true;
            }
          }
        } // 特效资源加载
 
 
        for (var effect_d in AniRes) {
          var effct_list = Utils.deepCopy(this.getCurEffectList(effect_config[AniRes[effect_d]]));
 
          for (var effect_i in effct_list) {
            var effect_info = effct_list[effect_i];
 
            if (effect_info.res_up) {
              var action_name = PlayerAction.action; // if (effect_info.up_action_name)
              //     action_name = effect_info.up_action_name;
 
              var res_path = "spine/" + effect_info.res_up + "/" + action_name;
              battle_res[res_path] = true;
            }
 
            if (effect_info.res_down) {
              var action_name = PlayerAction.action; // if (effect_info.down_action_name) {
              //     action_name = effect_info.down_action_name;
              // }
 
              var res_path = "spine/" + effect_info.res_down + "/" + action_name;
              battle_res[res_path] = true;
            }
          }
        }
      }
    }
 
    var total_num = 0;
    var finish_num = 0;
 
    for (var battle_i in battle_res) {
      total_num++;
    }
 
    for (var battle_i in battle_res) {
      var skeleton_path = battle_i + ".atlas";
      BattleResPool.getInstance().preLoadRes(skeleton_path, function (skeleton_path, res_object) {
        finish_num++;
 
        if (finish_num == total_num) {
          if (finish_cb) finish_cb();
        }
      }.bind(this, skeleton_path));
    }
 
    if (total_num == 0) {
      if (finish_cb) finish_cb();
    }
  }
});
module.exports = BattleModel;
 
cc._RF.pop();