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
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      战斗中需要的对象的对象池,区分真假战斗
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var BattleRolePool = cc.Class({
    extends: BaseClass,
    statics: {
        instance: null
    },
 
    initConfig:function(){
        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(){
        return this.realPools;
    },
 
    // 战斗对象丢到对象池中
    pushBackRole:function(role){
        this.realPools.put(role);
    },
 
    // 获取特效对象池
    getEffectPools:function(){
        return this.effectPools;
    },
 
    // 回收特效对象池
    pushBackEffect:function(effect){
        this.effectPools.put(effect);
    },
 
    // 返回文字对象
    getFontPools:function(){
        return this.fontPools;
    },
 
    // 回收文字对象
    pushBackFont:function(font){
        this.fontPools.put(font)
    },
 
    // bufficon对象
    getBuffPools:function(){
        return this.buffpools;
    },
 
    // 回收buff对象
    pushBackBuffPools:function(buff){
        this.buffpools.put(buff);
    },
 
    // 战斗治疗和伤害数字节点对象池
    getDmgPools:function(type){
        var pool = this.dmgPoolsList[type];
        if(pool == null){
            pool = new cc.NodePool();
            this.dmgPoolsList[type] = pool;
        }
        return pool;
    },
 
    // 回收伤害数字
    pushBackDmgPools:function(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;