SpliterObj.ts
1.85 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
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;
}
}