getToolboxItems;48的怪物上16像素透明
This commit is contained in:
parent
fa7f6ab764
commit
ea2fdb2887
@ -2608,10 +2608,6 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
||||
"!doc": "静默增减某种道具的持有量 不会更新游戏画面或是显示提示<br/>例如:core.addItem('yellowKey', -2) // 没收两把黄钥匙<br/>itemId: 道具id<br/>itemNum: 增加量,负数表示没收",
|
||||
"!type": "fn(itemId: string, itemNum?: number)"
|
||||
},
|
||||
"getDisplayItemsInToolbox": {
|
||||
"!doc": "获得所有应该在道具栏显示的某个类型道具",
|
||||
"!type": "fn(cls: string) -> [string]"
|
||||
},
|
||||
"unloadEquip": {
|
||||
"!doc": "脱下某个类型的装备<br/>例如:core.unloadEquip(1) // 卸下盾牌,无回调<br/>equipType: 装备类型编号,自然数<br/>callback: 卸下装备后的回调函数",
|
||||
"!type": "fn(equipType: number, callback?: fn())"
|
||||
@ -3550,6 +3546,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
||||
"!doc": "绘制怪物属性的详细信息",
|
||||
"!type": "fn(index?: ?)"
|
||||
},
|
||||
"getToolboxItems": {
|
||||
"!doc": "获得所有应该在道具栏显示的某个类型道具",
|
||||
"!type": "fn(cls: string) -> [string]"
|
||||
},
|
||||
"drawToolbox": {
|
||||
"!doc": "绘制道具栏",
|
||||
"!type": "fn(index?: ?)"
|
||||
|
||||
@ -182,6 +182,12 @@ var functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"ui": {
|
||||
"_type": "object",
|
||||
"_data": {
|
||||
"getToolboxItems": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
"_lint": true,
|
||||
"_data": "道具栏显示项"
|
||||
},
|
||||
"drawStatusBar": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
41
libs/ui.js
41
libs/ui.js
@ -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,6 +1938,18 @@ 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 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,
|
||||
@ -1933,6 +1957,7 @@ ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) {
|
||||
'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
|
||||
|
||||
@ -1451,6 +1451,15 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"getToolboxItems": function (cls) {
|
||||
// 获得道具栏中当前某类型道具的显示项和显示顺序
|
||||
// cls为道具类型,只可能是 tools, constants 和 equips
|
||||
// 返回一个数组,代表当前某类型道具的显示内容和顺序
|
||||
|
||||
return Object.keys(core.status.hero.items[cls] || {})
|
||||
.filter(function (id) { return !core.material.items[id].hideInToolbox; })
|
||||
.sort();
|
||||
},
|
||||
"drawStatusBar": function () {
|
||||
// 自定义绘制状态栏,需要开启状态栏canvas化
|
||||
|
||||
|
||||
@ -1277,7 +1277,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
|
||||
}
|
||||
|
||||
// 获得所有应该在道具栏显示的某个类型道具
|
||||
core.items.getDisplayItemsInToolbox = function (cls) {
|
||||
core.ui.getToolboxItems = function (cls) {
|
||||
// 检查类别
|
||||
return Object.keys(core.status.hero.items[cls])
|
||||
.filter(function (id) {
|
||||
|
||||
6
runtime.d.ts
vendored
6
runtime.d.ts
vendored
@ -1928,9 +1928,6 @@ declare class items {
|
||||
*/
|
||||
addItem(itemId: string, itemNum?: number): void
|
||||
|
||||
/** 获得所有应该在道具栏显示的某个类型道具 */
|
||||
getDisplayItemsInToolbox(cls: string): string[]
|
||||
|
||||
/**
|
||||
* 判定某件装备的类型
|
||||
* @example core.getEquipTypeById('shield5') // 1(盾牌)
|
||||
@ -2244,6 +2241,9 @@ declare class ui {
|
||||
/** 绘制道具栏 */
|
||||
drawToolbox(index?: any): void
|
||||
|
||||
/** 获得所有应该在道具栏显示的某个类型道具 */
|
||||
getToolboxItems(cls: string): string[]
|
||||
|
||||
/** 绘制装备界面 */
|
||||
drawEquipbox(index?: any): void
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user