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
"use strict";
cc._RF.push(module, '23f6eZJlRZG/4Aiz3Ouv2AU', 'arena_champion_cur_rank_panel');
// Scripts/mod/arena/view/champion/arena_champion_cur_rank_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-13 11:43:40
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var ArenaEvent = require("arena_event");
 
var RoleEvent = require("role_event");
 
var CommonScrollView = require("common_scrollview");
 
var RankItem = require("arena_champion_cur_rank_item");
 
var RoleEvent = require("role_event");
 
var ArenaChampionCurRankPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("arena", "arena_champion_cur_rank_panel");
    this.ctrl = arguments[0];
    this.model = this.ctrl.getChamPionModel();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    var RoleController = require("role_controller");
 
    this.role_vo = RoleController.getInstance().getRoleVo();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.items_container_nd = this.seekChild("items_container");
    this.empty_tips_nd = this.seekChild("empty_tips");
    this.rank_img_nd = this.seekChild("rank_img");
    this.rank_img_sp = this.rank_img_nd.getComponent(cc.Sprite);
    this.rank_txt_nd = this.seekChild("rank_txt");
    this.rank_txt_rt = this.rank_txt_nd.getComponent("CusRichText");
    this.role_name_lb = this.seekChild("role_name", cc.Label);
    this.role_power_lb = this.seekChild("role_power", cc.Label);
    this.worship_num_lb = this.seekChild("num", cc.Label);
    this.head_con_nd = this.seekChild("head_con");
 
    var PlayerHead = require("playerhead");
 
    this.role_head = new PlayerHead();
    this.role_head.setParent(this.head_con_nd);
    this.role_head.show();
    this.initRankList();
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.addGlobalEvent(ArenaEvent.UpdateChampionRankEvent, function (data) {
      if (data) this.updateRankList(data);
    }.bind(this));
    this.addGlobalEvent(RoleEvent.WorshipOtherRole, function (data) {
      if (data) this.updateOtherWorship(data);
    }.bind(this));
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.ctrl.sender20281();
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onVisible: function onVisible(status) {
    if (status) this.ctrl.sender20281();
  },
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.activity_sv) this.activity_sv.deleteMe();
    this.activity_sv = null;
  },
  // 主界面基础信息更新
  updateBaseInfo: function updateBaseInfo() {},
  initRankList: function initRankList() {
    var scorll_size = this.items_container_nd.getContentSize();
    var size = cc.size(scorll_size.width, scorll_size.height);
    var setting = {
      item_class: RankItem,
      start_x: 0,
      space_x: 0,
      start_y: 0,
      space_y: 0,
      item_width: 680,
      item_height: 140,
      row: 0,
      col: 1,
      need_dynamic: true
    };
    this.activity_sv = new CommonScrollView();
    this.activity_sv.createScroll(this.items_container_nd, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, size, setting, cc.v2(0.5, 0.5));
  },
  updateRankList: function updateRankList(rank_data) {
    var rank_list = this.rank_list = rank_data.rank_list;
    this.activity_sv.setData(rank_list);
 
    if (rank_list.length === 0) {
      this.empty_tips_nd.active = true;
    } else {
      this.empty_tips_nd.active = false;
    }
 
    this.updateMyInfo(rank_data);
  },
  updateMyInfo: function updateMyInfo(rank_data) {
    if (!rank_data) return;
 
    if (rank_data.rank <= 3 && rank_data.rank > 0) {
      this.rank_img_nd.active = true;
      this.rank_txt_nd.active = false;
      var rank_img_path = PathTool.getUIIconPath("common", cc.js.formatStr("common_300%s", rank_data.rank));
      this.loadRes(rank_img_path, function (rank_sf) {
        this.rank_img_sp.spriteFrame = rank_sf;
      }.bind(this));
    } else if (rank_data.rank === 0) {
      this.rank_img_nd.active = false;
      this.rank_txt_nd.active = false;
    } else {
      this.rank_img_nd.active = false;
      this.rank_txt_nd.active = true;
      this.rank_txt_rt.setNum(rank_data.rank);
    }
 
    this.role_name_lb.string = this.role_vo.name;
    this.role_power_lb.string = this.role_vo.power;
    this.worship_num_lb.string = rank_data.worship; // this.score_num_lb.string = rank_data.score;
 
    this.role_head.setHeadRes(this.role_vo.face_id);
    this.role_head.setLev(this.role_vo.lev);
  },
  updateOtherWorship: function updateOtherWorship(data) {
    var update_index = data.idx - 1;
    var update_item = this.rank_list[update_index];
    update_item.worship += 1;
    update_item.worship_status = 1;
    this.activity_sv.updateItemData(update_index, update_item);
  }
});
 
cc._RF.pop();