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
"use strict";
cc._RF.push(module, 'cb705YL5LFHF6D9qaJoi8H3', 'activity_item_panel');
// Scripts/mod/activity/view/activity_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     活动 Item 项
// <br/>Create: 2019-05-06 14:34:33
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var ActivityConst = require("activity_const");
 
var GuildBossController = require("guildboss_controller");
 
var ActivityController = require("activity_controller");
 
var MainuiController = require("mainui_controller");
 
var Activity_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("activity", "activity_item");
    this.ctrl = ActivityController.getInstance();
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.is_double = false;
    this.list_item = [];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.mainContainer = this.root_wnd.getChildByName("main_container");
    this.itemMask = this.mainContainer.getChildByName("itemMask");
    this.textLimit = this.itemMask.getChildByName("textLimit").getComponent(cc.Label);
    this.textLimit.string = Utils.TI18N("敬请期待");
    this.itemMask.zIndex = 11;
    this.btnRule = this.mainContainer.getChildByName("btnRule");
    this.btnRule.active = false;
    this.textTimeStart = this.mainContainer.getChildByName("textTimeStart").getComponent(cc.Label);
    this.textTimeStart.string = "";
    this.textTimeStart.node.active = false;
    this.itemBG = this.mainContainer.getChildByName("itemBG");
    this.redPoint = this.mainContainer.getChildByName("redPoint");
    this.redPoint.active = false;
  },
  changeEscortCount: function changeEscortCount() {
    if (this.activityData.id == ActivityConst.limit_index.escort) {
      // var totle = EscortController.getInstance().getModel().getMyMaxCount(EscortConst.times_type.escort);
      // var current = EscortController.getInstance().getModel().getMyCount(EscortConst.times_type.escort);
      var num = totle - current;
 
      if (num < 0) {
        num = 0;
      }
 
      var str = cc.js.formatStr(Utils.TI18N("护送次数:%d/%d"), num, totle);
 
      if (!this.count) {
        this.count = Utils.createLabel(20, new cc.Color(0xff, 0xff, 0xff, 0xff), new cc.Color(0x74, 0x35, 0x0b, 0xff), 582, 65, str, this.mainContainer, 2, cc.v2(1, 0.5));
      } else {
        this.count.string = str;
      }
    }
  },
  setData: function setData(data) {
    this.activityData = data; // 只对萌受夺宝列表做判断
 
    if (this.activityData.id == ActivityConst.limit_index.escort) {
      // this.is_double = EscortController.getInstance().getModel().isDoubleTimes();
      this.changeEscortCount();
    }
 
    this.changeItemData(data); // 引导使用,不要删
    // if(data && data.id){
    //     this.setName("guide_activity_item_"+data.id)
    // }
  },
  getData: function getData() {
    return this.activityData;
  },
  addCallBack: function addCallBack(value) {
    this.callback = value;
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.btnRule, function () {
      if (this.activityData.id == ActivityConst.limit_index.escort) {
        MainuiController.getInstance().openCommonExplainView(true, Config.EscortData.data_explain);
      } else if (this.activityData.id == ActivityConst.limit_index.union) {
        MainuiController.getInstance().openCommonExplainView(true, Config.GuildDunData.data_explain);
      } else if (this.activityData.id == ActivityConst.limit_index.fightFirst) {} else if (this.activityData.id == ActivityConst.limit_index.allGod) {
        MainuiController.getInstance().openCommonExplainView(true, Config.ZsWarData.data_explain);
      } else if (this.activityData.id == ActivityConst.limit_index.guildwar) {
        MainuiController.getInstance().openCommonExplainView(true, Config.GuildWarData.data_explain);
      } else if (this.activityData.id == ActivityConst.limit_index.champion) {
        MainuiController.getInstance().openCommonExplainView(true, Config.ArenaChampionData.data_explain);
      } else if (this.activityData.id == ActivityConst.limit_index.ladder) {
        MainuiController.getInstance().openCommonExplainView(true, Config.SkyLadderData.data_explain);
      }
    }.bind(this), 1); //当用户点击的时候记录鼠标点击状态
 
    this.root_wnd.on(cc.Node.EventType.TOUCH_START, function (event) {
      var touches = event.getTouches();
      this.touch_began = touches[0].getDelta();
    }, this); //当鼠标抬起的时候恢复状态
 
    this.root_wnd.on(cc.Node.EventType.TOUCH_END, function (event) {
      var touches = event.getTouches();
      this.touch_end = touches[0].getDelta();
      var is_click = true;
 
      if (this.touch_began != null) {
        is_click = Math.abs(this.touch_end.x - this.touch_began.x) <= 20 && Math.abs(this.touch_end.y - this.touch_began.y) <= 20;
      }
 
      if (is_click == true) {
        Utils.playButtonSound(ButtonSound.Normal);
 
        if (this.callback) {
          this.callback();
        }
      }
    }, this);
  },
  updateRedStatus: function updateRedStatus() {
    if (this.activityData) {
      var red_status = false;
 
      if (this.activityData.id == ActivityConst.limit_index.escort) {// red_status = EscortController:getInstance():getModel():checkRedStatus()
      } else if (this.activityData.id == ActivityConst.limit_index.union) {
        if (GuildBossController.getInstance().getModel().getChangeCount() == true && this.ctrl.getBossActivityDoubleTime() == true && this.ctrl.getFirstComeGuild() == true) {
          red_status = true;
        }
      } else if (this.activityData.id == ActivityConst.limit_index.guildwar) {// red_status = GuildwarController.getInstance().getModel().checkGuildGuildWarRedStatus();
      } else if (this.activityData.id == ActivityConst.limit_index.ladder) {// red_status = LadderController.getInstance().getModel().checkLadderRedStatus();
      }
 
      this.redPoint.active = red_status;
    }
  },
  changeItemData: function changeItemData(data) {
    if (data.val[0]) {
      for (var i in data.val[0]) {
        if (!this.list_item[i]) {
          var item = ItemsPool.getInstance().getItem("backpack_item");
 
          if (this.mainContainer) {
            item.setParent(this.mainContainer);
          }
 
          this.list_item[i] = item;
        }
 
        if (this.list_item[i]) {
          this.list_item[i].initConfig(false, 0.5, false, true);
          this.list_item[i].show();
          this.list_item[i].setPosition(40 * i + (24 * i - 1), 67);
          this.list_item[i].setData(data.val[0][i]); // this.list_item[i].setDoubleIcon(this.is_double);
        }
      }
    }
 
    this.limitItemData(data);
 
    if (data.desc) {
      if (this.textTimeStart) {
        this.textTimeStart.string = data.desc;
        this.textTimeStart.node.active = true;
      }
    }
  },
  // 限时活动子项
  limitItemData: function limitItemData(data) {
    var RoleController = require("role_controller");
 
    var role_vo = RoleController.getInstance().getRoleVo();
    var res = PathTool.getIconPath("activity/activity_big", "txt_cn_activity_item_" + data.id, false, false);
    this.loadRes(res, function (resObject) {
      this.itemBG.getComponent(cc.Sprite).spriteFrame = resObject;
    }.bind(this));
 
    if (data.is_open == 1) {
      var _bool = MainuiController.getInstance().checkIsOpenByActivate(data.activate);
 
      if (_bool == true) {
        this.handleEffect(true);
        this.itemMask.active = false;
 
        if (this.btnRule) {
          this.btnRule.active = true;
        }
 
        if (data.id == ActivityConst.limit_index.union) {
          if (role_vo.gname == "") {
            this.textLimit.string = Utils.TI18N("当前未加入公会");
            this.handleEffect(false);
          }
        }
      } else {
        this.handleEffect(false);
 
        if (this.btnRule) {
          this.btnRule.active = false;
        }
 
        this.textLimit.string = data.lock_desc;
      }
    } else {
      if (data.id == ActivityConst.limit_index.union) {
        if (role_vo.gname != "") {
          this.textLimit.string = Utils.TI18N("公会副本玩法暂未开启");
        }
      }
    }
  },
  handleEffect: function handleEffect(status) {
    if (status == false) {
      if (this.play_effect) {
        this.play_effect.setToSetupPose();
        this.play_effect.clearTracks();
        this.play_effect = null;
      }
    } else {
      if (this.mainContainer && this.play_effect == null) {
        var node = new cc.Node();
        node.setAnchorPoint(1, 0);
        node.setPosition(this.itemBG.getContentSize().width - 106, 28);
        this.mainContainer.addChild(node, 1);
        this.play_effect = node.addComponent(sp.Skeleton);
        var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(505), "action");
        LoaderManager.getInstance().loadRes(anima_path, function (ske_data) {
          if (this.play_effect) {
            this.play_effect.skeletonData = ske_data;
            this.play_effect.setAnimation(0, PlayerAction.action, true);
          }
        }.bind(this));
      }
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    if (this.list_item && Utils.next(this.list_item) != null) {
      for (var i in this.list_item) {
        if (this.list_item[i].deleteMe) {
          this.list_item[i].deleteMe();
        }
      }
    }
 
    this.list_item = [];
    this.handleEffect(false);
    this.count = null;
  }
});
 
cc._RF.pop();