main.init('editor')
This commit is contained in:
parent
f92124e162
commit
627bcee8c4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.vscode
|
.vscode
|
||||||
|
*ce5eec52_2fa1_447b_8dad_764e267a7fab*
|
||||||
|
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
if (isset(callback)) callback(null);
|
if (isset(callback)) callback(null);
|
||||||
}
|
}
|
||||||
//callback(err:String)
|
//callback(err:String)
|
||||||
editor_file.saveFloorFile = function(editor,saveAsFilename,callback){
|
editor_file.saveFloorFileAs = function(editor,saveAsFilename,callback){
|
||||||
if (isset(callback)) callback(null);
|
if (isset(callback)) callback(null);
|
||||||
}
|
}
|
||||||
//callback(err:String)
|
//callback(err:String)
|
||||||
|
|||||||
@ -421,7 +421,7 @@ editor.prototype.init = function() {
|
|||||||
editor.prototype.loadMod = function (callback) {
|
editor.prototype.loadMod = function (callback) {
|
||||||
main={'instance':{}};
|
main={'instance':{}};
|
||||||
var loadedNum=0;
|
var loadedNum=0;
|
||||||
['libs/floors/icons.js','libs/floors/maps.js','libs/icons.js','libs/maps.js'].forEach( function (value,ii,aa) {
|
['libs/project/icons.js','libs/project/maps.js','libs/icons.js','libs/maps.js'].forEach( function (value,ii,aa) {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = value + '?' + editor.version;
|
script.src = value + '?' + editor.version;
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
|
|||||||
43
libs/core.js
43
libs/core.js
@ -1778,12 +1778,9 @@ core.prototype.setFillStyle = function (map, style) {
|
|||||||
* @param callback 绘制完毕后的回调函数
|
* @param callback 绘制完毕后的回调函数
|
||||||
*/
|
*/
|
||||||
core.prototype.drawMap = function (mapName, callback) {
|
core.prototype.drawMap = function (mapName, callback) {
|
||||||
var mapData = core.status.maps[mapName];
|
|
||||||
var mapBlocks = mapData.blocks;
|
|
||||||
core.status.floorId = mapName;
|
|
||||||
core.status.thisMap = mapData;
|
|
||||||
core.clearMap('all');
|
core.clearMap('all');
|
||||||
core.removeGlobalAnimate(null, null, true);
|
core.removeGlobalAnimate(null, null, true);
|
||||||
|
var drawBg = function(){
|
||||||
var groundId = core.floors[mapName].defaultGround || "ground";
|
var groundId = core.floors[mapName].defaultGround || "ground";
|
||||||
var blockIcon = core.material.icons.terrains[groundId];
|
var blockIcon = core.material.icons.terrains[groundId];
|
||||||
var blockImage = core.material.images.terrains;
|
var blockImage = core.material.images.terrains;
|
||||||
@ -1792,6 +1789,22 @@ core.prototype.drawMap = function (mapName, callback) {
|
|||||||
core.canvas.bg.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32);
|
core.canvas.bg.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (main.mode=='editor'){
|
||||||
|
main.editor.drawMapBg = function(){
|
||||||
|
core.clearMap('bg', 0, 0, 416, 416);
|
||||||
|
drawBg();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drawBg();
|
||||||
|
}
|
||||||
|
|
||||||
|
var drawEvent = function(){
|
||||||
|
var mapData = core.status.maps[mapName];
|
||||||
|
var mapBlocks = mapData.blocks;
|
||||||
|
core.status.floorId = mapName;
|
||||||
|
core.status.thisMap = mapData;
|
||||||
var autotileMaps = [];
|
var autotileMaps = [];
|
||||||
for (var b = 0; b < mapBlocks.length; b++) {
|
for (var b = 0; b < mapBlocks.length; b++) {
|
||||||
// 事件启用
|
// 事件启用
|
||||||
@ -1803,14 +1816,24 @@ core.prototype.drawMap = function (mapName, callback) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
blockIcon = core.material.icons[block.event.cls][block.event.id];
|
var blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||||
blockImage = core.material.images[block.event.cls];
|
var blockImage = core.material.images[block.event.cls];
|
||||||
core.canvas.event.drawImage(core.material.images[block.event.cls], 0, blockIcon * 32, 32, 32, block.x * 32, block.y * 32, 32, 32);
|
core.canvas.event.drawImage(core.material.images[block.event.cls], 0, blockIcon * 32, 32, 32, block.x * 32, block.y * 32, 32, 32);
|
||||||
core.addGlobalAnimate(block.event.animate, block.x * 32, block.y * 32, blockIcon, blockImage);
|
core.addGlobalAnimate(block.event.animate, block.x * 32, block.y * 32, blockIcon, blockImage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.drawAutotile(mapName, 'event', autotileMaps, 0, 0, 32);
|
core.drawAutotile(mapName, 'event', autotileMaps, 0, 0, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (main.mode=='editor'){
|
||||||
|
main.editor.updateMap = function(){
|
||||||
|
core.clearMap('event', 0, 0, 416, 416);
|
||||||
|
drawEvent();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drawEvent();
|
||||||
|
}
|
||||||
core.setGlobalAnimate(core.values.animateSpeed);
|
core.setGlobalAnimate(core.values.animateSpeed);
|
||||||
|
|
||||||
if (core.isset(callback))
|
if (core.isset(callback))
|
||||||
@ -2023,8 +2046,8 @@ core.prototype.moveBlock = function(x,y,steps,time,immediateHide,callback) {
|
|||||||
core.setAlpha('ui', 1.0);
|
core.setAlpha('ui', 1.0);
|
||||||
|
|
||||||
block=block.block;
|
block=block.block;
|
||||||
blockIcon = core.material.icons[block.event.cls][block.event.id];
|
var blockIcon = core.material.icons[block.event.cls][block.event.id];
|
||||||
blockImage = core.material.images[block.event.cls];
|
var blockImage = core.material.images[block.event.cls];
|
||||||
|
|
||||||
// 绘制data层
|
// 绘制data层
|
||||||
var opacityVal = 1;
|
var opacityVal = 1;
|
||||||
@ -2215,6 +2238,7 @@ core.prototype.removeBlockByIds = function (floorId, ids) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) {
|
core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) {
|
||||||
|
if (main.mode=='editor') return;
|
||||||
if (animateMore == 2) {
|
if (animateMore == 2) {
|
||||||
core.status.twoAnimateObjs.push({
|
core.status.twoAnimateObjs.push({
|
||||||
'x': x,
|
'x': x,
|
||||||
@ -2236,6 +2260,7 @@ core.prototype.addGlobalAnimate = function (animateMore, x, y, loc, image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.prototype.removeGlobalAnimate = function (x, y, all) {
|
core.prototype.removeGlobalAnimate = function (x, y, all) {
|
||||||
|
if (main.mode=='editor') return;
|
||||||
if (all == true) {
|
if (all == true) {
|
||||||
core.status.twoAnimateObjs = [];
|
core.status.twoAnimateObjs = [];
|
||||||
core.status.fourAnimateObjs = [];
|
core.status.fourAnimateObjs = [];
|
||||||
@ -2255,6 +2280,7 @@ core.prototype.removeGlobalAnimate = function (x, y, all) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.prototype.setGlobalAnimate = function (speed) {
|
core.prototype.setGlobalAnimate = function (speed) {
|
||||||
|
if (main.mode=='editor') return;
|
||||||
clearInterval(core.interval.twoAnimate);
|
clearInterval(core.interval.twoAnimate);
|
||||||
clearInterval(core.interval.fourAnimate);
|
clearInterval(core.interval.fourAnimate);
|
||||||
var animateClose = false;
|
var animateClose = false;
|
||||||
@ -3419,6 +3445,7 @@ core.prototype.checkLvUp = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
core.prototype.resize = function(clientWidth, clientHeight) {
|
core.prototype.resize = function(clientWidth, clientHeight) {
|
||||||
|
if (main.mode=='editor')return;
|
||||||
|
|
||||||
// 默认画布大小
|
// 默认画布大小
|
||||||
var DEFAULT_CANVAS_WIDTH = 422;
|
var DEFAULT_CANVAS_WIDTH = 422;
|
||||||
|
|||||||
7
main.js
7
main.js
@ -40,6 +40,7 @@ function main() {
|
|||||||
'debuffCol': document.getElementById('debuffCol'),
|
'debuffCol': document.getElementById('debuffCol'),
|
||||||
'hard': document.getElementById('hard'),
|
'hard': document.getElementById('hard'),
|
||||||
};
|
};
|
||||||
|
this.mode = 'play';
|
||||||
this.loadList = [
|
this.loadList = [
|
||||||
'items', 'icons', 'maps', 'enemys', 'events', 'data', 'ui', 'core'
|
'items', 'icons', 'maps', 'enemys', 'events', 'data', 'ui', 'core'
|
||||||
];
|
];
|
||||||
@ -100,10 +101,14 @@ function main() {
|
|||||||
this.canvas = {};
|
this.canvas = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
main.prototype.init = function () {
|
main.prototype.init = function (mode) {
|
||||||
for (var i = 0; i < main.dom.gameCanvas.length; i++) {
|
for (var i = 0; i < main.dom.gameCanvas.length; i++) {
|
||||||
main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d');
|
main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d');
|
||||||
}
|
}
|
||||||
|
if (({"editor":0,"replay":0}).hasOwnProperty(mode)) {
|
||||||
|
main.mode = mode;
|
||||||
|
if (mode === 'editor')main.editor = {};
|
||||||
|
}
|
||||||
main.loadPureData(function(){
|
main.loadPureData(function(){
|
||||||
main.useCompress=data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.useCompress;
|
main.useCompress=data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.useCompress;
|
||||||
main.floorIds=data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds;
|
main.floorIds=data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main.floorIds;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user