First Commit

This commit is contained in:
oc 2017-12-04 01:35:38 +08:00
commit 4297e6998c
62 changed files with 6923 additions and 0 deletions

52
.gitignore vendored Normal file
View File

@ -0,0 +1,52 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

View File

@ -0,0 +1,13 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
<inspection_tool class="UnterminatedStatementJS" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoreSemicolonAtEndOfBlock" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,9 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="projectProfile" value="Default" />
<option name="useProjectProfile" value="false" />
<option name="PROJECT_PROFILE" value="Default" />
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mota-js.iml" filepath="$PROJECT_DIR$/.idea/mota-js.iml" />
</modules>
</component>
</project>

12
.idea/mota-js.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

24
.idea/watcherTasks.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="false">
<option name="arguments" value="$FileName$ -o $FileNameWithoutExtension$.min.js" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="js" />
<option name="immediateSync" value="true" />
<option name="name" value="YUI Compressor JS" />
<option name="output" value="$FileNameWithoutExtension$.min.js" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="$APPLICATION_HOME_DIR$/lib/yuicompressor-2.4.8.jar" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="true" />
<option name="workingDir" value="$FileDir$" />
<envs />
</TaskOptions>
</component>
</project>

BIN
fonts/number.ttf Normal file

Binary file not shown.

BIN
images/animates.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/atk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

BIN
images/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/book.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

BIN
images/def.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

BIN
images/enemys.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
images/experience.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

BIN
images/floor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

BIN
images/fly.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

BIN
images/ground.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

BIN
images/heros.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
images/hp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

BIN
images/items.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
images/load.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/mdef.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

83
images/meaning.txt Normal file
View File

@ -0,0 +1,83 @@
# 此文件是每个数字所代表的意思,可被地图生成器读取和使用
# 可以模仿此格式在后面写上任意被识别内容
# 文件格式:
# 编号,图标所在的图片名,图标在图片上的索引从上到下第几个从0开始计算
# 注意中间以小逗号分开;不要有空格;后面可以加任意"#"代表注释
### 0-20 地形 ###
0,terrains,0 # 路面
1,terrains,1 # 黄色墙(经典墙)
2,terrains,2 # 白色墙
3,terrains,3 # 蓝色墙
4,terrains,4 # 星空
5,terrains,5 # 岩浆
6,terrains,15 # 蓝色商店左
7,terrains,16 # 蓝色商店右
8,terrains,17 # 红色商店左
9,terrains,18 # 红色商店右
10,animates,23 #血网(经过收到伤害)
# 备注11-20待定也许是毒网等地形
### 21-80 物品 ###
# 消耗品
21,items,0 # 黄钥匙
22,items,1 # 蓝钥匙
23,items,2 # 红钥匙
24,items,3 # 绿钥匙
25,items,4 # 铁门钥匙
26,items,6 # 大黄门钥匙(钥匙盒)
27,items,16 # 红宝石
28,items,17 # 蓝宝石
29,items,18 # 绿宝石
30,items,19 # 黄宝石
31,items,20 # 红血瓶
32,items,21 # 蓝血瓶
33,items,22 # 绿血瓶
34,items,23 # 黄血瓶
35,items,50 # 铁剑
36,items,55 # 铁盾
37,items,51 # 银剑
38,items,56 # 银盾
39,items,52 # 骑士剑
40,items,57 # 骑士盾
41,items,53 # 圣剑
42,items,58 # 圣盾
43,items,54 # 神圣剑
44,items,59 # 神圣盾
# 特殊道具
45,items,9 # 怪物手册
46,items,12 # 楼层传送器
47,items,45 # 破墙镐
48,items,44 # 破冰镐
49,items,43 # 炸弹
50,items,13 # 中心对称飞行器
51,items,15 # 上楼器
52,items,14 # 下楼器
53,items,11 # 幸运金币
54,items,41 # 冰冻徽章
55,items,40 # 十字架
56,items,29 # 圣水
57,items,8 # 地震卷轴
58,items,24 # 解毒药水
59,items,25 # 解衰药水
60,items,26 # 解咒药水
61,items,28 # 万能药水
62,items,42 # 屠龙匕首
# 备注63-80待定比如类似于新新魔塔的魔杖
### 81-100 门、楼梯、传送门 ###
81,terrains,9 # 黄门
82,terrains,10 # 蓝门
83,terrains,11 # 红门
84,terrains,12 # 绿门
85,terrains,13 # 机关门
86,terrains,14 # 铁门
87,terrains,7 # 上楼梯
88,terrains,6 # 下楼梯
89,animates,21 # 传送门
### 101-200 怪物 ###
# 将会按照enemys.png顺序依次读取怪物
# 如101绿色史莱姆102红色史莱姆依次类推

BIN
images/money.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

BIN
images/npcs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
images/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
images/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
images/shop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
images/terrains.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
images/toolbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

93
index.html Normal file
View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='content-type' content='text/html' charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=Edge, chrome=1'>
<meta name='author' content='ckcz123'>
<meta name='viewport'
content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=yes'>
<!-- 做出塔后需要在这里改成塔本身的名字 -->
<title>魔塔样板 - HTML5魔塔</title>
<meta name="apple-mobile-web-app-title" content="魔塔样板">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="screen-orientation" content="portrait">
<meta name="full-screen" content="yes">
<meta name="browsermode" content="application">
<meta name="x5-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="x5-page-mode" content="app">
<link type='text/css' href='styles.css' rel='stylesheet'>
</head>
<body>
<div id='gameGroup'>
<p id='mainTips'>请稍后...</p>
<div id='startPanel'>
<div id='startTop'>
<div id='startTopProgressBar'>
<div id='startTopProgress'></div>
</div>
<p id='startTopLoadTips'>资源即将开始加载</p>
</div>
<img id='startBackground' src='images/bg.png'>
<!-- 标题界面可以改style的color使标题改变颜色 -->
<p id='startLogo' style="color: black">魔塔样板</p>
<div id='startButtonGroup'>
<div id='startButtons'>
<span class='startButton' id='playGame'>开始游戏</span>
<span class='startButton' id='loadGame'>载入游戏</span>
<span class='startButton' id='aboutGame'>关于本塔</span>
</div>
<div id='levelChooseButtons'>
<!-- 如果不需要三个难度,直接像这样注释掉即可 -->
<span class='startButton' id='easyLevel'>简单</span>
<span class='startButton' id='normalLevel'>普通</span>
<span class='startButton' id='hardLevel'>困难</span>
</div>
</div>
</div>
<div id='floorMsgGroup'>
<p id='logoLabel'></p>
<p id='versionLabel'></p>
<p id='floorNameLabel'></p>
</div>
<div id='statusBar'>
<img src='images/floor.png' id="img-floor">
<p class='statusLabel' id='floor'></p>
<img src='images/hp.png' id="img-hp">
<p class='statusLabel' id='hp'></p>
<img src='images/atk.png' id="img-atk">
<p class='statusLabel' id='atk'></p>
<img src='images/def.png' id="img-def">
<p class='statusLabel' id='def'></p>
<img src='images/mdef.png' id="img-mdef">
<p class='statusLabel' id='mdef'></p>
<img src='images/money.png' id="img-money">
<p class='statusLabel' id='money'></p>
<img src='images/experience.png' id="img-experience">
<p class='statusLabel' id='experience'></p>
<p class='statusLabel' id='yellowKey' style="color:#FFCCAA"></p>
<p class='statusLabel' id='blueKey' style="color:#AAAADD"></p>
<p class='statusLabel' id='redKey' style="color:#FF8888"></p>
<p class='statusLabel' id='poison' style="color: #AFFCA8;"></p>
<p class='statusLabel' id='weak' style="color: #FECCD0;"></p>
<p class='statusLabel' id='curse' style="color: #59ACFF;"></p>
<img src="images/book.png" id='img-book'>
<img src="images/fly.png" id='img-fly'>
<img src="images/toolbox.png" id='img-toolbox'>
<img src="images/shop.png" id='img-shop'>
<img src="images/save.png" id='img-save'>
<img src="images/load.png" id=img-load>
<img src="images/settings.png" id='img-settings'>
<p class=statusLabel id="hard"></p>
</div>
<div id="toolBar"></div>
<canvas class='gameCanvas' id='bg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='event' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='fg' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='hero' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
</div>
<script id='mainScript' src='main.js'></script>
</body>
</html>

3120
libs/core.js Normal file

File diff suppressed because it is too large Load Diff

1
libs/core.min.js vendored Normal file

File diff suppressed because one or more lines are too long

126
libs/data.js Normal file
View File

@ -0,0 +1,126 @@
function data() {
}
data.prototype.init = function() {
this.firstData = {
'title': '魔塔样板',
'name': 'template',
'version': 'Ver 1.0.0 (Beta)',
'floorId': 'MT1',
'enableExperience': true,
'hero': {
'id': 'hero1',
'name': '勇士',
'hp': 1000,
'atk': 10,
'def': 10,
'mdef': 0,
'money': 0,
'experience': 0,
'items': {
'keys': {
'yellowKey': 0,
'blueKey': 0,
'redKey': 0
},
'constants': {},
'tools': {}
},
'flyRange': [],
'loc': {'direction': 'up', 'x': 6, 'y': 11},
'steps': 0,
'time': {
'starttime': new Date(),
'playtime': 0,
'totaltime': 0,
'lasttime': new Date()
},
'flags': {
'visitFloors': {},
'passLava': false, // 经过岩浆则禁用商店
'hasShield5': false, // 有神圣盾
'seal20F': false, // 20F封印
'poison': true,
}
},
'shops': {
'shop1': {
'id': 'shop1', 'title': '贪婪之神', 'name': '3楼金币商店', 'icon': 'blueShop',
'times': 0, 'need': "25", 'visited': false, 'use': 'money',
'choices': [
{'text': '生命+800', 'effect': 'status,hp,800'},
{'text': '攻击+4', 'effect': 'status,atk,4'},
{'text': '防御+4', 'effect': 'status,def,4'}
]
},
'shop2': {
'id': 'shop2', 'title': '经验之神', 'name': '5楼经验商店', 'icon': 'redShop',
'times': 0, 'need': -1, 'visited': false, 'use': 'experience',
'choices': [
{'text': '攻击+5', 'effect': 'status,atk,5', 'need': '30'},
{'text': '防御+5', 'effect': 'status,def,5' ,'need': '30'},
{'text': '等级+1', 'effect': 'status,hp,1000;status,atk,7;status,def,7', 'need': '100'}
]
},
'shop3': {
'id': 'shop3', 'title': '钥匙商人', 'name': '6楼钥匙商人', 'icon': 'womanMagician',
'times': 0, 'need': -1, 'visited': false, 'use': 'money',
'choices': [
{'text': '黄钥匙+1', 'effect': 'item,yellowKey,1', 'need': '10'},
{'text': '蓝钥匙+1', 'effect': 'item,blueKey,1', 'need': '50'},
{'text': '红钥匙+1', 'effect': 'item,redKey,1', 'need': '100'}
]
},
'shop4': {
'id': 'shop4', 'title': '贪婪之神', 'name': '10楼金币商店', 'icon': 'blueShop',
'times': 0, 'need': "100", 'visited': false, 'use': 'money',
'choices': [
{'text': '生命+4000', 'effect': 'status,hp,4000'},
{'text': '攻击+20', 'effect': 'status,atk,20'},
{'text': '防御+20', 'effect': 'status,def,20'}
]
},
'shop5': {
'id': 'shop5', 'title': '经验之神', 'name': '15楼经验商店', 'icon': 'redShop',
'times': 0, 'need': -1, 'visited': false, 'use': 'experience',
'choices': [
{'text': '攻击+17', 'effect': 'status,atk,17', 'need': '95'},
{'text': '防御+17', 'effect': 'status,def,17' ,'need': '95'},
{'text': '等级+3', 'effect': 'status,hp,3000;status,atk,21;status,def,21', 'need': '270'}
]
},
},
'npcs': {},
'animateSpeed': 500,
'startText': [
"测试"
]
}
// 系统FLAG在游戏运行中中请不要修改它。
this.flags = {
/****** 角色状态相关 ******/
"HPMAX": 999999, // HP上限-1则无上限
"enableMDef": true, // 是否涉及勇士的魔防值如果此项为false则状态栏不会显示勇士的魔防值
"enableExperience": true, // 是否涉及经验值如果此项为false则状态栏和怪物手册均将不会显示经验值
// 重要说明如果enableMDef和enableExperience均为true则在状态栏不会显示当前楼层 //
/****** 道具相关 ******/
"flyNearStair": false, // 是否需要在楼梯边使用传送器
"bombTrigger": true, // 使用炸弹后是否触发怪物事件(如开门)
"pickaxeFourDirections": true, // 使用破墙镐是否四个方向都破坏如果false则只破坏面前的墙壁
"bigKeyIsBox": true, // 如果此项为true则视为钥匙盒红黄蓝钥匙+1若为false则视为大黄门钥匙
/****** 系统相关 ******/
"potionWhileRouting": false, // 寻路算法是否经过血瓶如果该项为false则寻路算法会自动尽量绕过血瓶
}
}
data.prototype.getFirstData = function() {
return core.clone(this.firstData);
}
main.instance.data = new data();

1
libs/data.min.js vendored Normal file
View File

@ -0,0 +1 @@
function data(){}data.prototype.init=function(){this.firstData={name:"yikongjian",version:"Ver 1.0.0 (Beta)",floorId:"MT1",enableExperience:true,hero:{id:"hero1",name:"勇士",hp:1000,atk:10,def:10,mdef:0,money:0,experience:0,items:{keys:{yellowKey:0,blueKey:0,redKey:0},constants:{},tools:{}},flyRange:["MT1"],loc:{direction:"up",x:6,y:11},steps:0,time:{starttime:new Date(),playtime:0,totaltime:0,lasttime:new Date()},flags:{visitFloors:{},passLava:false,hasShield5:false,seal20F:false}},shops:{shop1:{id:"shop1",title:"贪婪之神",name:"3楼金币商店",icon:"blueShop",times:0,need:"25",visited:false,use:"money",choices:[{text:"生命+800",effect:"status,hp,800"},{text:"攻击+4",effect:"status,atk,4"},{text:"防御+4",effect:"status,def,4"}]},shop2:{id:"shop2",title:"经验之神",name:"5楼经验商店",icon:"redShop",times:0,need:-1,visited:false,use:"experience",choices:[{text:"攻击+5",effect:"status,atk,5",need:"30"},{text:"防御+5",effect:"status,def,5",need:"30"},{text:"等级+1",effect:"status,hp,1000;status,atk,7;status,def,7",need:"100"}]},shop3:{id:"shop3",title:"钥匙商人",name:"6楼钥匙商人",icon:"womanMagician",times:0,need:-1,visited:false,use:"money",choices:[{text:"黄钥匙+1",effect:"item,yellowKey,1",need:"10"},{text:"蓝钥匙+1",effect:"item,blueKey,1",need:"50"},{text:"红钥匙+1",effect:"item,redKey,1",need:"100"}]},shop4:{id:"shop4",title:"贪婪之神",name:"10楼金币商店",icon:"blueShop",times:0,need:"100",visited:false,use:"money",choices:[{text:"生命+4000",effect:"status,hp,4000"},{text:"攻击+20",effect:"status,atk,20"},{text:"防御+20",effect:"status,def,20"}]},shop5:{id:"shop5",title:"经验之神",name:"15楼经验商店",icon:"redShop",times:0,need:-1,visited:false,use:"experience",choices:[{text:"攻击+17",effect:"status,atk,17",need:"95"},{text:"防御+17",effect:"status,def,17",need:"95"},{text:"等级+3",effect:"status,hp,3000;status,atk,21;status,def,21",need:"270"}]}},npcs:{},animateSpeed:500};this.flags={HPMAX:999999,enableExperience:true,flyNearStair:false,bombTrigger:true,picaxeFourDirections:true,potionWhileRouting:false}};data.prototype.getFirstData=function(){return core.clone(this.firstData)};main.instance.data=new data();

229
libs/enemys.js Normal file
View File

