139 lines
3.2 KiB
JavaScript
139 lines
3.2 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'eb82fgOOEZPkLvsoGFKvxe/', 'cmp.adventure.role');
|
|
// Scripts/mod/pve/adventure/cmp/cmp.adventure.role.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 歼星迷途角色
|
|
*
|
|
******************************************************************/
|
|
|
|
var FxSpine = require("nx.fx.spine");
|
|
var ACTION_WALK = "float";
|
|
var ACTION_IDLE = "stand2";
|
|
var DEF_MODEL = "H30072";
|
|
cc.Class({
|
|
"extends": cc.Component,
|
|
properties: {
|
|
spAnim: {
|
|
"default": null,
|
|
type: FxSpine
|
|
},
|
|
spEft: {
|
|
"default": null,
|
|
type: FxSpine
|
|
},
|
|
spBuff: {
|
|
"default": null,
|
|
type: FxSpine
|
|
},
|
|
methyStatus: 0 //中毒状态 默认0
|
|
},
|
|
|
|
// 设定角色
|
|
setModel: function setModel(_model, _cb) {
|
|
var _this = this;
|
|
this.points = [];
|
|
this.cbEvent = _cb;
|
|
var model = _model || DEF_MODEL;
|
|
var path = PathTool.getSpinePath(model, model, false);
|
|
this.spAnim.load(path, function (_e) {
|
|
if (!_e) {
|
|
_this.spAnim.action(ACTION_IDLE, true);
|
|
}
|
|
});
|
|
},
|
|
setMethyStatus: function setMethyStatus(in_methy) {
|
|
var _this2 = this;
|
|
this.methyStatus = in_methy;
|
|
if (in_methy == 1) {
|
|
var path = PathTool.getSpinePath("E66002", null, false);
|
|
this.spEft.load(path, function (_e) {
|
|
if (!_e) {
|
|
_this2.spEft.action("action", true);
|
|
} else {
|
|
_this2.spEft.stop();
|
|
}
|
|
});
|
|
} else {
|
|
this.spEft.stop();
|
|
}
|
|
},
|
|
setBuffEft: function setBuffEft(eft_id) {
|
|
var _this3 = this;
|
|
if (!eft_id || eft_id == "") {
|
|
return;
|
|
//return this.setMethyStatus(0);
|
|
}
|
|
|
|
var spath = PathTool.getSpinePath(eft_id, null, false);
|
|
this.spBuff.load(spath, function (_e) {
|
|
if (!_e) {
|
|
_this3.spBuff.action("action", false, function (_key, _name) {
|
|
// if(_key == "complete"){
|
|
// this.setMethyStatus(this.methyStatus);
|
|
// return;
|
|
// }
|
|
});
|
|
} else {
|
|
_this3.spBuff.stop();
|
|
}
|
|
});
|
|
},
|
|
// 设置位置
|
|
setPosition: function setPosition(_pos) {
|
|
cc.Tween.stopAllByTarget(this);
|
|
this.node.position(_pos);
|
|
this.points = [];
|
|
},
|
|
// 移动路径
|
|
pushPaths: function pushPaths(_pts, _reset) {
|
|
if (_reset === void 0) {
|
|
_reset = true;
|
|
}
|
|
// 空路径
|
|
if (nx.dt.arrEmpty(_pts)) {
|
|
return;
|
|
}
|
|
if (_reset) {
|
|
this.cur = null;
|
|
this.points = [];
|
|
cc.Tween.stopAllByTarget(this.node);
|
|
}
|
|
this.points = this.points.concat(_pts);
|
|
|
|
// 下一步
|
|
this.toNext();
|
|
},
|
|
// 下一步
|
|
toNext: function toNext() {
|
|
var _this4 = this;
|
|
// 到底
|
|
if (nx.dt.arrEmpty(this.points)) {
|
|
nx.dt.fnInvoke(this.cbEvent, "end");
|
|
this.spAnim.action(ACTION_IDLE, true);
|
|
return;
|
|
}
|
|
|
|
// 开始
|
|
if (!this.cur) {
|
|
nx.dt.fnInvoke(this.cbEvent, "start");
|
|
}
|
|
this.spAnim.action(ACTION_WALK, true);
|
|
this.cur = this.points.shift();
|
|
cc.tween(this.node).to(0.5, {
|
|
position: this.cur
|
|
}).call(function () {
|
|
nx.dt.fnInvoke(_this4.cbEvent, "move");
|
|
_this4.toNext();
|
|
}).start();
|
|
|
|
// 方向调整
|
|
var pos = this.node.position;
|
|
this.spAnim.node.scaleX = this.cur.x < pos.x ? -1 : 1;
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |