multi equipments

This commit is contained in:
oc 2019-01-21 23:19:49 +08:00
parent fb8145a9f4
commit a2018b50ba
8 changed files with 99 additions and 24 deletions

View File

@ -1808,8 +1808,8 @@ Floor_Meta_List
/*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/; /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/;
Global_Attribute_List Global_Attribute_List
: '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'难度显示文字色'|'楼层转换背景'|'楼层转换文字色' : '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'难度显示文字色'|'楼层转换背景'|'楼层转换文字色'|'装备列表'
/*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'hardLabelColor', 'floorChangingBackground', 'floorChangingTextColor']*/; /*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'hardLabelColor', 'floorChangingBackground', 'floorChangingTextColor', 'equipName']*/;
Global_Value_List Global_Value_List
: '血网伤害'|'中毒伤害'|'衰弱效果'|'红宝石效果'|'蓝宝石效果'|'绿宝石效果'|'红血瓶效果'|'蓝血瓶效果'|'黄血瓶效果'|'绿血瓶效果'|'破甲比例'|'反击比例'|'净化比例'|'仇恨增加值'|'行走速度'|'动画时间'|'楼层切换时间' : '血网伤害'|'中毒伤害'|'衰弱效果'|'红宝石效果'|'蓝宝石效果'|'绿宝石效果'|'红血瓶效果'|'蓝血瓶效果'|'黄血瓶效果'|'绿血瓶效果'|'破甲比例'|'反击比例'|'净化比例'|'仇恨增加值'|'行走速度'|'动画时间'|'楼层切换时间'

View File

@ -85,6 +85,30 @@ percentage为该装备是否按比例增加属性。
更多相关API详见[附录API列表](api)。 更多相关API详见[附录API列表](api)。
### 多重装备
从V2.5.4开始,允许支持多重装备,即有若干的装备可共用若干的格子(例如永不复还那样)。
要实现这一点,上面的写法有所改变。
在全塔属性中的`equipName`项写法不变不过可以写重复的装备孔名称。但仍然最多只能写6个
``` js
"equipName": ["武器", "武器", "武器", "防具", "防具", "首饰"]
```
然后对于某个装备,将其`type`(装备类型)写对应的装备孔名称即可。
``` js
{"type": "武器", "atk": 20, "def": 0, ...}
```
这样写的话,则所有该名称的装备孔均可装上此装备。
当尝试装上此装备时,会取最小的一个空的装备孔进行装备。如果没有空闲的装备孔,则会提示“请先卸下装备”。
装备动画仍然会取第一个装备类型为0的装备的`animate`项,即使装备了多个有动画的武器。
## 门 ## 门
本塔支持6种门黄蓝红绿铁花。前五种门需要有对应的钥匙打开花门只能通过调用`openDoor`事件进行打开。 本塔支持6种门黄蓝红绿铁花。前五种门需要有对应的钥匙打开花门只能通过调用`openDoor`事件进行打开。

View File

