Battle
This commit is contained in:
parent
73545866f4
commit
2f42a9402b
72
.idea/markdown-navigator.xml
Normal file
72
.idea/markdown-navigator.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MarkdownProjectSettings">
|
||||
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true">
|
||||
<PanelProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
|
||||
</PanelProvider>
|
||||
</PreviewSettings>
|
||||
<ParserSettings gitHubSyntaxChange="false">
|
||||
<PegdownExtensions>
|
||||
<option name="ABBREVIATIONS" value="false" />
|
||||
<option name="ANCHORLINKS" value="true" />
|
||||
<option name="ASIDE" value="false" />
|
||||
<option name="ATXHEADERSPACE" value="true" />
|
||||
<option name="AUTOLINKS" value="true" />
|
||||
<option name="DEFINITIONS" value="false" />
|
||||
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
|
||||
<option name="FENCED_CODE_BLOCKS" value="true" />
|
||||
<option name="FOOTNOTES" value="false" />
|
||||
<option name="HARDWRAPS" value="false" />
|
||||
<option name="HTML_DEEP_PARSER" value="false" />
|
||||
<option name="INSERTED" value="false" />
|
||||
<option name="QUOTES" value="false" />
|
||||
<option name="RELAXEDHRULES" value="true" />
|
||||
<option name="SMARTS" value="false" />
|
||||
<option name="STRIKETHROUGH" value="true" />
|
||||
<option name="SUBSCRIPT" value="false" />
|
||||
<option name="SUPERSCRIPT" value="false" />
|
||||
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
|
||||
<option name="SUPPRESS_INLINE_HTML" value="false" />
|
||||
<option name="TABLES" value="true" />
|
||||
<option name="TASKLISTITEMS" value="true" />
|
||||
<option name="TOC" value="false" />
|
||||
<option name="WIKILINKS" value="true" />
|
||||
</PegdownExtensions>
|
||||
<ParserOptions>
|
||||
<option name="COMMONMARK_LISTS" value="true" />
|
||||
<option name="DUMMY" value="false" />
|
||||
<option name="EMOJI_SHORTCUTS" value="true" />
|
||||
<option name="FLEXMARK_FRONT_MATTER" value="false" />
|
||||
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
|
||||
<option name="GFM_TABLE_RENDERING" value="true" />
|
||||
<option name="GITBOOK_URL_ENCODING" value="false" />
|
||||
<option name="GITHUB_EMOJI_URL" value="false" />
|
||||
<option name="GITHUB_LISTS" value="false" />
|
||||
<option name="GITHUB_WIKI_LINKS" value="true" />
|
||||
<option name="JEKYLL_FRONT_MATTER" value="false" />
|
||||
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
|
||||
</ParserOptions>
|
||||
</ParserSettings>
|
||||
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false">
|
||||
<GeneratorProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
|
||||
</GeneratorProvider>
|
||||
<headerTop />
|
||||
<headerBottom />
|
||||
<bodyTop />
|
||||
<bodyBottom />
|
||||
</HtmlSettings>
|
||||
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
|
||||
<StylesheetProvider>
|
||||
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
|
||||
</StylesheetProvider>
|
||||
<ScriptProviders />
|
||||
<cssText />
|
||||
</CssSettings>
|
||||
<HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
|
||||
<LinkMapSettings>
|
||||
<textMaps />
|
||||
</LinkMapSettings>
|
||||
</component>
|
||||
</project>
|
||||
3
.idea/markdown-navigator/profiles_settings.xml
Normal file
3
.idea/markdown-navigator/profiles_settings.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<component name="MarkdownNavigator.ProfileManager">
|
||||
<settings default="" pdf-export="" />
|
||||
</component>
|
||||
@ -8,7 +8,8 @@
|
||||
|
||||
- Windows 8以上操作系统;Windows 7需要安装.Net Framework 4.0。(能打开同目录下的“地图生成器.exe”即可)
|
||||
- 任一款现代浏览器。强烈推荐Chrome。
|
||||
- 一个很好的文本编辑器。推荐带有高亮染色、错误提示等效果。例如:WebStorm,VSCode,或者至少也要Sublime Text。[Sublime Text下载地址](https://www.sublimetext.com/ ),如提示注册的话百度随便搜索一个注册码输入即可。
|
||||
- 一个很好的文本编辑器。推荐带有高亮染色、错误提示等效果。例如:WebStorm,VSCode,或者至少也要Sublime Text。
|
||||
([VSCode下载地址](https://code.visualstudio.com/ ),群里的群文件中也有,强烈推荐值。)
|
||||
- RPG Maker XP,任一个魔塔样板(推荐魔塔样板7630)
|
||||
|
||||
只要满足了上述条件,你就可以开始做自己的塔啦!
|
||||
@ -36,7 +37,8 @@
|
||||
|
||||
然后,任意绘制一张地图。
|
||||
|
||||
在这里我们就以1层小塔的地图为例。你也可以任意绘制自己的地图
|
||||
在这里我们就以1层小塔的地图为例。你也可以任意绘制自己的地图。
|
||||
|
||||

|
||||
|
||||
(我把原塔素材改成了经典样式,但是本质上是一样的。)
|
||||
|
||||
29
libs/core.js
29
libs/core.js
@ -1262,8 +1262,21 @@ core.prototype.battle = function (id, x, y, force, callback) {
|
||||
core.clearContinueAutomaticRoute();
|
||||
return;
|
||||
}
|
||||
if (core.flags.battleAnimate) {
|
||||
core.waitHeroToStop(function() {
|
||||
core.ui.drawBattleAnimate(id, function() {
|
||||
core.afterBattle(id, x, y, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.playSound('attack', 'ogg');
|
||||
core.status.hero.hp -= damage;
|
||||
core.afterBattle(id, x, y, callback);
|
||||
}
|
||||
}
|
||||
|
||||
core.prototype.afterBattle = function(id, x, y, callback) {
|
||||
core.status.hero.hp -= core.enemys.getDamage(id);
|
||||
if (core.status.hero.hp<=0) {
|
||||
core.status.hero.hp=0;
|
||||
core.updateStatusBar();
|
||||
@ -1290,6 +1303,7 @@ core.prototype.battle = function (id, x, y, force, callback) {
|
||||
|
||||
// 打完怪物,触发事件
|
||||
core.events.afterBattle(id,x,y,callback);
|
||||
|
||||
}
|
||||
|
||||
core.prototype.trigger = function (x, y) {
|
||||
@ -1422,6 +1436,19 @@ core.prototype.strokeRect = function (map, x, y, width, height, style, lineWidth
|
||||
core.canvas[map].strokeRect(x, y, width, height);
|
||||
}
|
||||
|
||||
core.prototype.drawLine = function (map, x1, y1, x2, y2, style, lineWidth) {
|
||||
if (core.isset(style)) {
|
||||
core.setStrokeStyle(map, style);
|
||||
}
|
||||
if (core.isset(lineWidth)) {
|
||||
core.setLineWidth(map, lineWidth);
|
||||
}
|
||||
core.canvas[map].beginPath();
|
||||
core.canvas[map].moveTo(x1, y1);
|
||||
core.canvas[map].lineTo(x2, y2);
|
||||
core.canvas[map].stroke();
|
||||
}
|
||||
|
||||
core.prototype.setFont = function (map, font) {
|
||||
core.canvas[map].font = font;
|
||||
}
|
||||
|
||||
@ -109,7 +109,6 @@ data.prototype.init = function() {
|
||||
"moneyPocket": 500, // 金钱袋加金币的数值
|
||||
|
||||
/****** 系统相关 ******/
|
||||
"cannotUseQuickShop": ["MT0"], // 不能使用快捷商店的楼层列表
|
||||
'animateSpeed': 500,
|
||||
}
|
||||
// 系统FLAG,在游戏运行中中请不要修改它。
|
||||
@ -125,7 +124,7 @@ data.prototype.init = function() {
|
||||
"bigKeyIsBox": false, // 如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙
|
||||
|
||||
/****** 系统相关 ******/
|
||||
"startDirectly": true, // 点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面
|
||||
"startDirectly": false, // 点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面
|
||||
"battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中关闭
|
||||
"portalWithoutTrigger": true, // 经过楼梯、传送门时是否能“穿透”。穿透的意思是,自动寻路得到的的路径中间经过了楼梯,行走时是否触发楼层转换事件
|
||||
"potionWhileRouting": false, // 寻路算法是否经过血瓶;如果该项为false,则寻路算法会自动尽量绕过血瓶
|
||||
|
||||
@ -103,14 +103,17 @@ enemys.prototype.getDamage = function (monsterId) {
|
||||
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_special = monster.special;
|
||||
var damage = this.calDamage(hero_atk, hero_def, hero_mdef, mon_hp, mon_atk, mon_def, mon_special);
|
||||
if (damage == 999999999) return damage;
|
||||
return damage + this.getExtraDamage(monster);
|
||||
}
|
||||
|
||||
enemys.prototype.getExtraDamage = function (monster) {
|
||||
var extra_damage = 0;
|
||||
if (monster.special == 11) { // 吸血
|
||||
// 吸血的比例
|
||||
extra_damage = core.status.hero.hp * monster.value;
|
||||
extra_damage = parseInt(extra_damage);
|
||||
}
|
||||
return damage + extra_damage;
|
||||
return extra_damage;
|
||||
}
|
||||
|
||||
// 临界值计算
|
||||
|
||||
@ -461,8 +461,9 @@ events.prototype.decreaseHard = function() {
|
||||
|
||||
////// 能否使用快捷商店 //////
|
||||
events.prototype.canUseQuickShop = function(shopIndex) {
|
||||
if (core.isset(core.values.cannotUseQuickShop) && core.values.cannotUseQuickShop.indexOf(core.status.floorId)>=0)
|
||||
if (core.isset(core.floors[core.status.floorId].canUseQuickShop) && !core.isset(core.floors[core.status.floorId].canUseQuickShop))
|
||||
return '当前不能使用快捷商店。';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ main.floors.MT0 = {
|
||||
"title": "主塔 0 层", // 楼层中文名
|
||||
"name": 0, // 显示在状态栏中的层数
|
||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
|
||||
],
|
||||
|
||||
@ -6,6 +6,7 @@ main.floors.sample0 = {
|
||||
"title": "样板 0 层", // 楼层中文名
|
||||
"name": 0, // 显示在状态栏中的层数
|
||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
[0, 0, 220, 0, 0, 6, 87, 3, 65, 64, 44, 43, 42],
|
||||
[0, 246, 0, 246, 0, 6, 0, 3, 58, 59, 60, 61, 41],
|
||||
@ -98,8 +99,7 @@ main.floors.sample0 = {
|
||||
],
|
||||
"10,5": ["破墙镐是破面前的墙壁还是四个方向的墙壁,由data.js中的系统Flag所决定。"],
|
||||
"8,4": [
|
||||
"炸弹可以炸四个方向的怪物。\n如只需要炸前方怪物请使用上面的圣锤。",
|
||||
"不能被炸的怪物在enemys中可以定义,可参见样板里黑衣魔王的写法。\n\n炸死怪物是否触发事件由 data.js 中的系统Flag所决定。"
|
||||
"炸弹可以炸四个方向的怪物。\n如只需要炸前方怪物请使用上面的圣锤。\n不能被炸的怪物在enemys中可以定义,可参见样板里黑衣魔王和黑暗大法师的写法。",
|
||||
],
|
||||
"10,4": ["“上楼”和“下楼”的目标层由 main.js 的 floorIds顺序所决定。"],
|
||||
"10,3": ["十字架目前未被定义,可能需要自行实现功能。\n有关如何实现一个道具功能参见doc文档。"],
|
||||
|
||||
@ -6,6 +6,7 @@ main.floors.sample1 = {
|
||||
"title": "样板 1 层", // 楼层中文名
|
||||
"name": 1, // 显示在状态栏中的层数
|
||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
[7, 131, 8, 2, 9, 130, 10, 2, 0, 0, 132, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0],
|
||||
|
||||
@ -6,6 +6,7 @@ main.floors.sample2 = {
|
||||
"title": "主塔 40 层", // 楼层中文名
|
||||
"name": 40, // 显示在状态栏中的层数
|
||||
"canFlyTo": false, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||
[5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5],
|
||||
[5, 4, 4, 4, 4, 1, 0, 1, 4, 4, 4, 4, 5],
|
||||
|
||||
245
libs/ui.js
245
libs/ui.js
@ -362,12 +362,255 @@ ui.prototype.drawQuickShop = function (need) {
|
||||
|
||||
}
|
||||
|
||||
ui.prototype.drawBattleAnimate = function() {
|
||||
ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
|
||||
// UI层
|
||||
core.lockControl();
|
||||
if (!core.isset(core.status.event.id)) {
|
||||
core.status.event = {'id': 'battle'};
|
||||
}
|
||||
|
||||
var hero_hp = core.getStatus('hp'), hero_atk = core.getStatus('atk'), hero_def = core.getStatus('def'),
|
||||
hero_mdef = core.getStatus('mdef');
|
||||
var monster = core.material.enemys[monsterId];
|
||||
var mon_hp = monster.hp, mon_atk = monster.atk, mon_def = monster.def, mon_money=monster.money, mon_exp = monster.experience, mon_special=monster.special;
|
||||
|
||||
hero_hp -= core.enemys.getExtraDamage(monster);
|
||||
|
||||
if (mon_special==2) hero_def=0; // 魔攻
|
||||
if (mon_special==3 && mon_def<hero_atk) mon_def=hero_atk-1; // 坚固
|
||||
if (mon_special==10) { // 模仿
|
||||
mon_atk=hero_atk;
|
||||
mon_def=hero_def;
|
||||
}
|
||||
var turns = 2;
|
||||
if (mon_special==4) turns=3;
|
||||
if (mon_special==5) turns=4;
|
||||
if (mon_special==6) turns=5;
|
||||
|
||||
// 初始伤害(破甲、净化)
|
||||
var initDamage = 0;
|
||||
if (mon_special==7) initDamage=parseInt(0.9 * hero_def);
|
||||
if (mon_special==9) initDamage=parseInt(3*hero_mdef);
|
||||
hero_mdef-=initDamage;
|
||||
if (hero_mdef<0) {
|
||||
hero_hp+=hero_mdef;
|
||||
hero_mdef=0;
|
||||
}
|
||||
|
||||
|
||||
var specialText = core.enemys.getSpecialText(monsterId);
|
||||
|
||||
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
var left=10, right=416-2*left;
|
||||
|
||||
|
||||
var lines = core.flags.enableExperience?5:4;
|
||||
|
||||
var lineHeight = 60;
|
||||
var height = lineHeight * lines + 50;
|
||||
|
||||
var top = (416-height)/2, bottom = height;
|
||||
|
||||
// var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', left, top, right, bottom, '#000000');
|
||||
core.setAlpha('ui', 1);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
|
||||
var margin = 35;
|
||||
var boxWidth = 40;
|
||||
|
||||
// 方块
|
||||
var heroHeight = core.material.icons.hero.height;
|
||||
core.strokeRect('ui', left + margin - 1, top + margin - 1, boxWidth+2, heroHeight+boxWidth-32+2, '#FFD700', 2);
|
||||
core.strokeRect('ui', left + right - margin - boxWidth - 1 , top+margin-1, boxWidth+2, boxWidth+2);
|
||||
|
||||
// 名称
|
||||
core.canvas.ui.textAlign='center';
|
||||
core.fillText('ui', core.status.hero.name, left+margin+boxWidth/2, top+margin+heroHeight+40, '#FFD700', 'bold 22px Verdana');
|
||||
core.fillText('ui', "怪物", left+right-margin-boxWidth/2, top+margin+32+40);
|
||||
core.fillText('ui', specialText, left+right-margin-boxWidth/2, top+margin+32+40+24, '#FF6A6A', '15px Verdana');
|
||||
|
||||
// 图标
|
||||
core.clearMap('ui', left + margin, top + margin, boxWidth, heroHeight+boxWidth-32);
|
||||
core.fillRect('ui', left + margin, top + margin, boxWidth, heroHeight+boxWidth-32, background);
|
||||
var heroIcon = core.material.icons.hero['down'];
|
||||
core.canvas.ui.drawImage(core.material.images.hero, heroIcon.stop * 32, heroIcon.loc *heroHeight, 32, heroHeight, left+margin+(boxWidth-32)/2, top+margin+(boxWidth-32)/2, 32, heroHeight);
|
||||
// 怪物的
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.status.boxAnimateObjs.push({
|
||||
'bgx': left + right - margin - 40, 'bgy': top+margin, 'bgsize': boxWidth,
|
||||
'image': core.material.images.enemys, 'x': left + right - margin - 40 + (boxWidth-32)/2, 'y': top + margin + (boxWidth-32)/2, 'icon': core.material.icons.enemys[monsterId]
|
||||
});
|
||||
core.setBoxAnimate();
|
||||
|
||||
var lineWidth = 80;
|
||||
|
||||
var left_start = left + margin + boxWidth + 10;
|
||||
var left_end = left_start+lineWidth;
|
||||
|
||||
var right_end = left+right-margin-boxWidth-10;
|
||||
var right_start = right_end-lineWidth;
|
||||
|
||||
// 勇士的线
|
||||
core.canvas.ui.textAlign='left';
|
||||
var textTop = top+margin+10;
|
||||
core.fillText('ui', "生命值", left_start, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', left_start, textTop+8, left_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.data.textAlign='right';
|
||||
core.fillText('data', hero_hp, left_end, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
textTop+=lineHeight;
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', "攻击", left_start, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', left_start, textTop+8, left_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', hero_atk, left_end, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
textTop+=lineHeight;
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', "防御", left_start, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', left_start, textTop+8, left_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', hero_def, left_end, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
if (core.flags.enableMDef) {
|
||||
textTop += lineHeight;
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', "魔防", left_start, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', left_start, textTop + 8, left_end, textTop + 8, '#FFFFFF', 2);
|
||||
core.canvas.data.textAlign='right';
|
||||
core.fillText('data', hero_mdef, left_end, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
}
|
||||
|
||||
// 怪物的线
|
||||
core.canvas.ui.textAlign='right';
|
||||
var textTop = top+margin+10;
|
||||
core.fillText('ui', "生命值", right_end, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', right_start, textTop+8, right_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.data.textAlign='left';
|
||||
core.fillText('data', mon_hp, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
textTop+=lineHeight;
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', "攻击", right_end, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', right_start, textTop+8, right_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', mon_atk, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
textTop+=lineHeight;
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', "防御", right_end, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', right_start, textTop+8, right_end, textTop+8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', mon_def, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
textTop += lineHeight;
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', "金币", right_end, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', right_start, textTop + 8, right_end, textTop + 8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', mon_money, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
if (core.flags.enableExperience) {
|
||||
textTop += lineHeight;
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText('ui', "经验", right_end, textTop, '#DDDDDD', '16px Verdana');
|
||||
core.drawLine('ui', right_start, textTop + 8, right_end, textTop + 8, '#FFFFFF', 2);
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText('ui', mon_exp, right_start, textTop+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
}
|
||||
|
||||
core.canvas.ui.textAlign='left';
|
||||
core.fillText("ui", "V", left_end+8, 208-15, "#FFFFFF", "italic bold 40px Verdana");
|
||||
|
||||
core.canvas.ui.textAlign='right';
|
||||
core.fillText("ui", "S", right_start-8, 208+15, "#FFFFFF", "italic bold 40px Verdana");
|
||||
/*
|
||||
core.drawLine('data', left + right - margin - boxWidth + 6, top+margin+boxWidth-6,
|
||||
left+right-margin-6, top+margin+6, '#FF0000', 4);
|
||||
core.drawLine('data', left + margin + 6, top+margin+heroHeight+(boxWidth-32)-6,
|
||||
left+margin+boxWidth-6, top+margin+6, '#FF0000', 4);
|
||||
*/
|
||||
|
||||
// 实际操作
|
||||
var turn = 0; // 0为勇士攻击
|
||||
if (mon_special==1) turn=1;
|
||||
var battleInterval = setInterval(function() {
|
||||
core.playSound("attack", "ogg");
|
||||
|
||||
if (turn==0) {
|
||||
// 勇士攻击
|
||||
core.drawLine('data', left + right - margin - boxWidth + 6, top+margin+boxWidth-6,
|
||||
left+right-margin-6, top+margin+6, '#FF0000', 4);
|
||||
setTimeout(function() {
|
||||
core.clearMap('data', left + right - margin - boxWidth, top+margin,
|
||||
boxWidth, boxWidth);
|
||||
}, 250);
|
||||
|
||||
if (hero_atk-mon_def>0)
|
||||
mon_hp-=hero_atk-mon_def;
|
||||
if (mon_hp<0) mon_hp=0;
|
||||
|
||||
// 更新怪物伤害
|
||||
core.clearMap('data', right_start, top+margin+10, lineWidth, 40);
|
||||
core.canvas.data.textAlign='left';
|
||||
core.fillText('data', mon_hp, right_start, top+margin+10+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
}
|
||||
else {
|
||||
// 怪物攻击
|
||||
core.drawLine('data', left + margin + 6, top+margin+heroHeight+(boxWidth-32)-6,
|
||||
left+margin+boxWidth-6, top+margin+6, '#FF0000', 4);
|
||||
setTimeout(function() {
|
||||
core.clearMap('data', left + margin, top+margin, boxWidth, heroHeight+boxWidth-32);
|
||||
}, 250);
|
||||
|
||||
var per_damage = mon_atk-hero_def;
|
||||
if (mon_special == 8) per_damage += parseInt(0.1 * hero_atk); // 反击
|
||||
|
||||
hero_mdef-=per_damage;
|
||||
if (hero_mdef<0) {
|
||||
hero_hp+=hero_mdef;
|
||||
hero_mdef=0;
|
||||
}
|
||||
// 更新勇士数据
|
||||
core.clearMap('data', left_start, top+margin+10, lineWidth, 40);
|
||||
core.canvas.data.textAlign='right';
|
||||
core.fillText('data', hero_hp, left_end, top+margin+10+26, '#DDDDDD', 'bold 16px Verdana');
|
||||
|
||||
if (core.flags.enableMDef) {
|
||||
core.clearMap('data', left_start, top+margin+10+3*lineHeight, lineWidth, 40);
|
||||
core.fillText('data', hero_mdef, left_end, top+margin+10+26+3*lineHeight);
|
||||
}
|
||||
|
||||
}
|
||||
turn++;
|
||||
if (turn>=turns) turn=0;
|
||||
|
||||
if (hero_hp<=0 || mon_hp<=0) {
|
||||
// 战斗结束
|
||||
clearInterval(battleInterval);
|
||||
core.status.boxAnimateObjs = [];
|
||||
core.setBoxAnimate();
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1.0);
|
||||
core.clearMap('data', 0, 0, 416, 416);
|
||||
if (core.status.event.id=='battle') {
|
||||
core.unLockControl();
|
||||
core.status.event.id=null;
|
||||
}
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user