From 43a58f173d8b0b2addfa36e49e31948df083bcae Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 15 Dec 2017 15:22:45 +0800 Subject: [PATCH] Update --- index.html | 4 +--- libs/core.js | 44 ++++++++++++++++++++++++++++-------------- libs/data.js | 2 ++ libs/events.js | 12 ++++++++++-- libs/floors/sample1.js | 6 +++--- libs/ui.js | 18 ++++++++++++----- main.js | 12 ++++-------- 7 files changed, 63 insertions(+), 35 deletions(-) diff --git a/index.html b/index.html index 4e5dad15..f474ad47 100644 --- a/index.html +++ b/index.html @@ -4,10 +4,8 @@ - + - diff --git a/libs/core.js b/libs/core.js index 3a67f6a0..6b5313f5 100644 --- a/libs/core.js +++ b/libs/core.js @@ -105,7 +105,8 @@ core.prototype.init = function (dom, statusBar, canvas, images, sounds, floorIds for (var key in coreData) { core[key] = coreData[key]; } - core.flags = core.data.flags; + core.flags = core.clone(core.data.flags); + core.flags.battleAnimate = core.getLocalStorage('battleAnimate', core.flags.battleAnimate); core.values = core.clone(core.data.values); core.firstData = core.data.getFirstData(); core.initStatus.shops = core.firstData.shops; @@ -681,8 +682,17 @@ core.prototype.onclick = function (x, y, stepPostfix) { core.syncSave("load"); } } - if (x>=5 && x<=7 && y==7) { - core.ui.drawSettings(false); + if (x>=5 && x<=7) { + if (y==7) { + core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() { + localStorage.clear(); + core.drawText("\t[操作成功]你的本地所有存档已被清空。"); + }, function() { + core.ui.drawSettings(false); + }) + } + if (y==8) + core.ui.drawSettings(false); } } @@ -2795,9 +2805,9 @@ core.prototype.resize = function(clientWidth, clientHeight) { var statusLineHeight = BASE_LINEHEIGHT * 9/count; - var shopDisplay, mdefDispaly, expDispaly; - mdefDispaly = core.flags.enableMDef ? 'block' : 'none'; - expDispaly = core.flags.enableExperience ? 'block' : 'none'; + var shopDisplay, mdefDisplay, expDisplay; + mdefDisplay = core.flags.enableMDef ? 'block' : 'none'; + expDisplay = core.flags.enableExperience ? 'block' : 'none'; statusBarBorder = '3px #fff solid'; toolBarBorder = '3px #fff solid'; @@ -2898,7 +2908,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { var unit = 'px' core.domStyle.styles = [ - { id: 'gameGroup', + { + id: 'gameGroup', rules:{ width: gameGroupWidth + unit, height: gameGroupHeight + unit, @@ -2906,7 +2917,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { left: (clientWidth-gameGroupWidth)/2 + unit, } }, - { className: 'gameCanvas', + { + className: 'gameCanvas', rules:{ width: canvasWidth + unit, height: canvasWidth + unit, @@ -2916,7 +2928,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { border: '3px #fff solid', } }, - { id: 'statusBar', + { + id: 'statusBar', rules:{ width: statusBarWidth + unit, height: statusBarHeight + unit, @@ -2930,7 +2943,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { fontSize: fontSize + unit } }, - { className: 'status', + { + className: 'status', rules:{ width: '100%', maxWidth: statusMaxWidth + unit, @@ -2945,7 +2959,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { lineHeight: statusLabelsLH + unit, } }, - { id: 'toolBar', + { + id: 'toolBar', rules:{ width: toolBarWidth + unit, height: toolBarHeight + unit, @@ -2958,7 +2973,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { fontSize: fontSize + unit } }, - { className: 'tools', + { + className: 'tools', rules:{ height: toolsHeight + unit, maxWidth: toolsPMaxwidth + unit, @@ -2975,13 +2991,13 @@ core.prototype.resize = function(clientWidth, clientHeight) { { id: 'expCol', rules: { - display: expDispaly + display: expDisplay } }, { id: 'mdefCol', rules: { - display: mdefDispaly + display: mdefDisplay } }, ] diff --git a/libs/data.js b/libs/data.js index 1cf2a836..d82a37b9 100644 --- a/libs/data.js +++ b/libs/data.js @@ -125,6 +125,8 @@ data.prototype.init = function() { "bigKeyIsBox": false, // 如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙 /****** 系统相关 ******/ + "startDirectly": true, // 点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面 + "battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中关闭 "portalWithoutTrigger": true, // 经过楼梯、传送门时是否能“穿透”。穿透的意思是,自动寻路得到的的路径中间经过了楼梯,行走时是否触发楼层转换事件 "potionWhileRouting": false, // 寻路算法是否经过血瓶;如果该项为false,则寻路算法会自动尽量绕过血瓶 } diff --git a/libs/events.js b/libs/events.js index 2fad26ca..898b09b4 100644 --- a/libs/events.js +++ b/libs/events.js @@ -282,6 +282,7 @@ events.prototype.doAction = function() { break; case "disableShop": // 禁用一个全局商店 core.events.disableQuickShop(data.id); + this.doAction(); break; case "battle": // 强制战斗 core.battle(data.id,null,null,true,function() { @@ -796,11 +797,17 @@ events.prototype.clickSettings = function (x,y) { core.changeSoundStatus(); core.ui.drawSettings(false); } - if (y == 4) core.ui.drawQuickShop(); + if (y==4) { + core.flags.battleAnimate=!core.flags.battleAnimate; + core.setLocalStorage('battleAnimate', core.flags.battleAnimate); + core.ui.drawSettings(false); + } + if (y == 5) core.ui.drawQuickShop(); // if (y == 5) this.decreaseHard(); - if (y == 5) { + if (y == 6) { core.ui.drawSyncSave(); } + /* if (y == 6) { core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() { localStorage.clear(); @@ -809,6 +816,7 @@ events.prototype.clickSettings = function (x,y) { core.ui.drawSettings(false); }) } + */ if (y == 7) { core.ui.drawConfirmBox("你确定要重新开始吗?", function () { core.ui.closePanel(); diff --git a/libs/floors/sample1.js b/libs/floors/sample1.js index 06dbf05f..d95d7703 100644 --- a/libs/floors/sample1.js +++ b/libs/floors/sample1.js @@ -29,8 +29,8 @@ main.floors.sample1 = { "4,10": [ // 走到中间时的提示 "\t[样板提示]本层楼将会对各类事件进行介绍。", "左边是一个仿50层的陷阱做法,上方是商店、快捷商店的使用方法,右上是一个典型的杀怪开门的例子,右下是各类可能的NPC事件。", - "本样板目前支持的事件列表大致有:\ntext: 显示一段文字(比如你现在正在看到的)\nshow: 使一个事件有效(可见、可被交互)\nhide: 使一个事件失效(不可见、不可被交互)\ntrigger: 触发另一个地点的事件\nbattle: 强制和某怪物战斗\nopenDoor: 无需钥匙开门(例如机关门、暗墙)\nopenShop: 打开一个全局商店\nchangeFloor: 传送勇士到某层某位置\nchangePos: 传送勇士到当层某位置\nwin: 获得胜利(游戏通关)\nlose: 游戏失败", - "move: 移动事件效果\nplaySound: 播放某个音频\nif: 条件判断\nchoices: 提供选项\nsetValue: 设置勇士属性道具,或某个变量/flag\nupdate: 更新状态栏和地图显伤\nsleep: 等待多少毫秒\nexit: 立刻结束当前事件\nrevisit: 立刻结束事件并重新触发\nfunction: 自定义JS脚本\n\n更多支持的事件还在编写中,欢迎您宝贵的意见。", + "本样板目前支持的事件列表大致有:\ntext: 显示一段文字(比如你现在正在看到的)\nshow: 使一个事件有效(可见、可被交互)\nhide: 使一个事件失效(不可见、不可被交互)\ntrigger: 触发另一个地点的事件\nbattle: 强制和某怪物战斗\nopenDoor: 无需钥匙开门(例如机关门、暗墙)\nopenShop: 打开一个全局商店\ndisableShop: 禁用一个全局商店\nchangeFloor: 传送勇士到某层某位置\nchangePos: 传送勇士到当层某位置;转向\nsetFg: 更改画面色调", + "move: 移动事件效果\nplaySound: 播放某个音频\nif: 条件判断\nchoices: 提供选项\nsetValue: 设置勇士属性道具,或某个变量/flag\nupdate: 更新状态栏和地图显伤\nwin: 获得胜利(游戏通关)\nlose: 游戏失败\nsleep: 等待多少毫秒\nexit: 立刻结束当前事件\nrevisit: 立刻结束事件并重新触发\nfunction: 自定义JS脚本\n更多支持的事件还在编写中,欢迎您宝贵的意见。", "有关各事件的样例,可参见本层一些NPC的写法。\n所有事件样例本层都有介绍。\n\n一个自定义事件处理完后,需要调用{\"type\": \"hide\"}该事件才不会再次出现。", {"type": "hide"} ], @@ -59,7 +59,7 @@ main.floors.sample1 = { {"type": "hide", "loc": [1,8]}, {"type": "hide", "loc": [1,5], "time": 500}, // 隐藏红衣魔王,动画500ms {"type": "hide"}, // 隐藏本事件 - {"type": "setFg", "color": [255,255,255], 'time': 1250}, // 渐变为黑色 + {"type": "setFg", "color": [0,0,0], 'time': 1250}, // 渐变为白色 {"type": "sleep", "time": 700}, {"type": "changeFloor", "floorId": "sample1", "loc": [1,11], 'direction': 'right', 'time': 1000}, // 楼层切换。changeFloor必须指定floorId和loc。 // 备注:这里也可以下面的这种写法: diff --git a/libs/ui.js b/libs/ui.js index f7197b4a..e3856ec1 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -320,10 +320,10 @@ ui.prototype.drawSettings = function (need) { core.canvas.ui.textAlign = "center"; core.fillText('ui', "音乐: " + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 56, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "快捷商店", 208, top + 88, "#FFFFFF", "bold 17px Verdana"); - //core.fillText('ui', "降低难度", 208, top + 120, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "同步存档", 208, top + 120, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "清空存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana"); + core.fillText('ui', '战斗过程: ' +(core.flags.battleAnimate?'[ON]':'[OFF]'), 208, top + 88, "#FFFFFF", "bold 17px Verdana") + core.fillText('ui', "快捷商店", 208, top + 120, "#FFFFFF", "bold 17px Verdana"); + core.fillText('ui', "同步存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana"); + // core.fillText('ui', "清空存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "重新开始", 208, top + 184, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "关于本塔", 208, top + 216, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "返回游戏", 208, top + 248, "#FFFFFF", "bold 17px Verdana"); @@ -362,6 +362,13 @@ ui.prototype.drawQuickShop = function (need) { } +ui.prototype.drawBattleAnimate = function() { + + + + + +} /** * 绘制“请等候...” @@ -397,13 +404,14 @@ ui.prototype.drawSyncSave = function () { core.setAlpha('ui', 1); core.setFillStyle('ui', background); - var left = 97, top = 208 - 32 - 16 * 3, right = 416 - 2 * left, bottom = 416 - 2 * top; + var left = 97, top = 208 - 32 - 16 * 3, right = 416 - 2 * left, bottom = 416 - 2 * top + 32; core.fillRect('ui', left, top, right, bottom, background); core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); core.canvas.ui.textAlign = "center"; core.fillText('ui', "同步存档到服务器", 208, top + 56, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "从服务器加载存档", 208, top + 56 + 32, "#FFFFFF", "bold 17px Verdana"); + core.fillText('ui', "清空本地存档", 208, top + 56 + 64, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "返回游戏", 208, top + bottom - 40); } diff --git a/main.js b/main.js index 5451c043..736ef6b9 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,4 @@ function main() { - this.version = "0.1"; this.dom = { 'body': document.body, 'gameGroup': document.getElementById('gameGroup'), @@ -79,6 +78,8 @@ function main() { 'curse': document.getElementById('curse'), 'hard': document.getElementById("hard") } + this.version = "0.1"; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。 + this.useCompress = false; // 是否使用压缩文件 // 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。 // 请注意,只有useCompress是false时才会读取floors目录下的文件,为true时会直接读取libs目录下的floors.min.js文件。 @@ -321,13 +322,8 @@ main.statusBar.image.settings.onclick = function () { main.dom.playGame.onclick = function () { main.dom.startButtons.style.display='none'; - /** - * 如果点击“开始游戏”直接开始游戏而不是进入难度选择页面,则将下面这个改成true - */ - var startGameNow = false; - - if (startGameNow) { - core.events.startGame(); + if (main.core.isset(main.core.flags.startDirectly) && main.core.flags.startDirectly) { + core.events.startGame(""); } else { main.dom.levelChooseButtons.style.display='block';