@ -1539,7 +1539,7 @@ actions.prototype.clickEquipbox = function(x,y) {
////// 选择装备栏界面中某个Index后的操作 ////// ////// 选择装备栏界面中某个Index后的操作 //////
actions.prototype.clickEquipboxIndex = function(index) { actions.prototype.clickEquipboxIndex = function(index) {
if (index<6) { if (index<6) {
if (index>=(main.equipName||[]).length) return; if (index>=core.status.globalAttribute.equipName.length) return;
if (index==core.status.event.selection && core.isset(core.status.hero.equipment[index])) { if (index==core.status.event.selection && core.isset(core.status.hero.equipment[index])) {
core.unloadEquip(index); core.unloadEquip(index);
core.status.route.push("unEquip:"+index); core.status.route.push("unEquip:"+index);
@ -1560,7 +1560,7 @@ actions.prototype.clickEquipboxIndex = function(index) {
actions.prototype.keyDownEquipbox = function (keycode) { actions.prototype.keyDownEquipbox = function (keycode) {
if (!core.isset(core.status.event.data)) return; if (!core.isset(core.status.event.data)) return;
var equipCapacity = (main.equipName||[]).length; var equipCapacity = core.status.globalAttribute.equipName.length;
var ownEquipment = Object.keys(core.status.hero.items.equips).sort(); var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
var index = core.status.event.selection; var index = core.status.event.selection;
var page = core.status.event.data.page; var page = core.status.event.data.page;

View File

@ -2494,6 +2494,7 @@ control.prototype.hasSave = function (index) {
////// 设置勇士属性 ////// ////// 设置勇士属性 //////
control.prototype.setStatus = function (statusName, statusVal) { control.prototype.setStatus = function (statusName, statusVal) {
if (!core.isset(core.status.hero)) return;
if (statusName == 'exp') statusName = 'experience'; if (statusName == 'exp') statusName = 'experience';
if (core.isset(core.status.hero.loc[statusName])) if (core.isset(core.status.hero.loc[statusName]))
core.status.hero.loc[statusName] = statusVal; core.status.hero.loc[statusName] = statusVal;
@ -2503,6 +2504,7 @@ control.prototype.setStatus = function (statusName, statusVal) {
////// 获得勇士属性 ////// ////// 获得勇士属性 //////
control.prototype.getStatus = function (statusName) { control.prototype.getStatus = function (statusName) {
if (!core.isset(core.status.hero)) return null;
// support status:x // support status:x
if (core.isset(core.status.hero.loc[statusName])) if (core.isset(core.status.hero.loc[statusName]))
return core.status.hero.loc[statusName]; return core.status.hero.loc[statusName];
@ -2512,6 +2514,7 @@ control.prototype.getStatus = function (statusName) {
////// 获得某个等级的名称 ////// ////// 获得某个等级的名称 //////
control.prototype.getLvName = function () { control.prototype.getLvName = function () {
if (!core.isset(core.status.hero)) return null;
return ((core.firstData.levelUp||[])[core.status.hero.lv-1]||{}).title || core.status.hero.lv; return ((core.firstData.levelUp||[])[core.status.hero.lv-1]||{}).title || core.status.hero.lv;
} }
@ -2708,7 +2711,8 @@ control.prototype.clearStatusBar = function() {
////// 更新状态栏 ////// ////// 更新状态栏 //////
control.prototype.updateStatusBar = function () { control.prototype.updateStatusBar = function () {
this.controldata.updateStatusBar(); if (core.isPlaying())
this.controldata.updateStatusBar();
// 回放 // 回放
if (core.isReplaying()) { if (core.isReplaying()) {

View File

@ -177,6 +177,7 @@ function core() {
"time": 0, "time": 0,
}, },
"globalAttribute": { "globalAttribute": {
'equipName': main.equipName || [],
"statusLeftBackground": main.statusLeftBackground || "url(project/images/ground.png) repeat", "statusLeftBackground": main.statusLeftBackground || "url(project/images/ground.png) repeat",
"statusTopBackground": main.statusTopBackground || "url(project/images/ground.png) repeat", "statusTopBackground": main.statusTopBackground || "url(project/images/ground.png) repeat",
"toolsBackground": main.toolsBackground || "url(project/images/ground.png) repeat", "toolsBackground": main.toolsBackground || "url(project/images/ground.png) repeat",

View File

@ -1004,6 +1004,9 @@ events.prototype.doAction = function() {
if ((data.value.charAt(0)=='"' && data.value.charAt(data.value.length-1)=='"') if ((data.value.charAt(0)=='"' && data.value.charAt(data.value.length-1)=='"')
|| (data.value.charAt(0)=="'" && data.value.charAt(data.value.length-1)=="'")) || (data.value.charAt(0)=="'" && data.value.charAt(data.value.length-1)=="'"))
data.value = data.value.substring(1, data.value.length-1); data.value = data.value.substring(1, data.value.length-1);
// --- 检查 []
if (data.value.charAt(0) == '[' && data.value.charAt(data.value.length-1)==']')
data.value = eval(data.value);
} }
core.status.globalAttribute[data.name] = data.value; core.status.globalAttribute[data.name] = data.value;
core.control.updateGlobalAttribute(data.name); core.control.updateGlobalAttribute(data.name);

View File

@ -120,6 +120,7 @@ items.prototype.canUseItem = function (itemId) {
////// 获得某个物品的个数 ////// ////// 获得某个物品的个数 //////
items.prototype.itemCount = function (itemId) { items.prototype.itemCount = function (itemId) {
if (!core.isset(core.status.hero)) return 0;
if (!core.isset(itemId) || !core.isset(core.material.items[itemId])) return 0; if (!core.isset(itemId) || !core.isset(core.material.items[itemId])) return 0;
var itemCls = core.material.items[itemId].cls; var itemCls = core.material.items[itemId].cls;
if (itemCls=="items") return 0; if (itemCls=="items") return 0;
@ -128,25 +129,31 @@ items.prototype.itemCount = function (itemId) {
////// 是否存在某个物品 ////// ////// 是否存在某个物品 //////
items.prototype.hasItem = function (itemId) { items.prototype.hasItem = function (itemId) {
return core.itemCount(itemId) > 0; return this.itemCount(itemId) > 0;
} }
////// 是否装备某件装备 ////// ////// 是否装备某件装备 //////
items.prototype.hasEquip = function (itemId) { items.prototype.hasEquip = function (itemId) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(itemId)) return null; if (!core.isset(itemId)) return null;
if (!core.isset((core.material.items[itemId]||{}).equip)) return null; if (!core.isset((core.material.items[itemId]||{}).equip)) return null;
return this.getEquip(core.material.items[itemId].equip.type) == itemId; for (var i in core.status.hero.equipment||[])
if (core.status.hero.equipment[i] == itemId)
return true;
return false
} }
////// 获得某个装备类型的当前装备 ////// ////// 获得某个装备类型的当前装备 //////
items.prototype.getEquip = function (equipType) { items.prototype.getEquip = function (equipType) {
if (!core.isset(core.status.hero)) return null;
return (core.status.hero.equipment||[])[equipType]||null; return (core.status.hero.equipment||[])[equipType]||null;
} }
////// 设置某个物品的个数 ////// ////// 设置某个物品的个数 //////
items.prototype.setItem = function (itemId, itemNum) { items.prototype.setItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
itemNum = itemNum || 0; itemNum = itemNum || 0;
var itemCls = core.material.items[itemId].cls; var itemCls = core.material.items[itemId].cls;
if (itemCls == 'items') return; if (itemCls == 'items') return;
@ -163,6 +170,7 @@ items.prototype.setItem = function (itemId, itemNum) {
////// 删除某个物品 ////// ////// 删除某个物品 //////
items.prototype.removeItem = function (itemId, itemNum) { items.prototype.removeItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
itemNum = itemNum || 1; itemNum = itemNum || 1;
if (!core.hasItem(itemId)) return false; if (!core.hasItem(itemId)) return false;
var itemCls = core.material.items[itemId].cls; var itemCls = core.material.items[itemId].cls;
@ -177,6 +185,7 @@ items.prototype.removeItem = function (itemId, itemNum) {
////// 增加某个物品的个数 ////// ////// 增加某个物品的个数 //////
items.prototype.addItem = function (itemId, itemNum) { items.prototype.addItem = function (itemId, itemNum) {
if (!core.isset(core.status.hero)) return null;
itemNum = itemNum || 1; itemNum = itemNum || 1;
var itemData = core.material.items[itemId]; var itemData = core.material.items[itemId];
var itemCls = itemData.cls; var itemCls = itemData.cls;
@ -199,9 +208,19 @@ items.prototype.addItem = function (itemId, itemNum) {
core.updateStatusBar(); core.updateStatusBar();
} }
items.prototype.getEquipTypeByName = function (name) {
var names = core.status.globalAttribute.equipName;
for (var i = 0; i < names.length; ++i) {
if (names[i] === name && !core.isset((core.status.hero.equipment||[])[i])) {
return i;
}
}
return -1;
}
////// 换上 ////// ////// 换上 //////
items.prototype.loadEquip = function (equipId, callback) { items.prototype.loadEquip = function (equipId, callback) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = []; if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
@ -228,6 +247,16 @@ items.prototype.loadEquip = function (equipId, callback) {
core.playSound('equip.mp3'); core.playSound('equip.mp3');
var loadEquipType = loadEquip.equip.type; var loadEquipType = loadEquip.equip.type;
// ------ 判定多重装备 ------
if (typeof loadEquipType === 'string') {
loadEquipType = this.getEquipTypeByName(loadEquipType);
if (loadEquipType < 0) {
core.drawTip("当前没有"+loadEquip.equip.type+"的空位!");
return;
}
}
var unloadEquipId = core.status.hero.equipment[loadEquipType]; var unloadEquipId = core.status.hero.equipment[loadEquipType];
var unloadEquip = core.material.items[unloadEquipId] || {}; var unloadEquip = core.material.items[unloadEquipId] || {};
@ -272,6 +301,7 @@ items.prototype.loadEquip = function (equipId, callback) {
////// 卸下 ////// ////// 卸下 //////
items.prototype.unloadEquip = function (equipType, callback) { items.prototype.unloadEquip = function (equipType, callback) {
if (!core.isset(core.status.hero)) return null;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = []; if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
@ -343,7 +373,7 @@ items.prototype.quickLoadEquip = function (index) {
return; return;
} }
// 检查所有的装备 // 检查所有的装备
var equipSize = (main.equipName||[]).length; var equipSize = core.status.globalAttribute.equipName.length;
for (var i=0;i<equipSize;i++) { for (var i=0;i<equipSize;i++) {
var v = current[i]; var v = current[i];
if (core.isset(v) && !core.hasItem(v) && !core.hasEquip(v)) { if (core.isset(v) && !core.hasItem(v) && !core.hasEquip(v)) {
@ -364,14 +394,15 @@ items.prototype.quickLoadEquip = function (index) {
// 快速换装 // 快速换装
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = []; if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
for (var i=0;i<equipSize;i++) { for (var i=0;i<equipSize;i++) {
var now = core.status.hero.equipment[i]||null; var now = core.status.hero.equipment[i] || null;
var to = current[i]||null; if (now != null) {
if (now==to) continue;
if (to==null) {
this.unloadEquip(i); this.unloadEquip(i);
core.status.route.push("unEquip:"+i); core.status.route.push("unEquip:" + i);
} }
else { }
for (var i=0;i<equipSize;i++) {
var to = current[i]||null;
if (to!=null) {
this.loadEquip(to); this.loadEquip(to);
core.status.route.push("equip:"+to); core.status.route.push("equip:"+to);
} }

View File

@ -2107,7 +2107,7 @@ ui.prototype.drawEquipbox = function(index) {
if (!core.isset(core.status.event.data) || !core.isset(core.status.event.data.page)) if (!core.isset(core.status.event.data) || !core.isset(core.status.event.data.page))
core.status.event.data = {"page":1, "selectId":null}; core.status.event.data = {"page":1, "selectId":null};
var allEquips = main.equipName||[]; var allEquips = core.status.globalAttribute.equipName;
var equipLength = allEquips.length; var equipLength = allEquips.length;
if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = []; if (!core.isset(core.status.hero.equipment)) core.status.hero.equipment = [];
@ -2185,7 +2185,14 @@ ui.prototype.drawEquipbox = function(index) {
var equip=core.material.items[selectId]; var equip=core.material.items[selectId];
if (!core.isset(equip.equip)) equip.equip = {"type": 0}; if (!core.isset(equip.equip)) equip.equip = {"type": 0};
var equipType = equip.equip.type; var equipType = equip.equip.type;
core.fillText('ui', equip.name + "" + (allEquips[equipType]||"未知部位") + "", 10, 32, '#FFD700', "bold 20px "+globalFont) var equipString;
if (typeof equipType === 'string') {
equipString = equipType||"未知部位";
equipType = core.items.getEquipTypeByName(equipType);
}
else equipString = allEquips[equipType]||"未知部位";
core.fillText('ui', equip.name + "" + equipString + "", 10, 32, '#FFD700', "bold 20px "+globalFont)
var text = equip.text||"该装备暂无描述。"; var text = equip.text||"该装备暂无描述。";
var lines = core.splitLines('ui', text, 406, '17px '+globalFont); var lines = core.splitLines('ui', text, 406, '17px '+globalFont);
@ -2194,20 +2201,25 @@ ui.prototype.drawEquipbox = function(index) {
// 比较属性 // 比较属性
if (lines.length==1) { if (lines.length==1) {
var compare, differentMode = false; var compare, differentMode = null;
if (index<12) compare = core.compareEquipment(null, selectId); if (index<12) compare = core.compareEquipment(null, selectId);
else { else {
var last = core.material.items[equipEquipment[equipType]]||{}; if (equipType<0) {
// 检查是不是数值模式和比例模式之间的切换 differentMode = '<当前没有该装备的空位,请先卸下装备>';
if (core.isset(last.equip) && (last.equip.percentage||false) != (equip.equip.percentage||false)) {
differentMode = true;
} }
else { else {
compare = core.compareEquipment(selectId, equipEquipment[equipType]); var last = core.material.items[equipEquipment[equipType]]||{};
// 检查是不是数值模式和比例模式之间的切换
if (core.isset(last.equip) && (last.equip.percentage||false) != (equip.equip.percentage||false)) {
differentMode = '<数值和比例模式之间的切换不显示属性变化>';
}
else {
compare = core.compareEquipment(selectId, equipEquipment[equipType]);
}
} }
} }
if (differentMode) { if (differentMode != null) {
core.fillText('ui', '<数值和比例模式之间的切换不显示属性变化>', 10, 89, '#CCCCCC', '14px '+globalFont); core.fillText('ui', differentMode, 10, 89, '#CCCCCC', '14px '+globalFont);
} }
else { else {
var drawOffset = 10; var drawOffset = 10;