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
"use strict";
cc._RF.push(module, 'e5612BfZ4hM2ZR697gDpqGX', 'arena_loop_my_log_item');
// Scripts/mod/arena/view/loop/arena_loop_my_log_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-19 09:46:41
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var PlayerHead = require("playerhead");
 
var RoleController = require("role_controller");
 
var TimeTool = require("timetool");
 
var Arena_loop_my_log_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("arena", "arena_loop_my_log_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.role_vo = RoleController.getInstance().getRoleVo();
    this.score_iocn = Config.arena_data.data_const.score_iocn;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.left_role_nd = this.seekChild("left_role");
    this.right_role_nd = this.seekChild("right_role");
    this.down_arrow_nd = this.seekChild("down_arrow");
    this.up_arrow_nd = this.seekChild("up_arrow");
    this.score_item_sp = this.seekChild("score_item", cc.Sprite);
    this.fight_result_nd = this.seekChild("fight_result");
    this.fight_result_lb = this.seekChild("fight_result", cc.Label); // this.result_nd       = this.seekChild("result");
 
    this.arrow_con_nd = this.seekChild("arrow_con");
    this.check_fight_btn_nd = this.seekChild("check_fight_btn");
    this.right_name_lb = this.seekChild("right_name", cc.Label);
    this.left_name_lb = this.seekChild("left_name", cc.Label);
    this.fight_type_lb = this.seekChild("fight_type", cc.Label);
    this.time_lb = this.seekChild("time", cc.Label);
    this.success_img_nd = this.seekChild("success_img");
    this.faild_img_nd = this.seekChild("faild_img");
    this.left_head = new PlayerHead();
    this.left_head.setParent(this.left_role_nd);
    this.left_head.show();
    this.right_head = new PlayerHead();
    this.right_head.setParent(this.right_role_nd);
    this.right_head.show();
    this.check_fight_btn_nd.on(cc.Node.EventType.TOUCH_END, this.onClickFightBtn, this);
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {
    this.updateWidgets();
  },
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.left_head) {
      this.left_head.deleteMe();
      this.left_head = null;
    }
 
    if (this.right_head) {
      this.right_head.deleteMe();
      this.right_head = null;
    }
  },
  setData: function setData(data) {
    this.data = data;
    if (this.root_wnd) this.updateWidgets();
  },
  updateWidgets: function updateWidgets() {
    if (!this.data) return;
    this.left_head.setHeadRes(this.role_vo.face_id);
    this.right_head.setHeadRes(this.data.face);
    this.left_name_lb.string = this.role_vo.name;
    this.right_name_lb.string = this.data.name;
 
    if (this.data.ret === 1) {
      this.success_img_nd.active = true;
      this.faild_img_nd.active = false;
    } else {
      this.success_img_nd.active = false;
      this.faild_img_nd.active = true;
    }
 
    var fight_str = "";
 
    if (this.data.type === 1) {
      if (this.data.ret === 1) {
        fight_str = Utils.TI18N("进攻成功");
      } else {
        fight_str = Utils.TI18N("进攻失败");
      }
    } else {
      if (this.data.ret === 1) {
        fight_str = Utils.TI18N("防守成功");
      } else {
        fight_str = Utils.TI18N("防守失败");
      }
    }
 
    this.fight_type_lb.string = fight_str;
    this.time_lb.string = TimeTool.getYMDHMS(this.data.time);
    var result_str = "";
 
    if (this.score_iocn) {
      if (this.data.score === 0) {
        result_str = Utils.TI18N("不变");
        this.score_item_sp.spriteFrame = null;
        this.arrow_con_nd.active = false;
      } else {
        if (this.data.ret == 1) {
          this.up_arrow_nd.active = true;
          this.down_arrow_nd.active = false;
          this.fight_result_nd.color = new cc.Color().fromHEX('#249003');
          result_str = "+" + this.data.score;
        } else {
          this.up_arrow_nd.active = false;
          this.down_arrow_nd.active = true;
          this.fight_result_nd.color = new cc.Color().fromHEX('#e14737'); // result_str = "-" + this.data.score
 
          result_str = this.data.score;
        }
      }
 
      this.fight_result_lb.string = result_str;
      var item_path = PathTool.getIconPath("item", this.score_iocn.val);
      this.loadRes(item_path, function (item_sf) {
        this.score_item_sp.spriteFrame = item_sf;
      }.bind(this));
    } else {
      this.score_item_sp.spriteFrame = null;
      this.arrow_con_nd.active = false;
    }
  },
  onClickFightBtn: function onClickFightBtn() {
    if (this.data) {
      var BattleController = require("battle_controller");
 
      BattleController.getInstance().csRecordBattle(this.data.replay_id);
    }
  }
});
 
cc._RF.pop();