@ -0,0 +1,229 @@
function enemys() {
}
enemys.prototype.init = function () {
this.enemys = {
'greenSlime': {'name': '绿头怪', 'hp': 50, 'atk': 18, 'def': 1, 'money': 1, 'experience': 1, 'special': 0},
'redSlime': {'name': '红头怪', 'hp': 70, 'atk': 20, 'def': 2, 'money': 2, 'experience': 2, 'special': 0},
/* 'blackSlime': {'name': '青头怪', 'hp': 189, 'atk': 27, 'def': 6, 'money': 3, 'experience': 1, 'special': 0}, */
/* 'slimelord': {'name': '怪王', 'hp': 472, 'atk': 300, 'def': 150, 'money': 35, 'experience': 1,'special': 0}, */
'bat': {'name': '小蝙蝠', 'hp': 90, 'atk': 30, 'def': 4, 'money': 4, 'experience': 3,'special': 0},
/* 'bigBat': {'name': '大蝙蝠', 'hp': 451, 'atk': 92, 'def': 18, 'money': 12,'experience': 1, 'special': 0}, */
/* 'redBat': {'name': '红蝙蝠', 'hp': 439, 'atk': 260, 'def': 140, 'money': 30,'experience': 1, 'special': 0}, */
'vampire': {'name': '冥灵魔王', 'hp': 10000, 'atk': 2000, 'def': 2000, 'money': 100,'experience': 100, 'special': 0, 'bomb': false },
'skeleton': {'name': '骷髅人', 'hp': 100, 'atk': 35, 'def': 5, 'money': 6,'experience': 4, 'special': 0},
'skeletonSoilder': {'name': '骷髅士兵', 'hp': 150, 'atk': 55, 'def': 15, 'money': 10,'experience': 8, 'special': 0},
/* 'skeletonCaptain': {'name': '骷髅队长', 'hp': 600, 'atk': 110, 'def': 20, 'money': 13,'experience': 1, 'special': 0}, */
/* 'ghostSkeleton': {'name': '冥队长', 'hp': 836, 'atk': 236, 'def': 81, 'money': 28,'experience': 1, 'special': 0}, */
'zombie': {'name': '兽人', 'hp': 1000, 'atk': 245, 'def': 45, 'money': 26,'experience': 21, 'special': 0},
'zombieKnight': {'name': '兽人武士', 'hp': 2000, 'atk': 340, 'def': 170, 'money': 70,'experience': 55, 'special': 0},
'rock': {'name': '石头人', 'hp': 1600, 'atk': 750, 'def': 950, 'money': 31,'experience': 23, 'special': 3},
'slimeMan': {'name': '影子战士', 'hp': 3000, 'atk': 500, 'def': 250, 'money': 80,'experience': 60, 'special': 0},
'bluePriest': {'name': '初级法师', 'hp': 150, 'atk': 50, 'def': 10, 'money': 8,'experience': 7, 'special': 0},
'redPriest': {'name': '高级法师', 'hp': 300, 'atk': 100, 'def': 20, 'money': 20,'experience': 15,'special': 0},
/* 'brownWizard': {'name': '初级巫师', 'hp': 500, 'atk': 358, 'def': 222, 'money': 44,'experience': 1, 'special': 2}, */
/* 'redWizard': {'name': '高级巫师', 'hp': 1000, 'atk': 100, 'def': 350, 'money': 51,'experience': 1, 'special': 2}, */
/* 'yellowGuard': {'name': '初级卫兵', 'hp': 444, 'atk': 85, 'def': 24, 'money': 10,'experience': 1,'special': 0}, */
/* 'blueGuard': {'name': '中级卫兵', 'hp': 746, 'atk': 160, 'def': 90, 'money': 24,'experience': 1, 'special': 0}, */
/* 'redGuard': {'name': '高级卫兵', 'hp': 560, 'atk': 280, 'def': 160, 'money': 33,'experience': 1, 'special': 0}, */
'swordsman': {'name': '双手剑士', 'hp': 600, 'atk': 888, 'def': 60, 'money': 77,'experience': 66, 'special': 4},
/* 'soldier': {'name': '冥战士', 'hp': 888, 'atk': 388, 'def': 88, 'money': 39,'experience': 1, 'special': 0}, */
'yellowKnight': {'name': '金骑士', 'hp': 2000, 'atk': 1200, 'def': 1000, 'money': 103,'experience': 94, 'special': 0},
'redKnight': {'name': '红骑士', 'hp': 3500, 'atk': 1350, 'def': 1200, 'money': 125,'experience': 112, 'special': 0},
'darkKnight': {'name': '黑骑士', 'hp': 6000, 'atk': 1600, 'def': 1400, 'money': 173,'experience': 144, 'special': 0},
/* 'blackKing': {'name': '黑衣魔王', 'hp': 1356, 'atk': 650, 'def': 356, 'money': 0,'experience': 1, 'special': 0},*/
/* 'yellowKing': {'name': '黄衣魔王', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'greenKing': {'name': '青衣武士', 'hp': 688, 'atk': 502, 'def': 332, 'money': 53, 'experience': 1,'special': 0},*/
/* 'blueKnight': {'name': '近卫骑士', 'hp': 400, 'atk': 375, 'def': 350, 'money': 49, 'experience': 1,'special': 0},*/
/* 'goldSlime': {'name': '黄头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'poisonSkeleton': {'name': '紫骷髅', 'hp': 550, 'atk': 370, 'def': 250, 'money': 42,'experience': 1, 'special': 0},*/
/* 'poisonBat': {'name': '紫蝙蝠', 'hp': 743, 'atk': 440, 'def': 304, 'money': 52,'experience': 1, 'special': 0},*/
/* 'steelRock': {'name': '铁面人', 'hp': 120, 'atk': 270, 'def': 0, 'money': 50, 'experience': 1,'special': 3},*/
/* 'skeletonPriest': {'name': '骷髅法师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'skeletonKing': {'name': '骷髅王', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'skeletonWizard': {'name': '骷髅巫师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'redSkeletonCaption': {'name': '骷髅武士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'special': 0},*/
/* 'badHero': {'name': '迷失勇者', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'demon': {'name': '魔神武士', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'demonPriest': {'name': '魔神法师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'goldHornSlime': {'name': '金角怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'redKing': {'name': '红衣魔王', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0}, */
/* 'whiteKing': {'name': '白衣武士', 'hp': 766, 'atk': 544, 'def': 162, 'money': 46, 'experience': 1,'special': 0}, */
'blackMagician': {'name': '黑魔法师', 'hp': 7000, 'atk': 2000, 'def': 1500, 'money': 200,'experience': 156,'special': 11, 'value': 1/3},
/* 'silverSlime': {'name': '银头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0}, */
/* 'swordEmperor': {'name': '剑圣', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0}, */
/* 'whiteHornSlime': {'name': '尖角怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'badPrincess': {'name': '痛苦魔女', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'badFairy': {'name': '黑暗仙子', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
/* 'grayPriest': {'name': '中级法师', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0,'experience': 1, 'special': 0},*/
/* 'redSwordsman': {'name': '剑王', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 1,'special': 0},*/
'whiteGhost': {'name': '水银战士', 'hp': 4500, 'atk': 1000, 'def': 500, 'money': 100, 'experience': 80,'special': 0},
/* 'poisonZombie': {'name': '绿兽人', 'hp': 660, 'atk': 443, 'def': 210, 'money': 43, 'experience': 1,'special': 0},*/
'magicDragon': {'name': '魔龙', 'hp': 33333, 'atk': 3333, 'def': 3333, 'money': 0, 'experience': 0,'special': 0, 'bomb': false },
'octopus': {'name': '血影', 'hp': 10000, 'atk': 999, 'def': 999, 'money': 999, 'experience': 999, 'special': 0},
'fairy': {'name': '仙子', 'hp': 600000, 'atk': 250000, 'def': 50000, 'money': 0, 'experience': 0,'special': 0, 'bomb': false },
'greenKnight': {'name': '强盾骑士', 'hp': 15000, 'atk': 3000, 'def': 2000, 'money': 148, 'experience': 133,'special': 3},
}
}
enemys.prototype.getEnemys = function (enemyId) {
if (enemyId == undefined) {
return this.enemys;
}
return this.enemys[enemyId];
}
enemys.prototype.getSpecialText = function (enemyId) {
if (enemyId == undefined) return "";
var special = this.enemys[enemyId].special;
if (special == 1) return "先攻";
if (special == 2) return "魔攻";
if (special == 3) return "坚固";
if (special == 4) return "2连击";
if (special == 5) return "3连击";
if (special == 6) return "4连击";
if (special == 7) return "破甲";
if (special == 8) return "反击";
if (special == 9) return "净化";
if (special == 11) return "吸血";
return "";
}
enemys.prototype.getDamage = function (monsterId) {
var monster = core.material.enemys[monsterId];
var hero_atk = core.status.hero.atk, hero_def = core.status.hero.def, hero_mdef = core.status.hero.mdef;
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);
var extra_damage = 0;
if (monster.special == 11) { // 吸血
// 吸血的比例
extra_damage = core.status.hero.hp * monster.value;
if (core.status.hero.flags.hasShield5) // 存在神圣盾
extra_damage /= 2;
extra_damage = parseInt(extra_damage);
}
return damage + extra_damage;
}
// 临界值计算
enemys.prototype.getCritical = function (monsterId) {
var monster = core.material.enemys[monsterId];
if (monster.special == 3) return "???";
var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
if (last == 0) return 0;
for (var i = core.status.hero.atk + 1; i <= monster.hp + monster.def; i++) {
var damage = this.calDamage(i, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
if (damage < last)
return i - core.status.hero.atk;
last = damage;
}
return 0;
}
// 临界减伤计算
enemys.prototype.getCriticalDamage = function (monsterId) {
var c = this.getCritical(monsterId);
if (c == '???') return '???';
if (c == 0) return 0;
var monster = core.material.enemys[monsterId];
// if (c<=0) return 0;
var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
if (last == 999999999) return '???';
return last - this.calDamage(core.status.hero.atk + c, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special);
}
// 1防减伤计算
enemys.prototype.getDefDamage = function (monsterId) {
var monster = core.material.enemys[monsterId];
return this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special) -
this.calDamage(core.status.hero.atk, core.status.hero.def + 1, core.status.hero.mdef,
monster.hp, monster.atk, monster.def, monster.special)
}
enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mon_atk, mon_def, mon_special) {
// 魔攻
if (mon_special == 2) hero_def = 0;
// 坚固
if (mon_special == 3 && mon_def < hero_atk - 1) mon_def = hero_atk - 1;
// 模仿
if (mon_special == 10) {
mon_atk = hero_atk;
mon_def = hero_def;
}
if (hero_atk <= mon_def) return 999999999;
var per_damage = mon_atk - hero_def;
if (per_damage < 0) per_damage = 0;
// 2连击 & 3连击
if (mon_special == 4) per_damage *= 2;
if (mon_special == 5) per_damage *= 3;
if (mon_special == 6) per_damage *= 4;
// 反击
if (mon_special == 8) per_damage += parseInt(0.1 * hero_atk);
// 先攻
var damage = mon_special == 1 ? per_damage : 0;
// 破甲
if (mon_special == 7) damage = parseInt(0.9 * hero_def);
// 净化
if (mon_special == 9) damage = 3 * hero_mdef;
var turn = parseInt((mon_hp - 1) / (hero_atk - mon_def));
var ans = damage + turn * per_damage;
ans -= hero_mdef;
// 魔防回血
// return ans;
// 魔防不回血
return ans <= 0 ? 0 : ans;
}
// 获得当前楼层的怪物列表
enemys.prototype.getCurrentEnemys = function () {
var enemys = [];
var used = {};
var mapBlocks = core.status.thisMap.blocks;
for (var b = 0; b < mapBlocks.length; b++) {
if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls == 'enemys') {
var monsterId = mapBlocks[b].event.id;
if (core.isset(used[monsterId])) continue;
var monster = core.material.enemys[monsterId];
var mon_def = monster.def;
// 坚固
if (monster.special==3 && mon_def<core.status.hero.atk-1)
mon_def = core.status.hero.atk-1;
enemys.push({
'id': monsterId, 'name': monster.name, 'hp': monster.hp, 'atk': monster.atk, 'def': mon_def,
'money': monster.money, 'experience': monster.experience, 'special': core.enemys.getSpecialText(monsterId),
'damage': this.getDamage(monsterId), 'critical': this.getCritical(monsterId),
'criticalDamage': this.getCriticalDamage(monsterId), 'defDamage': this.getDefDamage(monsterId)
});
used[monsterId] = true;
}
}
enemys.sort(function (a, b) {
if (a.damage == b.damage) {
return a.money - b.money;
}
return a.damage - b.damage;
});
return enemys;
}
main.instance.enemys = new enemys();

1
libs/enemys.min.js vendored Normal file

File diff suppressed because one or more lines are too long

606
libs/events.js Normal file
View File

