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
"use strict";
cc._RF.push(module, 'a1aa6boItVC84F8MhXqHGe7', 'battle_role_pool');
// Scripts/mod/battle/battle_role_pool.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      战斗中需要的对象的对象池,区分真假战斗
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var BattleRolePool = cc.Class({
  "extends": BaseClass,
  statics: {
    instance: null
  },
  initConfig: function initConfig() {
    this.realPools = new cc.NodePool(); // 战斗对象的预制体缓存对象池
 
    this.effectPools = new cc.NodePool(); // 战斗特效缓存对象池
 
    this.fontPools = new cc.NodePool(); // 战斗中的程序字缓存,主要是被动或者buff播报
 
    this.buffpools = new cc.NodePool(); // 战斗中的buff图标缓存
 
    this.dmgPoolsList = {}; // 战斗中伤害具体区分的对象池
  },
  // 返回这个对象池
  getRealPools: function getRealPools() {
    return this.realPools;
  },
  // 战斗对象丢到对象池中
  pushBackRole: function pushBackRole(role) {
    this.realPools.put(role);
  },
  // 获取特效对象池
  getEffectPools: function getEffectPools() {
    return this.effectPools;
  },
  // 回收特效对象池
  pushBackEffect: function pushBackEffect(effect) {
    this.effectPools.put(effect);
  },
  // 返回文字对象
  getFontPools: function getFontPools() {
    return this.fontPools;
  },
  // 回收文字对象
  pushBackFont: function pushBackFont(font) {
    this.fontPools.put(font);
  },
  // bufficon对象
  getBuffPools: function getBuffPools() {
    return this.buffpools;
  },
  // 回收buff对象
  pushBackBuffPools: function pushBackBuffPools(buff) {
    this.buffpools.put(buff);
  },
  // 战斗治疗和伤害数字节点对象池
  getDmgPools: function getDmgPools(type) {
    var pool = this.dmgPoolsList[type];
 
    if (pool == null) {
      pool = new cc.NodePool();
      this.dmgPoolsList[type] = pool;
    }
 
    return pool;
  },
  // 回收伤害数字
  pushBackDmgPools: function pushBackDmgPools(type, dmg) {
    var pool = this.dmgPoolsList[type];
 
    if (pool == null) {
      pool = new cc.NodePool();
      this.dmgPoolsList[type] = pool;
    }
 
    pool.put(dmg);
  }
});
 
BattleRolePool.getInstance = function () {
  if (!BattleRolePool.instance) {
    BattleRolePool.instance = new BattleRolePool();
    BattleRolePool.instance.initConfig();
  }
 
  return BattleRolePool.instance;
};
 
module.exports = BattleRolePool;
 
cc._RF.pop();