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
"use strict";
cc._RF.push(module, '88431Z3SJVGCqdRuthx3n7Z', 'hero_exhibition_item');
// Scripts/mod/hero/view/hero_exhibition_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-01-24 11:43:27
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var HeroConst = require("hero_const");
 
var HeroCalculate = require("hero_calculate");
 
var ExhibitionItem = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.rleasePrefab = false;
    this.prefabPath = PathTool.getPrefabPath("hero", "hero_exhibition_item");
 
    var HeroBagController = require("hero_controller");
 
    this.ctrl = HeroBagController.getInstance();
    this.model = this.ctrl.getModel();
    this.isCache = true; //缓存
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.scale = 1;
    this.data = null;
    this.id = null;
    this.is_allow_select = true; // 是否允许选中和取消选中
 
    this.is_ui_select = false;
    this.percent = null;
    this.percent_lab = null;
    this.str_tips_obj = null;
    this.effect = true; // 是否响应按钮过滤
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    if (this.cur_pos) {
      this.setPosition(this.cur_pos.x, this.cur_pos.y);
      this.cur_pos = null;
    }
 
    if (this.scale) {
      this.root_wnd.scale = this.scale;
    }
 
    this.star_item_nd = this.seekChild("star_item");
    this.stars_container_nd = this.seekChild("stars_container");
    this.head_icon_nd = this.seekChild("head_icon");
    this.head_icon_sp = this.seekChild("head_icon", cc.Sprite);
    this.comp_type_nd = this.seekChild("comp_type");
    this.comp_type_sp = this.seekChild("comp_type", cc.Sprite);
    this.background_sp = this.seekChild("background", cc.Sprite);
    this.level_lb = this.seekChild("level", cc.Label);
    this.fight_nd = this.seekChild("fight");
    this.select_item_nd = this.seekChild("select_item");
    this.lock_item_nd = this.seekChild("lock_item");
    this.lock_item_sp = this.seekChild("lock_item", cc.Sprite);
    this.red_icon_nd = this.seekChild("red_icon");
    this.chip_icon_nd = this.seekChild("chip_icon");
    this.special_nd = this.seekChild("special");
    this.special_sp = this.seekChild("special", cc.Sprite);
    this.comp_type_sp.spriteFrame = null;
    this.level_lb.string = "";
    this.red_icon_nd.active = this.red_status || false;
 
    if (this.data) {
      this.setData(this.data);
    } else if (this.id != null) {
      this.setUnitData(this.id);
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    if (this.root_wnd && !this.click_event) {
      this.root_wnd.on(cc.Node.EventType.TOUCH_END, this.onClickRootWnd, this);
      this.root_wnd.on(cc.Node.EventType.TOUCH_START, this.onClickRootWnd, this);
      this.root_wnd.on(cc.Node.EventType.TOUCH_CANCEL, this.onClickRootWnd, this);
      this.click_event = true;
    }
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    this.unBindEvent();
 
    if (this.head_icon_sp) {
      this.head_icon_sp.spriteFrame = null;
    }
 
    if (this.root_wnd && this.click_event) {
      this.root_wnd.off(cc.Node.EventType.TOUCH_END, this.onClickRootWnd, this);
      this.root_wnd.off(cc.Node.EventType.TOUCH_START, this.onClickRootWnd, this);
      this.root_wnd.off(cc.Node.EventType.TOUCH_CANCEL, this.onClickRootWnd, this);
      this.click_event = false;
    }
 
    ItemsPool.getInstance().cacheItem(this);
  },
  addCallBack: function addCallBack(click_cb) {
    this.click_cb = click_cb;
  },
  addTouchCb: function addTouchCb(touch_cb) {
    this.touch_cb = touch_cb;
  },
  onClickRootWnd: function onClickRootWnd(event) {
    var is_callback = true;
 
    if (this.from_type == HeroConst.ExhibitionItemType.eFormFight) {
      if (!this.data) is_callback = false;
    }
 
    if (event.type === cc.Node.EventType.TOUCH_START) {
      if (this.effect) {
        this.root_wnd.scale = (this.scale || 1) * 0.9;
      }
 
      if (this.touch_cb && is_callback) this.touch_cb(this);
    }
 
    if (event.type === cc.Node.EventType.TOUCH_CANCEL) {
      if (this.effect) {
        this.root_wnd.scale = this.scale || 1;
      }
    }
 
    if (event.type === cc.Node.EventType.TOUCH_END) {
      if (this.effect) {
        this.root_wnd.scale = this.scale || 1;
      }
 
      if (this.click_cb && is_callback) {
        Utils.playButtonSound(3);
        this.click_cb(this);
      }
    }
  },
  setButtonEffect: function setButtonEffect(status) {
    this.effect = status;
  },
  setExtendData: function setExtendData(extend_data) {
    if (!extend_data) return;
    this.scale = extend_data.scale || 1;
    this.can_click = extend_data.can_click || false;
    this.from_type = extend_data.from_type || HeroConst.ExhibitionItemType.eNone;
    this.boold_type = extend_data.boold_type || null;
    this.click_delay = extend_data.click_delay || 0;
    this.hide_star = extend_data.hide_star || false;
  },
  // ==============================--
  // desc:根据单位id设置相关现实
  // @id:
  // @return 
  // ==============================--
  setUnitData: function setUnitData(id) {
    this.id = id;
    if (!this.root_wnd) return;
    id = id || 0;
    var config = Utils.getUnitConfig(id);
 
    if (config == null) {
      this.head_icon_nd.active = false;
      this.stars_container_nd.active = false;
      this.level_lb.string = "";
      var background_res = PathTool.getItemQualityBG(0);
      var common_res_path = PathTool.getCommonIcomPath(background_res);
      this.loadRes(common_res_path, function (sf_obj) {
        this.background_sp.spriteFrame = sf_obj;
      }.bind(this));
 
      if (this.comp_type_nd) {
        this.comp_type_nd.active = false;
      }
    } else {
      this.head_icon_nd.active = true;
      this.stars_container_nd.active = true;
      var monster_id = config.monster3;
 
      if (monster_id) {
        var monster_config = Utils.getUnitConfig(monster_id);
 
        if (monster_config) {
          // 设置头像
          var head_res_path = PathTool.getHeadRes(monster_config.head_icon);
          this.loadRes(head_res_path, function (head_sf) {
            this.head_icon_sp.spriteFrame = head_sf;
          }.bind(this)); // 设置品质框
 
          var background_res = PathTool.getItemQualityBG(monster_config.star);
          var common_res_path = PathTool.getCommonIcomPath(background_res);
          this.loadRes(common_res_path, function (sf_obj) {
            this.background_sp.spriteFrame = sf_obj;
          }.bind(this)); // 设置阵营
 
          var camp_res = PathTool.getHeroCampRes(monster_config.camp_type);
          var common_res_path = PathTool.getUIIconPath("common", camp_res);
          this.loadRes(common_res_path, function (sf_obj) {
            this.comp_type_sp.spriteFrame = sf_obj;
          }.bind(this)); // -- 设置星数
 
          this.updateStars(monster_config.star); // 设置等级
 
          this.level_lb.string = monster_config.lev.toString();
        }
      }
    }
  },
  //头像
  setHeadImg: function setHeadImg(head_icon) {
    var head_res_path = PathTool.getHeadRes(head_icon);
    this.loadRes(head_res_path, function (head_sf) {
      this.head_icon_sp.spriteFrame = head_sf;
    }.bind(this));
  },
  //品质框
  setQualityImg: function setQualityImg(quality) {
    var background_res = PathTool.getItemQualityBG(quality);
    var common_res_path = PathTool.getCommonIcomPath(background_res);
    this.loadRes(common_res_path, function (sf_obj) {
      this.background_sp.spriteFrame = sf_obj;
    }.bind(this));
  },
  //阵营
  setCampImg: function setCampImg(camp_type) {
    var camp_res = PathTool.getHeroCampRes(camp_type);
    var common_res_path = PathTool.getUIIconPath("common", camp_res);
    this.loadRes(common_res_path, function (sf_obj) {
      this.comp_type_sp.spriteFrame = sf_obj;
    }.bind(this));
  },
  //等级
  setLev: function setLev(lev) {
    this.level_lb.string = lev.toString();
  },
  init: function init() {
    this.setRootScale(1);
    this.cur_pos = null;
    this.setPosition(0, 0);
    this.setData(null);
    this.setExtendData({});
    this.record_res_id = null;
    this.showChipIcon(false); // this.setHeadUnEnabled(true)
 
    this.showRedPoint(false);
 
    if (this.bgImg) {
      this.bgImg.node.active = false;
    }
 
    if (this.barNode) {
      this.barNode.active = false;
    }
 
    if (this.lock_icon) {
      this.lock_icon.node.active = false;
    }
 
    this.showLockIcon(false);
    this.setSelected(false);
 
    if (this.hireHero) {
      this.hireHero.node.active = false;
    }
 
    this.showStrTips(false);
    this.showHelpImg(false);
 
    if (this.fight_nd) {
      this.fight_nd.active = false;
    }
 
    this.str_tips_obj = null;
    this.cur_visible = false;
    this.id = null;
    this.is_allow_select = true; // 是否允许选中和取消选中
 
    this.is_ui_select = false;
    this.percent = null;
    this.percent_lab = null;
    this.effect = true;
    this.addCallBack(null);
    this.addTouchCb(null);
 
    if (this.special_nd) {
      this.special_nd.active = false;
    }
 
    if (this.root_wnd_cb) {
      this.root_wnd_cb = null;
    }
 
    if (this.head_icon_nd) {
      this.head_icon_nd.active = true;
    }
 
    if (this.root_wnd) {
      Utils.setChildUnEnabled(this.root_wnd, false);
    }
  },
  setData: function setData(data) {
    if (this.data && this.item_update_event) {
      this.data.unbind(this.item_update_event);
      this.item_update_event = null;
    }
 
    this.data = data;
 
    if (this.root_wnd) {
      if (!data) {
        this.head_icon_nd.active = false;
        this.head_icon_sp.spriteFrame = null;
        this.stars_container_nd.active = false;
        this.level_lb.string = "";
        this.comp_type_sp.spriteFrame = null;
        var background_res = this.record_res_id = PathTool.getItemQualityBG(0);
        var common_res_path = PathTool.getCommonIcomPath(background_res);
        this.loadRes(common_res_path, function (sf_obj) {
          this.background_sp.spriteFrame = sf_obj;
        }.bind(this));
 
        if (this.special_nd.active) {
          this.special_nd.active = false;
        }
      } else {
        this.head_icon_nd.active = true;
        this.stars_container_nd.active = true;
      }
 
      this.setRootScale(this.scale);
      this.updateWidget(data);
    }
 
    ;
    if (this.data && this.data.UPDATE_PARTNER_ATTR) this.addVoBindEvent();
  },
  updateWidget: function updateWidget(info) {
    if (!info) {
      this.setSelected(false);
      return;
    }
 
    var data = info;
 
    if (typeof info == "number") {
      data = Config.partner_data.data_partner_base[data];
      if (!data) return;
    } else {
      if (info.data) data = info.data;
    }
 
    if (!data || data.bid === undefined) return;
    var star = data.star || data.init_star; // 根节点名称
 
    this.root_wnd.name = "hero" + "_" + data.bid; // 头像
 
    this.record_head_id = null;
    var head_res_path = null;
 
    if (data.bid === 0) {
      if (this.default_path) {
        head_res_path = this.default_path;
      } else if (data.icon) {
        head_res_path = PathTool.getIconPath("item", data.icon);
      }
    } else {
      var use_skin = this.findUseSkin(info);
 
      if (use_skin != null && use_skin != 0) {
        var skin_config = Config.partner_skin_data.data_skin_info[use_skin];
 
        if (skin_config) {
          head_res_path = PathTool.getHeadRes(skin_config.head_id);
        }
      } else {
        var star_key = data.bid + "_" + star;
        var star_cfg = gdata("partner_data", "data_partner_star", star_key);
 
        if (star_cfg) {
          var shwo_head_id = star_cfg.head_id;
 
          if (!this.record_head_id || this.record_head_id !== shwo_head_id) {
            this.record_head_id = shwo_head_id;
            head_res_path = PathTool.getHeadRes(this.record_head_id); // if (data.item_id) {
            //     var item_cfg = gdata("item_data", "data_unit5", data.item_id);
            //     head_res_path = PathTool.getIconPath("item", item_cfg.icon);
            // }
          }
        }
      }
    }
 
    if (head_res_path) {
      this.loadRes(head_res_path, function (head_sf) {
        if (this.root_wnd && this.root_wnd.isValid) {
          this.head_icon_sp.spriteFrame = head_sf;
        }
      }.bind(this));
    } // 背景
 
 
    var background_res = PathTool.getItemQualityBG(star - 1);
 
    if (!this.record_res_id || this.record_res_id != background_res) {
      this.record_res_id = background_res;
      var common_res_path = PathTool.getCommonIcomPath(background_res);
      this.loadRes(common_res_path, function (sf_obj) {
        if (this.root_wnd && this.root_wnd.isValid) {
          this.background_sp.spriteFrame = sf_obj;
        }
      }.bind(this));
    } // 阵营
 
 
    var camp_type;
    var par_config = Config.partner_data.data_partner_base[data.bid];
 
    if (par_config) {
      camp_type = par_config.camp_type;
    }
 
    if (data.bid == 0 && data.camp_type) {
      camp_type = data.camp_type;
    }
 
    if (camp_type === 0) {
      this.comp_type_nd.active = false;
    } else {
      if (camp_type && this.comp_type_nd) {
        this.comp_type_nd.active = true;
        var camp_res = PathTool.getHeroCampRes(camp_type);
        var common_res_path = PathTool.getUIIconPath("common", camp_res);
        this.loadRes(common_res_path, function (sf_obj) {
          if (this.root_wnd && this.root_wnd.isValid) {
            this.comp_type_sp.spriteFrame = sf_obj;
          }
        }.bind(this));
      }
    } //碎片
 
 
    if (this.chip_status != null) {
      this.showChipIcon(this.chip_status);
    } // 星星
 
 
    if (this.hide_star) {
      this.stars_container_nd.active = false;
    } else {
      this.stars_container_nd.active = true;
      this.updateStars(data.star);
    } // 等级
 
 
    if (data.lev) {
      this.level_lb.string = data.lev;
    } else {
      this.level_lb.string = "";
    } // 图鉴显示变灰逻辑
 
 
    this.setHeadUnEnabled(true);
 
    if (this.red_status != null) {
      this.showRedPoint(this.red_status);
    } else {
      this.showRedPoint(false);
    }
 
    this.fight_nd.active = false;
 
    if (this.bgImg) {
      this.bgImg.node.active = false;
    }
 
    if (this.barNode) {
      this.barNode.active = false;
    }
 
    if (this.lock_icon) {
      this.lock_icon.node.active = false;
    }
 
    if (this.from_type == HeroConst.ExhibitionItemType.eHeroBag) {
      // 英雄界面判断红点
      this.setSelected(false);
      this.showRedPoint(false);
 
      if (HeroCalculate.getInstance().isCheckHeroRedPointByHeroVo(data)) {
        var is_redpoint = HeroCalculate.getInstance().checkSingleHeroRedPoint(data);
        this.showRedPoint(is_redpoint);
      }
 
      this.fight_nd.active = this.data.isFormDrama();
    } else if (this.from_type == HeroConst.ExhibitionItemType.eHeroChange) {
      // 英雄转换界面
      if (this.lock_icon) {
        this.lock_icon.node.destroy();
        this.lock_icon = null;
      }
 
      if (this.lock_label) {
        this.lock_label.node.destroy();
        this.lock_label = null;
      } // --设置锁住状态
 
 
      this.showLockIcon(data.is_locked || false, data.lock_str); // --设置选中状态 
 
      this.setSelected(data.is_ui_select == true);
    } else if (this.from_type == HeroConst.ExhibitionItemType.ePokedex) {
      // 图鉴界面是否置灰
      this.showRedPoint(false);
      var is_have = false;
      var par_max_star = this.model.getHadHeroStarBybid(data.bid);
      if (!par_max_star || par_max_star < data.star) this.setHeadUnEnabled(false);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eFormFight) {
      // 布阵
      this.setSelected(data.is_ui_select);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eHeroSelect) {
      // 
      this.setSelected(data.is_ui_select);
      this.showLockIcon(data.is_ui_lock);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eUpStar) {
      // 英雄生星
      this.setGrayHead(data.head_gray);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eHeroReset) {
      // 英雄分解
      if (!data.is_ui_lock) {
        this.setSelected(data.is_ui_select);
      }
 
      this.showLockIcon(data.is_ui_lock);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eExpeditFight) {
      //远征
      // 血条
      var blood = 100;
 
      if (this.boold_type == true) {
        var HeroExpeditController = require("heroexpedit_controller");
 
        var partner_id = data.partner_id;
 
        if (data.partner_id > 100000) {
          partner_id = data.partner_id - 100000;
        }
 
        blood = HeroExpeditController.getInstance().getModel().getHeroBloodById(partner_id, data.rid, data.srv_id);
        var status = false;
        status = HeroExpeditController.getInstance().getModel().getHireHero(partner_id, data.rid, data.srv_id);
 
        if (status == true && data.is_used != null) {
          // -- self:showHelpImg(true)
          // --远征的支援标志......2019.1.28。20:37  晓勤特地叫改回来的
          if (!this.hireHero) {
            this.hireHero = Utils.createImage(this.root_wnd, null, 20, -63, cc.v2(0, 0));
          } else {
            this.hireHero.node.active = true;
          }
 
          this.loadRes(PathTool.getUIIconPath("heroexpedit", "txt_heroexpedit_1"), function (resObject) {
            this.hireHero.spriteFrame = resObject;
          }.bind(this));
        } else {
          if (this.hireHero) {
            this.hireHero.node.active = false;
          }
        }
      } else {
        blood = data.blood || 0;
      }
 
      this.showProgressbar(blood);
 
      if (blood <= 0) {
        this.showStrTips(true, Utils.TI18N("已阵亡"), {
          c3b: new cc.Color(255, 255, 255, 255)
        });
      } else {
        this.showStrTips(false);
      } // 设置选中状态 
 
 
      this.setSelected(data.is_ui_select == true);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eEndLessHero) {
      // 设置选中状态 
      this.setSelected(data.is_ui_select == true); // 是雇佣兵
 
      if (data.is_endless) {
        this.showHelpImg(true);
      } else {
        this.showHelpImg(false);
      }
 
      if (data.hp_per != null) {
        this.showProgressbar(data.hp_per);
 
        if (data.hp_per <= 0) {
          this.showStrTips(true, Utils.TI18N("已阵亡"), {
            c3b: new cc.Color(255, 255, 255, 255)
          });
        } else {
          this.showStrTips(false);
        }
      }
    } else if (this.from_type == HeroConst.ExhibitionItemType.eHeroFuse) {
      var need_count = data.need_count || 0;
      var total_count = data.total_count || 0;
      var label = cc.js.formatStr("%s/%s", total_count, need_count);
 
      if (data.cur_redpoint === 1) {
        this.showRedPoint(true);
      } else {
        this.showRedPoint(false);
      }
 
      this.showProgressbar(total_count / need_count * 100, label);
      this.setSelected(data.is_ui_select == true);
    } else if (this.from_type == HeroConst.ExhibitionItemType.eVoyage) {
      //远航
      this.showStrTips(data.in_task, Utils.TI18N("任务中"));
    } else {
      this.setSelected(this.is_ui_select);
 
      if (this.percent != null) {
        this.showProgressbar(this.percent, this.percent_lab);
      }
 
      if (this.str_tips_obj) {
        this.showStrTips(this.str_tips_obj.status, this.str_tips_obj.str, this.str_tips_obj.color);
      }
    }
  },
  unBindEvent: function unBindEvent() {
    if (this.data && this.item_update_event) {
      this.data.unbind(this.item_update_event);
      this.item_update_event = null;
    }
  },
  updateStars: function updateStars(star_num) {
    var star_res = "";
    var star_scal = 1;
    var star;
    this.special_nd.active = false;
    this.stars_container_nd.width = 0;
    this.stars_container_nd.removeAllChildren();
 
    if (star_num > 0 && star_num <= 5) {
      star_res = "common_90074";
    } else if (star_num > 5 && star_num <= 9) {
      star_num = star_num - 5;
      star_res = "common_90075";
    } else if (star_num > 9) {
      star = star_num - 10;
      star_num = 1;
      star_res = "common_90073";
      star_scal = 1.2;
      this.special_nd.active = true;
      var path;
 
      if (star > 0) {
        path = PathTool.getUIIconPath("common", "common_90084");
      } else {
        path = PathTool.getUIIconPath("common", "common_90076");
      }
 
      this.loadRes(path, function (res) {
        this.special_sp.spriteFrame = res;
      }.bind(this));
    }
 
    for (var star_i = 0; star_i < star_num; star_i++) {
      var star_nd = cc.instantiate(this.star_item_nd);
      star_nd.scale = star_scal;
      var star_sp = star_nd.getComponent(cc.Sprite);
      var common_res_path = PathTool.getCommonIcomPath(star_res);
      this.loadRes(common_res_path, function (star_sp, sf_obj) {
        star_sp.spriteFrame = sf_obj;
      }.bind(this, star_sp));
      this.stars_container_nd.addChild(star_nd);
 
      if (star) {
        var node = new cc.Node();
        node.y = -1;
        var lab = node.addComponent(cc.Label);
        lab.string = star;
        lab.fontSize = 15;
        lab.lineHeight = 16;
        lab.horizontalAlign = cc.macro.TextAlignment.CENTER;
        lab.verticalAlign = cc.macro.TextAlignment.CENTER;
        node.addComponent(cc.LabelOutline).color = new cc.color(0, 0, 0);
        star_nd.addChild(node);
      }
    }
  },
  setHeadUnEnabled: function setHeadUnEnabled(status) {
    var sp_status = cc.Sprite.State.NORMAL;
 
    if (!status) {
      sp_status = cc.Sprite.State.GRAY;
    }
 
    if (this.head_icon_sp) {
      this.head_icon_sp.setState(sp_status);
    }
 
    if (this.comp_type_sp) {
      this.comp_type_sp.setState(sp_status);
    }
  },
  setSelected: function setSelected(status) {
    if (!this.is_allow_select) return;
    this.is_ui_select = status;
 
    if (this.root_wnd == null) {
      return;
    }
 
    if (status) {
      this.select_item_nd.active = true;
    } else {
      this.select_item_nd.active = false;
    }
  },
  setRootPosition: function setRootPosition(pos) {
    if (!pos) return;
 
    if (this.root_wnd) {
      this.setPosition(pos.x, pos.y);
    } else {
      this.cur_pos = pos;
    }
  },
  setRootScale: function setRootScale(scale) {
    if (!scale) return;
    this.scale = scale;
 
    if (this.root_wnd) {
      this.root_wnd.scale = scale;
    }
  },
  getWorldPos: function getWorldPos() {
    if (this.root_wnd) {
      return this.root_wnd.convertToWorldSpaceAR(cc.v2(0, 0));
    }
 
    return null;
  },
  updagePositon: function updagePositon(new_pos) {
    if (!new_pos) return;
    if (this.root_wnd) this.root_wnd.setPosition(new_pos);
  },
  addVoBindEvent: function addVoBindEvent() {
    if (this.data && this.data.id) {
      if (this.item_update_event) return;
      this.item_update_event = this.data.bind(this.data.UPDATE_PARTNER_ATTR, function (hero_vo) {
        if (this.root_wnd) this.setData(hero_vo);
      }.bind(this));
    }
  },
  setDefaultHead: function setDefaultHead(icon_path) {
    if (icon_path) this.default_path = icon_path;
  },
  setGrayHead: function setGrayHead(status) {
    var sp_state = cc.Sprite.State.NORMAL;
 
    if (status) {
      sp_state = cc.Sprite.State.GRAY;
    }
 
    this.head_icon_sp.setState(sp_state);
  },
  // --设置锁
  showLockIcon: function showLockIcon(bool, str) {
    var self = this;
    if (bool == false && !self.lock_icon) return;
 
    if (!self.lock_icon) {
      var res = PathTool.getUIIconPath("common", "common_90009");
 
      var _size = cc.size(this.root_wnd.width, this.root_wnd.height);
 
      self.lock_icon = Utils.createImage(self.root_wnd, res, 0, 0, cc.v2(0.5, 0.5), true, 0, false);
      this.loadRes(res, function (resObject) {
        self.lock_icon.spriteFrame = resObject;
      }.bind(this));
    }
 
    if (str) {
      if (!self.lock_label) {
        self.lock_label = Utils.createLabel(22, Config.color_data.data_color16[1], Config.color_data.data_color4[9], size.width / 2, 22, "", this.root_wnd, 2, cc.v2(0.5, 0));
      }
 
      self.lock_label.string = str;
    }
 
    self.lock_icon.node.active = bool; // -- 锁住的时候某些部分要置灰
 
    self.setHeadUnEnabled(!bool);
 
    if (self.partner_type) {// setChildUnEnabled(bool, self.partner_type)
    }
 
    if (self.lock_label) {
      self.lock_label.node.active = bool;
    }
  },
  // 显示支援图片
  showHelpImg: function showHelpImg(bool) {
    if (bool == false && !this.help_img) return;
 
    if (!this.help_img) {
      var res = PathTool.getCommonIcomPath("txt_cn_common_90014");
      this.help_img = Utils.createImage(this.root_wnd, res, -this.root_wnd.width / 2 + 20, -this.root_wnd.height / 2 + 20, cc.v2(0.5, 0.5), true, 0, false);
      this.loadRes(res, function (resObject) {
        this.help_img.spriteFrame = resObject;
      }.bind(this));
    }
 
    this.help_img.node.active = bool;
  },
  // @percent 百分比
  // @label 进度条中间文字描述
  showProgressbar: function showProgressbar(percent, label) {
    this.percent = percent;
    this.percent_lab = label;
    if (!this.root_wnd) return;
    var size = cc.size(118, 15);
 
    if (this.bgImg) {
      this.bgImg.node.active = true;
    }
 
    if (this.barNode) {
      this.barNode.active = true;
    }
 
    if (!this.comp_bar) {
      var res = PathTool.getCommonIcomPath("common_90005");
      var res1 = PathTool.getCommonIcomPath("common_90006");
      this.bgImg = Utils.createImage(this.root_wnd, null, 0, -this.root_wnd.height / 2 - size.height / 2 - 2, cc.v2(0.5, 0.5), true, 0, true);
      this.bgImg.node.setContentSize(size.width + 2, size.height + 2);
      this.loadRes(res, function (resObject) {
        this.bgImg.spriteFrame = resObject;
      }.bind(this));
      this.barNode = new cc.Node();
      this.barNode.setAnchorPoint(cc.v2(0.5, 0.5));
      this.barNode.setContentSize(size);
      this.barNode.setPosition(0, -this.root_wnd.height / 2 - size.height / 2 - 2);
      this.root_wnd.addChild(this.barNode);
      var barImg = this.barNode.addComponent(cc.Sprite);
      barImg.type = cc.Sprite.Type.SLICED;
      barImg.sizeMode = cc.Sprite.SizeMode.CUSTOM;
      this.loadRes(res1, function (resObject) {
        barImg.spriteFrame = resObject;
      }.bind(this));
      var comp_bar = this.barNode.addComponent(cc.ProgressBar);
      comp_bar.barSprite = barImg;
      comp_bar.mode = cc.ProgressBar.Mode.HORIZONTAL;
      comp_bar.totalLength = size.width;
      this.comp_bar = comp_bar;
    }
 
    if (this.comp_bar_label) {
      this.comp_bar_label.string = "";
    }
 
    if (label) {
      if (!this.comp_bar_label) {
        var text_color = new cc.Color(255, 255, 255, 255);
        var line_color = new cc.Color(0, 0, 0, 255);
        var size = cc.size(118, 19);
        this.comp_bar_label = Utils.createLabel(18, text_color, line_color, size.width / 2, 0, "", this.comp_bar.node, 2, cc.v2(0.5, 0.5));
      }
 
      this.comp_bar_label.string = label;
    }
 
    this.comp_bar.progress = percent / 100;
  },
  //  显示文字提示
  showStrTips: function showStrTips(status, str, color) {
    this.str_tips_obj = {
      status: status,
      str: str,
      color: color
    };
    if (!this.root_wnd) return;
 
    if (status) {
      if (this.lay_tips == null) {
        this.lay_tips = new cc.Node();
        this.lay_tips.setAnchorPoint(cc.v2(0.5, 0.5));
        var size = this.root_wnd.getContentSize();
        this.lay_tips.setContentSize(size);
        this.lay_tips.setPosition(0, 0);
        var graphics_cp = this.lay_tips.addComponent(cc.Graphics);
        graphics_cp.clear();
        graphics_cp.fillColor = cc.color(0, 0, 0, 150);
        graphics_cp.rect(-size.width / 2, -size.height / 2, size.width, size.height);
        graphics_cp.fill();
        var c3b = new cc.Color(255, 255, 255, 255);
        var enable = new cc.Color(132, 0, 0, 255);
 
        if (color) {
          c3b = color.c3b || c3b;
          enable = color.enable || enable;
        }
 
        var tips_text = Utils.createLabel(26, c3b, enable, 0, 0, str, this.lay_tips, 1, cc.v2(0.5, 0.5));
        this.root_wnd.addChild(this.lay_tips);
      }
 
      this.lay_tips.active = true;
    } else {
      if (this.lay_tips) {
        this.lay_tips.active = false;
      }
    }
  },
  findUseSkin: function findUseSkin(info) {
    if (info.ext_data) {
      var ext = info.ext_data || {};
 
      for (var i in ext) {
        var v = ext[i];
 
        if (v.key == 5) {
          return v.val;
        }
      }
    }
 
    if (info.ext != null) {
      var _ext = info.ext || {};
 
      for (var _i in _ext) {
        var _v = _ext[_i];
 
        if (_v.key == 5) {
          return _v.val;
        }
      }
    }
 
    if (info.use_skin) {
      return info.use_skin;
    }
 
    return 0;
  },
  getData: function getData() {
    return this.data || {};
  },
  showRedPoint: function showRedPoint(status) {
    this.red_status = status;
    if (this.red_icon_nd) this.red_icon_nd.active = !!status;
  },
  showChipIcon: function showChipIcon(status) {
    this.chip_status = status;
 
    if (this.chip_icon_nd) {
      this.chip_icon_nd.active = status;
    }
  } // showLockIcon: function(status) {
  //     this.lock_item_nd.active = status;
  //     this.lock_item_sp.setState(!status);
  //     if (status) {
  //         this.setHeadUnEnabled(false);
  //     } else {
  //         this.setHeadUnEnabled(true);
  //     }
  // },
 
});
 
cc._RF.pop();