@ -0,0 +1,606 @@
function events() {
}
events.prototype.init = function () {
this.events = {
'battle': function (data, core, callback) {
//core.playSound('floor', 'mp3');
//core.rmBlock('event', data.x, data.y);
core.battle(data.event.id, data.x, data.y);
if (core.isset(callback))
callback();
},
'changeFloor': function (data, core, callback) {
// core.changeFloor(data.event.data.floorId, data.event.data.heroLoc);
core.changeFloor(data.event.data.floorId, data.event.data.stair,
data.event.data.heroLoc, callback);
},
'getItem': function (data, core, callback) {
core.getItem(data.event.id, 1, data.x, data.y);
if (core.isset(callback))
callback();
},
'openDoor': function (data, core, callback) {
core.openDoor(data.event.id, data.x, data.y, true);
if (core.isset(callback))
callback();
},
'visitNpc': function (data, core, callback) {
core.visitNpc(data.event.npcid, data.x, data.y);
if (core.isset(callback))
callback();
},
'openShop': function (data, core, callback) {
core.ui.drawShop(data.event.shopid);
if (core.isset(callback))
callback();
},
'passNet': function (data, core, callback) {
core.events.passNet(data);
if (core.isset(callback))
callback();
},
'blockEvent': function (data, core, callback) {
core.events.blockEvent(data);
if (core.isset(callback)) callback();
}
}
}
events.prototype.getEvents = function (eventName) {
if (eventName == undefined) {
return this.events;
}
return this.events[eventName];
}
main.instance.events = new events();
/**
* 游戏开始事件
* @param hard 难度
*/
events.prototype.startGame = function (hard) {
core.hideStartAnimate(function() {
core.drawText(core.firstData.startText, function() {
core.startGame(hard);
});
})
}
////// 走到某位置时触发事件 //////
events.prototype.blockEvent = function (data) {
if (core.status.floorId=='MT16' && data.x==6 && data.y==2) {
core.waitHeroToStop(function (){
// 和魔王对话
core.drawText([
{'content': '冥灵魔王?你不是已经被我杀了吗?\n为什么会出现在这里', 'id': 'hero'},
{'content': '因为...这里位于魔塔的另一个位面。\n大多数情况下塔内死亡的生物都会回归这里。', 'id': 'vampire'},
{'content': '你的意思是说,我现在已经死了?', 'id': 'hero'},
{'content': '是的,能到达这里的,\n除了可以掌控位面的高智慧生物以外只有\n亡灵。', 'id': 'vampire'},
{'content': '呵,既然,我的生命已经不复存在。\n我已经没有什么好怕的了。\n大魔头我们冤家路窄居然又见面了\n决斗吧', 'id': 'hero'},
{'content': '你似乎还没明白。。。', 'id': 'vampire'},
{'content': '明白什么?', 'id': 'hero'},
{'content': '诶,算了,决一死战吧。', 'id': 'vampire'},
], function() {
core.removeBlock('data', data.x, data.y);
})
});
return;
}
}
/////////////////// onclick事件处理 ///////////////////
////// 转换楼层结束的事件 //////
events.prototype.afterChangeFloor = function (floorId) {
core.status.hero.flags.passLava = false;
// 首次到达某层
if (!core.isset(core.status.hero.flags.visitFloors[floorId])) {
core.status.hero.flags.visitFloors[floorId]=true;
if (floorId=='MT1') {
core.drawText([
{'content': '这里...是哪里?', 'id': 'hero'},
{'content': '难道?我还活着?', 'id': 'hero'},
{'content': '一股似曾相识的感觉,\n但我又不知道在哪里见过。', 'id': 'hero'},
{'content': '魔塔已经被大火烧成了灰烬,\n这里为什么安然无恙这到底是什么地方', 'id': 'hero'},
{'content': '这里,我感觉到不像是我生活的地方。\n难道我已经到了异世界吗', 'id': 'hero'},
{'content': '算了,不管这么多了。\n只要我还活着一切都好。', 'id': 'hero'},
{'content': '我先四处看看要怎么出去吧。', 'id': 'hero'},
{'content': '(系统提示)本塔快捷键如下:\n\n[↑][↓][←][→] 移动\n[X] 怪物手册\n[G] 楼层传送器\n[T] 工具栏\n[K] 快捷商店\n[S/L] 存/读档\n[ESC] 菜单栏\n同时也可以点击状态栏中的图标进行操作。'},
{'content': '(系统提示)\n在菜单栏里可以同步存档这样可以很方便的让你\n在多设备例如手机/电脑)之间接档游戏。'}
]);
}
if (floorId=='MT2') {
core.drawText([
{'content': '奇怪,我明明杀死了血影。\n为什么这里又出现了一个。', 'id': 'hero'},
{'content': '不过我的力量似乎都被冻结了。\n目前肯定是无法杀死血影\n等我变强以后再回来吧。', 'id': 'hero'},
]);
}
if (floorId=='MT11') {
core.drawText([
{'content': '诶,奇怪,我明明只是上了一层楼而已。\n为什么这里变得如此的寒冷...', 'id': 'hero'},
{'content': '诶,毕竟我已经不在我生活的世界了。\n很多事情都是预料不到的。', 'id': 'hero'},
{'content': '不管怎么说,我要继续上去看个究竟。', 'id': 'hero'}
])
}
if (floorId=='MT20') {
core.drawText([
{'content': '这...这里就是塔顶了吗。\n仙子你怎么也在这里。\n魔塔倒塌了你也死掉了所以到达这里了吗', 'id': 'hero'},
{'content': '呵,怎么可能。我怎么会这么容易死。\n这里就是位面的交界处了\n我就是这个位面的操纵者。', 'id': 'fairy'},
{'content': '你居然有这样强大的能力!\n跟我第一次遇见你差距太大了吧', 'id': 'hero'},
{'content': '是的,一开始,我弱不禁风。\n但是你帮我集齐了十字架和三个灵杖\n让我的能力得到了巨幅度的提高。', 'id': 'fairy'},
{'content': '估计你自己也想不到这些东西有这么大的威力。\n不过还要感谢你的无私奉献成就了我的现在。', 'id': 'fairy'},
{'content': '......', 'id': 'hero'},
{'content': '其实,魔塔倒塌是我一手策划的,\n就是为了把所有的生物都驱逐进这个亡灵位面。', 'id': 'fairy'},
{'content': '我一直策划着等我有一天变强了,\n我要一人统治世界消灭掉所有的其他生物。\n如今我的目标达成了。', 'id': 'fairy'},
{'content': '消灭其他所有生物?也就是说也包括我?', 'id': 'hero'},
{'content': '没错。愚蠢的人类终于觉悟了。', 'id': 'fairy'},
{'content': '呵呵,想当初,我就应该一刀把你杀了。\n真没想到我会轻信你的鬼话。', 'id': 'hero'},
{'content': '现在说这些还有什么用呢,\n你和我的力量根本就不是一个级别的。\n劝你放弃抵抗吧。', 'id': 'fairy'},
{'content': '(仙子有来源于高维度的力量支持,\n所以目前强大无比。我是不可能战胜的。', 'id': 'hero'},
{'content': '(不过,这个位面力量非常不稳定,\n如果我能成功的封印她切断外界的支持\n也许还能有机会求胜。', 'id': 'hero'},
{'content': '(仙子目前的位置正好被八个小怪包围,\n如果按照当年封印Zeno的方法去封印她\n能否成功呢这是我唯一的希望。', 'id': 'hero'},
{'content': '系统提示专门给没玩过TSW的玩家看的\n击杀仙子周围的四个怪保留四个角的怪。\n如果还看不懂的看一眼你的小键盘\n仙子在5的位置击杀2468。'},
]);
}
}
}
////// 选中菜单栏 //////
////// 降低难度 //////
events.prototype.decreaseHard = function() {
if (core.status.hard == 0) {
core.drawTip("当前已是难度0不能再降低难度了");
return;
}
var add = 100, x=core.status.hard;
while (x<10) {
x++; add*=2;
}
core.ui.drawConfirmBox("本次操作可生命+" + add + ",确定吗?", function () {
core.status.hero.hp += add;
core.status.hard--;
core.updateStatusBar();
core.ui.closePanel();
core.drawTip("降低难度成功,生命+" + add);
}, function () {
core.ui.drawSettings(false);
});
}
////// 能否使用快捷商店 //////
events.prototype.canUseQuickShop = function(index) {
if (core.status.floorId == 'MT20') return '当前不能使用快捷商店。';
if (core.status.hero.flags.passLava) return '由于你刚刚经过岩浆,此时不得使用快捷商店。\n切换楼层后恢复。';
return null;
}
////// 尝试使用道具 //////
events.prototype.useItem = function(itemId) {
console.log("使用道具:"+core.material.items[itemId].name);
core.ui.closePanel(false);
if (itemId=='book') {
core.openBook(false);
return;
}
if (itemId=='fly') {
core.useFly(false);
return;
}
// TODO add other items
if (core.canUseItem(itemId)) core.useItem(itemId);
else core.drawTip("当前无法使用"+core.material.items[itemId].name);
}
/****** 打完怪物 ******/
events.prototype.afterBattle = function(enemyId) {
if (core.status.floorId == 'MT14' && !core.enemyExists(5,9) && !core.enemyExists(7,9)) {
core.openDoor("specialDoor", 6, 8, false);
}
if (core.status.floorId == 'MT20') {
// 检查封印
if (!core.status.hero.flags.seal20F) {
// 四个角都存在,四边都不存在
if (core.enemyExists(5,5) && core.enemyExists(5,7) && core.enemyExists(7,7) && core.enemyExists(7,5)
&& !core.enemyExists(5,6) && !core.enemyExists(7,6) && !core.enemyExists(6,5) && !core.enemyExists(6,7)) {
// 触发封印
core.status.hero.flags.seal20F = true;
core.material.enemys.fairy.hp /= 10;
core.material.enemys.fairy.atk /= 10;
core.material.enemys.fairy.def /= 10;
core.updateFg();
core.drawText([
{'content': '啊,我怎么被封印了!\n能量只剩下一成了', 'id': 'fairy'}
]);
// core.drawTip("触发仙子封印");
core.clearContinueAutomaticRoute();
return;
}
}
// 打败仙子
if (enemyId == 'fairy') {
core.events.win();
core.clearContinueAutomaticRoute();
return;
}
}
//继续行走
core.continueAutomaticRoute();
}
/****** 开完门 ******/
events.prototype.afterOpenDoor = function(doorId) {
//继续行走
core.continueAutomaticRoute();
}
/****** 经过路障 ******/
events.prototype.passNet = function (data) {
if (data.event.id=='lavaNet') {
core.status.hero.hp -= 100;
if (core.status.hero.hp<=0) {
core.status.hero.hp=0;
core.updateStatusBar();
core.events.lose();
return;
}
core.status.hero.flags.passLava = true;
core.updateStatusBar();
core.drawTip('经过熔岩,生命-100');
}
}
/*********** 界面上的点击事件 ***************/
// 怪物手册
events.prototype.clickBook = function(x,y) {
// 上一页
if ((x == 3 || x == 4) && y == 12) {
core.ui.drawEnemyBook(core.status.event.data - 1);
}
// 下一页
if ((x == 8 || x == 9) && y == 12) {
core.ui.drawEnemyBook(core.status.event.data + 1);
}
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel(true);
}
return;
}
// 飞行器
events.prototype.clickFly = function(x,y) {
if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1);
if ((x==10 || x==11) && y==5) core.ui.drawFly(core.status.event.data+1);
if (x>=5 && x<=7 && y==12) core.ui.closePanel();
if (x>=0 && x<=9 && y>=3 && y<=11) {
var index=core.status.hero.flyRange.indexOf(core.status.floorId);
var stair=core.status.event.data<index?"upFloor":"downFloor";
var floorId=core.status.event.data;
core.changeFloor(core.status.hero.flyRange[floorId], stair);
core.ui.closePanel();
}
return;
}
// 商店
events.prototype.clickShop = function(x,y) {
if (core.status.event.data == null) {
console.log("发生错误,商店不存在?");
return;
}
if (x >= 5 && x <= 7) {
if (y >= 5 && y <= 8) {
if (y >= 5 + core.status.event.data.choices.length) return;
var money = core.getStatus('money'), experience = core.getStatus('experience');
var shop = core.status.event.data;
var times = shop.times, need = eval(shop.need);
var use = shop.use;
var use_text = use=='money'?"金币":"经验";
var choice = shop.choices[y-5];
if (core.isset(choice.need))
need = eval(choice.need);
if (need > eval(use)) {
core.drawTip("你的"+use_text+"不足");
return;
}
eval(use+'-='+need);
core.setStatus('money', money);
core.setStatus('experience', experience);
core.updateStatusBar();
core.npcEffect(choice.effect);
core.status.event.data.times++;
core.ui.openShop(core.status.event.data.id);
return;
}
// 退出商店
if (y == 9) {
core.status.event.data = null;
core.ui.closePanel();
return;
}
}
}
events.prototype.clickSelectShop = function(x,y) {
if (x >= 5 && x <= 7) {
var shopList = core.status.shops, keys = Object.keys(shopList);
var topIndex = 6 - parseInt((keys.length + 1) / 2);
var exitIndex = 6 + parseInt((keys.length + 1) / 2);
if (y >= topIndex && y - topIndex < keys.length) {
var reason = core.events.canUseQuickShop(y-topIndex);
if (core.isset(reason)) {
core.drawText(reason);
return;
}
var shop=shopList[keys[y - topIndex]];
if (!shop.visited) {
if (shop.times==0) core.drawTip('该商店尚未开启');
else core.drawTip('该商店已失效');
return;
}
core.ui.drawShop(keys[y - topIndex]);
}
if (y == exitIndex) {
core.ui.closePanel();
}
}
}
// 工具栏
events.prototype.clickToolbox = function(x,y) {
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel(false);
return;
}
var itemId = null;
var items = null;
if (y>=4 && y<=7 && x!=12)
items = Object.keys(core.status.hero.items.tools).sort();
if (y>=9 && y<=12 && x!=12)
items = Object.keys(core.status.hero.items.constants).sort();
if (items==null) return;
var index=0;
if (y==4||y==5||y==9||y==10) index=parseInt(x/2);
else index=6+parseInt(x/2);
if (index>=items.length) return;
itemId=items[index];
if (itemId==core.status.event.data) {
core.events.useItem(itemId);
}
else {
core.ui.drawToolbox(itemId);
}
}
// 存读档
events.prototype.clickSL = function(x,y) {
// 上一页
if ((x == 3 || x == 4) && y == 12) {
core.ui.drawSLPanel(core.status.event.data - 1);
}
// 下一页
if ((x == 8 || x == 9) && y == 12) {
core.ui.drawSLPanel(core.status.event.data + 1);
}
// 返回
if (x>=10 && x<=12 && y==12) {
core.ui.closePanel(false);
if (!core.isPlaying()) {
core.showStartAnimate();
}
return;
}
var index=6*core.status.event.data+1;
if (y>=1 && y<=4) {
if (x>=1 && x<=3) core.doSL(index, core.status.event.id);
if (x>=5 && x<=7) core.doSL(index+1, core.status.event.id);
if (x>=9 && x<=11) core.doSL(index+2, core.status.event.id);
}
if (y>=7 && y<=10) {
if (x>=1 && x<=3) core.doSL(index+3, core.status.event.id);
if (x>=5 && x<=7) core.doSL(index+4, core.status.event.id);
if (x>=9 && x<=11) core.doSL(index+5, core.status.event.id);
}
}
// 菜单栏
events.prototype.clickSettings = function (x,y) {
if (x<5 || x>7) return;
if (y == 3) {
if (core.musicStatus.isIOS) {
core.drawTip("iOS设备不支持播放音乐");
return;
}
core.changeSoundStatus();
core.ui.drawSettings(false);
}
if (y == 4) core.ui.drawSelectShop();
if (y == 5) this.decreaseHard();
if (y == 6) {
core.ui.drawSyncSave();
}
if (y == 7) {
core.ui.drawConfirmBox("你确定要重新开始吗?", function () {
core.ui.closePanel();
core.restart();
}, function () {
core.ui.drawSettings(false);
});
}
if (y==8) {
core.ui.drawAbout();
// core.debug();
}
if (y == 9) core.ui.closePanel();
return;
}
events.prototype.clickNPC = function(x,y) {
var data = core.status.event.data.current;
if (core.isset(data)) {
// 对话,任意位置继续
if (data.action == 'text') {
core.npcAction();
return;
}
if (data.action == 'choices') {
if (x >= 5 && x <= 7) {
if (y >= 5 && y <= 8) {
if (y >= 5 + data.choices.length) return;
var choice = data.choices[y - 5];
if (core.isset(choice.need)) {
var able = true;
choice.need.split(';').forEach(function (e) {
var ones = e.split(',');
var type = ones[0], key = ones[1], value = ones[2];
if (type == 'status') {
if (core.getStatus(key)<parseInt(value)) able=false;
}
else if (type == 'item') {
if (core.itemCount(key)<parseInt(value)) able=false;
}
});
if (!able) {
core.drawTip("无法选择此项");
return;
}
choice.need.split(';').forEach(function (e) {
var ones = e.split(',');
var type = ones[0], key = ones[1], value = ones[2];
if (type == 'status') {
core.setStatus(key, core.getStatus(key)-parseInt(value));
}
else if (type == 'item') {
core.setItem(key, core.itemCount(key)-parseInt(value));
}
});
}
core.npcEffect(choice.effect);
core.npcAction();
return;
}
// 退出商店
if (y == 9 && !(core.isset(data.cancel) && !data.cancel)) {
core.status.event.data = null;
core.ui.closePanel();
return;
}
}
}
if (data.action == 'custom') {
core.events.npcCustomActionOnClick(data, x, y);
return;
}
}
}
/*********** 点击事件 END ***************/
// NPC自定义操作
events.prototype.npcCustomAction = function (npcData) {
}
// 当点击(x,y)位置后自定义操作
events.prototype.npcCustomActionOnClick = function (npcData, x, y) {
}
// NPC自定义事件处理
events.prototype.npcCustomEffect = function (effect, npc) {
}
// 存档事件前一刻的处理
events.prototype.beforeSaveData = function(data) {
}
// 读档事件后,载入事件前,对数据的处理
events.prototype.afterLoadData = function(data) {
// 重新封印仙子
if (core.status.hero.flags.seal20F) {
var fairy = core.material.enemys.fairy;
fairy.hp/=10;
fairy.atk/=10;
fairy.def/=10;
}
}
events.prototype.win = function() {
// 获胜
core.waitHeroToStop(function() {
core.clearMap('all');
core.rmGlobalAnimate(0,0,true);
core.drawText([
{'content': '终于,我逃脱了这个可怕的异空间。', 'id': 'hero'},
{'content': '接下来,我要何去何从。', 'id': 'hero'},
{'content': '顺着这条漆黑的甬道走下去,\n我能回到我的现实世界吗', 'id': 'hero'},
{'content': '恭喜通关难度' + core.status.hard + '!你的分数是:' + core.status.hero.hp + '\n欢迎截图到发布帖下进行炫耀\n\n再次感谢对本塔的支持'}
], function () {
core.restart();
})
});
}
events.prototype.lose = function() {
// 失败
core.drawText('很不好意思,但是你死了。', function () {
core.restart();
});
}

1
libs/events.min.js vendored Normal file

File diff suppressed because one or more lines are too long

30
libs/floors/MT0.js Normal file
View File

@ -0,0 +1,30 @@
function MT0() {}
MT0.prototype.init = function() {
this.data = {
'id': 'MT0', // 楼层唯一标识符
'title': "样板层", // 楼层中文名
'name': 0, // 显示在status bar中的名称
"canFlyTo": true, // 该楼能否被飞行器飞到(不能的话在该楼也不允许使用)
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
],
"firstArrive": [ // 第一次到该楼层触发的事件
],
"events": [ // 该楼的所有可能事件列表
],
"afterOpenDoor": [ // 开完门后可能触发的事件列表
],
"afterBattle": [ // 战斗后可能触发的事件列表
],
"afterGetItem": [ // 获得道具后可能触发的事件列表
]
};
}
main.floors.MT0 = new MT0();

30
libs/floors/MT1.js Normal file
View File

@ -0,0 +1,30 @@
function MT1() {}
MT1.prototype.init = function() {
this.data = {
'id': 'MT1', // 楼层唯一标识符
'title': "样板层", // 楼层中文名
'name': 0, // 显示在status bar中的名称
"canFlyTo": true, // 该楼能否被飞行器飞到(不能的话在该楼也不允许使用)
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
],
"firstArrive": [ // 第一次到该楼层触发的事件
],
"events": [ // 该楼的所有可能事件列表
],
"afterOpenDoor": [ // 开完门后可能触发的事件列表
],
"afterBattle": [ // 战斗后可能触发的事件列表
],
"afterGetItem": [ // 获得道具后可能触发的事件列表
]
};
}
main.floors.template = new MT1();

30
libs/floors/template.js Normal file
View File

@ -0,0 +1,30 @@
function template() {}
template.prototype.init = function() {
this.data = {
'id': 'template', // 楼层唯一标识符,需要和名字完全一致
'title': "样板层", // 楼层中文名
'name': 0, // 显示在status bar中的名称
"canFlyTo": true, // 该楼能否被飞行器飞到(不能的话在该楼也不允许使用)
"map": [ // 地图数据需要是13x13建议使用地图生成器来生成
],
"firstArrive": [ // 第一次到该楼层触发的事件
],
"events": [ // 该楼的所有可能事件列表
],
"afterOpenDoor": [ // 开完门后可能触发的事件列表
],
"afterBattle": [ // 战斗后可能触发的事件列表
],
"afterGetItem": [ // 获得道具后可能触发的事件列表
]
};
}
main.floors.template = new template();

186
libs/icons.js Normal file
View File

@ -0,0 +1,186 @@
function icons() {
}
icons.prototype.init = function () {
this.icons = {
'heros': {
'hero1': {
'down': {'loc': {'iconLoc': 0, 'stop': 0, 'leftFoot': 1, 'rightFoot': 2}, 'size': 32},
'left': {'loc': {'iconLoc': 1, 'stop': 0, 'leftFoot': 1, 'rightFoot': 2}, 'size': 32},
'right': {'loc': {'iconLoc': 2, 'stop': 0, 'leftFoot': 1, 'rightFoot': 2}, 'size': 32},
'up': {'loc': {'iconLoc': 3, 'stop': 0, 'leftFoot': 1, 'rightFoot': 2}, 'size': 32}
}
},
'terrains': {
'ground': {'loc': 0, 'size': 32},
'yellowWall': {'loc': 1, 'size': 32},
'whiteWall': {'loc': 2, 'size': 32},
'blueWall': {'loc': 3, 'size': 32},
'starWall': {'loc': 4, 'size': 32},
'lavaWall': {'loc': 5, 'size': 32},
'downFloor': {'loc': 6, 'size': 32},
'upFloor': {'loc': 7, 'size': 32},
'cavity': {'loc': 8, 'size': 32},
'yellowDoor': {'loc': 9, 'size': 32},
'blueDoor': {'loc': 10, 'size': 32},
'redDoor': {'loc': 11, 'size': 32},
'greenDoor': {'loc': 12, 'size': 32},
'specialDoor': {'loc': 13, 'size': 32},
'steelDoor': {'loc': 14, 'size': 32},
'blueShop-left': {'loc': 15, 'size': 32},
'blueShop-right': {'loc': 16, 'size': 32},
'redShop-left': {'loc': 17, 'size': 32},
'redShop-right': {'loc': 18, 'size': 32}
},
'animates': {
'star': {'loc': 0, 'size': 32},
'lava': {'loc': 1, 'size': 32},
'water': {'loc': 2, 'size': 32},
'yellowDoor': {'loc': 3, 'size': 32},
'blueDoor': {'loc': 4, 'size': 32},
'redDoor': {'loc': 5, 'size': 32},
'greenDoor': {'loc': 6, 'size': 32},
'specialDoor': {'loc': 7, 'size': 32},
'blueWallDoor': {'loc': 8, 'size': 32},
'yellowWallDoor': {'loc': 9, 'size': 32},
'whiteWallDoor': {'loc': 10, 'size': 32},
'ironDoor': {'loc': 11, 'size': 32},
'lavaDoor': {'loc': 12, 'size': 32},
'grayLavaDoor': {'loc': 13, 'size': 32},
'starDoor': {'loc': 14, 'size': 32},
'mockBlueWallDoor': {'loc': 15, 'size': 32},
'mockYellowWallDoor': {'loc': 16, 'size': 32},
'mockWhiteWallDoor': {'loc': 17, 'size': 32},
'iceYellowWallDoor': {'loc': 18, 'size': 32},
'transparentStar': {'loc': 19, 'size': 32},
'exclamation': {'loc': 20, 'size': 32},
'portal': {'loc': 21, 'size': 32},
'switch': {'loc': 22, 'size': 32},
'lavaNet': {'loc': 23, 'size': 32}
},
'npcs': {
'man': {'loc': 0, 'size': 32},
'woman': {'loc': 1, 'size': 32},
'thief': {'loc': 2, 'size': 32},
'fairy': {'loc': 3, 'size': 32},
'magician': {'loc': 4, 'size': 32},
'womanMagician': {'loc': 5, 'size': 32},
'wood': {'loc': 8, 'size': 32},
'blueShop': {'loc': 10, 'size': 32},
'redShop': {'loc': 9, 'size': 32},
'princess': {'loc': 11, 'size': 32}
},
'enemys': {
'greenSlime': {'loc': 0, 'size': 32},
'redSlime': {'loc': 1, 'size': 32},
'blackSlime': {'loc': 2, 'size': 32},
'slimelord': {'loc': 3, 'size': 32},
'bat': {'loc': 4, 'size': 32},
'bigBat': {'loc': 5, 'size': 32},
'redBat': {'loc': 6, 'size': 32},
'vampire': {'loc': 7, 'size': 32},
'skeleton': {'loc': 8, 'size': 32},
'skeletonSoilder': {'loc': 9, 'size': 32},
'skeletonCaptain': {'loc': 10, 'size': 32},
'ghostSkeleton': {'loc': 11, 'size': 32},
'zombie': {'loc': 12, 'size': 32},
'zombieKnight': {'loc': 13, 'size': 32},
'rock': {'loc': 14, 'size': 32},
'slimeMan': {'loc': 15, 'size': 32},
'bluePriest': {'loc': 16, 'size': 32},
'redPriest': {'loc': 17, 'size': 32},
'brownWizard': {'loc': 18, 'size': 32},
'redWizard': {'loc': 19, 'size': 32},
'yellowGuard': {'loc': 20, 'size': 32},
'blueGuard': {'loc': 21, 'size': 32},
'redGuard': {'loc': 22, 'size': 32},
'swordsman': {'loc': 23, 'size': 32},
'soldier': {'loc': 24, 'size': 32},
'yellowKnight': {'loc': 25, 'size': 32},
'redKnight': {'loc': 26, 'size': 32},
'darkKnight': {'loc': 27, 'size': 32},
'blackKing': {'loc': 28, 'size': 32},
'yellowKing': {'loc': 29, 'size': 32},
'greenKing': {'loc': 30, 'size': 32},
'blueKnight': {'loc': 31, 'size': 32},
'goldSlime': {'loc': 32, 'size': 32},
'poisonSkeleton': {'loc': 33, 'size': 32},
'poisonBat': {'loc': 34, 'size': 32},
'steelRock': {'loc': 35, 'size': 32},
'skeletonPriest': {'loc': 36, 'size': 32},
'skeletonKing': {'loc': 37, 'size': 32},
'skeletonWizard': {'loc': 38, 'size': 32},
'redSkeletonCaption': {'loc': 39, 'size': 32},
'badHero': {'loc': 40, 'size': 32},
'demon': {'loc': 41, 'size': 32},
'demonPriest': {'loc': 42, 'size': 32},
'goldHornSlime': {'loc': 43, 'size': 32},
'redKing': {'loc': 44, 'size': 32},
'whiteKing': {'loc': 45, 'size': 32},
'blackMagician': {'loc': 46, 'size': 32},
'silverSlime': {'loc': 47, 'size': 32},
'swordEmperor': {'loc': 48, 'size': 32},
'whiteHornSlime': {'loc': 49, 'size': 32},
'badPrincess': {'loc': 50, 'size': 32},
'badFairy': {'loc': 51, 'size': 32},
'grayPriest': {'loc': 52, 'size': 32},
'redSwordsman': {'loc': 53, 'size': 32},
'whiteGhost': {'loc': 54, 'size': 32},
'poisonZombie': {'loc': 55, 'size': 32},
'magicDragon': {'loc': 56, 'size': 32},
'octopus': {'loc': 57, 'size': 32},
'fairy': {'loc': 58, 'size': 32},
'greenKnight': {'loc': 59, 'size': 32},
},
'items': {
'yellowKey': {'loc': 0, 'size': 32},
'blueKey': {'loc': 1, 'size': 32},
'redKey': {'loc': 2, 'size': 32},
'greenKey': {'loc': 3, 'size': 32},
'steelKey': {'loc': 4, 'size': 32},
'bigKey': {'loc': 6, 'size': 32},
'redJewel': {'loc': 16, 'size': 32},
'blueJewel': {'loc': 17, 'size': 32},
'greenJewel': {'loc': 18, 'size': 32},
'yellowJewel': {'loc': 19, 'size': 32},
'redPotion': {'loc': 20, 'size': 32},
'bluePotion': {'loc': 21, 'size': 32},
'greenPotion': {'loc': 22, 'size': 32},
'yellowPotion': {'loc': 23, 'size': 32},
'book': {'loc': 9, 'size': 32},
'fly': {'loc': 12, 'size': 32},
'coin': {'loc': 11, 'size': 32},
'wand': {'loc': 10, 'size': 32},
'cross': {'loc': 40, 'size': 32},
'snow': {'loc': 41, 'size': 32},
'pickaxe': {'loc': 45, 'size': 32},
'icePickaxe': {'loc': 44, 'size': 32},
'bomb': {'loc': 43, 'size': 32},
'centerFly': {'loc': 13, 'size': 32},
'downFly': {'loc': 14, 'size': 32},
'upFly': {'loc': 15, 'size': 32},
'earthquake': {'loc': 8, 'size': 32},
'sword1': {'loc': 50, 'size': 32},
'sword2': {'loc': 51, 'size': 32},
'sword3': {'loc': 52, 'size': 32},
'sword4': {'loc': 53, 'size': 32},
'sword5': {'loc': 54, 'size': 32},
'shield1': {'loc': 55, 'size': 32},
'shield2': {'loc': 56, 'size': 32},
'shield3': {'loc': 57, 'size': 32},
'shield4': {'loc': 58, 'size': 32},
'shield5': {'loc': 59, 'size': 32},
'superPotion': {'loc': 29, 'size': 32},
}
}
}
icons.prototype.getIcons = function (iconName) {
if (iconName == undefined) {
return this.icons;
}
return this.icons[iconName];
}
main.instance.icons = new icons();

1
libs/icons.min.js vendored Normal file
View File

@ -0,0 +1 @@
function icons(){}icons.prototype.init=function(){this.icons={heros:{hero1:{down:{loc:{iconLoc:0,stop:0,leftFoot:1,rightFoot:2},size:32},left:{loc:{iconLoc:1,stop:0,leftFoot:1,rightFoot:2},size:32},right:{loc:{iconLoc:2,stop:0,leftFoot:1,rightFoot:2},size:32},up:{loc:{iconLoc:3,stop:0,leftFoot:1,rightFoot:2},size:32}}},terrains:{ground:{loc:0,size:32},yellowWall:{loc:1,size:32},whiteWall:{loc:2,size:32},blueWall:{loc:3,size:32},starWall:{loc:4,size:32},lavaWall:{loc:5,size:32},downFloor:{loc:6,size:32},upFloor:{loc:7,size:32},cavity:{loc:8,size:32},yellowDoor:{loc:9,size:32},blueDoor:{loc:10,size:32},redDoor:{loc:11,size:32},greenDoor:{loc:12,size:32},specialDoor:{loc:13,size:32},steelDoor:{loc:14,size:32},"blueShop-left":{loc:15,size:32},"blueShop-right":{loc:16,size:32},"redShop-left":{loc:17,size:32},"redShop-right":{loc:18,size:32}},animates:{star:{loc:0,size:32},lava:{loc:1,size:32},water:{loc:2,size:32},yellowDoor:{loc:3,size:32},blueDoor:{loc:4,size:32},redDoor:{loc:5,size:32},greenDoor:{loc:6,size:32},specialDoor:{loc:7,size:32},blueWallDoor:{loc:8,size:32},yellowWallDoor:{loc:9,size:32},whiteWallDoor:{loc:10,size:32},ironDoor:{loc:11,size:32},lavaDoor:{loc:12,size:32},grayLavaDoor:{loc:13,size:32},starDoor:{loc:14,size:32},mockBlueWallDoor:{loc:15,size:32},mockYellowWallDoor:{loc:16,size:32},mockWhiteWallDoor:{loc:17,size:32},iceYellowWallDoor:{loc:18,size:32},transparentStar:{loc:19,size:32},exclamation:{loc:20,size:32},portal:{loc:21,size:32},"switch":{loc:22,size:32},lavaNet:{loc:23,size:32}},npcs:{man:{loc:0,size:32},woman:{loc:1,size:32},thief:{loc:2,size:32},fairy:{loc:3,size:32},magician:{loc:4,size:32},womanMagician:{loc:5,size:32},wood:{loc:8,size:32},blueShop:{loc:10,size:32},redShop:{loc:9,size:32},princess:{loc:11,size:32}},enemys:{greenSlime:{loc:0,size:32},redSlime:{loc:1,size:32},blackSlime:{loc:2,size:32},slimelord:{loc:3,size:32},bat:{loc:4,size:32},bigBat:{loc:5,size:32},redBat:{loc:6,size:32},vampire:{loc:7,size:32},skeleton:{loc:8,size:32},skeletonSoilder:{loc:9,size:32},skeletonCaptain:{loc:10,size:32},ghostSkeleton:{loc:11,size:32},zombie:{loc:12,size:32},zombieKnight:{loc:13,size:32},rock:{loc:14,size:32},slimeMan:{loc:15,size:32},bluePriest:{loc:16,size:32},redPriest:{loc:17,size:32},brownWizard:{loc:18,size:32},redWizard:{loc:19,size:32},yellowGuard:{loc:20,size:32},blueGuard:{loc:21,size:32},redGuard:{loc:22,size:32},swordsman:{loc:23,size:32},soldier:{loc:24,size:32},yellowKnight:{loc:25,size:32},redKnight:{loc:26,size:32},darkKnight:{loc:27,size:32},blackKing:{loc:28,size:32},yellowKing:{loc:29,size:32},greenKing:{loc:30,size:32},blueKnight:{loc:31,size:32},goldSlime:{loc:32,size:32},poisonSkeleton:{loc:33,size:32},poisonBat:{loc:34,size:32},steelRock:{loc:35,size:32},skeletonPriest:{loc:36,size:32},skeletonKing:{loc:37,size:32},skeletonWizard:{loc:38,size:32},redSkeletonCaption:{loc:39,size:32},badHero:{loc:40,size:32},demon:{loc:41,size:32},demonPriest:{loc:42,size:32},goldHornSlime:{loc:43,size:32},redKing:{loc:44,size:32},whiteKing:{loc:45,size:32},blackMagician:{loc:46,size:32},silverSlime:{loc:47,size:32},swordEmperor:{loc:48,size:32},whiteHornSlime:{loc:49,size:32},badPrincess:{loc:50,size:32},badFairy:{loc:51,size:32},grayPriest:{loc:52,size:32},redSwordsman:{loc:53,size:32},whiteGhost:{loc:54,size:32},poisonZombie:{loc:55,size:32},magicDragon:{loc:56,size:32},octopus:{loc:57,size:32},fairy:{loc:58,size:32},greenKnight:{loc:59,size:32}},items:{yellowKey:{loc:0,size:32},blueKey:{loc:1,size:32},redKey:{loc:2,size:32},greenKey:{loc:3,size:32},steelKey:{loc:4,size:32},bigKey:{loc:6,size:32},redJewel:{loc:16,size:32},blueJewel:{loc:17,size:32},greenJewel:{loc:18,size:32},yellowJewel:{loc:19,size:32},redPotion:{loc:20,size:32},bluePotion:{loc:21,size:32},greenPotion:{loc:22,size:32},yellowPotion:{loc:23,size:32},book:{loc:9,size:32},fly:{loc:12,size:32},coin:{loc:11,size:32},wand:{loc:10,size:32},cross:{loc:40,size:32},snow:{loc:41,size:32},pickaxe:{loc:45,size:32},icePickaxe:{loc:44,size:32},bomb:{loc:43,size:32},centerFly:{loc:13,size:32},downFly:{loc:14,size:32},upFly:{loc:15,size:32},earthquake:{loc:8,size:32},sword1:{loc:50,size:32},sword2:{loc:51,size:32},sword3:{loc:52,size:32},sword4:{loc:53,size:32},sword5:{loc:54,size:32},shield1:{loc:55,size:32},shield2:{loc:56,size:32},shield3:{loc:57,size:32},shield4:{loc:58,size:32},shield5:{loc:59,size:32},superPotion:{loc:29,size:32}}}};icons.prototype.getIcons=function(a){if(a==undefined){return this.icons}return this.icons[a]};main.instance.icons=new icons();

292
libs/items.js Normal file
View File

@ -0,0 +1,292 @@
function items() {
}
items.prototype.init = function () {
this.items = {
// 钥匙
'yellowKey': {'cls': 'keys', 'name': '黄钥匙'},
'blueKey': {'cls': 'keys', 'name': '蓝钥匙'},
'redKey': {'cls': 'keys', 'name': '红钥匙'},
// 宝石、血瓶
'redJewel': {'cls': 'items', 'name': '红宝石'},
'blueJewel': {'cls': 'items', 'name': '蓝宝石'},
'greenJewel': {'cls': 'items', 'name': '绿宝石'},
'yellowJewel': {'cls': 'items', 'name': '黄宝石'},
'redPotion': {'cls': 'items', 'name': '红血瓶'},
'bluePotion': {'cls': 'items', 'name': '蓝血瓶'},
'yellowPotion': {'cls': 'items', 'name': '黄血瓶'},
'greenPotion': {'cls': 'items', 'name': '绿血瓶'},
'sword1': {'cls': 'items', 'name': '铁剑'},
'sword2': {'cls': 'items', 'name': '银剑'},
'sword3': {'cls': 'items', 'name': '骑士剑'},
'sword4': {'cls': 'items', 'name': '圣剑'},
'sword5': {'cls': 'items', 'name': '神圣剑'},
'shield1': {'cls': 'items', 'name': '铁盾'},
'shield2': {'cls': 'items', 'name': '银盾'},
'shield3': {'cls': 'items', 'name': '骑士盾'},
'shield4': {'cls': 'items', 'name': '圣盾'},
'shield5': {'cls': 'items', 'name': '神圣盾'},
'superPotion': {'cls': 'items', 'name': '圣水'},
'bigKey': {'cls': 'items', 'name': '钥匙盒'},
// 物品
'greenKey': {'cls': 'tools', 'name': '绿钥匙', 'text': '可以打开一扇绿门'},
'steelKey': {'cls': 'tools', 'name': '铁门钥匙', 'text': '可以打开一扇铁门'},
'book': {'cls': 'constants', 'name': '怪物手册', 'text': '可以查看当前楼层各怪物属性。'},
'fly': {'cls': 'constants', 'name': '楼层传送器', 'text': '可以自由往来去过的楼层。'},
'coin': {'cls': 'constants', 'name': '幸运金币', 'text': '持有时打败怪物可得双倍金币'},
'snow': {'cls': 'constants', 'name': '冰冻徽章', 'text': '可以将面前的一块熔岩变成平地'},
'cross': {'cls': 'constants', 'name': '十字架', 'text': '持有后无视怪物的无敌属性'},
// 道具
'pickaxe': {'cls': 'tools', 'name': '破墙镐', 'text': '可以破坏勇士四周的墙。'},
'icePickaxe': {'cls': 'tools', 'name': '破冰稿', 'text': '可以破坏勇士面前的一堵冰墙。'},
'bomb': {'cls': 'tools', 'name': '炸弹', 'text': '可以炸掉勇士四周的怪物。'},
'centerFly': {'cls': 'tools', 'name': '中心对称飞行器', 'text': '可以飞向当前楼层中心对称的位置。'},
'upFly': {'cls': 'tools', 'name': '上楼器', 'text': '可以飞往楼上的相同位置。'},
'downFly': {'cls': 'tools', 'name': '下楼器', 'text': '可以飞往楼下的相同位置。'},
'earthquake': {'cls': 'tools', 'name': '地震卷轴', 'text': '可以破坏当前层的所有墙'}
}
}
items.prototype.getItems = function (itemName) {
if (itemName == undefined) {
return this.items;
}
return this.items[itemsName];
}
main.instance.items = new items();
items.prototype.useItem = function (itemId) {
// 使用道具
if (!this.canUseItem(itemId)) return;
var itemCls = core.material.items[itemId].cls;
// 永久道具
if (itemCls == 'constants') {
if (itemId=='book') {
core.ui.drawEnemyBook(1);
}
if (itemId=='fly') {
core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));
}
}
// 消耗道具
if (itemCls == 'tools') {
core.status.hero.items[itemCls][itemId]--;
if (itemId == 'earthquake' || itemId == 'bomb' || itemId == 'pickaxe') {
// 地震卷轴/炸弹/破墙镐
core.removeBlockByIds(core.status.floorId, core.status.event.data);
core.drawMap(core.status.floorId, function () {
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.updateFg();
core.drawTip(core.material.items[itemId].name + "使用成功");
if (itemId == 'bomb' && core.flags.bombTrigger) {
core.events.afterBattle();
}
});
}
if (itemId == 'centerFly') {
// 对称飞
core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('x', core.status.event.data.x);
core.setHeroLoc('y', core.status.event.data.y);
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
core.drawTip(core.material.items[itemId].name + "使用成功");
}
if (itemId == 'upFly' || itemId == 'downFly') {
// 上楼器/下楼器
core.changeFloor(core.status.event.data.id, null, {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y}, function (){
core.drawTip(core.material.items[itemId].name + "使用成功");
});
}
if (core.status.hero.items[itemCls][itemId]==0)
delete core.status.hero.items[itemCls][itemId];
}
}
items.prototype.canUseItem = function (itemId) {
// 没有道具
if (!core.hasItem(itemId)) return false;
var itemCls = core.material.items[itemId].cls;
if (itemId == 'book') return true;
if (itemId == 'fly') return core.status.hero.flyRange.indexOf(core.status.floorId)>=0;
if (itemId == 'pickaxe') {
// 破墙镐
var ids = [];
for (var i in core.status.thisMap.blocks) {
var block = core.status.thisMap.blocks[i];
if (core.isset(block.event) && block.event.id == 'yellowWall') {
// 四个方向
if (core.flags.pickaxeFourDirections) {
if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
ids.push(i);
}
}
else {
// 获得勇士的下一个位置
var scan = {
'up': {'x': 0, 'y': -1},
'left': {'x': -1, 'y': 0},
'down': {'x': 0, 'y': 1},
'right': {'x': 1, 'y': 0}
};
if (block.x == core.status.hero.loc.x+scan[core.status.hero.loc.direction].x && block.y == core.status.hero.loc.y+scan[core.status.hero.loc.direction].y) {
ids.push(i);
}
}
}
}
if (ids.length>0) {
core.status.event.data = ids;
return true;
}
return false;
}
if (itemId == 'bomb') {
// 炸弹
var ids = [];
for (var i in core.status.thisMap.blocks) {
var block = core.status.thisMap.blocks[i];
if (core.isset(block.event) && block.event.cls == 'enemys' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
var enemy = core.material.enemys[block.event.id];
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
ids.push(i);
}
}
if (ids.length>0) {
core.status.event.data = ids;
return true;
}
return false;
}
if (itemId == 'earthquake') {
var ids = []
for (var i in core.status.thisMap.blocks) {
var block = core.status.thisMap.blocks[i];
if (core.isset(block.event) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall'))
ids.push(i);
}
if (ids.length>0) {
core.status.event.data = ids;
return true;
}
return false;
}
if (itemId == 'centerFly') {
// 中心对称
var toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');
var blocks = core.status.thisMap.blocks;
for (var s = 0; s < blocks.length; s++) {
if (blocks[s].x == toX && blocks[s].y == toY) {
return false;
}
}
core.status.event.data = {'x': toX, 'y': toY};
return true;
}
if (itemId == 'upFly') {
// 上楼器
if (core.status.floorId == 'MT20' || core.status.floorId == 'MT21') // 禁用条件
return false;
var toId = null, found = false; // 上楼后的楼层ID
for (var id in core.status.maps) {
if (found) {toId = id; break;}
if (id == core.status.floorId) found=true;
}
if (!found) return false;
// 检查是否存在block不是空地
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
var blocks = core.status.maps[toId].blocks;
for (var s = 0; s < blocks.length; s++) {
if (blocks[s].x == toX && blocks[s].y == toY) {
return false;
}
}
// 可以上楼记录下位置信息返回true
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
return true;
}
if (itemId == 'downFly') {
// 下楼器
if (core.status.floorId == 'MT0' || core.status.floorId == 'MT21')
return false;
var toId = null;
for (var id in core.status.maps) {
if (id == core.status.floorId) break;
toId = id;
}
if (toId == null) return false;
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
var blocks = core.status.maps[toId].blocks;
for (var s = 0; s < blocks.length; s++) {
if (blocks[s].x == toX && blocks[s].y == toY) {
return false;
}
}
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
return true;
}
return false;
}
items.prototype.getItemEffect = function(itemId, itemNum) {
var itemCls = core.material.items[itemId].cls;
// 消耗品
if (itemCls === 'items') {
if (itemId === 'redJewel') core.status.hero.atk += 3;
if (itemId === 'blueJewel') core.status.hero.def += 3;
if (itemId === 'greenJewel') core.status.hero.mdef += 3;
// if (itemId == 'yellowJewel') core.status.hero.atk+=0;
if (itemId === 'redPotion') core.status.hero.hp += 200;
if (itemId === 'bluePotion') core.status.hero.hp += 500;
if (itemId === 'yellowPotion') core.status.hero.hp += 500;
if (itemId === 'greenPotion') core.status.hero.hp += 800;
if (itemId === 'sword1') core.status.hero.atk += 10;
if (itemId === 'sword2') core.status.hero.atk += 100;
if (itemId === 'sword5') core.status.hero.atk += 1000;
if (itemId === 'shield1') core.status.hero.def += 10;
if (itemId === 'shield2') core.status.hero.def += 100;
if (itemId === 'shield5') {
core.status.hero.def += 1000;
core.status.hero.flags.hasShield5 = true;
}
if (itemId === 'bigKey') {
core.status.hero.items.keys.yellowKey++;
core.status.hero.items.keys.blueKey++;
core.status.hero.items.keys.redKey++;
}
if (itemId == 'superPotion') core.status.hero.hp *= 2;
}
else {
core.addItem(itemId, itemNum);
}
}
items.prototype.getItemEffectTip = function(itemId) {
if (itemId === 'redJewel') return ",攻击+3";
if (itemId === 'blueJewel') return ",防御+3";
if (itemId === 'greenJewel') return ",魔防+3";
// if (itemId == 'yellowJewel') ;
if (itemId === 'redPotion') return ",生命+200";
if (itemId === 'bluePotion') return ",生命+500";
if (itemId === 'yellowPotion') return ",生命+500";
if (itemId === 'greenPotion') return ",生命+800";
if (itemId === 'sword1') return ",攻击+10";
if (itemId === 'sword2') return ",攻击+100";
if (itemId === 'sword5') return ",攻击+1000";
if (itemId === 'shield1') return ",防御+10";
if (itemId === 'shield2') return ",防御+100";
if (itemId === 'shield5') return ",防御+1000";
if (itemId === 'bigKey') return ",全钥匙+1";
if (itemId === 'superPotion') return ",生命值翻倍";
return "";
}

