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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-05-16 17:20:08
// --------------------------------------------------------------------
var VedioEvent = require("vedio_event")
var VedioConst = require("vedio_const")
var VedioController = cc.Class({
    extends: BaseController,
    ctor: function () {
    },
 
    // 初始化配置数据
    initConfig: function () {
        var VedioModel = require("vedio_model");
 
        this.model = new VedioModel();
        this.model.initConfig();
    },
 
    // 返回当前的model
    getModel: function () {
        return this.model;
    },
 
    // 注册监听事件
    registerEvents: function () {
    },
 
    // 注册协议接受事件
    registerProtocals: function () {
        // this.RegisterProtocal(1110, this.on1110);
        this.RegisterProtocal(19901,this.handle19901.bind(this)) //个人录像数据返回
        this.RegisterProtocal(19902,this.handle19902.bind(this)) //录像大厅数据返回
        this.RegisterProtocal(19903,this.handle19903.bind(this)) //点赞返回
        this.RegisterProtocal(19904,this.handle19904.bind(this)) //收藏返回
        this.RegisterProtocal(19905,this.handle19905.bind(this)) //分享返回
        this.RegisterProtocal(19906,this.handle19906.bind(this)) //今日点赞数
        this.RegisterProtocal(19907,this.handle19907.bind(this)) //伙伴信息数据
 
        this.RegisterProtocal(19908,this.handle19908.bind(this)) //查看分享录像
    },
    handle19901(data){
        if(data){
            if(data.type == VedioConst.MyVedio_Type.Myself){
                gcore.GlobalEvent.fire(VedioEvent.UpdateMyselfVedioEvent, data.replay_list)
            }else if(data.type == VedioConst.MyVedio_Type.Collect){
                gcore.GlobalEvent.fire(VedioEvent.UpdateCollectVedioEvent, data.replay_list)
            }
        }
        
    },
    handle19902(data){
        if(data){
            this.model.setPublicVedioData(data)
            gcore.GlobalEvent.fire(VedioEvent.UpdatePublicVedioEvent, data.type)
        }
    },
    handle19903(data){
        message(data.msg)
        if(data.code == 1){
            gcore.GlobalEvent.fire(VedioEvent.CLICK_Like_Vedio_EVENT)
        }
    },
    handle19904(data){
        message(data.msg)
        if(data.code == 1 && data.type == 1){  //-- 收藏成功
            let new_data = this.model.updateVedioData(this.vedioType_flag, data.id, "is_collect", 1)
            gcore.GlobalEvent.fire(VedioEvent.UpdateVedioDataEvent, new_data)
            gcore.GlobalEvent.fire(VedioEvent.CollectSuccessVedioEvent, data.id)
        }
        if(data.type == 0){
            gcore.GlobalEvent.fire(VedioEvent.CancelCollectVedioEvent, data.id)
        }
    },
    handle19905(data){
        message(data.msg)
    },
    handle19906(data){
        if(data.like != null){
            this.model.setTodayLikeNum(data.like)
            gcore.GlobalEvent.fire(VedioEvent.UpdateTodayLikeNum)
        }
    },
    handle19907(data){
        if(data){
            let config = Config.partner_data.data_partner_base[data.bid]
            let camp_type = 1
            if(config){
                camp_type = config.camp_type
            }
            data.camp_type = camp_type
            data.ext_data = data.ext
            data.name = config.name
            for(let i=0;i<data.ext.length;++i){
                let v = data.ext[i]
                if(v.key == 111){ //--命中
                    data.hit_rate = v.val
                }else if(v.key == 112){ // --闪避
                    data.dodge_rate = v.val
                }else if(v.key == 117){ //--抗暴
                    data.tenacity = v.val
                }else if(v.key == 121){  //--伤害加成
                    data.dam = v.val
                }else if(v.key == 122){ //--免伤
                    data.res = v.val
                }else if(v.key == 123){ //--被治疗
                    data.be_cure = v.val
                }else if(v.key == 124){ //--治疗
                    data.cure = v.val
                }else if(v.key == 125){  //--物伤
                    data.dam_p = v.val
                }else if(v.key == 126){  //--法伤
                    data.dam_s = v.val
                }else if(v.key == 127){   //--物免
                    data.res_p = v.val
                }else if(v.key == 128){  //--法免
                    data.res_s = v.val
                }
            }
 
            // --后端问题.没法改结构..现在模拟神装数据 从artifacts里面拿数据
            // data.holy_eqm = {}
            // for i,v in ipairs(data.artifacts) do
            //     if v.artifact_pos == BackPackConst.item_type.GOD_EARRING + 100 or
            //         v.artifact_pos == BackPackConst.item_type.GOD_RING + 100 or
            //         v.artifact_pos == BackPackConst.item_type.GOD_NECKLACE + 100 or
            //         v.artifact_pos == BackPackConst.item_type.GOD_BANGLE + 100 then
            //         --说明是神装
            //         local holy_data = {}
            //         holy_data.id = v.id
            //         holy_data.base_id = v.base_id
            //         holy_data.main_attr = v.attr
            //         holy_data.holy_eqm_attr = v.extra_attr
            //         for i,v in ipairs(holy_data.holy_eqm_attr) do
            //             v.pos = i
            //         end
            //         table.insert(data.holy_eqm, holy_data)
            //     end
            // end
            var HeroController = require("hero_controller")
            HeroController.getInstance().openHeroTipsPanel(true, data)
        }
    },
    handle19908(){
 
    },
    // - 请求录像大厅的数据
    requestPublicVedioData( type, cond_type, start, num ){
        let protocal = {}
        protocal.type = type
        protocal.cond_type = cond_type
        protocal.start = start
        protocal.num = num
        this.SendProtocal(19902, protocal)
    },
    // -- 请求伙伴信息
    requestVedioHeroData( replay_id, partner_id, type, srv_id, combat_type ){
        let protocal = {}
        protocal.replay_id = replay_id
        protocal.partner_id = partner_id
        protocal.type = type
        protocal.srv_id = srv_id
        protocal.combat_type = combat_type
        this.SendProtocal(19907, protocal)
    },
    // -- 请求录像分享
    requestShareVedio( id, channel, srv_id, combat_type ){
        let protocal = {}
        protocal.id = id
        protocal.channel = channel
        protocal.srv_id = srv_id
        protocal.combat_type = combat_type
        this.SendProtocal(19905, protocal)
    },
    // -- 请求录像收藏
    requestCollectVedio( id, type, srv_id, combat_type, vedioType ){
        this.vedioType_flag = vedioType  //-- 记录一下请求收藏的类型
        let protocal = {}
        protocal.id = id
        protocal.type = type
        protocal.srv_id = srv_id
        protocal.combat_type = combat_type
        this.SendProtocal(19904, protocal)
    },    
    // -- 请求录像点赞
    requestLikeVedio( id, srv_id, combat_type ){
        let protocal = {}
        protocal.id = id
        protocal.srv_id = srv_id
        protocal.combat_type = combat_type
        this.SendProtocal(19903, protocal)
    },
    // -- 请求个人录像数据(我的记录、我的收藏)
    requestMyVedioByType( type ){
        let protocal = {}
        protocal.type = type
        this.SendProtocal(19901, protocal)
    },
    // -- 录像信息
    send19908( replay_id, srv_id, type, channel ){
        let protocal = {}
        protocal.replay_id = replay_id
        protocal.srv_id = srv_id
        protocal.type = type
        protocal.channel = channel
        this.SendProtocal(19908, protocal)
    } ,
    handle19908(data){
        this.openVedioLookPanel(true, data)
        // -- GlobalEvent:getInstance():Fire(VedioEvent.LOOK_VEDIO_EVENT, data)
    },
 
    // 打开录像馆
    openVedioMainWindow( status, sub_type ){
        if(status == true){
            if(!this.vedio_main_wnd){
                var VedioMainWindow = require("vedio_main_window")
                this.vedio_main_wnd = new VedioMainWindow()
            }
            if(this.vedio_main_wnd.isOpen() == false){
                this.vedio_main_wnd.open(sub_type)
            }
        }else{
            if(this.vedio_main_wnd){
                this.vedio_main_wnd.close()
                this.vedio_main_wnd = null
            }
        }
    },
    //打开录像收藏界面
    openVedioCollectWindow(status){
        var self = this
        if(status == true){
            if(self.vedio_collect_win == null){
                var VedioCollectWindow = require("vedio_collect_window")
                self.vedio_collect_win = new VedioCollectWindow()
            }
            if(self.vedio_collect_win.isOpen() == false){
                self.vedio_collect_win.open()
            }
        }else{
            if(self.vedio_collect_win){
                self.vedio_collect_win.close()
                self.vedio_collect_win = null
            }
        }
    },
    //打开个人记录界面
    openVedioMyselfWindow(status){
        var self = this
        if(status == true){
            if(self.vedio_myself_win == null){
                var VedioMyselfWindow = require("vedio_myself_window")
                self.vedio_myself_win = new VedioMyselfWindow()
            }
            if(self.vedio_myself_win.isOpen() == false){
                self.vedio_myself_win.open()
            }
        }else{
            if(self.vedio_myself_win){
                self.vedio_myself_win.close()
                self.vedio_myself_win = null
            }
        }
    },
    openVedioLookPanel(status, data){
        if(status == true){
            if(!this.vedio_look_panel){
                let VedioLookPanel = require("vedio_look_window")
                this.vedio_look_panel = new VedioLookPanel()
            }
            if(this.vedio_look_panel.isOpen() == false){
                this.vedio_look_panel.open(data)
            }
        }else{
            if(this.vedio_look_panel){
                this.vedio_look_panel.close()
                this.vedio_look_panel = null
            }
        }
    },
    openVedioSharePanel(status,  vedio_id, world_pos, callback, srv_id, combat_type){
        if(status == true){
            if(!this.vedio_share_panel){
                let VedioSharePanel = require("vedio_share_window")
                this.vedio_share_panel = new VedioSharePanel()
            }
            if(this.vedio_share_panel.isOpen() == false){
                this.vedio_share_panel.open({replay_id:vedio_id, world_pos:world_pos, callback:callback, srv_id:srv_id, combat_type:combat_type})
            }
        }else{
            if(this.vedio_share_panel){
                this.vedio_share_panel.close()
                this.vedio_share_panel = null;
            }
        }
    },
});
 
module.exports = VedioController;