BlockSkillBomb.ts
1.41 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
import { SoundManager } from "../../../../component/SoundManager";
import { SoundName } from "../../../../Global";
import { BlockSkill } from "../../BattleConst";
import { BlockData } from "../BlockData";
import { BlockSkillBase } from "./BlockSkillBase";
export class BlockSkillBomb extends BlockSkillBase {
constructor(owner: BlockData) {
super(BlockSkill.BOMB, owner);
}
onDead(): void {
super.onDead();
if (this.enable) {
let startX = slib.MathUtil.clamp(this.owner.gridPos.x - 1, 0, this.owner.map.mapGridSize.x - 1);
let endX = slib.MathUtil.clamp(this.owner.gridPos.x + 1, 0, this.owner.map.mapGridSize.x - 1);
let startY = slib.MathUtil.clamp(this.owner.gridPos.y - 1, 0, this.owner.map.mapGridSize.y - 1);
let endY = slib.MathUtil.clamp(this.owner.gridPos.y + 1, 0, this.owner.map.mapGridSize.y - 1);
for (let x = startX; x <= endX; ++x) {
for (let y = startY; y <= endY; ++y) {
let block = this.owner.map.getBlockByGridPos(x, y);
if (!block || block.uid == this.owner.uid) {
continue;
}
//消除周围的格子
if (block) {
block.dead();
}
}
}
SoundManager.ins.playEffect(SoundName.BOMB);
}
}
}