1
libs/items.min.js vendored Normal file

File diff suppressed because one or more lines are too long

633
libs/maps.js Normal file
View File

@ -0,0 +1,633 @@
function maps() {
}
maps.prototype.init = function () {
var map_txt = [
[ // 0F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 43, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 1F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 87, 0, 101, 102, 101, 0, 0, 0, 0, 0, 0, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6],
[6, 18, 0, 105, 81, 0, 1, 12, 19, 15, 1, 0, 6],
[6, 15, 113, 12, 1, 0, 1, 1, 82, 1, 1, 0, 6],
[6, 1, 81, 1, 1, 0, 1, 0, 105, 0, 1, 101, 6],
[6, 0, 113, 0, 1, 0, 1, 15, 102, 15, 1, 0, 6],
[6, 15, 113, 11, 1, 0, 1, 1, 81, 1, 1, 0, 6],
[6, 1, 81, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 12, 114, 11, 1, 1, 81, 1, 1, 1, 83, 1, 6],
[6, 0, 18, 0, 1, 15, 15, 16, 1, 16, 113, 16, 6],
[6, 15, 35, 16, 1, 32, 0, 33, 1, 15, 15, 15, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 2F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 88, 1, 117, 19, 19, 19, 0, 19, 19, 19, 117, 6],
[6, 0, 1, 0, 1, 1, 1, 81, 1, 1, 1, 0, 6],
[6, 0, 1, 12, 1, 1, 0, 0, 0, 1, 1, 11, 6],
[6, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 6],
[6, 0, 1, 118, 1, 1, 0, 143, 0, 1, 1, 118, 6],
[6, 0, 1, 141, 37, 1, 1, 83, 1, 1, 38, 141, 6],
[6, 0, 1, 12, 1, 1, 1, 11, 1, 1, 1, 11, 6],
[6, 0, 1, 1, 1, 1, 12, 12, 12, 1, 1, 1, 6],
[6, 0, 1, 0, 1, 19, 110, 16, 110, 15, 0, 117, 6],
[6, 0, 81, 110, 1, 1, 1, 1, 1, 1, 1, 81, 6],
[6, 87, 1, 0, 0, 0, 18, 18, 18, 0, 0, 0, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 3F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 15, 113, 16, 1, 113, 71, 113, 1, 11, 18, 101, 6],
[6, 105, 1, 105, 1, 12, 113, 11, 1, 18, 101, 0, 6],
[6, 0, 1, 0, 1, 1, 82, 1, 1, 101, 113, 19, 6],
[6, 0, 81, 0, 15, 15, 0, 0, 1, 1, 81, 1, 6],
[6, 101, 1, 81, 1, 1, 1, 0, 1, 0, 0, 0, 6],
[6, 102, 1, 0, 1, 0, 81, 0, 1, 0, 1, 0, 6],
[6, 101, 1, 0, 102, 0, 1, 101, 1, 17, 1, 0, 6],
[6, 0, 1, 1, 1, 81, 1, 113, 1, 15, 1, 113, 6],
[6, 0, 0, 0, 1, 105, 1, 101, 1, 15, 1, 0, 6],
[6, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 6],
[6, 88, 0, 0, 1, 0, 102, 0, 105, 0, 1, 87, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 4F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 0, 0, 0, 0, 114, 105, 105, 0, 0, 0, 87, 6],
[6, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 0, 0, 0, 0, 18, 0, 109, 0, 0, 81, 0, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6],
[6, 1, 117, 15, 1, 11, 18, 1, 12, 15, 1, 114, 6],
[6, 1, 47, 117, 81, 0, 110, 82, 19, 109, 81, 0, 6],
[6, 1, 117, 15, 1, 11, 19, 1, 12, 15, 1, 113, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6],
[6, 0, 0, 0, 0, 18, 0, 109, 0, 0, 81, 0, 6],
[6, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 0, 0, 0, 0, 113, 105, 105, 0, 0, 0, 88, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 5F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 22, 1, 118, 81, 0, 72, 0, 82, 0, 81, 88, 6],
[6, 0, 1, 0, 1, 0, 0, 0, 1, 113, 1, 0, 6],
[6, 110, 1, 110, 1, 1, 110, 1, 1, 19, 1, 0, 6],
[6, 0, 0, 0, 1, 16, 114, 15, 1, 12, 1, 0, 6],
[6, 1, 83, 1, 1, 1, 81, 1, 1, 1, 1, 0, 6],
[6, 0, 0, 0, 114, 0, 0, 81, 0, 0, 0, 0, 6],
[6, 1, 81, 1, 1, 1, 114, 1, 110, 1, 1, 1, 6],
[6, 19, 117, 19, 1, 0, 0, 1, 0, 11, 11, 0, 6],
[6, 15, 15, 15, 1, 0, 1, 1, 1, 1, 1, 0, 6],
[6, 1, 1, 1, 1, 81, 1, 15, 1, 15, 1, 0, 6],
[6, 87, 117, 0, 7, 0, 114, 18, 110, 18, 114, 0, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 6F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 19, 19, 19, 1, 118, 34, 118, 1, 12, 12, 12, 6],
[6, 18, 18, 18, 1, 0, 117, 0, 1, 11, 11, 11, 6],
[6, 1, 81, 1, 1, 1, 82, 1, 1, 1, 81, 1, 6],
[6, 114, 0, 0, 110, 81, 117, 81, 110, 0, 0, 114, 6],
[6, 1, 1, 7, 1, 1, 1, 1, 1, 7, 1, 1, 6],
[6, 18, 1, 110, 1, 17, 16, 15, 1, 110, 1, 19, 6],
[6, 114, 81, 0, 1, 1, 82, 1, 1, 0, 81, 114, 6],
[6, 11, 1, 109, 1, 19, 114, 19, 1, 109, 1, 12, 6],
[6, 11, 1, 110, 1, 1, 81, 1, 1, 110, 1, 12, 6],
[6, 1, 1, 109, 1, 18, 0, 73, 1, 109, 1, 1, 6],
[6, 88, 81, 0, 0, 0, 114, 0, 0, 0, 81, 87, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 7F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 23, 7, 7, 7, 0, 16, 0, 83, 18, 118, 18, 6],
[6, 1, 1, 1, 1, 117, 1, 117, 1, 117, 18, 117, 6],
[6, 0, 1, 0, 1, 117, 1, 19, 1, 1, 81, 1, 6],
[6, 118, 0, 117, 0, 12, 1, 11, 1, 15, 19, 19, 6],
[6, 1, 1, 1, 81, 1, 1, 1, 1, 15, 1, 81, 6],
[6, 11, 0, 0, 118, 0, 1, 0, 81, 0, 1, 117, 6],
[6, 11, 1, 117, 19, 117, 19, 117, 1, 117, 1, 117, 6],
[6, 11, 1, 1, 1, 1, 1, 1, 1, 117, 1, 46, 6],
[6, 0, 0, 117, 12, 117, 0, 0, 1, 81, 1, 1, 6],
[6, 1, 81, 1, 1, 1, 1, 7, 1, 117, 0, 0, 6],
[6, 87, 118, 117, 11, 117, 0, 0, 1, 0, 0, 88, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 8F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 120, 0, 120, 0, 0, 0, 0, 0, 81, 0, 87, 6],
[6, 0, 81, 6, 6, 6, 6, 6, 6, 6, 0, 0, 6],
[6, 120, 6, 6, 12, 12, 6, 11, 11, 6, 6, 82, 6],
[6, 0, 6, 12, 12, 12, 6, 11, 11, 11, 6, 0, 6],
[6, 0, 6, 12, 12, 12, 6, 11, 11, 11, 6, 0, 6],
[6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6],
[6, 0, 6, 19, 19, 19, 6, 15, 15, 15, 6, 0, 6],
[6, 0, 6, 19, 19, 19, 6, 16, 16, 16, 6, 0, 6],
[6, 81, 6, 6, 19, 19, 6, 17, 17, 6, 6, 118, 6],
[6, 0, 51, 6, 6, 6, 6, 6, 6, 6, 81, 0, 6],
[6, 88, 0, 81, 0, 0, 0, 0, 0, 118, 0, 120, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 9F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 25, 7, 0, 1, 0, 1, 0, 0, 0, 0, 88, 6],
[6, 7, 120, 124, 83, 15, 1, 124, 1, 1, 1, 1, 6],
[6, 1, 81, 1, 1, 15, 1, 12, 1, 19, 12, 11, 6],
[6, 19, 19, 19, 1, 124, 1, 118, 1, 0, 118, 0, 6],
[6, 124, 0, 124, 1, 15, 1, 12, 1, 118, 124, 118, 6],
[6, 1, 82, 1, 1, 15, 1, 118, 1, 1, 81, 1, 6],
[6, 118, 0, 118, 120, 0, 1, 0, 118, 18, 18, 18, 6],
[6, 1, 81, 1, 1, 0, 81, 0, 1, 1, 81, 1, 6],
[6, 18, 0, 0, 1, 1, 81, 1, 1, 0, 120, 0, 6],
[6, 1, 1, 118, 1, 118, 0, 118, 1, 81, 1, 81, 6],
[6, 87, 120, 0, 82, 0, 1, 46, 1, 12, 1, 11, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 10F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 12, 1, 11, 1, 19, 1, 16, 1, 17, 1, 15, 6],
[6, 12, 1, 11, 1, 19, 1, 16, 1, 17, 1, 15, 6],
[6, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 6],
[6, 119, 0, 119, 0, 119, 1, 124, 0, 124, 0, 124, 6],
[6, 81, 1, 82, 1, 1, 1, 1, 1, 82, 1, 81, 6],
[6, 18, 1, 0, 120, 145, 119, 145, 120, 0, 1, 18, 6],
[6, 18, 1, 0, 1, 1, 1, 1, 1, 0, 1, 18, 6],
[6, 1, 1, 145, 1, 120, 74, 120, 1, 145, 1, 1, 6],
[6, 19, 120, 0, 1, 0, 145, 0, 1, 0, 120, 19, 6],
[6, 1, 83, 1, 1, 15, 15, 15, 1, 1, 83, 1, 6],
[6, 88, 0, 0, 120, 0, 145, 0, 120, 0, 0, 87, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 11F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 24, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 87, 0, 145, 46, 145, 119, 145, 46, 145, 0, 88, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 12F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 19, 1, 1, 1, 1, 0, 0, 0, 0, 0, 87, 6],
[6, 0, 1, 0, 0, 127, 0, 1, 1, 1, 1, 0, 6],
[6, 0, 1, 0, 1, 1, 0, 1, 12, 12, 1, 0, 6],
[6, 0, 1, 0, 43, 1, 0, 1, 12, 12, 1, 0, 6],
[6, 119, 1, 1, 1, 1, 119, 1, 1, 1, 1, 119, 6],
[6, 0, 0, 0, 0, 145, 0, 145, 0, 0, 0, 0, 6],
[6, 126, 1, 1, 1, 1, 126, 1, 1, 1, 1, 126, 6],
[6, 0, 1, 11, 11, 1, 0, 1, 47, 0, 141, 0, 6],
[6, 0, 1, 11, 11, 1, 0, 1, 1, 1, 1, 0, 6],
[6, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 6],
[6, 88, 0, 0, 0, 0, 0, 1, 0, 0, 0, 19, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 13F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 87, 0, 126, 0, 0, 82, 0, 0, 126, 0, 88, 6],
[6, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 6],
[6, 126, 1, 1, 15, 1, 0, 1, 19, 1, 1, 126, 6],
[6, 0, 1, 36, 15, 1, 0, 1, 19, 19, 1, 0, 6],
[6, 127, 1, 15, 126, 1, 0, 1, 126, 19, 1, 127, 6],
[6, 0, 1, 126, 127, 82, 128, 82, 127, 126, 1, 0, 6],
[6, 127, 1, 12, 126, 1, 0, 1, 126, 11, 1, 127, 6],
[6, 0, 1, 12, 12, 1, 0, 1, 11, 11, 1, 0, 6],
[6, 127, 1, 1, 12, 1, 0, 1, 11, 1, 1, 127, 6],
[6, 0, 0, 1, 1, 1, 83, 1, 1, 1, 0, 0, 6],
[6, 0, 0, 128, 0, 128, 0, 128, 0, 128, 0, 0, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 14F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 1, 1, 18, 1, 1, 0, 0, 0, 6],
[6, 0, 0, 0, 1, 18, 31, 18, 1, 0, 0, 0, 6],
[6, 0, 0, 0, 1, 1, 18, 1, 1, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 1, 85, 1, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 141, 0, 141, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6],
[6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 15F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 53, 6, 18, 1, 19, 1, 12, 12, 12, 1, 87, 6],
[6, 0, 1, 131, 1, 126, 1, 12, 128, 12, 1, 0, 6],
[6, 141, 82, 0, 1, 81, 1, 1, 81, 1, 1, 0, 6],
[6, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 6],
[6, 19, 18, 1, 127, 1, 126, 1, 1, 0, 1, 0, 6],
[6, 19, 18, 18, 1, 75, 0, 1, 52, 127, 83, 0, 6],
[6, 19, 18, 1, 127, 1, 126, 1, 1, 0, 1, 0, 6],
[6, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 6],
[6, 0, 82, 0, 1, 81, 1, 1, 81, 1, 1, 0, 6],
[6, 43, 1, 131, 1, 126, 1, 11, 128, 11, 1, 0, 6],
[6, 44, 6, 18, 1, 19, 1, 11, 11, 11, 1, 88, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 16F
[4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[4, 4, 4, 4, 6, 0, 0, 0, 0, 0, 0, 88, 6],
[4, 4, 4, 4, 6, 6, 0, 6, 6, 6, 6, 6, 6],
[4, 4, 4, 4, 4, 6, 0, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 0, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 0, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 108, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 0, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 87, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
],
[ // 17F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 1, 131, 128, 0, 0, 0, 0, 0, 0, 0, 131, 6],
[6, 1, 128, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6],
[6, 1, 0, 1, 131, 0, 0, 0, 0, 0, 0, 131, 6],
[6, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 6],
[6, 1, 0, 1, 0, 1, 131, 0, 0, 0, 131, 89, 6],
[6, 1, 0, 1, 131, 0, 0, 1, 1, 1, 0, 1, 6],
[6, 1, 0, 1, 1, 1, 1, 1, 131, 0, 131, 1, 6],
[6, 1, 128, 1, 1, 1, 88, 1, 0, 1, 1, 1, 6],
[6, 1, 131, 128, 0, 0, 0, 1, 131, 0, 0, 131, 6],
[6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 6],
[6, 87, 84, 131, 0, 0, 0, 0, 0, 0, 0, 131, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 18F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 1, 1, 1, 126, 0, 87, 0, 131, 1, 1, 1, 6],
[6, 1, 1, 1, 1, 19, 1, 19, 1, 1, 1, 1, 6],
[6, 1, 1, 1, 126, 0, 19, 0, 131, 1, 1, 1, 6],
[6, 126, 1, 126, 1, 128, 1, 128, 1, 131, 1, 131, 6],
[6, 0, 15, 0, 128, 0, 0, 0, 128, 0, 15, 0, 6],
[6, 15, 1, 15, 1, 0, 54, 0, 1, 15, 1, 15, 6],
[6, 0, 15, 0, 128, 0, 0, 0, 128, 0, 15, 0, 6],
[6, 131, 1, 131, 1, 128, 1, 128, 1, 127, 1, 127, 6],
[6, 0, 0, 0, 131, 0, 17, 0, 127, 1, 1, 1, 6],
[6, 0, 1, 0, 1, 17, 1, 17, 1, 1, 1, 1, 6],
[6, 88, 0, 0, 131, 0, 17, 0, 127, 1, 1, 1, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 19F
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
[6, 128, 0, 12, 12, 0, 88, 0, 18, 18, 0, 141, 6],
[6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6],
[6, 19, 6, 4, 4, 4, 4, 4, 4, 4, 6, 11, 6],
[6, 19, 6, 4, 4, 4, 4, 4, 4, 4, 6, 11, 6],
[6, 0, 6, 4, 4, 4, 4, 4, 4, 4, 6, 0, 6],
[6, 131, 6, 4, 4, 4, 4, 4, 4, 4, 6, 131, 6],
[6, 0, 6, 4, 4, 4, 4, 4, 4, 4, 6, 0, 6],
[6, 11, 6, 4, 4, 4, 4, 4, 4, 4, 6, 19, 6],
[6, 11, 6, 4, 4, 4, 4, 4, 4, 4, 6, 19, 6],
[6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6],
[6, 141, 0, 18, 18, 0, 89, 0, 12, 12, 0, 128, 6],
[6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
],
[ // 20F
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4],
[4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 131, 131, 131, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 131, 144, 131, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 131, 131, 131, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 6, 4, 4],
[4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 6, 4, 4],
[4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
],
// 隐藏1层
[
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4],
[4, 4, 2, 11, 2, 43, 0, 30, 2, 12, 2, 4, 4],
[4, 4, 2, 11, 2, 2, 81, 2, 2, 12, 2, 4, 4],
[4, 4, 2, 11, 81, 0, 0, 0, 81, 12, 2, 4, 4],
[4, 4, 2, 11, 2, 0, 0, 0, 2, 12, 2, 4, 4],
[4, 4, 2, 11, 2, 0, 142, 0, 2, 12, 2, 4, 4],
[4, 4, 2, 2, 2, 2, 83, 2, 2, 2, 2, 4, 4],
[4, 4, 2, 0, 0, 0, 0, 0, 0, 89, 2, 4, 4],
[4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
]
]
this.maps = [];
for (var f = 0; f < map_txt.length; f++) {
var floorId = 'MT' + f;
var map = map_txt[f];
var content = {};
content['floorId'] = floorId;
content['name'] = f;
content['title'] = '主塔 ' + f + ' 层';
if (f==21) { // 隐藏层
content['name'] = '17';
content['title'] = '隐藏层';
}
content['canFlyTo'] = true;
if (f==0 || f==14 || f==20 || f==21) content['canFlyTo'] = false;
var blocks = [];
for (var i = 0; i < 13; i++) {
for (var j = 0; j < 13; j++) {
var id = map[i][j];
var block = this.getBlock(floorId, f, j, i, id);
if (block!=null) blocks.push(block);
}
}
content['blocks'] = blocks;
this.maps[floorId] = content;
}
}
maps.prototype.getBlock = function (floorId, f, x, y, id) {
var tmp = {'x': x, 'y': y, 'id': id};
// 16F的事件处理
if (id == 0) {
if (floorId=="MT16" && x==6 && y==2) {
tmp.event = {'cls': 'terrains', 'id': 'ground', 'noPass': false, 'trigger': 'blockEvent'};
}
}
// 0-9 地形
if (id == 1) tmp.event = {'cls': 'terrains', 'id': 'yellowWall'}; // 黄墙
if (id == 2) tmp.event = {'cls': 'terrains', 'id': 'blueWall'}; // 蓝墙
if (id == 3) tmp.event = {'cls': 'animates', 'id': 'lava', 'animate': 4, 'noPass': true}; // 岩浆
if (id == 4) tmp.event = {'cls': 'animates', 'id': 'star', 'animate': 4, 'noPass': true}; // 星空
// if (id==5) tmp.fg = {'cls': 'animates', 'id': 'star', 'animate': 4, 'noPass': true}; // 栅栏
if (id == 6) tmp.event = {'cls': 'terrains', 'id': 'whiteWall'}; // 白墙
if (id == 7) tmp.event = {'cls': 'animates', 'id': 'lavaNet', 'animate': 4, 'noPass': false, 'trigger': 'passNet'};
// 11-50 物品
if (id == 11) tmp.event = {'cls': 'items', 'id': 'redJewel', 'trigger': 'getItem'}; // 红宝石
if (id == 12) tmp.event = {'cls': 'items', 'id': 'blueJewel', 'trigger': 'getItem'}; // 蓝宝石
if (id == 13) tmp.event = {'cls': 'items', 'id': 'greenJewel', 'trigger': 'getItem'}; // 绿宝石
if (id == 14) tmp.event = {'cls': 'items', 'id': 'yellowJewel', 'trigger': 'getItem'}; // 黄宝石
if (id == 15) tmp.event = {'cls': 'items', 'id': 'yellowKey', 'trigger': 'getItem'}; // 黄钥匙
if (id == 16) tmp.event = {'cls': 'items', 'id': 'blueKey', 'trigger': 'getItem'}; // 蓝钥匙
if (id == 17) tmp.event = {'cls': 'items', 'id': 'redKey', 'trigger': 'getItem'}; // 红钥匙
if (id == 18) tmp.event = {'cls': 'items', 'id': 'redPotion', 'trigger': 'getItem'}; // 红血瓶
if (id == 19) tmp.event = {'cls': 'items', 'id': 'bluePotion', 'trigger': 'getItem'}; // 蓝血瓶
if (id == 20) tmp.event = {'cls': 'items', 'id': 'yellowPotion', 'trigger': 'getItem'}; // 黄血瓶
if (id == 21) tmp.event = {'cls': 'items', 'id': 'greenPotion', 'trigger': 'getItem'}; // 绿血瓶
if (id == 22) tmp.event = {'cls': 'items', 'id': 'sword1', 'trigger': 'getItem'}; // 铁剑
if (id == 23) tmp.event = {'cls': 'items', 'id': 'shield1', 'trigger': 'getItem'}; // 铁盾
if (id == 24) tmp.event = {'cls': 'items', 'id': 'sword2', 'trigger': 'getItem'}; // 银剑
if (id == 25) tmp.event = {'cls': 'items', 'id': 'shield2', 'trigger': 'getItem'}; // 银盾
if (id == 26) tmp.event = {'cls': 'items', 'id': 'sword3', 'trigger': 'getItem'}; // 骑士剑
if (id == 27) tmp.event = {'cls': 'items', 'id': 'shield3', 'trigger': 'getItem'}; // 骑士盾
if (id == 28) tmp.event = {'cls': 'items', 'id': 'sword4', 'trigger': 'getItem'}; // 圣剑
if (id == 29) tmp.event = {'cls': 'items', 'id': 'shield4', 'trigger': 'getItem'}; // 圣盾
if (id == 30) tmp.event = {'cls': 'items', 'id': 'sword5', 'trigger': 'getItem'}; // 神圣剑
if (id == 31) tmp.event = {'cls': 'items', 'id': 'shield5', 'trigger': 'getItem'}; // 神圣盾
if (id == 32) tmp.event = {'cls': 'items', 'id': 'book', 'trigger': 'getItem'}; // 怪物手册
if (id == 33) tmp.event = {'cls': 'items', 'id': 'fly', 'trigger': 'getItem'}; // 楼层传送器
if (id == 34) tmp.event = {'cls': 'items', 'id': 'pickaxe', 'trigger': 'getItem'}; // 破墙镐
if (id == 35) tmp.event = {'cls': 'items', 'id': 'bomb', 'trigger': 'getItem'}; // 炸弹
if (id == 36) tmp.event = {'cls': 'items', 'id': 'centerFly', 'trigger': 'getItem'}; // 中心对称
if (id == 37) tmp.event = {'cls': 'items', 'id': 'upFly', 'trigger': 'getItem'}; // 上楼器
if (id == 38) tmp.event = {'cls': 'items', 'id': 'downFly', 'trigger': 'getItem'}; // 下楼器
if (id == 39) tmp.event = {'cls': 'items', 'id': 'icePickaxe', 'trigger': 'getItem'}; // 破冰镐
if (id == 40) tmp.event = {'cls': 'items', 'id': 'coin', 'trigger': 'getItem'}; // 幸运金币
if (id == 41) tmp.event = {'cls': 'items', 'id': 'snow', 'trigger': 'getItem'}; // 冰冻徽章
if (id == 42) tmp.event = {'cls': 'items', 'id': 'cross', 'trigger': 'getItem'}; // 十字架
if (id == 43) tmp.event = {'cls': 'items', 'id': 'superPotion', 'trigger': 'getItem'}; // 圣水
if (id == 44) tmp.event = {'cls': 'items', 'id': 'greenKey', 'trigger': 'getItem'}; // 绿钥匙
if (id == 45) tmp.event = {'cls': 'items', 'id': 'steelKey', 'trigger': 'getItem'}; // 铁门钥匙
if (id == 46) tmp.event = {'cls': 'items', 'id': 'bigKey', 'trigger': 'getItem'}; // 钥匙盒/大黄门钥匙
if (id == 47) tmp.event = {'cls': 'items', 'id': 'earthquake', 'trigger': 'getItem'} // 地震卷轴
// 51-80 NPC
if (id == 51) tmp.event = {'cls': 'npcs', 'id': 'magician', 'trigger': 'visitNpc', 'npcid': 'npc1'};
if (id == 52) tmp.event = {'cls': 'npcs', 'id': 'magician', 'trigger': 'visitNpc', 'npcid': 'npc2'};
if (id == 53) tmp.event = {'cls': 'npcs', 'id': 'womanMagician', 'trigger': 'visitNpc', 'npcid': 'npc3'};
if (id == 54) tmp.event = {'cls': 'npcs', 'id': 'womanMagician', 'trigger': 'visitNpc', 'npcid': 'npc4'};
// 商店
if (id == 71) tmp.event = {'cls': 'npcs', 'id': 'blueShop', 'trigger': 'openShop', 'shopid': 'shop1'};
if (id == 72) tmp.event = {'cls': 'npcs', 'id': 'redShop', 'trigger': 'openShop', 'shopid': 'shop2'};
if (id == 73) tmp.event = {'cls': 'npcs', 'id': 'womanMagician', 'trigger': 'openShop', 'shopid': 'shop3'};
if (id == 74) tmp.event = {'cls': 'npcs', 'id': 'blueShop', 'trigger': 'openShop', 'shopid': 'shop4'};
if (id == 75) tmp.event = {'cls': 'npcs', 'id': 'redShop', 'trigger': 'openShop', 'shopid': 'shop5'};
// 81-100 门
if (id == 81) tmp.event = {'cls': 'terrains', 'id': 'yellowDoor', 'trigger': 'openDoor'};
if (id == 82) tmp.event = {'cls': 'terrains', 'id': 'blueDoor', 'trigger': 'openDoor'};
if (id == 83) tmp.event = {'cls': 'terrains', 'id': 'redDoor', 'trigger': 'openDoor'};
if (id == 84) tmp.event = {'cls': 'terrains', 'id': 'greenDoor', 'trigger': 'openDoor'};
if (id == 85) tmp.event = {'cls': 'terrains', 'id': 'specialDoor', 'trigger': 'openDoor'}; // 商店左
if (id == 86) tmp.event = {'cls': 'terrains', 'id': 'steelDoor', 'trigger': 'openDoor'}; // 商店左
if (id == 87) {
var toFloor = f+1;
if (f==13) toFloor = 15;
tmp.event = {
'cls': 'terrains', 'id': 'upFloor', 'trigger': 'changeFloor', 'noPass': false,
'data': {'floorId': 'MT' + toFloor, 'stair': 'downFloor'}, 'noTriggerCross': true
};
}
if (id == 88) {
var toFloor = f-1;
if (f==15) toFloor = 13;
tmp.event = {
'cls': 'terrains', 'id': 'downFloor', 'trigger': 'changeFloor', 'noPass': false,
'data': {'floorId': 'MT' + toFloor, 'stair': 'upFloor'}, 'noTriggerCross': true
};
}
// 传送门
if (id==89) {
var toFloor = 0, toX = 0, toY = 0;
if (floorId == "MT17") {toFloor = 21; toX = 9; toY = 9;}
else if (floorId == "MT21") {toFloor = 17; toX = 11; toY = 5;}
else if (floorId == "MT19") {toFloor = 20; toX = 6; toY = 9;}
tmp.event = {
'cls': 'animates', 'id': 'portal', 'trigger': 'changeFloor', 'noPass': false, 'animate': 4,
'data': {'floorId': 'MT' + toFloor, 'heroLoc': {'direction': 'up', 'x': toX, 'y': toY}}
}
}
// 101-200 怪物
if (id == 101) tmp.event = {'cls': 'enemys', 'id': 'greenSlime', 'trigger': 'battle'};
if (id == 102) tmp.event = {'cls': 'enemys', 'id': 'redSlime', 'trigger': 'battle'};
if (id == 103) tmp.event = {'cls': 'enemys', 'id': 'blackSlime', 'trigger': 'battle'};
if (id == 104) tmp.event = {'cls': 'enemys', 'id': 'slimelord', 'trigger': 'battle'};
if (id == 105) tmp.event = {'cls': 'enemys', 'id': 'bat', 'trigger': 'battle'};
if (id == 106) tmp.event = {'cls': 'enemys', 'id': 'bigBat', 'trigger': 'battle'};
if (id == 107) tmp.event = {'cls': 'enemys', 'id': 'redBat', 'trigger': 'battle'};
if (id == 108) tmp.event = {'cls': 'enemys', 'id': 'vampire', 'trigger': 'battle'};
if (id == 109) tmp.event = {'cls': 'enemys', 'id': 'bluePriest', 'trigger': 'battle'};
if (id == 110) tmp.event = {'cls': 'enemys', 'id': 'redPriest', 'trigger': 'battle'};
if (id == 111) tmp.event = {'cls': 'enemys', 'id': 'brownWizard', 'trigger': 'battle'};
if (id == 112) tmp.event = {'cls': 'enemys', 'id': 'redWizard', 'trigger': 'battle'};
if (id == 113) tmp.event = {'cls': 'enemys', 'id': 'skeleton', 'trigger': 'battle'};
if (id == 114) tmp.event = {'cls': 'enemys', 'id': 'skeletonSoilder', 'trigger': 'battle'};
if (id == 115) tmp.event = {'cls': 'enemys', 'id': 'skeletonCaptain', 'trigger': 'battle'};
if (id == 116) tmp.event = {'cls': 'enemys', 'id': 'ghostSkeleton', 'trigger': 'battle'};
if (id == 117) tmp.event = {'cls': 'enemys', 'id': 'zombie', 'trigger': 'battle'};
if (id == 118) tmp.event = {'cls': 'enemys', 'id': 'zombieKnight', 'trigger': 'battle'};
if (id == 119) tmp.event = {'cls': 'enemys', 'id': 'rock', 'trigger': 'battle'};
if (id == 120) tmp.event = {'cls': 'enemys', 'id': 'slimeMan', 'trigger': 'battle'};
if (id == 121) tmp.event = {'cls': 'enemys', 'id': 'yellowGuard', 'trigger': 'battle'};
if (id == 122) tmp.event = {'cls': 'enemys', 'id': 'blueGuard', 'trigger': 'battle'};
if (id == 123) tmp.event = {'cls': 'enemys', 'id': 'redGuard', 'trigger': 'battle'};
if (id == 124) tmp.event = {'cls': 'enemys', 'id': 'swordsman', 'trigger': 'battle'};
if (id == 125) tmp.event = {'cls': 'enemys', 'id': 'soldier', 'trigger': 'battle'};
if (id == 126) tmp.event = {'cls': 'enemys', 'id': 'yellowKnight', 'trigger': 'battle'};
if (id == 127) tmp.event = {'cls': 'enemys', 'id': 'redKnight', 'trigger': 'battle'};
if (id == 128) tmp.event = {'cls': 'enemys', 'id': 'darkKnight', 'trigger': 'battle'};
if (id == 129) tmp.event = {'cls': 'enemys', 'id': 'redKing', 'trigger': 'battle'};
if (id == 130) tmp.event = {'cls': 'enemys', 'id': 'whiteKing', 'trigger': 'battle'};
if (id == 131) tmp.event = {'cls': 'enemys', 'id': 'blackMagician', 'trigger': 'battle'};
if (id == 132) tmp.event = {'cls': 'enemys', 'id': 'silverSlime', 'trigger': 'battle'};
if (id == 133) tmp.event = {'cls': 'enemys', 'id': 'poisonSkeleton', 'trigger': 'battle'};
if (id == 134) tmp.event = {'cls': 'enemys', 'id': 'poisonBat', 'trigger': 'battle'};
if (id == 135) tmp.event = {'cls': 'enemys', 'id': 'steelRock', 'trigger': 'battle'};
if (id == 136) tmp.event = {'cls': 'enemys', 'id': 'poisonZombie', 'trigger': 'battle'};
if (id == 137) tmp.event = {'cls': 'enemys', 'id': 'blackKing', 'trigger': 'battle'};
if (id == 138) tmp.event = {'cls': 'enemys', 'id': 'yellowKing', 'trigger': 'battle'};
if (id == 139) tmp.event = {'cls': 'enemys', 'id': 'greenKing', 'trigger': 'battle'};
if (id == 140) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 141) tmp.event = {'cls': 'enemys', 'id': 'greenKnight', 'trigger': 'battle'};
if (id == 142) tmp.event = {'cls': 'enemys', 'id': 'magicDragon', 'trigger': 'battle'};
if (id == 143) tmp.event = {'cls': 'enemys', 'id': 'octopus', 'trigger': 'battle'};
if (id == 144) tmp.event = {'cls': 'enemys', 'id': 'fairy', 'trigger': 'battle'};
if (id == 145) tmp.event = {'cls': 'enemys', 'id': 'whiteGhost', 'trigger': 'battle'};
if (id == 146) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 147) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 148) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 149) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 150) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 151) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 152) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 153) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
if (id == 154) tmp.event = {'cls': 'enemys', 'id': 'blueKnight', 'trigger': 'battle'};
// 200+ 特殊
if (tmp.event == undefined) return null;
return tmp;
}
maps.prototype.getMaps = function (mapName) {
if (mapName == undefined) {
return this.updateNoPass(this.maps);
}
return this.maps[mapName];
}
maps.prototype.updateNoPass = function (maps) {
if (maps.floorId == undefined) {
for (var floorId in maps) {
this.updateNoPass(maps[floorId]);
}
return maps;
}
var blocks = maps['blocks'];
blocks.forEach(function (t) {
if (t.event == undefined) return;
if (t.event.noPass == undefined) {
if (t.event.cls=='enemys' || t.event.cls=='terrains' || t.event.cls=='npcs') {
t.event.noPass = true;
}
}
if (t.event.animate == undefined) {
if (t.event.cls=='enemys' || t.event.cls=='npcs') {
t.event.animate = 2;
}
}
});
return maps;
}
maps.prototype.save = function(maps, floorId) {
if (floorId==undefined || floorId==null) {
var map = [];
for (var id in maps) {
// map[id] = this.save(maps, id);
map.push(this.save(maps, id));
}
return map;
}
var thisFloor = maps[floorId];
var floor = {};
floor.floorId = thisFloor.floorId;
floor.name = thisFloor.name;
floor.title = thisFloor.title;
floor.canFlyTo = thisFloor.canFlyTo;
var blocks = [];
for (var x=0;x<13;x++) {
blocks[x]=[];
for (var y=0;y<13;y++) {
blocks[x].push(0);
}
}
thisFloor.blocks.forEach(function (block) {
blocks[block.x][block.y] = block.id;
});
floor.blocks = blocks;
return floor;
}
maps.prototype.load = function (data, floorId) {
if (floorId == undefined) {
var map = [];
for (var id in data) {
map[data[id].floorId] = this.load(data, data[id].floorId);
}
return map;
}
var x = null;
for (var id in data) {
if (data[id].floorId == floorId) {
x = data[id];
break;
}
}
if (x==null) return {};
var content = {};
content['floorId'] = x.floorId;
content['name'] = x.name;
content['title'] = x.title;
content['canFlyTo'] = x.canFlyTo;
var blocks = [];
for (var i = 0; i < 13; i++) {
for (var j = 0; j < 13; j++) {
var id = x.blocks[i][j];
var block = this.getBlock(x.floorId, x.name, i, j, id);
if (block!=null) blocks.push(block);
}
}
content['blocks'] = blocks;
return this.updateNoPass(content);
}
main.instance.maps = new maps();

