import { SoundManager } from "../../../component/SoundManager"; import { SoundName } from "../../../Global"; import { LASER_DIR, ObjType } from "../BattleConst"; import { MapData } from "./MapData"; import { ObjData } from "./ObjData"; export class LaserObj extends ObjData { private _dir: LASER_DIR = LASER_DIR.NONE; get dir(): LASER_DIR { return this._dir; } //#region life cycle init(map: MapData, type: ObjType, gridX: number, gridY: number): void { super.init(map, type, gridX, gridY); if (type == ObjType.LANCER_1) { this._dir = LASER_DIR.VERTICAL; this._imgName = 'UI_yxz_tsfk_jg1'; } else if (type == ObjType.LANCER_2) { this._dir = LASER_DIR.HORIZEN; this._imgName = 'UI_yxz_tsfk_jg2'; } else if (type == ObjType.LANCER_3) { this._dir = LASER_DIR.COMBINE; this._imgName = 'UI_yxz_tsfk_jg3'; } } clone(): LaserObj { return this.cloneValue(new LaserObj()); } protected cloneValue(target: LaserObj): LaserObj { super.cloneValue(target); target._dir = this._dir; return target; } //#endregion //#region public method //#endregion //#region event onCollisonToBall(collider: cc.Collider): void { super.onCollisonToBall(collider); this.map.battle.addToRoundClear(this); if (this._dir == LASER_DIR.HORIZEN || this._dir == LASER_DIR.COMBINE) { for (let x: number = 0; x < this.map.mapGridSize.x; ++x) { let block = this.map.getBlockByGridPos(x, this.gridPos.y); if (block) { block.onCollisonToBall(null); // if (block instanceof RectBlockData) { // // block.widthGrid // x += (block.widthGrid - 1); //跳过宽度 // } } } } if (this._dir == LASER_DIR.VERTICAL || this._dir == LASER_DIR.COMBINE) { for (let y: number = 0; y < this.map.mapGridSize.y; ++y) { let block = this.map.getBlockByGridPos(this.gridPos.x, y); if (block) { block.onCollisonToBall(null); // if (block instanceof RectBlockData) { // // block.widthGrid // y += (block.heightGrid - 1); //跳过宽度 // } } } } SoundManager.ins.playEffect(SoundName.RAZER); } //#endregion //#region private method //#endregion }