import FSprite from "../object/FSprite"; import BObject from "./BObject"; /** * 炸弹 */ const { ccclass, property } = cc._decorator; @ccclass export default class BBObject extends BObject { private isOver = false onBeginContact(contact: cc.PhysicsContact, self, other) { if(this.isOver){ return } if (self.node == this.node) { if (other.tag != 0) { } else if (other.node.group == 'map') {//撞到地图 this.isOver = true this.__destroy() } else { if (this.sprite && this.sprite.isValid && this.sprite.hp > 0 && this.sprite.node.group != other.node.group) { if (self.isValid && other.node.isValid) { this.isOver = true this.__destroy() } } } } } public __destroy() { super.__destroy() this.roundHit() } /** * 炸开后周围受到伤害 */ public roundHit() { let ff = this.sprite.ff let mGroup = this.sprite.getEnemyGroup(); let nodes = ff.mMap.getSprites(); for (let i = 0; i < nodes.length; i++) { const node = nodes[i]; let target = node.getComponent(FSprite); if (target && node.active && target.isActive && target.hp > 0 && target.node.group == mGroup) { let dis = cc.Vec2.distance(this.node.getPosition(), node.getPosition()); if (dis < 300) { if (target.hp > 0) { if (target != null && target.isActive) { this.sprite.atkjs(target, this._skillData); super.__destroy() } } } } } } }