1
libs/maps.min.js vendored Normal file

File diff suppressed because one or more lines are too long

71
libs/npcs.js Normal file
View File

@ -0,0 +1,71 @@
function npcs() {
}
npcs.prototype.init = function () {
this.npcs = {
'npc1': {'id': 'npc1', 'name': '神秘老人', 'icon': 'magician'},
'npc2': {'id': 'npc2', 'name': '神秘老人', 'icon': 'magician'},
'npc3': {'id': 'npc3', 'name': '神秘老人', 'icon': 'womanMagician'},
'npc4': {'id': 'npc4', 'name': '神秘老人', 'icon': 'womanMagician'},
}
}
npcs.prototype.getNpcs = function (npcId) {
if (npcId == undefined) return this.npcs;
return this.npcs[npcId];
}
npcs.prototype.getEffect = function (npcid, times) {
switch (npcid) {
case 'npc1':
return [
{
'action': 'text', 'id': 'npc1',
'content': '提示:灰色的水泥墙比棕色的更为坚固。\n用破墙镐无法破坏水泥墙。\n例如本层墙内的宝物可以使用地震卷轴获取。'
},
];
break;
case 'npc2':
return [
{
'action': 'text', 'id': 'npc2',
'content': '提示14F位于神秘空间之中无法直接到达。\n只能使用特殊道具到达。\n类似14F的还有一层在0F。'
}
];
break;
case 'npc3':
return [
{
'action': 'choices', 'id': 'npc3', 'cancel': true, 'hint': '送你一件道具,你自己\n选吧',
'choices': [
{"text": '破墙镐', 'effect': 'item,pickaxe,1'},
{"text": '炸弹', 'effect': 'item,bomb,1'},
{"text": '中心对称飞行器', 'effect': 'item,centerFly,1'}
]
},
{
'action': 'text', 'id': 'npc3',
'content': '祝你好运,我先溜了~'
},
{'action': 'disappear'}
];
break;
case 'npc4':
return [
{
'action': 'choices', 'id': 'npc4', 'cancel': true, 'hint': '低价回收各种钥匙:',
'choices': [
{"text": '黄钥匙7金币', 'effect': 'status,money,7', 'need': 'item,yellowKey,1'},
{"text": '蓝钥匙35金币', 'effect': 'status,money,35', 'need': 'item,blueKey,1'},
{"text": '红钥匙70金币', 'effect': 'status,money,70', 'need': 'item,redKey,1'}
]
},
{'action': 'revisit'}
];
break;
}
return [];
}
main.instance.npcs = new npcs();

