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
"use strict";
cc._RF.push(module, 'ee4c9A9elhKrYRxAgCA1AbY', 'story_controller');
// Scripts/mod/story/story_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-04-15 14:45:57
// --------------------------------------------------------------------
var StoryView = require("story_view");
 
var StoryController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var StoryModel = require("story_model");
 
    this.model = new StoryModel(this);
    this.model.initConfig();
    this.view = new StoryView(this);
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {// this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function() {
    //     for (var drama_i in Config.drama_data.data_get) {
    //         var config = Config.drama_data.data_get[drama_i];
    //         var server_data = {};
    //         server_data.drama_bid = config.bid;
    //         this.handle11101(server_data);
    //     }
    // }.bind(this))
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(11101, this.handle11101.bind(this)); // 服务端触发剧情
 
    this.RegisterProtocal(11102, this.handle11102.bind(this)); // 跳过剧情
 
    this.RegisterProtocal(11100, this.handle11100.bind(this));
  },
  handle11101: function handle11101(data_list) {
    cc.log("收到服务端执行剧情协议"); // return
 
    cc.log(data_list);
    this.model.setCurStory(data_list);
  },
  send11102: function send11102(drama_bid) {
    var protocal = {};
    protocal.drama_bid = drama_bid;
    this.SendProtocal(11102, protocal);
  },
  handle11102: function handle11102(data_list) {
    if (this.model) {
      if (data_list.code == 1) gcore.GlobalEvent.fire(StoryEvent.SKIP_STORY);
    }
  },
  send11100: function send11100(drama_bid, step_id) {
    cc.log("通知服务端剧情步骤" + "--" + drama_bid + "--" + step_id);
    var protocal = {};
    protocal.drama_bid = drama_bid;
    protocal.step_id = step_id;
    this.SendProtocal(11100, protocal);
  },
  handle11100: function handle11100(data) {
    if (this.view) this.view.playStepOver();
  },
  isInStory: function isInStory() {
    if (!this.model) return false;
    return this.model.isStoryState();
  }
});
module.exports = StoryController;
 
cc._RF.pop();