commit
4df1c05d5a
@ -310,6 +310,18 @@ var code = '[\n'+action_0+']\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//item 事件编辑器入口之一
|
||||
item_m
|
||||
: '使用道具事件' BGNL? Newline action+ BEND
|
||||
|
||||
|
||||
/* item_m
|
||||
tooltip : 使用道具事件
|
||||
helpUrl : https://h5mota.com/games/template/_docs/#/event
|
||||
var code = '[\n'+action_0+']\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
//为了避免关键字冲突,全部加了_s
|
||||
//动作
|
||||
action
|
||||
|
||||
@ -69,6 +69,7 @@ editor_blockly = function () {
|
||||
MotaActionBlocks['eachArrive_m'].xmlText(),
|
||||
MotaActionBlocks['level_m'].xmlText(),
|
||||
MotaActionBlocks['commonEvent_m'].xmlText(),
|
||||
MotaActionBlocks['item_m'].xmlText(),
|
||||
],
|
||||
'显示文字':[
|
||||
MotaActionBlocks['text_0_s'].xmlText(),
|
||||
|
||||
@ -67,6 +67,12 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
|
||||
"_lint": true,
|
||||
"_data": "即捡即用类物品在获得时提示的文字,仅对cls为items有效。"
|
||||
},
|
||||
"useItemEvent": {
|
||||
"_leaf": true,
|
||||
"_type": "event",
|
||||
"_event": "item",
|
||||
"_data": "碰触或使用本道具所执行的事件"
|
||||
},
|
||||
"useItemEffect": {
|
||||
"_leaf": true,
|
||||
"_type": "textarea",
|
||||
|
||||
@ -211,6 +211,7 @@
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
|
||||
@ -207,6 +207,7 @@
|
||||
<option value="firstArrive">firstArrive</option>
|
||||
<option value="eachArrive">eachArrive</option>
|
||||
<option value="commonEvent">commonEvent</option>
|
||||
<option value="item">item</option>
|
||||
</select>
|
||||
<button onclick="editor_blockly.confirm()">确认</button>
|
||||
<button onclick="editor_blockly.parse()">解析</button>
|
||||
|
||||
@ -12,16 +12,9 @@ function dynamicMapEditor() {
|
||||
'redPotion', 'bluePotion', 'yellowPotion', 'greenPotion', 'pickaxe', 'bomb', 'centerFly',
|
||||
'cls:autotile', 'cls:enemys', 'cls:enemy48'
|
||||
];
|
||||
this.userParams = {
|
||||
hotKeys: {
|
||||
openToolBox: 219,
|
||||
save: 221,
|
||||
undo: 220
|
||||
}
|
||||
};
|
||||
this.items = [];
|
||||
this.userChanged = [];
|
||||
this.key2Function = {};
|
||||
this.savedItems = [];
|
||||
this.dom = null;
|
||||
this.canvas = null;
|
||||
this.mapRecord = {};
|
||||
@ -38,11 +31,6 @@ function dynamicMapEditor() {
|
||||
// ------ init
|
||||
|
||||
dynamicMapEditor.prototype._init = function () {
|
||||
var hotkeys = this.userParams.hotKeys;
|
||||
this.key2Function[hotkeys.openToolBox] = this.openToolBox;
|
||||
this.key2Function[hotkeys.save] = this.applyCurrentChange;
|
||||
this.key2Function[hotkeys.undo] = this.undo;
|
||||
|
||||
this.dom = document.createElement("canvas");
|
||||
this.dom.id = 'dynamicMapEditor';
|
||||
this.dom.style.display = 'none';
|
||||
@ -56,7 +44,7 @@ dynamicMapEditor.prototype._init = function () {
|
||||
|
||||
this.initInfos();
|
||||
this.pageMax = Math.ceil(this.items.length / this.pageMaxItems);
|
||||
core.registerAction('onkeyUp', 'plugin_dme_keydown', this.onKeyDown.bind(this), 200);
|
||||
core.registerAction('onkeyUp', 'plugin_dme_keydown', this.onKeyUp.bind(this), 200);
|
||||
core.registerAction('onclick', 'plugin_dme_click', this.onMapClick.bind(this), 200);
|
||||
this.dom.addEventListener("click",this.onBoxClick.bind(this));
|
||||
this.showInitHelp();
|
||||
@ -80,6 +68,7 @@ dynamicMapEditor.prototype.initInfos = function () {
|
||||
}
|
||||
}, this);
|
||||
this.items = this.items.filter(function (v) { return v && v.id && v.number >= 0; });
|
||||
this.savedItems = core.getLocalStorage('_dynamicMapEditor_savedItems', []);
|
||||
}
|
||||
|
||||
// ------ bind actions
|
||||
@ -88,10 +77,31 @@ dynamicMapEditor.prototype.isValid = function () {
|
||||
return main.mode == 'play' && core.isPlaying() && !core.isReplaying() && !core.status.lockControl;
|
||||
}
|
||||
|
||||
dynamicMapEditor.prototype.onKeyDown = function(e) {
|
||||
dynamicMapEditor.prototype.onKeyUp = function(e) {
|
||||
if (!this.isValid()) return false;
|
||||
var func = this.key2Function[e.keyCode];
|
||||
func && func.call(this);
|
||||
if (e.keyCode == 219) {
|
||||
this.openToolBox();
|
||||
return true;
|
||||
}
|
||||
if (!this.isUsingTool) return false;
|
||||
|
||||
if (e.keyCode == 220) {
|
||||
this.undo();
|
||||
return true;
|
||||
} else if (e.keyCode == 221) {
|
||||
this.applyCurrentChange();
|
||||
return true;
|
||||
} else {
|
||||
// 0-9
|
||||
if (e.keyCode >= 48 && e.keyCode <= 57) {
|
||||
if (e.altKey) {
|
||||
this.savedItem(e.keyCode - 48);
|
||||
} else {
|
||||
this.loadItem(e.keyCode - 48);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -286,6 +296,23 @@ dynamicMapEditor.prototype.changePage = function(delta) {
|
||||
this.refreshToolBox();
|
||||
}
|
||||
|
||||
dynamicMapEditor.prototype.savedItem = function (number) {
|
||||
if (!this.isUsingTool || this.selectedItem < 0) return;
|
||||
this.savedItems[number] = [this.pageId, this.selectedIndex];
|
||||
core.setLocalStorage('_dynamicMapEditor_savedItems', this.savedItems);
|
||||
core.drawTip("已保存此图块");
|
||||
}
|
||||
|
||||
dynamicMapEditor.prototype.loadItem = function (number) {
|
||||
if (!this.isUsingTool) return;
|
||||
var u = this.savedItems[number];
|
||||
if (!u) return core.drawTip("没有保存的图块!");
|
||||
this.pageId = u[0];
|
||||
this.selectedIndex = u[1];
|
||||
this.selectedItem = this.items[this.pageId * this.pageMaxItems + this.selectedIndex];
|
||||
this.refreshToolBox();
|
||||
}
|
||||
|
||||
// ------ draw
|
||||
|
||||
dynamicMapEditor.prototype.itemRect = function(index) {
|
||||
@ -366,7 +393,8 @@ dynamicMapEditor.prototype.showHelp = function (fromButton) {
|
||||
if (main.mode != 'play' || (!fromButton && core.getLocalStorage('_dynamicMapEditor_help'))) return;
|
||||
var text = "欢迎使用黄鸡编写的运行时编辑拓展!你可以一边游戏一边编辑地图或者修改数据。\n\n";
|
||||
text += "基本操作:\n - 点击图块再点地图可以放置;\n - 双击图块可以编辑数据;\n";
|
||||
text += " - [ 键将开关此模式;\n - ] 键将会把改动保存到文件;\n - \\ 键将撤销上步操作。\n\n";
|
||||
text += " - [ 键将开关此模式;\n - ] 键将会把改动保存到文件;\n - \\ 键将撤销上步操作。\n";
|
||||
text += " - Alt+0~9 保存当前图块 \n - 0~9 读取当前图块\n";
|
||||
text += "最下面三行数据分别是:\n"
|
||||
text += "血攻防魔防;金经黄蓝红;破炸飞和debuff。";
|
||||
if (!fromButton) text += "\n\n点取消将不再提示本页面。";
|
||||
|
||||
@ -595,12 +595,12 @@ actions.prototype._getClickLoc = function (x, y) {
|
||||
size = size * core.domStyle.scale;
|
||||
|
||||
if (core.domStyle.isVertical) {
|
||||
statusBar.x = 0;
|
||||
statusBar.x = 3;
|
||||
statusBar.y = core.dom.statusBar.offsetHeight + 3;
|
||||
}
|
||||
else {
|
||||
statusBar.x = core.dom.statusBar.offsetWidth + 3;
|
||||
statusBar.y = 0;
|
||||
statusBar.y = 3;
|
||||
}
|
||||
|
||||
var left = core.dom.gameGroup.offsetLeft + statusBar.x;
|
||||
|
||||
@ -13,7 +13,10 @@ items.prototype._init = function () {
|
||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItemEffect;
|
||||
if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition)
|
||||
items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition = {};
|
||||
if (!items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEvent)
|
||||
items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEvent = {};
|
||||
this.equipCondition = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.equipCondition;
|
||||
this.useItemEvent = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItemEvent;
|
||||
}
|
||||
|
||||
////// 获得所有道具 //////
|
||||
@ -67,6 +70,15 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
|
||||
}
|
||||
}
|
||||
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
|
||||
|
||||
if (this.useItemEvent[itemId]) {
|
||||
try {
|
||||
core.insertAction(this.useItemEvent[itemId]);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.addItem(itemId, itemNum);
|
||||
@ -116,6 +128,14 @@ items.prototype._useItemEffect = function (itemId) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
if (this.useItemEvent[itemId]) {
|
||||
try {
|
||||
core.insertAction(this.useItemEvent[itemId]);
|
||||
}
|
||||
catch (e) {
|
||||
main.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
items.prototype._afterUseItem = function (itemId) {
|
||||
|
||||
@ -50,6 +50,7 @@ loader.prototype._loadIcons = function () {
|
||||
}
|
||||
|
||||
loader.prototype._loadMaterialImages = function (callback) {
|
||||
this._setStartLoadTipText("正在加载资源文件...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/images/materials.zip', core.materials, core.material.images, callback);
|
||||
} else {
|
||||
@ -64,6 +65,7 @@ loader.prototype._loadExtraImages = function (callback) {
|
||||
if (images.indexOf("hero.png") < 0)
|
||||
images.push("hero.png");
|
||||
|
||||
this._setStartLoadTipText("正在加载图片文件...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/images/images.zip', images, core.material.images.images, callback);
|
||||
} else {
|
||||
@ -86,6 +88,7 @@ loader.prototype._loadAutotiles = function (callback) {
|
||||
|
||||
callback();
|
||||
}
|
||||
this._setStartLoadTipText("正在加载自动元件...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/images/autotiles.zip', keys, autotiles, _callback);
|
||||
} else {
|
||||
@ -109,6 +112,7 @@ loader.prototype._loadTilesets = function (callback) {
|
||||
}
|
||||
callback();
|
||||
}
|
||||
this._setStartLoadTipText("正在加载额外素材...");
|
||||
if (main.useCompress) {
|
||||
this.loadImagesFromZip('project/images/tilesets.zip', core.tilesets, core.material.images.tilesets, _callback);
|
||||
} else {
|
||||
@ -125,16 +129,16 @@ loader.prototype.loadImages = function (names, toSave, callback) {
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
this.loadImage(names[i], function (id, image) {
|
||||
core.loader._setStartLoadTipText('正在加载图片 ' + id + "...");
|
||||
if (toSave[id] !== undefined) {
|
||||
if (image != null)
|
||||
toSave[id] = image;
|
||||
return;
|
||||
}
|
||||
toSave[id] = image;
|
||||
items++;
|
||||
core.loader._setStartProgressVal(items * (100 / names.length));
|
||||
if (items == names.length) {
|
||||
if (callback) callback();
|
||||
if (toSave[id] !== undefined) {
|
||||
if (image != null)
|
||||
toSave[id] = image;
|
||||
return;
|
||||
}
|
||||
toSave[id] = image;
|
||||
items++;
|
||||
core.loader._setStartProgressVal(items * (100 / names.length));
|
||||
if (items == names.length) {
|
||||
if (callback) callback();
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -166,6 +170,8 @@ loader.prototype.loadImagesFromZip = function (url, names, toSave, callback) {
|
||||
});
|
||||
cnt--;
|
||||
if (cnt == 0 && callback) callback();
|
||||
}, null, false, function (percentage) {
|
||||
core.loader._setStartProgressVal(percentage * 100);
|
||||
});
|
||||
}
|
||||
|
||||
@ -191,6 +197,7 @@ loader.prototype.loadImage = function (imgName, callback) {
|
||||
}
|
||||
|
||||
loader.prototype._loadAnimates = function () {
|
||||
this._setStartLoadTipText("正在加载动画文件...");
|
||||
if (main.useCompress) {
|
||||
core.unzip('project/animates/animates.zip?v=' + main.version, function (animates) {
|
||||
for (var name in animates) {
|
||||
@ -200,7 +207,9 @@ loader.prototype._loadAnimates = function () {
|
||||
core.loader._loadAnimate(t, animates[name]);
|
||||
}
|
||||
}
|
||||
}, null, true);
|
||||
}, null, true, function (percentage) {
|
||||
core.loader._setStartProgressVal(percentage * 100);
|
||||
});
|
||||
} else {
|
||||
core.animates.forEach(function (t) {
|
||||
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
||||
@ -267,6 +276,7 @@ loader.prototype._loadMusic = function () {
|
||||
core.loader.loadOneMusic(t);
|
||||
});
|
||||
|
||||
this._setStartLoadTipText("正在加载音效文件...");
|
||||
if (main.useCompress && core.musicStatus.audioContext) {
|
||||
core.unzip('project/sounds/sounds.zip?v=' + main.version, function (data) {
|
||||
for (var name in data) {
|
||||
@ -274,6 +284,8 @@ loader.prototype._loadMusic = function () {
|
||||
core.loader._loadOneSound_decodeData(name, data[name]);
|
||||
}
|
||||
}
|
||||
}, null, false, function (percentage) {
|
||||
core.loader._setStartProgressVal(percentage * 100);
|
||||
});
|
||||
} else {
|
||||
core.sounds.forEach(function (t) {
|
||||
|
||||
@ -1166,7 +1166,7 @@ utils.prototype._export = function (floorIds) {
|
||||
console.log(content);
|
||||
}
|
||||
|
||||
utils.prototype.unzip = function (blobOrUrl, success, error, convertToText) {
|
||||
utils.prototype.unzip = function (blobOrUrl, success, error, convertToText, onprogress) {
|
||||
var _error = function (msg) {
|
||||
main.log(msg);
|
||||
if (error) error(msg);
|
||||
@ -1179,7 +1179,7 @@ utils.prototype.unzip = function (blobOrUrl, success, error, convertToText) {
|
||||
if (typeof blobOrUrl == 'string') {
|
||||
return core.http('GET', blobOrUrl, null, function (data) {
|
||||
core.unzip(data, success, error, convertToText);
|
||||
}, _error, 'application/zip', 'blob');
|
||||
}, _error, 'application/zip', 'blob', onprogress);
|
||||
}
|
||||
|
||||
if (!(blobOrUrl instanceof Blob)) {
|
||||
@ -1214,7 +1214,7 @@ utils.prototype._unzip_readEntries = function (entries, success, convertToText)
|
||||
});
|
||||
}
|
||||
|
||||
utils.prototype.http = function (type, url, formData, success, error, mimeType, responseType) {
|
||||
utils.prototype.http = function (type, url, formData, success, error, mimeType, responseType, onprogress) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(type, url, true);
|
||||
if (mimeType) xhr.overrideMimeType(mimeType);
|
||||
@ -1227,6 +1227,11 @@ utils.prototype.http = function (type, url, formData, success, error, mimeType,
|
||||
if (error) error("HTTP " + xhr.status);
|
||||
}
|
||||
};
|
||||
xhr.onprogress = function (e) {
|
||||
if (e.lengthComputable) {
|
||||
if (onprogress) onprogress(e.loaded / e.total);
|
||||
}
|
||||
}
|
||||
xhr.onabort = function () {
|
||||
if (error) error("Abort");
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user