import { tMgr } from "../../../Global"; import { TableName, GamePlayTable } from "../../table/TableDefine"; import { ObjType } from "../BattleConst"; import { MapData } from "./MapData"; import { ObjData } from "./ObjData"; export class SpliterObj extends ObjData { private _speedVec: cc.Vec2 = cc.v2(0, 32); private _cacheVec: cc.Vec2 = cc.v2(); private _hit: boolean = false; private _randomRange: number[] = []; init(map: MapData, type: ObjType, gridX: number, gridY: number): void { super.init(map, type, gridX, gridY); this._imgName = 'UI_yxz_tsfk_ss'; // let speed = this.map.battle.getPhysiceBallSpeed(); //预览时没有battle // this._speedVec.y = speed; let rad = slib.MathUtil.getRadianByDegree(60); this._randomRange.push(-rad, rad); } onCollisonToBall(collider: cc.Collider): void { super.onCollisonToBall(collider); if (!this._hit) { this._hit = true; this.map.battle.addToRoundClear(this); } let speed = this.map.battle.getPhysiceBallSpeed(); // let speed = (tMgr.getConfig(TableName.GAME_PLAY, 3) as GamePlayTable).Value; this._speedVec.y = speed; let rad = Math.random() * (this._randomRange[1] - this._randomRange[0]) + this._randomRange[0]; this._speedVec.rotate(rad, this._cacheVec); collider.node.getComponent(cc.RigidBody).linearVelocity = this._cacheVec; } clone(): SpliterObj { return this.cloneValue(new SpliterObj()); } protected cloneValue(target: SpliterObj): SpliterObj { super.cloneValue(target); target._hit = this._hit; target._speedVec.set(this._speedVec); for (let i = 0; i < this._randomRange.length; ++i) { target._randomRange.push(this._randomRange[i]); } return target; } }