getToolboxItems;48的怪物上16像素透明
This commit is contained in:
1 parent
fa7f6ab764
commit
ea2fdb2887
9 files changed
+80
-36
No files matched your search
+9
-9
@@ -1346,8 +1346,8 @@ actions.prototype._keyUpQuickShop = function (keycode) {
|
||||
|
||||
////// 工具栏界面时的点击操作 //////
|
||||
actions.prototype._clickToolbox = function (x, y) {
|
||||
var tools = core.getDisplayItemsInToolbox('tools'),
|
||||
constants = core.getDisplayItemsInToolbox('constants');
|
||||
var tools = core.getToolboxItems('tools'),
|
||||
constants = core.getToolboxItems('constants');
|
||||
|
||||
// 装备栏
|
||||
if (x >= this.LAST - 2 && y == 0) {
|
||||
@@ -1400,8 +1400,8 @@ actions.prototype._clickToolbox = function (x, y) {
|
||||
|
||||
////// 选择工具栏界面中某个Index后的操作 //////
|
||||
actions.prototype._clickToolboxIndex = function (index) {
|
||||
var tools = core.getDisplayItemsInToolbox('tools'),
|
||||
constants = core.getDisplayItemsInToolbox('constants');
|
||||
var tools = core.getToolboxItems('tools'),
|
||||
constants = core.getToolboxItems('constants');
|
||||
|
||||
var items = null;
|
||||
var select;
|
||||
@@ -1431,8 +1431,8 @@ actions.prototype._keyDownToolbox = function (keycode) {
|
||||
|
||||
var last_index = this.LAST - 1;
|
||||
|
||||
var tools = core.getDisplayItemsInToolbox('tools'),
|
||||
constants = core.getDisplayItemsInToolbox('constants');
|
||||
var tools = core.getToolboxItems('tools'),
|
||||
constants = core.getToolboxItems('constants');
|
||||
var index = core.status.event.selection;
|
||||
var toolsPage = core.status.event.data.toolsPage;
|
||||
var constantsPage = core.status.event.data.constantsPage;
|
||||
@@ -1565,7 +1565,7 @@ actions.prototype._clickEquipbox = function (x, y) {
|
||||
}
|
||||
// 下一页
|
||||
if ((x == this.HSIZE+2 || x == this.HSIZE+3) && y == this.LAST) {
|
||||
var lastPage = Math.ceil(Object.keys(core.status.hero.items.equips).length / this.LAST);
|
||||
var lastPage = Math.ceil(core.getToolboxItems('equips').length / this.LAST);
|
||||
if (core.status.event.data.page < lastPage) {
|
||||
core.status.event.data.page++;
|
||||
core.ui.drawEquipbox(core.status.event.selection);
|
||||
@@ -1601,7 +1601,7 @@ actions.prototype._clickEquipboxIndex = function (index) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var equips = Object.keys(core.status.hero.items.equips || {}).sort();
|
||||
var equips = core.getToolboxItems('equips');
|
||||
if (index == core.status.event.selection) {
|
||||
if (core.isReplaying()) return;
|
||||
var equipId = equips[index - this.LAST + (core.status.event.data.page - 1) * this.LAST];
|
||||
@@ -1619,7 +1619,7 @@ actions.prototype._keyDownEquipbox = function (keycode) {
|
||||
var last_index = this.LAST - 1;
|
||||
var per_line = this.HSIZE - 3;
|
||||
var equipCapacity = core.status.globalAttribute.equipName.length;
|
||||
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
|
||||
var ownEquipment = core.getToolboxItems('equips');
|
||||
var index = core.status.event.selection;
|
||||
var page = core.status.event.data.page;
|
||||
var totalPage = Math.ceil(ownEquipment.length / this.LAST);
|
||||
|
||||
+3
-3
@@ -1486,8 +1486,8 @@ control.prototype._replayAction_item = function (action) {
|
||||
core.useItem(itemId, false, core.replay);
|
||||
return true;
|
||||
}
|
||||
var tools = core.getDisplayItemsInToolbox('tools'),
|
||||
constants = core.getDisplayItemsInToolbox('constants');
|
||||
var tools = core.getToolboxItems('tools'),
|
||||
constants = core.getToolboxItems('constants');
|
||||
var index, per = core.__SIZE__-1;
|
||||
if ((index=tools.indexOf(itemId))>=0) {
|
||||
core.status.event.data = {"toolsPage": Math.floor(index/per)+1, "constantsPage":1};
|
||||
@@ -1509,7 +1509,7 @@ control.prototype._replayAction_item = function (action) {
|
||||
control.prototype._replayAction_equip = function (action) {
|
||||
if (action.indexOf("equip:")!=0) return false;
|
||||
var equipId = action.substring(6);
|
||||
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
|
||||
var ownEquipment = core.getToolboxItems('equips');
|
||||
var index = ownEquipment.indexOf(equipId), per = core.__SIZE__-1;
|
||||
if (index<0) return false;
|
||||
core.status.route.push(action);
|
||||
|
||||
@@ -207,12 +207,6 @@ items.prototype.removeItem = function (itemId, itemNum) {
|
||||
return true;
|
||||
}
|
||||
|
||||
////// 获得所有应该在道具栏显示的某个类型道具 //////
|
||||
items.prototype.getDisplayItemsInToolbox = function (cls) {
|
||||
return Object.keys(core.status.hero.items[cls])
|
||||
.filter(function (id) { return !core.material.items[id].hideInToolbox; }).sort();
|
||||
}
|
||||
|
||||
// ---------- 装备相关 ------------ //
|
||||
|
||||
items.prototype.getEquipTypeByName = function (name) {
|
||||
|
||||
+45
-10
@@ -1919,6 +1919,18 @@ ui.prototype._drawBook_drawOne = function (floorId, index, enemy, pageinfo, sele
|
||||
core.strokeRoundRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, 10, core.status.globalAttribute.selectColor);
|
||||
}
|
||||
|
||||
ui.prototype._drawBook_is32x32 = function (blockInfo) {
|
||||
// 判定48的怪物上半部分是否是全透明
|
||||
var height = blockInfo.height - 32;
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 32; canvas.height = height;
|
||||
var ctx = canvas.getContext("2d");
|
||||
core.drawImage(ctx, blockInfo.image, 0, blockInfo.posY * blockInfo.height, 32, height, 0, 0, 32, height);
|
||||
var url = canvas.toDataURL();
|
||||
core.clearMap(ctx);
|
||||
return url == canvas.toDataURL();
|
||||
}
|
||||
|
||||
ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) {
|
||||
// 横向:22+42;纵向:10 + 42 + 10(正好居中);内部图像 32x32
|
||||
var border_top = top + (pageinfo.per_height - 42) / 2, border_left = 22;
|
||||
@@ -1926,13 +1938,26 @@ ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) {
|
||||
core.strokeRect('ui', 22, border_top, 42, 42, '#DDDDDD', 2);
|
||||
var blockInfo = core.getBlockInfo(enemy.id);
|
||||
if (blockInfo.height >= 42) {
|
||||
var drawWidth = 42 * 32 / blockInfo.height;
|
||||
core.status.boxAnimateObjs.push({
|
||||
'bgx': border_left, 'bgy': border_top, 'bgWidth': 42, 'bgHeight': 42,
|
||||
'x': img_left - 5 + (42 - drawWidth) / 2, 'y': img_top - 5, 'dw': drawWidth, 'dh': 42,
|
||||
'height': blockInfo.height, 'animate': blockInfo.animate,
|
||||
'image': blockInfo.image, 'pos': blockInfo.posY * blockInfo.height
|
||||
});
|
||||
var originEnemy = core.material.enemys[enemy.id] || {};
|
||||
// 检查上半部分是不是纯透明的;取用原始值避免重复计算
|
||||
if (originEnemy.is32x32 == null) {
|
||||
originEnemy.is32x32 = this._drawBook_is32x32(blockInfo);
|
||||
}
|
||||
if (originEnemy.is32x32) {
|
||||
core.status.boxAnimateObjs.push({
|
||||
'bgx': border_left, 'bgy': border_top, 'bgWidth': 42, 'bgHeight': 42,
|
||||
'x': img_left, 'y': img_top, 'height': 32, 'animate': blockInfo.animate,
|
||||
'image': blockInfo.image, 'pos': blockInfo.posY * blockInfo.height + blockInfo.height - 32
|
||||
});
|
||||
} else {
|
||||
var drawWidth = 42 * 32 / blockInfo.height;
|
||||
core.status.boxAnimateObjs.push({
|
||||
'bgx': border_left, 'bgy': border_top, 'bgWidth': 42, 'bgHeight': 42,
|
||||
'x': img_left - 5 + (42 - drawWidth) / 2, 'y': img_top - 5, 'dw': drawWidth, 'dh': 42,
|
||||
'height': blockInfo.height, 'animate': blockInfo.animate,
|
||||
'image': blockInfo.image, 'pos': blockInfo.posY * blockInfo.height
|
||||
});
|
||||
}
|
||||
} else {
|
||||
core.status.boxAnimateObjs.push({
|
||||
'bgx': border_left, 'bgy': border_top, 'bgWidth': 42, 'bgHeight': 42,
|
||||
@@ -2377,13 +2402,23 @@ ui.prototype.drawToolbox = function(index) {
|
||||
core.fillText('ui', '返回游戏', this.PIXEL - 46, this.PIXEL - 13);
|
||||
}
|
||||
|
||||
////// 获得所有应该在道具栏显示的某个类型道具 //////
|
||||
ui.prototype.getToolboxItems = function (cls) {
|
||||
if (this.uidata.getToolboxItems) {
|
||||
return this.uidata.getToolboxItems(cls);
|
||||
}
|
||||
return Object.keys(core.status.hero.items[cls] || {})
|
||||
.filter(function (id) { return !core.material.items[id].hideInToolbox; })
|
||||
.sort();
|
||||
}
|
||||
|
||||
ui.prototype._drawToolbox_getInfo = function (index) {
|
||||
// 设定eventdata
|
||||
if (!core.status.event.data || core.status.event.data.toolsPage == null)
|
||||
core.status.event.data = {"toolsPage":1, "constantsPage":1, "selectId":null}
|
||||
// 获取物品列表
|
||||
var tools = core.getDisplayItemsInToolbox('tools'),
|
||||
constants = core.getDisplayItemsInToolbox('constants');
|
||||
var tools = core.getToolboxItems('tools'),
|
||||
constants = core.getToolboxItems('constants');
|
||||
// 处理页数
|
||||
var toolsPage = core.status.event.data.toolsPage;
|
||||
var constantsPage = core.status.event.data.constantsPage;
|
||||
@@ -2510,7 +2545,7 @@ ui.prototype._drawEquipbox_getInfo = function (index) {
|
||||
var equipLength = allEquips.length;
|
||||
if (!core.status.hero.equipment) core.status.hero.equipment = [];
|
||||
var equipEquipment = core.status.hero.equipment;
|
||||
var ownEquipment = Object.keys(core.status.hero.items.equips).sort();
|
||||
var ownEquipment = core.getToolboxItems('equips');
|
||||
var page = core.status.event.data.page;
|
||||
var totalPage = Math.ceil(ownEquipment.length / this.LAST);
|
||||
// 处理index
|
||||
|
||||
Reference in new issue
Block a user