77f6830a-26ee-4b84-8293-064a84753aa9.js
6.09 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
cc._RF.push(module, '77f68MKJu5LhIKTBkqEdTqp', 'LaserView');
// scripts/prefabs/LaserView.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var BattleConst_1 = require("../kernel/battle/BattleConst");
var BattleManager_1 = require("../kernel/battle/BattleManager");
var ObjBaseView_1 = require("./ObjBaseView");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var LaserView = /** @class */ (function (_super) {
__extends(LaserView, _super);
function LaserView() {
return _super !== null && _super.apply(this, arguments) || this;
}
//#region interface
LaserView.prototype.onHit = function () {
var ani = this._effect.getComponent(cc.Animation);
!ani.getAnimationState('ani_yxz_tsfk_jg02').isPlaying && ani.play('ani_yxz_tsfk_jg02', 0);
if (this._laser) {
!this._laser.active && (this._laser.active = true);
var laserAni = this._laser.getComponent(cc.Animation);
!laserAni.getAnimationState('fx_laser_02').isPlaying && laserAni.play('fx_laser_02', 0);
}
if (this._vLaser) {
!this._vLaser.active && (this._vLaser.active = true);
var laserAni = this._vLaser.getComponent(cc.Animation);
!laserAni.getAnimationState('fx_laser_02').isPlaying && laserAni.play('fx_laser_02', 0);
}
};
//#endregion
//#region LIFE-CYCLE CALLBACKS:
LaserView.prototype.init = function (owner, mapView) {
var _this = this;
var laserObj = owner;
if (laserObj.dir == BattleConst_1.LASER_DIR.HORIZEN || laserObj.dir == BattleConst_1.LASER_DIR.COMBINE) {
this._laser = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('laser'));
this._laser.scaleX = mapView.width / this._laser.width;
this._laser.active = false;
var laserAni = this._laser.getComponent(cc.Animation);
laserAni.on('finished', function () { _this._laser.active = false; }, this);
}
if (laserObj.dir == BattleConst_1.LASER_DIR.VERTICAL || laserObj.dir == BattleConst_1.LASER_DIR.COMBINE) {
this._vLaser = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('laser'));
this._vLaser.scaleX = mapView.height / this._vLaser.width;
this._vLaser.angle = 90;
this._vLaser.active = false;
var vlaserAni = this._vLaser.getComponent(cc.Animation);
vlaserAni.on('finished', function () { _this._vLaser.active = false; }, this);
}
this._effect = this.node.getChildByName('UI_yxz_tsfk_jg2');
this._effect.removeFromParent();
_super.prototype.init.call(this, owner, mapView);
this._img.active = false;
mapView.effectLayer.addChild(this._effect);
this._laser && mapView.effectLayer.addChild(this._laser);
this._vLaser && mapView.effectLayer.addChild(this._vLaser);
BattleManager_1.BattleManager.ins.eventNode.on(BattleConst_1.BattleEvent.BATTLE_START, this.onBattleStart, this);
};
LaserView.prototype.onPositionChange = function (x, y) {
_super.prototype.onPositionChange.call(this, x, y);
this._effect.setPosition(x, y);
this._laser && this._laser.setPosition(0, y);
this._vLaser && this._vLaser.setPosition(x, 0);
};
LaserView.prototype.onVisibleChange = function () {
this._img.active = false; //图片一直隐藏
};
LaserView.prototype.onDestroy = function () {
BattleManager_1.BattleManager.ins.eventNode.off(BattleConst_1.BattleEvent.BATTLE_START, this.onBattleStart, this);
this._effect.destroy();
this._laser && this._laser.destroy();
this._vLaser && this._vLaser.destroy();
};
LaserView.prototype.onImageLoaded = function () {
var _this = this;
//更新特效的图片
this._effect.getChildByName('UI_yxz_tsfk_jg2').getComponent(cc.Sprite).spriteFrame = this._img.getComponent(cc.Sprite).spriteFrame;
cc.resources.load('battle/' + this.owner.imgName + 'a', cc.SpriteFrame, function (error, asset) {
if (!_this._destroyed) {
_this._effect.getChildByName('UI_yxz_tsfk_jg2a').getComponent(cc.Sprite).spriteFrame = asset;
}
});
};
// update (dt) {}
//#endregion
LaserView.prototype.onBattleStart = function () {
var ani = this._effect.getComponent(cc.Animation);
ani.play("ani_yxz_tsfk_jg01", 0);
};
LaserView = __decorate([
ccclass
], LaserView);
return LaserView;
}(ObjBaseView_1.default));
exports.default = LaserView;
cc._RF.pop();