f6b19bee-afac-4f42-a6e6-5464061f78b9.js
5.22 KB
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
141
142
143
144
"use strict";
cc._RF.push(module, 'f6b19vur6xPQqbmVGQGH3i5', 'BlockData');
// scripts/kernel/battle/map/BlockData.ts
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockData = void 0;
var SoundManager_1 = require("../../../component/SoundManager");
var Global_1 = require("../../../Global");
var BlockColorTableMgr_1 = require("../../table/BlockColorTableMgr");
var ObjData_1 = require("./ObjData");
var BlockData = /** @class */ (function (_super) {
__extends(BlockData, _super);
function BlockData() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._hp = 1;
_this._contentY = 0;
_this.skill = null;
_this._isProtected = false;
return _this;
//#endregion
}
Object.defineProperty(BlockData.prototype, "hp", {
get: function () { return this._hp; },
enumerable: false,
configurable: true
});
Object.defineProperty(BlockData.prototype, "contentY", {
/**最大内容范围内的Y坐标 */
get: function () { return this._contentY; },
enumerable: false,
configurable: true
});
Object.defineProperty(BlockData.prototype, "isProtected", {
/**是否在被闸门保护状态 */
get: function () { return this._isProtected; },
enumerable: false,
configurable: true
});
//#region life cycle
BlockData.prototype.init = function (map, type, gridX, gridY) {
//屏蔽,调用initBlock
return;
};
BlockData.prototype.initBlock = function (map, type, hp, gridX, gridY) {
_super.prototype.init.call(this, map, type, gridX, gridY);
this._contentY = gridY;
this._hp = hp;
this._imgName = this.getImgName();
};
/**子类需覆写,返回对应的类型 */
BlockData.prototype.clone = function () {
//XXX 新增属性需要在此处增加处理
return this.cloneValue(new BlockData());
};
/**和球发生碰撞 */
BlockData.prototype.onCollisonToBall = function (collider) {
if (!this._deaded && !this.isProtected) {
_super.prototype.onCollisonToBall.call(this, collider);
this.skill && this.skill.onCollisionToBall();
if (this._hp >= 1) {
this.adJustHp(-1);
}
}
};
BlockData.prototype.onDead = function () {
_super.prototype.onDead.call(this);
this.skill && this.skill.onDead();
SoundManager_1.SoundManager.ins.playEffect(Global_1.SoundName.BREAK);
};
BlockData.prototype.onDestroy = function () {
this.skill && this.skill.destroy();
};
//#endregion
//#region public method
BlockData.prototype.addSkill = function (skill) {
this.skill = skill;
skill.onAddedToBlock();
};
BlockData.prototype.adJustHp = function (delta) {
if (delta < 0) {
//先只处理扣血
this._hp += delta;
if (this._hp > 0) {
var imgName = this.getImgName();
if (this._imgName != imgName) {
this._imgName = imgName;
this._IView.onImgChanged();
}
SoundManager_1.SoundManager.ins.playEffect(Global_1.SoundName.HIT);
}
if (this._hp <= 0) {
this._hp = 0;
this.dead();
}
}
};
BlockData.prototype.setIsProtected = function (value) {
if (this._isProtected != value) {
this._isProtected = value;
}
};
//#endregion
//#region child override
BlockData.prototype.cloneValue = function (target) {
_super.prototype.cloneValue.call(this, target);
target._hp = this._hp;
// target._skillImgName = this._skillImgName;
target._contentY = this._contentY;
if (this.skill) {
target.skill = this.skill;
target.skill.owner = target; //指向新的格子
target.skill.onAddedToBlock(); //重新触发一下
}
return target;
};
BlockData.prototype.getImgName = function () {
return BlockColorTableMgr_1.BlockColorTableMgr.ins.getByHp(this._hp).Img;
};
BlockData.prototype.setGridPos = function (gridX, gridY) {
this.map.blockData.delete(this.index); //删除旧索引
// super.setGridPos(gridX, gridY, false);
_super.prototype.setGridPos.call(this, gridX, gridY);
this.map.blockData.set(this.index, this); //增加新索引
this._contentY = this.gridPos.y;
};
return BlockData;
}(ObjData_1.ObjData));
exports.BlockData = BlockData;
cc._RF.pop();