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
"use strict";
cc._RF.push(module, '3b3fdxid1NEkLdSG5xltvzo', 'adventure_buff_tips');
// Scripts/mod/tips/view/adventure_buff_tips.js
 
"use strict";
 
var LoaderManager = require("loadermanager");
 
var PathTool = require("pathtool");
 
var PartnerCalculate = require("partner_calculate"); //神界冒险的bufftips
 
 
var AdventureBuffTips = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("tips", "adventure_buff_tips");
    this.delay = 10;
    this.buff_list = arguments[0] || [];
    this.holiday_buff_list = arguments[1] || {};
    this.initConfig();
  },
  initConfig: function initConfig() {
    this.label_list = {};
    this.holiday_label_list = {};
    LoaderManager.getInstance().loadRes(this.prefabPath, function (res_object) {
      var view = res_object;
      this.createRootWnd(view);
    }.bind(this));
  },
  createRootWnd: function createRootWnd(view) {
    this.root_wnd = view;
    this.root_wnd.setAnchorPoint(cc.v2(0.5, 0.5)); // this.root_wnd.setContentSize(cc.size(SCREEN_WIDTH, display.height))
 
    this.root_wnd.setContentSize(cc.size(SCREEN_WIDTH, 1280)); // this.root_wnd.setPosition(SCREEN_WIDTH * 0.5, SCREEN_HEIGHT * 0.5);
 
    this.root_wnd.setPosition(0, 0);
    ViewManager.getInstance().addToSceneNode(this.root_wnd, SCENE_TAG.msg);
    this.main_nd = this.root_wnd.getChildByName("main");
    this.bg_nd = this.main_nd.getChildByName("bg");
    this.registerEvent();
    this.showTips();
  },
  registerEvent: function registerEvent() {
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function () {
      require("tips_controller").getInstance().closeAllTips();
    }, this);
  },
  setPosition: function setPosition(x, y) {
    // this.main_nd.setAnchorPoint(cc.v2(1, 0));
    this.main_nd.setPosition(cc.v2(x, y));
  },
  addToParent: function addToParent(parent, zindex) {
    cc.log("common_tips");
  },
  setPos: function setPos(x, y) {
    this.main_nd.setPosition(cc.v2(x, y));
  },
  getBgContentSize: function getBgContentSize() {
    if (this.root_wnd) {
      return this.main_nd.getContentSize();
    }
  },
  getScreenBg: function getScreenBg() {
    return this.root_wnd;
  },
  addCallBack: function addCallBack(fun) {
    this.callback = fun;
 
    if (this.root_wnd) {
      this.callback();
    }
  },
  showTips: function showTips() {
    if (this.root_wnd == null) return;
    this.buff_list = this.buff_list || [];
    this.holiday_buff_list = this.holiday_buff_list || [];
    var count = this.buff_list.length;
    var width = 510;
 
    if (count == 1) {
      //线板宽度确定
      width = 255;
    }
 
    var col = Math.ceil(count * 0.5);
    var height = col * 40 + 55; //  活动buff
 
    var add_height = 0;
 
    if (Utils.next(this.holiday_buff_list) != null) {
      var add_count = this.holiday_buff_list.length;
      var add_col = Math.ceil(add_count * 0.5);
      add_height = add_col * 40 + 10;
      width = 510;
    }
 
    this.main_nd.setContentSize(cc.size(width, height + add_height));
    this.bg_nd.setContentSize(cc.size(width, height + add_height));
 
    if (this.desc_label == null) {
      this.desc_label = Utils.createLabel(20, new cc.Color(0xb4, 0xa9, 0x9a, 0xff), null, 0, -(height + add_height) / 2 + 8, Utils.TI18N("该属性仅本轮冒险生效"), this.main_nd, null, cc.v2(0.5, 0));
    }
 
    if (add_height > 0) {
      if (this.line_image == null) {
        this.line_image = Utils.createImage(this.main_nd, null, 0, height - 10, cc.v2(0.5, 0.5), true, null, true);
        LoaderManager.getInstance().loadRes(PathTool.getCommonIcomPath("common_1097"), function (sf_obj) {
          this.line_image.spriteFrame = sf_obj;
        }.bind(this));
      }
 
      if (this.holiday_label == null) {
        this.holiday_label = Utils.createLabel(24, new cc.Color(0xe0, 0xbf, 0x99, 0xff), null, 30, height + add_height - 20, Utils.TI18N("活动加成:"), this.main_nd, null, cc.v2(0, 1));
      }
    }
 
    this.createBuffList(width, height, add_height);
 
    if (this.callback) {
      this.callback();
    }
  },
  //  创建列表
  createBuffList: function createBuffList(width, height, add_height) {
    var color = new cc.Color(0xe0, 0xbf, 0x99, 0xff);
    var base_config = Config.buff_data.data_get_buff_data; // 活动buff
 
    for (var i in this.holiday_buff_list || {}) {
      if (this.holiday_label_list[i] == null) {
        this.holiday_label_list[i] = Utils.createRichLabel(24, color, cc.v2(0, 1));
        this.holiday_label_list[i].horizontalAlign = cc.macro.TextAlignment.LEFT;
        this.main_nd.addChild(this.holiday_label_list[i].node);
 
        var _x = -width / 2 + 30 + i % 2 * 220;
 
        var _y = (height + add_height) / 2 - Math.floor(i / 2) * 40 - 20;
 
        this.holiday_label_list[i].node.setPosition(cc.v2(_x, _y));
      }
 
      var label = this.holiday_label_list[i];
      var config = base_config[this.holiday_buff_list[i].bid];
      var time = this.holiday_buff_list[i].time || 1;
      this.setBuffLabelData(label, config, time);
    } // 冒险buff
 
 
    for (var i in this.buff_list) {
      if (this.label_list[i] == null) {
        this.label_list[i] = Utils.createRichLabel(24, color, cc.v2(0, 1));
        this.label_list[i].horizontalAlign = cc.macro.TextAlignment.LEFT;
        this.main_nd.addChild(this.label_list[i].node);
 
        var _x = -width / 2 + 30 + i % 2 * 220;
 
        var _y = -(height + add_height) / 2 + height - Math.floor(i / 2) * 40 - 20;
 
        this.label_list[i].node.setPosition(cc.v2(_x, _y));
      }
 
      var label = this.label_list[i];
      var config = base_config[this.buff_list[i].bid];
      var time = this.buff_list[i].time || 1;
      this.setBuffLabelData(label, config, time);
    }
  },
  setBuffLabelData: function setBuffLabelData(label, config, time) {
    if (label && config && time) {
      var buff_desc = "";
 
      for (var i in config.effect) {
        var attr_key = config.effect[i][0];
        var attr_val = config.effect[i][1] * time;
 
        if (buff_desc != "") {
          buff_desc = buff_desc + ",";
        }
 
        var attr_name = Config.attr_data.data_key_to_name[attr_key] || "";
 
        if (PartnerCalculate.isShowPerByStr(attr_key)) {
          buff_desc = cc.js.formatStr(Utils.TI18N("%s提升%s%s"), attr_name, attr_val * 0.1, "%");
        } else {
          buff_desc = cc.js.formatStr(Utils.TI18N("%s提升%s"), attr_name, attr_val);
        }
      }
 
      var str = cc.js.formatStr("<img src='%s'/>%s", config.icon, buff_desc);
      LoaderManager.getInstance().loadRes(PathTool.getBuffRes(config.icon), function (label, resObject) {
        label.addSpriteFrame(resObject);
      }.bind(this, label));
      label.string = str;
    }
  },
  setAnchorPoint: function setAnchorPoint(pos) {
    if (this.root_wnd) {
      this.root_wnd.setAnchorPoint(pos);
    }
  },
  open: function open() {
    gcore.Timer.set(function () {
      require("tips_controller").getInstance().closeAllTips();
    }, this.delay * 1000, 1, "close");
  },
  close: function close() {
    if (this.root_wnd) {
      this.root_wnd.destroy();
      this.root_wnd = null;
    }
 
    LoaderManager.getInstance().releasePrefab(this.prefabPath);
    gcore.Timer.del("close");
  }
});
 
cc._RF.pop();