canEquip -> equipCondition

This commit is contained in:
oc 2019-04-30 20:22:06 +08:00
parent 9264e7dfe5
commit 2426c8b010
4 changed files with 36 additions and 7 deletions

View File

@ -224,7 +224,11 @@ function () {
- 清晰明了。很容易方便知道自己修改过什么,尤其是可以和系统原有代码进行对比。 - 清晰明了。很容易方便知道自己修改过什么,尤其是可以和系统原有代码进行对比。
- 方便整理成新的插件,给其他的塔使用。 - 方便整理成新的插件,给其他的塔使用。
如果我想对xxx文件中的yyy函数进行重写其模式一般是`core.xxx.yyy = function (参数列表) { ... }` 一般而言,复写规则如下:
**对xxx文件中的yyy函数进行复写规则是`core.xxx.yyy = function (参数列表) { ... }`。**
但是,对于`registerXXX`所注册的函数是无效的,例如直接复写`core.control._animationFrame_globalAnimate`函数是没有效果的。对于这种情况引入的函数,需要注册同名函数,可参见最下面的样例。
下面是几个例子,从简单到复杂。 下面是几个例子,从简单到复杂。
@ -317,6 +321,32 @@ core.maps.drawMap = function (floorId, callback) {
详见[call和apply的用法](https://www.jianshu.com/p/80ea0d1c04f8)。 详见[call和apply的用法](https://www.jianshu.com/p/80ea0d1c04f8)。
### 复写全局动画绘制函数
全局动画绘制在`control.js`的`_animationFrame_globalAnimate`函数。
注意到此函数是由`registerAnimationFrame`注册的,因此直接复写是无效的。
其在control.js的注册的定义如下
```js
// 注册全局动画函数
this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
```
因此,可以在插件中自行注册一个**同名**的函数来覆盖原始的内容。
```js
// 插件中复写全局动画绘制函数
this.myGlobalAnimate = function (timestamp) {
// ...... 实际复写的函数内容
}
// 注册同名globalAnimate函数来覆盖系统原始内容
core.registerAnimationFrame("globalAnimate", true, "myGlobalAnimate");
```
========================================================================================== ==========================================================================================
[继续阅读下一章API列表](api) [继续阅读下一章API列表](api)

View File

@ -81,12 +81,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_lint": true, "_lint": true,
"_data": "当前能否使用该道具仅对cls为tools或constants有效。" "_data": "当前能否使用该道具仅对cls为tools或constants有效。"
}, },
"canEquip": { "equipCondition": {
"_leaf": true, "_leaf": true,
"_type": "textarea", "_type": "textarea",
"_string": true, "_string": true,
"_lint": true, "_lint": true,
"_data": "当前装备某个装备仅对cls为equips有效。\n与canUseItemEffect不同这里null代表可以装备。" "_data": "能装备某个装备的条件仅对cls为equips有效。\n与canUseItemEffect不同这里null代表可以装备。"
} }
} }
}, },

View File

@ -189,7 +189,6 @@ control.prototype._animationFrame_animate = function (timestamp) {
control.prototype._animationFrame_heroMoving = function (timestamp) { control.prototype._animationFrame_heroMoving = function (timestamp) {
if (core.status.heroMoving <= 0) return; if (core.status.heroMoving <= 0) return;
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
// 换腿 // 换腿
if (timestamp - core.animateFrame.moveTime > (core.values.moveSpeed||100)) { if (timestamp - core.animateFrame.moveTime > (core.values.moveSpeed||100)) {
core.animateFrame.leftLeg = !core.animateFrame.leftLeg; core.animateFrame.leftLeg = !core.animateFrame.leftLeg;

View File

@ -11,9 +11,9 @@ items.prototype._init = function () {
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip; this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect; this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEffect;
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect; this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip) if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition)
items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip = {}; items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition = {};
this.equipCondition = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canEquip; this.equipCondition = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition;
} }
////// 获得所有道具 ////// ////// 获得所有道具 //////