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
"use strict";
cc._RF.push(module, '9e7dbz2w61LkJmixigusZkE', 'onlinegift_controller');
// Scripts/mod/onlinegift/onlinegift_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: whjing2012@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-01-05 10:37:58
// --------------------------------------------------------------------
var OnlineGiftEvent = require("onlinegift_event");
 
var OnlinegiftController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var OnlinegiftModel = require("onlinegift_model");
 
    this.model = new OnlinegiftModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    if (!this.init_role_event) {
      this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
        gcore.GlobalEvent.unbind(this.init_role_event);
        this.init_role_event = null; // this.send10926();
      }.bind(this));
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(10926, this.on10926); // 已领福利
 
    this.RegisterProtocal(10927, this.on10927); // 领取福利
  },
  // 已领福利处理
  send10926: function send10926() {
    this.SendProtocal(10926, {});
  },
  on10926: function on10926(data) {
    this.model.updateData(data);
    gcore.GlobalEvent.fire(OnlineGiftEvent.Get_Data, data);
  },
  // 领取福利
  send10927: function send10927(time) {
    this.SendProtocal(10927, {
      time: time
    });
  },
  on10927: function on10927(data) {
    message(data.msg);
 
    if (data.code == 1) {
      gcore.GlobalEvent.fire(OnlineGiftEvent.Update_Data, data.time);
    }
  },
  // 打开窗口
  openOnlineGiftView: function openOnlineGiftView(bool) {
    if (bool) {
      if (!this.onlinegiftView) {
        var OnlineGiftWindow = require("onlinegift_window");
 
        this.onlinegiftView = new OnlineGiftWindow();
      }
 
      this.onlinegiftView.open();
    } else {
      if (this.onlinegiftView) {
        this.onlinegiftView.close();
        this.onlinegiftView = null;
      }
    }
  }
});
module.exports = OnlinegiftController;
 
cc._RF.pop();