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
"use strict";
cc._RF.push(module, '31bae3rDjJND6gEhy7c8h0j', 'worldmap_item');
// Scripts/mod/worldmap/view/worldmap_item.js
 
"use strict";
 
var _partner_event = require("../../partner/partner_event");
 
// -- --------------------------------------------------------------------
// -- 
// -- 
// -- @author: mengjiabin@syg.com(必填, 创建模块的人员)
// -- @editor: mengjiabin@syg.com(必填, 后续维护以及修改的人员)
// -- @description:
// --      世界地图的单个剧情副本
// -- <br/>Create: 2018-xx-xx
// -- --------------------------------------------------------------------
// 119 特效 1、选中未通过 2、选中通过 3、未选中通过 4、未选中未通过
var BattleDramaController = require("battle_drama_controller");
 
var WorldmapController = require("worldmap_controller");
 
var Battle_dramaEvent = require("battle_drama_event");
 
var BattleController = require("battle_controller");
 
var WorldMapItem = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {
    this.ctrl = BattleDramaController.getInstance();
    this.model = this.ctrl.getModel();
    this.config = arguments[0];
    this.size = cc.size(50, 50);
    this.scale = 4;
    this.open_data = arguments[1];
    this.createRootWnd();
  },
  // 初始化UI
  createRootWnd: function createRootWnd() {
    this.root_wnd = new cc.Node("map_item");
    this.root_wnd.setAnchorPoint(0.5, 0.5);
    this.root_wnd.setContentSize(this.size);
    var button = this.root_wnd.addComponent(cc.Button);
    button.transition = cc.Button.Transition.SCALE;
    button.duration = 0.1;
    button.zoomScale = 0.9;
    var node = new cc.Node();
    node.setAnchorPoint(0.5, 0.5);
    node.setPosition(this.size.width * 0.5, this.size.height * 0.5);
    this.root_wnd.addChild(node);
    this.effect = node.addComponent(sp.Skeleton);
    var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(119), "action");
    LoaderManager.getInstance().loadRes(anima_path, function (ske_data) {
      if (this.effect) {
        this.effect.skeletonData = ske_data;
        this.effect.setAnimation(0, PlayerAction.action_4, true);
        this.fillData();
      }
    }.bind(this));
    this.progress_bg = Utils.createImage(this.root_wnd, null, this.size.width * 0.5, 80, cc.v2(0.5, 0.5));
    LoaderManager.getInstance().loadRes(PathTool.getUIIconPath("worldmap", "worldmap_1008"), function (res_object) {
      this.progress_bg.spriteFrame = res_object;
    }.bind(this));
    this.progress_label = Utils.createLabel(18, new cc.Color(0xff, 0xff, 0xff, 0xff), null, 0, 0, "", this.progress_bg.node, null, cc.v2(0.5, 0.5));
    this.name_bg = Utils.createImage(this.root_wnd, null, this.size.width * 0.5, -20, cc.v2(0.5, 0.5));
    LoaderManager.getInstance().loadRes(PathTool.getUIIconPath("worldmap", "worldmap_1006"), function (res_object) {
      this.name_bg.spriteFrame = res_object;
    }.bind(this));
    this.name_label = Utils.createLabel(18, new cc.Color(0x68, 0x45, 0x2a, 0xff), null, this.size.width * 0.5, -15, this.config.name, this.root_wnd, null, cc.v2(0.5, 0.5));
    this.click_layout = new cc.Node();
    this.click_layout.setContentSize(cc.size(100, 100));
    this.click_layout.setAnchorPoint(0.5, 0.5);
    this.click_layout.setPosition(25, 25);
    this.root_wnd.addChild(this.click_layout, 90);
    this.registerEvent(); // this.fillData()
  },
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.click_layout, function () {
      if (this.call_back) {
        this.call_back();
      } // -- var max_chapter_id = model:getCurMaxChapterId(this.drama_data.mode)
      // -- -- var open_num = math.min(chapter_pass_sum + 1, tableLen(this.config))
      // -- if max_chapter_id ~= 1 then
      // --     max_chapter_id = max_chapter_id + 1
      // -- end
 
 
      var max_sum_chapter = this.model.getOpenSumChapter(this.drama_data.mode);
 
      if (this.drama_data) {
        if (this.config.bid <= max_sum_chapter && this.config.bid != this.drama_data.chapter_id) {
          var chapter_list = this.model.getChapterListByID(this.drama_data.mode, this.config.bid);
          var max_dun_id = this.model.getHasPassChapterMaxDunId(this.drama_data.mode, this.config.bid);
 
          if (chapter_list && max_dun_id != 0) {
            //直接切换
            var cur_drama_data = this.model.getDramaData();
            cur_drama_data.mode = this.drama_data.mode;
            cur_drama_data.chapter_id = this.config.bid;
            cur_drama_data.dun_id = max_dun_id;
            this.model.setDramaData(cur_drama_data);
          } else {
            this.ctrl.send13002();
          }
 
          WorldmapController.getInstance().openWorldMapMainWindow(false);
        } else {
          if (this.config.bid == this.drama_data.chapter_id) {
            if (this.open_data) {
              WorldmapController.getInstance().openWorldMapMainWindow(false);
            } else {
              message(Utils.TI18N("已在当前章节"));
            }
          } else {
            message(Utils.TI18N("前面章节暂没通关"));
          }
        }
      }
    }.bind(this), 1);
 
    if (!this.battle_event) {
      this.battle_event = gcore.GlobalEvent.getInstance().bind(Battle_dramaEvent.BattleDrama_Drama_Unlock_View, function (data) {
        if (this.config && this.config.bid == data.bid) {
          WorldmapController.getInstance().openWorldMapMainWindow(false);
        }
      }.bind(this));
    }
  },
  // showAfterEffect:function(){
  //     if(this.after_effect){
  //         this.after_effect.setToSetupPose();
  //         this.after_effect.clearTracks();
  //         this.after_effect = null;
  //     }
  //     if(!this.after_effect){
  //         return;
  //         // var parent_wnd = ViewManager:getInstance():getLayerByTag(ViewMgrTag.MSG_TAG)
  //         var world_pos = this.root_wnd.convertToWorldSpace(cc.v2(this.root_wnd.getContentSize().width / 2, this.root_wnd.getContentSize().height / 2))
  //         var node = new cc.Node();
  //         node.setAnchorPoint(0.5,0.5)
  //         node.setPosition(SCREEN_WIDTH / 2,SCREEN_HEIGHT / 2);
  //         parent_wnd.addChild(node);
  //         this.after_effect = node.addComponent(sp.Skeleton);
  //         var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(146), "action");
  //         LoaderManager.getInstance().loadRes(anima_path, function(ske_data) {
  //             if(this.after_effect){
  //                 this.after_effect.skeletonData = ske_data;
  //                 this.after_effect.setAnimation(0, PlayerAction.action, true);
  //             }
  //         }.bind(this));
  //         this.after_effect.node.runAction(cc.sequence(cc.moveTo(0.5,cc.v2(world_pos.x,world_pos.y))));
  //         var animationCompleteFunc = function(){
  //             if(this.after_effect){
  //                 this.after_effect.setToSetupPose();
  //                 this.after_effect.clearTracks();
  //                 this.after_effect = null;
  //             }
  //             this.showFingerEffect()
  //         }
  //         this.after_effect.setCompleteListener(animationCompleteFunc);
  //     }
  // },
  // showFingerEffect:function(){
  //     if(this.finger_effect){
  //         this.finger_effect.setToSetupPose();
  //         this.finger_effect.clearTracks();
  //         this.finger_effect = null;
  //     }
  //     if(!this.finger_effect){
  //         var node = new cc.Node();
  //         node.setAnchorPoint(0.5,0.5)
  //         node.setPosition(this.root_wnd.getContentSize().width / 2, this.root_wnd.getContentSize().height / 2);
  //         this.root_wnd.addChild(node);
  //         this.finger_effect = node.addComponent(sp.Skeleton);
  //         var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(240), "action");
  //         LoaderManager.getInstance().loadRes(anima_path, function(ske_data) {
  //             if(this.finger_effect){
  //                 this.finger_effect.skeletonData = ske_data;
  //                 this.finger_effect.setAnimation(0, PlayerAction.action, true);
  //             }
  //         }.bind(this));
  //         var animationCompleteFunc = function(){
  //             BattleController.getInstance().setUnlockChapterStatus(false)
  //             // WorldmapController.getInstance().addLockContainer(false)
  //             this.effect.setAnimation(0, PlayerAction.action_1, true)
  //         }
  //         this.after_effect.setCompleteListener(animationCompleteFunc);
  //     }
  // },
  addToParent: function addToParent(parent, call_back) {
    if (parent && this.config) {
      parent.addChild(this.root_wnd);
 
      if (call_back) {
        this.call_back = call_back;
      }
 
      this.root_wnd.setPosition(this.config.x, this.config.y);
    }
  },
  openEffect: function openEffect() {
    if (this.effect) {
      var self = this;
 
      var animationCompleteFunc = function animationCompleteFunc() {
        self.ctrl.openBattleDramaUnlockChapterView(true, self.config);
        BattleController.getInstance().setUnlockChapterStatus(false); // WorldmapController.getInstance().addLockContainer(false)
      };
 
      this.effect.setCompleteListener(animationCompleteFunc);
      this.effect.setAnimation(0, PlayerAction.action_6, false);
    }
  },
  // 填充数据
  fillData: function fillData() {
    this.drama_data = this.model.getDramaData();
 
    if (this.config != null && this.drama_data != null) {
      this.progress_bg.node.active = this.config.bid <= this.drama_data.chapter_id;
      this.progress_label.string = cc.js.formatStr("%s/%s", this.model.getHasCurChapterPassListNum(Battle_dramaEvent.BattleDramaConst.Normal, this.config.bid), this.model.getChapterLength(Battle_dramaEvent.BattleDramaConst.Normal, this.config.bid));
      var max_sum_chapter = this.model.getOpenSumChapter(this.drama_data.mode);
 
      if (this.config.bid == this.drama_data.chapter_id) {
        if (this.open_data) {
          this.openEffect();
        } else {
          // --this.progress_label:setString(cc.js.formatStr("%s/%s", model:getHasCurChapterPassListNum(Battle_dramaEvent.BattleDramaConst.Normal,this.config.bid), model:getChapterLength(Battle_dramaEvent.BattleDramaConst.Normal, this.config.bid)))
          this.effect.setAnimation(0, PlayerAction.action_1, true);
        }
      } else if (this.config.bid < max_sum_chapter) {
        this.effect.setAnimation(0, PlayerAction.action_3, true);
      } else if (this.config.bid > max_sum_chapter) {
        this.effect.setAnimation(0, PlayerAction.action_5, true);
      }
    }
  },
  clearEffect: function clearEffect() {
    if (this.finger_effect) {
      this.finger_effect.setToSetupPose();
      this.finger_effect.clearTracks();
      this.finger_effect = null;
    }
 
    if (this.after_effect) {
      this.after_effect.setToSetupPose();
      this.after_effect.clearTracks();
      this.after_effect = null;
    }
 
    if (this.open_effect) {
      this.open_effect.setToSetupPose();
      this.open_effect.clearTracks();
      this.open_effect = null;
    }
  },
  // 删掉的时候关闭
  DeleteMe: function DeleteMe() {
    if (this.item_container) {
      this.item_container.stopAllActions();
    }
 
    for (var i in this.item_list) {
      this.item_list[i].DeleteMe();
    }
 
    this.item_list = null;
 
    if (this.battle_event) {
      gcore.GlobalEvent.getInstance().unbind(this.battle_event);
      this.battle_event = null;
    }
  }
});
 
cc._RF.pop();