1
libs/npcs.min.js vendored Normal file
View File

@ -0,0 +1 @@
function npcs(){}npcs.prototype.init=function(){this.npcs={npc1:{id:"npc1",name:"神秘老人",icon:"magician"},npc2:{id:"npc2",name:"神秘老人",icon:"magician"},npc3:{id:"npc3",name:"神秘老人",icon:"womanMagician"},npc4:{id:"npc4",name:"神秘老人",icon:"womanMagician"}}};npcs.prototype.getNpcs=function(a){if(a==undefined){return this.npcs}return this.npcs[a]};npcs.prototype.getEffect=function(a,b){switch(a){case"npc1":return[{action:"text",id:"npc1",content:"提示:灰色的水泥墙比棕色的更为坚固。\n用破墙镐无法破坏水泥墙。\n例如本层墙内的宝物可以使用地震卷轴获取。"}];break;case"npc2":return[{action:"text",id:"npc2",content:"提示14F位于神秘空间之中无法直接到达。\n只能使用特殊道具到达。\n类似14F的还有一层在0F。"}];break;case"npc3":return[{action:"choices",id:"npc3",cancel:true,hint:"送你一件道具,你自己\n选吧",choices:[{text:"破墙镐",effect:"item,pickaxe,1"},{text:"炸弹",effect:"item,bomb,1"},{text:"中心对称飞行器",effect:"item,centerFly,1"}]},{action:"text",id:"npc3",content:"祝你好运,我先溜了~"},{action:"disappear"}];break;case"npc4":return[{action:"choices",id:"npc4",cancel:true,hint:"低价回收各种钥匙:",choices:[{text:"黄钥匙7金币",effect:"status,money,7",need:"item,yellowKey,1"},{text:"蓝钥匙35金币",effect:"status,money,35",need:"item,blueKey,1"},{text:"红钥匙70金币",effect:"status,money,70",need:"item,redKey,1"}]},{action:"revisit"}];break}return[]};main.instance.npcs=new npcs();

712
libs/ui.js Normal file
View File

@ -0,0 +1,712 @@
/**
* ui.js负责所有和UI界面相关的绘制
* 包括
* 自动寻路怪物手册楼传器存读档菜单栏NPC对话事件等等
*/
function ui() {}
// 初始化UI
ui.prototype.init = function () {
}
main.instance.ui = new ui();
/**
* 关闭一切UI窗口
* @param clearData 是否同时清掉data层
*/
ui.prototype.closePanel = function (clearData) {
core.status.boxAnimateObjs = [];
core.setBoxAnimate(core.firstData.animateSpeed);
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1.0);
if (core.isset(clearData) && clearData)
core.clearMap('data', 0, 0, 416, 416);
core.unLockControl();
core.status.event.data = null;
core.status.event.id = null;
}
/**
* 绘制对话框
* @param content
* @param id
*/
ui.prototype.drawTextBox = function(content, id) {
core.lockControl();
if (core.status.event.id == null)
core.status.event.id = 'text';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
var contents = content.split('\n');
core.clearMap('ui', 0, 0, 416, 416);
var height = 416 - 10 - Math.min(416-24*(contents.length+1)-65, 250);
var left=10, top = (416-height)/2, right = 416 - 2*left, 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.canvas.ui.textAlign = "left";
var content_left = left + 25, content_top = top + 35;
if (core.isset(id)) {
content_left = left+63;
content_top = top+57;
var name, image, cls;
// 动画
core.strokeRect('ui', left + 15 - 1, top + 40 - 1, 34, 34, '#FFD700', 2);
if (id == 'hero') {
core.fillText('ui', core.status.hero.name, left + 63, top + 30, '#FFD700', 'bold 22px Verdana');
core.status.boxAnimateObjs = [];
core.setBoxAnimate(core.firstData.animateSpeed);
core.clearMap('ui', left + 15, top + 40, 32, 32);
core.fillRect('ui', left + 15, top + 40, 32, 32, background);
var heroIcon = core.material.icons.heros[core.status.hero.id]['down'];
core.canvas.ui.drawImage(core.material.images.heros, heroIcon.loc['stop'] * heroIcon.size, heroIcon.loc.iconLoc * heroIcon.size, heroIcon.size, heroIcon.size, left+15, top+40, 32, 32);
}
else {
var name = null, image = null, icon = null;
if (core.material.npcs.hasOwnProperty(id)) {
name = core.material.npcs[id].name;
image = core.material.images.npcs;
icon = core.material.icons.npcs[core.material.npcs[id].icon];
}
else if (core.material.enemys.hasOwnProperty(id)) {
name = core.material.enemys[id].name;
image = core.material.images.enemys;
icon = core.material.icons.enemys[id];
}
if (name != null) {
core.fillText('ui', name, left + 63, top + 30, '#FFD700', 'bold 22px Verdana');
core.status.boxAnimateObjs = [];
core.status.boxAnimateObjs.push({
'bgx': left + 15, 'bgy': top + 40, 'bgsize': 32,
'image': image, 'x': left + 15, 'y': top + 40, 'icon': icon
});
core.setBoxAnimate(core.firstData.animateSpeed);
}
}
}
for (var i=0;i<contents.length;i++) {
core.fillText('ui', contents[i], content_left, content_top, '#FFFFFF', '16px Verdana');
content_top+=24;
}
core.fillText('ui', '<点击任意位置继续>', 270, top+height-13, '#CCCCCC', '13px Verdana');
}
/**
* 绘制确认/取消警告
* @param text
* @param yesCallback
* @param noCallback
*/
ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) {
core.status.event.id = 'confirmBox';
core.status.event.data = {'yes': yesCallback, 'no': noCallback};
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
core.setFont('ui', "bold 19px Verdana");
var contents = text.split('\n');
var lines = contents.length;
var max_length = 0;
for (var i in contents) {
max_length = Math.max(max_length, core.canvas.ui.measureText(contents[i]).width);
}
var left = Math.min(208 - 40 - max_length / 2, 100);
var top = 140 - (lines-1)*30;
var right = 416 - 2 * left, bottom = 416 - 140 - top;
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";
for (var i in contents) {
core.fillText('ui', contents[i], 208, top + 50 + i*30, "#FFFFFF");
}
core.fillText('ui', "确定", 208 - 38, top + bottom - 35, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "取消", 208 + 38, top + bottom - 35);
}
/**
* 绘制菜单栏
* @param need
*/
ui.prototype.drawSettings = function (need) {
if (!core.checkStatus('settings', need))
return;
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top;
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', "音乐: " + (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 + 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");
}
/**
* 绘制选择商店窗口
* @param need
*/
ui.prototype.drawSelectShop = function (need) {
if (core.isset(need) && !core.checkStatus('selectShop', need))
return;
core.status.event.id = 'selectShop';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var shopList = core.status.shops, keys = Object.keys(shopList);
var len = keys.length + 1;
if (len % 2 == 0) len++;
var left = 97, top = 208 - 32 - 16 * len, right = 416 - 2 * left, bottom = 416 - 2 * top;
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";
for (var i = 0; i < keys.length; i++) {
core.fillText('ui', shopList[keys[i]].name, 208, top + 56 + 32 * i, "#FFFFFF", "bold 17px Verdana");
}
core.fillText('ui', "返回游戏", 208, top + bottom - 40);
}
/**
* 绘制商店
* @param id
*/
ui.prototype.drawShop = function (id) {
var shop = core.status.shops[id];
// 正在移动中...
if (!core.status.heroStop) {
setTimeout(function () {
core.ui.drawShop(id);
}, 30);
return;
}
core.status.event.data = shop;
core.status.event.id = 'shop';
core.lockControl();
shop.visited = true;
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
var times = shop.times, need = eval(shop.need);
clearInterval(core.interval.tipAnimate);
core.clearMap('data', 0, 0, 416, 416);
core.setOpacity('data', 1);
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top;
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', shop.title, left + 135, top + 34, '#FFFFFF', 'bold 19px Verdana');
// 动画
core.strokeRect('ui', left + 15 - 1, top + 30 - 1, 34, 34, '#DDDDDD', 2);
core.status.boxAnimateObjs = [];
core.status.boxAnimateObjs.push({
'bgx': left + 15, 'bgy': top + 30, 'bgsize': 32,
'image': core.material.images.npcs,
'x': left + 15, 'y': top + 30, 'icon': core.material.icons.npcs[shop.icon]
});
core.setBoxAnimate(core.firstData.animateSpeed);
// 对话
core.canvas.ui.textAlign = "left";
if (need<0) need="若干";
var use = shop.use=='experience'?"经验":"金币";
core.fillText('ui', "勇敢的武士啊,给我" + need, left + 60, top + 65, '#FFFFFF', 'bold 14px Verdana');
core.fillText('ui', use + "你就可以:", left + 60, top + 83);
// 选项
core.canvas.ui.textAlign = "center";
for (var i = 0; i < shop.choices.length; i++) {
var choice = shop.choices[i];
var text = choice.text;
if (core.isset(choice.need))
text += ""+eval(choice.need)+use+""
core.fillText('ui', text, 208, top + 120 + 32 * i, "#FFFFFF", "bold 17px Verdana");
}
core.fillText('ui', "退出商店", 208, top + 248);
}
/**
* 绘制请等候...
* @param text
*/
ui.prototype.drawWaiting = function(text) {
core.lockControl();
core.status.event.id = 'waiting';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 208 - 32 - 16, right = 416 - 2 * left, bottom = 416 - 2 * top;
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', text, 208, top + 56, "#FFFFFF", "bold 17px Verdana");
}
/**
* 绘制存档同步选项
*/
ui.prototype.drawSyncSave = function () {
core.status.event.id = 'syncSave';
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
var left = 97, top = 208 - 32 - 16 * 3, right = 416 - 2 * left, bottom = 416 - 2 * top;
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 + bottom - 40);
}
/**
* 绘制分页
* @param page
* @param totalPage
*/
ui.prototype.drawPagination = function (page, totalPage) {
core.setFont('ui', 'bold 15px Verdana');
core.setFillStyle('ui', '#DDDDDD');
var length = core.canvas.ui.measureText(page + " / " + page).width;
core.canvas.ui.textAlign = 'left';
core.fillText('ui', page + " / " + totalPage, (416 - length) / 2, 403);
core.canvas.ui.textAlign = 'center';
if (page > 1)
core.fillText('ui', '上一页', 208 - 80, 403);
if (page < totalPage)
core.fillText('ui', '下一页', 208 + 80, 403);
// 退出
core.fillText('ui', '返回游戏', 370, 403);
}
/**
* 绘制怪物手册
* @param page 页数
*/
ui.prototype.drawEnemyBook = function (page) {
var enemys = core.enemys.getCurrentEnemys();
var background = core.canvas.ui.createPattern(core.material.ground, "repeat");
clearInterval(core.interval.tipAnimate);
core.clearMap('data', 0, 0, 416, 416);
core.setOpacity('data', 1);
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.setFillStyle('ui', background);
core.fillRect('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.6);
core.setFillStyle('ui', '#000000');
core.fillRect('ui', 0, 0, 416, 416);
core.setAlpha('ui', 1);
core.canvas.ui.textAlign = 'left';
core.setFont('ui', 'bold 15px Verdana');
if (enemys.length == 0) {
core.fillText('ui', "本层无怪物", 83, 222, '#999999', "bold 50px Verdana");
// 退出
core.canvas.ui.textAlign = 'center';
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
return;
}
var perpage = 6;
var totalPage = parseInt((enemys.length - 1) / perpage) + 1;
if (page < 1) page = 1;
if (page > totalPage) page = totalPage;
core.status.event.data = page;
var start = (page - 1) * perpage, end = Math.min(page * perpage, enemys.length);
enemys = enemys.slice(start, end);
core.status.boxAnimateObjs = [];
for (var i = 0; i < enemys.length; i++) {
// 边框
var enemy = enemys[i];
core.strokeRect('ui', 22, 62 * i + 22, 42, 42, '#DDDDDD', 2);
// 怪物
core.status.boxAnimateObjs.push({
'bgx': 22, 'bgy': 62 * i + 22, 'bgsize': 42,
'image': core.material.images.enemys,
'x': 27, 'y': 62 * i + 27, 'icon': core.material.icons.enemys[enemy.id]
});
// 数据
core.canvas.ui.textAlign = "center";
core.fillText('ui', enemy.name, 115, 62 * i + 47, '#DDDDDD', 'bold 17px Verdana');
core.canvas.ui.textAlign = "left";
core.fillText('ui', '生命', 165, 62 * i + 32, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.hp, 195, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '攻击', 255, 62 * i + 32, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.atk, 285, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '防御', 335, 62 * i + 32, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.def, 365, 62 * i + 32, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '金币', 165, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.money, 195, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
var damage_offset = 326;
if (core.flags.enableExperience) {
core.canvas.ui.textAlign = "left";
core.fillText('ui', '经验', 255, 62 * i + 50, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.experience, 285, 62 * i + 50, '#DDDDDD', 'bold 13px Verdana');
damage_offset = 361;
}
core.canvas.ui.textAlign = "center";
var damage = enemy.damage;
var color = '#FFFF00';
if (damage >= core.status.hero.hp) color = '#FF0000';
if (damage == 0) color = '#00FF00';
if (damage >= 999999999) damage = '无法战斗';
var length = core.canvas.ui.measureText(damage).width;
core.fillText('ui', damage, damage_offset, 62 * i + 50, color, 'bold 13px Verdana');
core.canvas.ui.textAlign = "left";
// 属性
if (enemy.special != '') {
core.setFont('data', 'bold 12px Verdana');
var length = core.canvas.data.measureText(enemy.special).width;
core.setAlpha('data', '0.4');
core.fillRect('data', 64 - 4 - length, 62 * i + 46, length + 4, 17, '#000000');
core.setAlpha('data', '1');
core.fillText('data', enemy.special, 64 - 2 - length, 62 * i + 59, '#FF6A6A', 'bold 12px Verdana')
}
core.fillText('ui', '临界', 165, 62 * i + 68, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.critical, 195, 62 * i + 68, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '减伤', 255, 62 * i + 68, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.criticalDamage, 285, 62 * i + 68, '#DDDDDD', 'bold 13px Verdana');
core.fillText('ui', '1防', 335, 62 * i + 68, '#DDDDDD', '13px Verdana');
core.fillText('ui', enemy.defDamage, 365, 62 * i + 68, '#DDDDDD', 'bold 13px Verdana');
}
core.setBoxAnimate(core.firstData.animateSpeed);
this.drawPagination(page, totalPage);
}
/**
* 绘制楼传器
* @param page
*/
ui.prototype.drawFly = function(page) {
if (page<0) page=0;
if (page>=core.status.hero.flyRange.length) page=core.status.hero.flyRange.length-1;
core.status.event.data = page;
var floorId = core.status.hero.flyRange[page];
var title = core.status.maps[floorId].title;
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
core.fillRect('ui', 0, 0, 416, 416, '#000000');
core.setAlpha('ui', 1);
core.canvas.ui.textAlign = 'center';
core.fillText('ui', '楼层跳跃', 208, 60, '#FFFFFF', "bold 28px Verdana");
core.fillText('ui', '返回游戏', 208, 403, '#FFFFFF', "bold 15px Verdana")
core.fillText('ui', title, 356, 247, '#FFFFFF', "bold 19px Verdana");
if (page<core.status.hero.flyRange.length-1)
core.fillText('ui', '▲', 356, 247-64, '#FFFFFF', "17px Verdana");
if (page>0)
core.fillText('ui', '▼', 356, 247+64, '#FFFFFF', "17px Verdana");
core.strokeRect('ui', 20, 100, 273, 273, '#FFFFFF', 2);
this.drawThumbnail('ui', core.status.maps[floorId].blocks, 20, 100, 273);
}
/**
* 绘制工具栏
* @param selectId
*/
ui.prototype.drawToolbox = function(selectId) {
if (!core.hasItem(selectId))
selectId=null;
core.status.event.data=selectId;
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
core.fillRect('ui', 0, 0, 416, 416, '#000000');
core.setAlpha('ui', 1);
core.setFillStyle('ui', '#DDDDDD');
core.setStrokeStyle('ui', '#DDDDDD');
core.canvas.ui.lineWidth = 2;
core.canvas.ui.strokeWidth = 2;
// 画线
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 130);
core.canvas.ui.lineTo(416, 130);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0,129);
core.canvas.ui.lineTo(0,105);
core.canvas.ui.lineTo(72,105);
core.canvas.ui.lineTo(102,129);
core.canvas.ui.fill();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0, 290);
core.canvas.ui.lineTo(416, 290);
core.canvas.ui.stroke();
core.canvas.ui.beginPath();
core.canvas.ui.moveTo(0,289);
core.canvas.ui.lineTo(0,265);
core.canvas.ui.lineTo(72,265);
core.canvas.ui.lineTo(102,289);
core.canvas.ui.fill();
// 文字
core.canvas.ui.textAlign = 'left';
core.fillText('ui', "消耗道具", 5, 124, '#333333', "bold 16px Verdana");
core.fillText('ui', "永久道具", 5, 284);
// 描述
if (core.isset(selectId)) {
var item=core.material.items[selectId];
core.fillText('ui', item.name, 10, 32, '#FFD700', "bold 20px Verdana")
core.fillText('ui', item.text, 10, 62, '#FFFFFF', '17px Verdana');
core.fillText('ui', '<继续点击该道具即可进行使用>', 10, 89, '#CCCCCC', '14px Verdana');
}
core.canvas.ui.textAlign = 'right';
var images = core.material.images.items;
// 消耗道具
var tools = Object.keys(core.status.hero.items.tools).sort();
for (var i=0;i<tools.length;i++) {
var tool=tools[i];
var icon=core.material.icons.items[tool];
if (i<6) {
core.canvas.ui.drawImage(images, 0, icon.loc*icon.size, icon.size, icon.size, 16*(4*i+1)+5, 144+5, icon.size, icon.size)
// 个数
core.fillText('ui', core.itemCount(tool), 16*(4*i+1)+40, 144+38, '#FFFFFF', "bold 14px Verdana");
if (selectId == tool)
core.strokeRect('ui', 16*(4*i+1)+1, 144+1, icon.size+8, icon.size+8, '#FFD700');
}
else {
core.canvas.ui.drawImage(images, 0, icon.loc*icon.size, icon.size, icon.size, 16*(4*(i-6)+1)+5, 144+64+5, icon.size, icon.size)
if (selectId == tool)
core.strokeRect('ui', 16*(4*(i-6)+1)+1, 144+64+1, icon.size+8, icon.size+8, '#FFD700');
}
}
// 永久道具
var constants = Object.keys(core.status.hero.items.constants).sort();
for (var i=0;i<constants.length;i++) {
var constant=constants[i];
var icon=core.material.icons.items[constant];
if (i<6) {
core.canvas.ui.drawImage(images, 0, icon.loc*icon.size, icon.size, icon.size, 16*(4*i+1)+5, 304+5, icon.size, icon.size)
// core.fillText('ui', core.itemCount(constant), 16*(4*i+1)+40, 304+38, '#FFFFFF', "bold 16px Verdana")
if (selectId == constant)
core.strokeRect('ui', 16*(4*i+1)+1, 304+1, icon.size+8, icon.size+8, '#FFD700');
}
else {
core.canvas.ui.drawImage(images, 0, icon.loc*icon.size, icon.size, icon.size, 16*(4*(i-6)+1)+5, 304+64+5, icon.size, icon.size)
if (selectId == constant)
core.strokeRect('ui', 16*(4*(i-6)+1)+1, 304+64+1, icon.size+8, icon.size+8, '#FFD700');
}
}
// 退出
core.canvas.ui.textAlign = 'center';
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
}
/**
* 绘制存档读档
* @param page
*/
ui.prototype.drawSLPanel = function(page) {
if (page<0) page=0;
if (page>=30) page=29;
core.status.event.data = page;
core.status.savePage = page;
core.clearMap('ui', 0, 0, 416, 416);
core.setAlpha('ui', 0.85);
core.fillRect('ui', 0, 0, 416, 416, '#000000');
core.setAlpha('ui', 1);
core.canvas.ui.textAlign = 'center';
var u=416/6, size=117;
var name=core.status.event.id=='save'?"存档":"读档";
for (var i=0;i<6;i++) {
var id=6*page+i+1;
var data=core.getLocalStorage("save"+id,null);
if (i<3) {
core.fillText('ui', name+id, (2*i+1)*u, 35, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, '#FFFFFF', 2);
if (core.isset(data) && core.isset(data.floorId)) {
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc, data.hero.id);
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i+1)*u, 65+size, '#FFFFFF', '10px Verdana');
}
else {
core.fillRect('ui', (2*i+1)*u-size/2, 50, size, size, '#333333', 2);
core.fillText('ui', '空', (2*i+1)*u, 117, '#FFFFFF', 'bold 30px Verdana');
}
}
else {
core.fillText('ui', name+id, (2*i-5)*u, 230, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, '#FFFFFF', 2);
if (core.isset(data) && core.isset(data.floorId)) {
this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc, data.hero.id);
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i-5)*u, 260+size, '#FFFFFF', '10px Verdana');
}
else {
core.fillRect('ui', (2*i-5)*u-size/2, 245, size, size, '#333333', 2);
core.fillText('ui', '空', (2*i-5)*u, 245+70, '#FFFFFF', 'bold 30px Verdana');
}
}
}
this.drawPagination(page+1, 30);
}
/**
* 绘制缩略图
* @param canvas
* @param blocks
* @param x
* @param y
* @param size
* @param heroLoc
* @param heroId
*/
ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc, heroId) {
core.clearMap(canvas, x, y, size, size);
var persize = size/13;
for (var i=0;i<13;i++) {
for (var j=0;j<13;j++) {
var blockIcon = core.material.icons.terrains.ground;
var blockImage = core.material.images.terrains;
core.canvas[canvas].drawImage(blockImage, 0, blockIcon.loc * blockIcon.size, blockIcon.size, blockIcon.size, x + i * persize, y + j * persize, persize, persize);
}
}
for (var b in blocks) {
var block = blocks[b];
if (core.isset(block.event)) {
var i = block.x, j = block.y;
var blockIcon = core.material.icons[block.event.cls][block.event.id];
var blockImage = core.material.images[block.event.cls];
//core.canvas[canvas].clearRect(x + i * persize, y + j * persize, persize, persize);
core.canvas[canvas].drawImage(blockImage, 0, blockIcon.loc * blockIcon.size, blockIcon.size, blockIcon.size, x + i * persize, y + j * persize, persize, persize);
}
}
if (core.isset(heroLoc)) {
var id = core.isset(heroId)?heroId:core.status.hero.id;
var heroIcon = core.material.icons.heros[id][heroLoc.direction];
core.canvas[canvas].drawImage(core.material.images.heros, heroIcon.loc['stop'] * heroIcon.size, heroIcon.loc.iconLoc * heroIcon.size, heroIcon.size, heroIcon.size, x+persize*heroLoc.x, y+persize*heroLoc.y, persize, persize);
}
}
/**
* 绘制"关于"
*/
ui.prototype.drawAbout = function() {
if (!core.isPlaying()) {
core.status.event = {'id': null, 'data': null};
core.dom.startPanel.style.display = 'none';
}
core.lockControl();
core.status.event.id = 'about';
core.clearMap('ui', 0, 0, 416, 416);
var left = 48, top = 36, 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);
var text_start = left + 24;
// 名称
core.canvas.ui.textAlign = "left";
core.fillText('ui', "异空间", text_start, top+35, "#FFD700", "bold 22px Verdana");
core.fillText('ui', "HTML5复刻版", text_start+75, top+37, "#DDDDDD", "bold 15px Verdana");
core.fillText('ui', "作者: 艾之葵", text_start, top + 80, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "原作: ss433_2", text_start, top + 112, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "制作工具: WebStorm", text_start, top + 144, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', "测试平台: Chrome/微信/iOS", text_start, top + 176, "#FFFFFF", "bold 17px Verdana");
core.fillText('ui', '特别鸣谢: ss433_2', text_start, top+208);
var len = core.canvas.ui.measureText('特别鸣谢: ').width;
core.fillText('ui', 'iEcho', text_start+len, top+240);
core.fillText('ui', '打Dota的喵', text_start+len, top+272);
core.fillText('ui', 'HTML5魔塔交流群539113091', text_start, top+304);
}

