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
"use strict";
cc._RF.push(module, 'b84b3Koa55LQ76IHhuo5iUi', 'story_model');
// Scripts/mod/story/story_model.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-04-15 14:45:57
// --------------------------------------------------------------------
var StoryEvent = require("story_event");
 
var RoleController = require("role_controller");
 
var StoryModel = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {
    this.ctrl = arguments[0];
  },
  properties: {},
  initConfig: function initConfig() {
    this.save_drama_list = null;
    this.cur_story_bid = null; //  当前剧情bid
 
    this.cur_story = null; //  当前剧情配置
 
    this.cur_act_list = null; //  当前动作列表
    // 当前是否在剧情中
 
    this.is_story_state = false; //  剧情状态
    // 当前是否是剧情触发的战斗;
 
    this.is_story_fight = false; //  战斗
    // 保存缓存的剧情数据;
 
    this.temp_story_list = [];
  },
  // 设置当前剧情配置
  setCurStory: function setCurStory(data_list) {
    if (!this.save_drama_list) this.initDrama(); // 是否已经执行过引导
 
    for (var drama_i in this.save_drama_list) {
      if (this.save_drama_list[data_list.drama_bid]) return;
    } // 这里看看需要不需要判断当前如果有窗体或者有全屏窗体打开的时候,也缓存剧情数据
 
 
    if (this.is_story_state) {
      //判断是否在剧情状态
      cc.log("model缓存剧情");
      if (this.cur_story_bid == data_list.drama_bid) return;
 
      for (var story_i in this.temp_story_list) {
        var story_info = this.temp_story_list[story_i];
 
        if (story_info.drama_bid == data_list.drama_bid) {
          return;
        }
      }
 
      this.temp_story_list.push(data_list);
      return;
    }
 
    this.cur_story_bid = data_list.drama_bid;
    this.cur_story = Config.drama_data.data_get[data_list.drama_bid];
 
    if (this.cur_story && this.cur_story.act) {
      this.cur_act_list = this.cur_story.act;
      gcore.GlobalEvent.fire(StoryEvent.READ_CONFIG_COMPLETE);
    } else {
      this.ctrl.send11100(this.cur_story_bid, 0);
    }
  },
  // 当剧情播放完成的时候判断一下是否有下一个剧情缓存
  isPlayNextStory: function isPlayNextStory() {
    if (this.temp_story_list.length > 0) {
      // var data_list = table.remove(self.temp_story_list, 1)
      var data_list = this.temp_story_list.shift();
      this.setCurStory(data_list);
    }
  },
  //  取到当前剧情bid
  getCurStoryBid: function getCurStoryBid() {
    return this.cur_story_bid;
  },
  //  取到当前剧情配置
  getCurStory: function getCurStory() {
    return this.cur_story;
  },
  //  取到当前动作列表
  getCurActList: function getCurActList() {
    return this.cur_act_list;
  },
  // 设置剧情状态
  setStoryState: function setStoryState(bool) {
    this.is_story_state = bool; // 如果剧情已经结束,则判断下一个剧情
 
    if (!bool) {
      gcore.GlobalEvent.fire(StoryEvent.STORY_OVER);
      this.isPlayNextStory();
    }
  },
  isStoryState: function isStoryState() {
    return this.is_story_state;
  },
  // 设置状态
  setStoryFight: function setStoryFight(bool) {
    this.is_story_fight = bool;
  },
  isStoryFight: function isStoryFight() {
    return this.is_story_fight;
  },
  // 清除剧情的数据
  clearActData: function clearActData() {
    this.cur_story_bid = null;
    this.cur_story = null;
    this.cur_act_list = null;
  },
  saveDrama: function saveDrama(drama_id) {
    if (!this.save_drama_list[drama_id]) {
      this.save_drama_list[drama_id] = true;
      var role_vo = RoleController.getInstance().getRoleVo();
      cc.sys.localStorage.setItem("drama_data" + role_vo.srv_id + role_vo.rid, JSON.stringify(this.save_drama_list));
    }
  },
  initDrama: function initDrama() {
    var role_vo = RoleController.getInstance().getRoleVo();
    var cache_data = cc.sys.localStorage.getItem("drama_data" + role_vo.srv_id + role_vo.rid);
 
    if (cache_data) {
      this.save_drama_list = JSON.parse(cache_data) || {};
    } else {
      this.save_drama_list = {};
    }
  }
});
 
cc._RF.pop();