1
libs/ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

313
main.js Normal file
View File

@ -0,0 +1,313 @@
function main() {
this.dom = {
'body': document.body,
'gameGroup': document.getElementById('gameGroup'),
'mainTips': document.getElementById('mainTips'),
'musicBtn': document.getElementById('musicBtn'),
'startPanel': document.getElementById('startPanel'),
'startTop': document.getElementById('startTop'),
'startTopProgressBar': document.getElementById('startTopProgressBar'),
'startTopProgress': document.getElementById('startTopProgress'),
'startTopLoadTips': document.getElementById('startTopLoadTips'),
'startBackground': document.getElementById('startBackground'),
'startButtonGroup': document.getElementById('startButtonGroup'),
'floorMsgGroup': document.getElementById('floorMsgGroup'),
'logoLabel': document.getElementById('logoLabel'),
'versionLabel': document.getElementById('versionLabel'),
'floorNameLabel': document.getElementById('floorNameLabel'),
'statusBar': document.getElementById('statusBar'),
'toolBar': document.getElementById('toolBar'),
'gameCanvas': document.getElementsByClassName('gameCanvas'),
'startButtons': document.getElementById('startButtons'),
'playGame': document.getElementById('playGame'),
'loadGame': document.getElementById('loadGame'),
'aboutGame': document.getElementById('aboutGame'),
'levelChooseButtons': document.getElementById('levelChooseButtons'),
'easyLevel': document.getElementById('easyLevel'),
'normalLevel': document.getElementById('normalLevel'),
'hardLevel': document.getElementById('hardLevel'),
'data': document.getElementById('data'),
'statusLabels': document.getElementsByClassName('statusLabel')
};
// console.log('加载游戏容器和开始界面dom对象完成 如下');
// console.log(this.dom);
this.loadList = [
'items', 'icons', 'maps', 'enemys', 'events',
'npcs', 'data', 'ui', 'core'
];
// console.log('加载js文件列表加载完成' + this.loadList);
this.images = [
'animates', 'enemys', 'heros', 'items', 'npcs', 'terrains'
];
this.sounds = {
'mp3': ['bgm-loop', 'floor'],
'ogg': ['attack', 'door', 'item']
}
this.statusBar = {
'image': {
'floor': document.getElementById('img-floor'),
'hp': document.getElementById("img-hp"),
'atk': document.getElementById("img-atk"),
'def': document.getElementById("img-def"),
'mdef': document.getElementById("img-mdef"),
'money': document.getElementById("img-money"),
'experience': document.getElementById("img-experience"),
'book': document.getElementById("img-book"),
'fly': document.getElementById("img-fly"),
'toolbox': document.getElementById("img-toolbox"),
'shop': document.getElementById("img-shop"),
'save': document.getElementById("img-save"),
'load': document.getElementById("img-load"),
'settings': document.getElementById("img-settings")
},
'floor': document.getElementById('floor'),
'hp': document.getElementById('hp'),
'atk': document.getElementById('atk'),
'def': document.getElementById("def"),
'mdef': document.getElementById('mdef'),
'money': document.getElementById("money"),
'experience': document.getElementById("experience"),
'yellowKey': document.getElementById("yellowKey"),
'blueKey': document.getElementById("blueKey"),
'redKey': document.getElementById("redKey"),
'poison': document.getElementById('poison'),
'weak':document.getElementById('weak'),
'curse': document.getElementById('curse'),
'hard': document.getElementById("hard")
}
this.floorIds = [
"MT1"
]
this.floors = {}
this.instance = {};
this.canvas = {};
}
main.prototype.init = function () {
for (var i = 0; i < main.dom.gameCanvas.length; i++) {
main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d');
}
main.loader(function () {
var coreData = {};
for (i = 0; i < main.loadList.length; i++) {
var name = main.loadList[i];
// end with ".min"
if (name.indexOf(".min")==name.length-4)
name=name.substring(0, name.length-4);
if (name === 'core') {
continue;
}
main[name].init(main.dom);
coreData[name] = main[name];
}
main.core.init(main.dom, main.statusBar, main.canvas, main.images, main.sounds, coreData);
main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
});
}
main.prototype.loader = function (callback) {
var instanceNum = 0;
for (var i = 0; i < main.loadList.length; i++) {
main.loadMod(main.loadList[i], function (modName) {
instanceNum = 0;
main.setMainTipsText(modName + '.js 加载完毕');
for (var key in main.instance) {
instanceNum++;
}
if (instanceNum === main.loadList.length) {
delete main.instance;
main.dom.mainTips.style.display = 'none';
callback();
}
});
}
}
main.prototype.loadMod = function (modName, callback) {
var script = document.createElement('script');
var name = modName;
// end with ".min"
if (name.indexOf(".min")==name.length-4)
name=name.substring(0, name.length-4);
script.src = 'libs/' + modName + '.js';
main.dom.body.appendChild(script);
script.onload = function () {
main[name] = main.instance[name];
callback(name);
}
}
main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text;
}
var main = new main();
main.init();
window.onresize = function () {
try {
main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
}catch (e) {}
}
main.dom.body.onkeydown = function(e) {
if (main.core.isPlaying())
main.core.keyDown(e);
}
main.dom.body.onkeyup = function(e) {
try {
if (main.core.isPlaying())
main.core.keyUp(e);
} catch (e) {}
}
main.dom.body.onselectstart = function () {
return false;
}
document.onmousemove = function() {
try {
main.core.loadSound();
}catch (e) {}
}
document.ontouchstart = function() {
try {
main.core.loadSound();
}catch (e) {}
}
main.dom.data.onmousedown = function (e) {
try {
e.stopPropagation();
var loc = main.core.getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
main.core.ondown(x, y);
} catch (e) {}
}
main.dom.data.onmousemove = function (e) {
try {
e.stopPropagation();
var loc = main.core.getClickLoc(e.clientX, e.clientY);
if (loc == null) return;
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
main.core.onmove(x, y);
}catch (e) {}
}
main.dom.data.onmouseup = function () {
try {
main.core.onup();
}catch (e) {}
}
main.dom.data.onmousewheel = function(e) {
try {
if (e.wheelDelta)
main.core.onmousewheel(Math.sign(e.wheelDelta))
else if (e.detal)
main.core.onmousewheel(Math.sign(e.detail));
} catch (ee) {}
}
main.dom.data.ontouchstart = function (e) {
try {
e.preventDefault();
var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return;
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
//main.core.onclick(x, y, []);
main.core.ondown(x, y);
}catch (e) {}
}
main.dom.data.ontouchmove = function (e) {
try {
e.preventDefault();
var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return;
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
main.core.onmove(x, y);
}catch (e) {}
}
main.dom.data.ontouchend = function () {
try {
main.core.onup();
} catch (e) {
}
}
main.statusBar.image.book.onclick = function () {
if (main.core.isPlaying())
main.core.openBook(true);
}
main.statusBar.image.fly.onclick = function (e) {
if (main.core.isPlaying())
main.core.useFly(true);
}
main.statusBar.image.toolbox.onclick = function (e) {
if (main.core.isPlaying())
main.core.openToolbox(true);
}
main.statusBar.image.shop.onclick = function () {
if (main.core.isPlaying())
main.core.ui.drawSelectShop(true);
}
main.statusBar.image.save.onclick = function (e) {
if (main.core.isPlaying())
main.core.save(true);
}
main.statusBar.image.load.onclick = function (e) {
if (main.core.isPlaying())
main.core.load(true);
}
main.statusBar.image.settings.onclick = function (e) {
if (main.core.isPlaying())
main.core.ui.drawSettings(true);
}
main.dom.playGame.onclick = function () {
main.dom.startButtons.style.display='none';
/**
* 如果点击开始游戏直接开始游戏而不是进入难度选择页面则将下面这个改成true
*/
var startGameNow = false;
if (startGameNow) {
core.events.startGame();
}
else {
main.dom.levelChooseButtons.style.display='block';
}
}
main.dom.loadGame.onclick = function() {
main.core.load();
}
main.dom.aboutGame.onclick = function () {
main.core.ui.drawAbout();
}
main.dom.easyLevel.onclick = function() {
core.events.startGame('Easy');
}
main.dom.normalLevel.onclick = function () {
core.events.startGame('Normal');
}
main.dom.hardLevel.onclick = function () {
core.events.startGame('Gard');
}

1
main.min.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
map_generator.exe Normal file

Binary file not shown.

BIN
sounds/attack.ogg Normal file

Binary file not shown.

BIN
sounds/bgm.mp3 Normal file

Binary file not shown.

BIN
sounds/door.ogg Normal file

Binary file not shown.

BIN
sounds/floor.mp3 Normal file

Binary file not shown.

BIN
sounds/item.ogg Normal file

Binary file not shown.

235
styles.css Normal file
View File

@ -0,0 +1,235 @@
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #000;
overflow: hidden;
}
@font-face {
font-family: number;
src: url("fonts/number.ttf");
}
#gameGroup {
position: absolute;
outline: 3px #fff solid;
background-color: #000;
}
#mainTips {
color: #fff;
font-size: 0.8rem;
position: fixed;
top: 10px;
left: 10px;
z-index: 12;
}
#startPanel {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #fff;
overflow: hidden;
z-index: 8;
}
#startTop {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #000;
z-index: 11;
}
#startTopProgressBar {
width: 90%;
height: 5%;
margin: 0 5%;
position: absolute;
top: 5%;
background-color: #fff;
z-index: 12;
}
#startTopProgress {
width: 0%;
height: 100%;
background-color: #666;
}
#startTopLoadTips {
color: #fff;
font-size: 0.6rem;
position: absolute;
top: 8%;
left: 5%;
z-index: 12;
}
#startBackground {
position:absolute;
top:50%;
left:50%;
height: 100%;
width: auto;
transform:translate(-50%,-50%);
z-index: 9;
}
#startLogo {
position: absolute;
z-index: 9;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
margin-top: 8%;
max-width: 100%;
text-align: center;
font: bold 4rem 华文行楷;
}
#startTitle {
position: absolute;
z-index: 10;
}
#startButtonGroup {
width: 100%;
position: absolute;
text-align: center;
font-size: 1.4rem;
background-color: #000;
opacity: 0.85;
display: none;
z-index: 9;
bottom: 0;
margin-bottom: 7%;
}
#startButtons {
display: block;
}
#levelChooseButtons {
display: none;
}
.startButton {
width: 100%;
margin: 20px 0;
color: #fff;
font-weight: bold;
display: block;
cursor: pointer;
}
.startButton:hover {
color: #ff0000;
}
#floorMsgGroup {
width: 416px;
height: 100%;
position: absolute;
top: 0;
right: 0;
text-align: center;
display: none;
color: #fff;
background-color: #000;
z-index: 7;
}
#logoLabel {
margin-top: 8%;
font: bold 3rem 华文行楷;
margin-left: auto;
margin-right: auto;
}
#versionLabel {
margin-top: -3%;
font-size: 1.2rem;
font-weight: bold;
}
#floorNameLabel {
margin-top: 30px;
font-size: 1.6rem;
font-weight: bold;
}
#statusBar {
position: absolute;
background: url(images/ground.png) round;
z-index: 6;
}
#toolBar {
position: absolute;
background: url(images/ground.png) round;
z-index: 5;
display: none;
left: 0px;
border-top: 3px #fff solid;
}
#statusBar img {
position: absolute;
display: none;
}
#statusBar p {
position: absolute;
color: white;
font: bold italic 1.1em Verdana;
margin: 0;
}
#statusBar p#hard {
color: red;
font: bold normal 1.1em "Arial Black";
text-align: center;
right: 0;
}
p#poison, p#weak, p#curse {
font-style: normal;
font-size: 1em;
}
.gameCanvas {
position: absolute;
}
#bg {
z-index: 1;
}
#event {
z-index: 2;
}
#fg {
z-index: 3;
}
#hero {
z-index: 4;
}
#ui {
z-index: 5;
}
#data {
z-index: 6;
}