Enable Level Up
This commit is contained in:
parent
cf02a59dee
commit
68f0a28a61
56
libs/core.js
56
libs/core.js
@ -1537,12 +1537,11 @@ core.prototype.afterBattle = function(id, x, y, callback) {
|
|||||||
var experience = core.material.enemys[id].experience;
|
var experience = core.material.enemys[id].experience;
|
||||||
if (core.hasFlag('curse')) experience=0;
|
if (core.hasFlag('curse')) experience=0;
|
||||||
core.status.hero.experience += experience;
|
core.status.hero.experience += experience;
|
||||||
core.updateStatusBar();
|
|
||||||
if (core.isset(x) && core.isset(y)) {
|
if (core.isset(x) && core.isset(y)) {
|
||||||
core.removeBlock(x, y);
|
core.removeBlock(x, y);
|
||||||
core.canvas.event.clearRect(32 * x, 32 * y, 32, 32);
|
core.canvas.event.clearRect(32 * x, 32 * y, 32, 32);
|
||||||
}
|
}
|
||||||
core.updateFg();
|
// core.updateStatusBar();
|
||||||
var hint = "打败 " + core.material.enemys[id].name;
|
var hint = "打败 " + core.material.enemys[id].name;
|
||||||
if (core.flags.enableMoney)
|
if (core.flags.enableMoney)
|
||||||
hint += ",金币+" + money;
|
hint += ",金币+" + money;
|
||||||
@ -1625,7 +1624,6 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback)
|
|||||||
core.statusBar.floor.style.fontStyle = 'italic';
|
core.statusBar.floor.style.fontStyle = 'italic';
|
||||||
else core.statusBar.floor.style.fontStyle = 'normal';
|
else core.statusBar.floor.style.fontStyle = 'normal';
|
||||||
|
|
||||||
core.updateStatusBar();
|
|
||||||
core.drawMap(floorId, function () {
|
core.drawMap(floorId, function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
core.mapChangeAnimate('hide', time/4, function () {
|
core.mapChangeAnimate('hide', time/4, function () {
|
||||||
@ -1638,9 +1636,10 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback)
|
|||||||
core.setHeroLoc('x', heroLoc.x);
|
core.setHeroLoc('x', heroLoc.x);
|
||||||
core.setHeroLoc('y', heroLoc.y);
|
core.setHeroLoc('y', heroLoc.y);
|
||||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||||
core.updateCheckBlockMap();
|
core.updateStatusBar();
|
||||||
core.updateCheckBlock();
|
// core.updateCheckBlockMap();
|
||||||
core.updateFg();
|
// core.updateCheckBlock();
|
||||||
|
// core.updateFg();
|
||||||
}, 15)
|
}, 15)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2783,6 +2782,21 @@ core.prototype.calValue = function (value) {
|
|||||||
return eval(value);
|
return eval(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.prototype.doEffect = function (expression) {
|
||||||
|
// 必须使用"+="
|
||||||
|
var arr = expression.split("+=");
|
||||||
|
if (arr.length!=2) return;
|
||||||
|
var name=arr[0], value=core.calValue(arr[1]);
|
||||||
|
if (name.indexOf("status:")==0) {
|
||||||
|
var status=name.substring(7);
|
||||||
|
core.setStatus(status, core.getStatus(status)+value);
|
||||||
|
}
|
||||||
|
else if (name.indexOf("item:")==0) {
|
||||||
|
var itemId=name.substring(5);
|
||||||
|
core.setItem(itemId, core.itemCount(itemId)+value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.prototype.splitLines = function(canvas, text, maxLength, font) {
|
core.prototype.splitLines = function(canvas, text, maxLength, font) {
|
||||||
if (core.isset(font)) core.setFont(canvas, font);
|
if (core.isset(font)) core.setFont(canvas, font);
|
||||||
|
|
||||||
@ -3334,6 +3348,9 @@ core.prototype.clearStatusBar = function() {
|
|||||||
*/
|
*/
|
||||||
core.prototype.updateStatusBar = function () {
|
core.prototype.updateStatusBar = function () {
|
||||||
|
|
||||||
|
// 检查登记
|
||||||
|
core.checkLvUp();
|
||||||
|
|
||||||
// 上限999999
|
// 上限999999
|
||||||
if (core.values.HPMAX>0) {
|
if (core.values.HPMAX>0) {
|
||||||
core.setStatus('hp', Math.min(core.values.HPMAX, core.getStatus('hp')));
|
core.setStatus('hp', Math.min(core.values.HPMAX, core.getStatus('hp')));
|
||||||
@ -3349,6 +3366,12 @@ core.prototype.updateStatusBar = function () {
|
|||||||
statusList.forEach(function (item) {
|
statusList.forEach(function (item) {
|
||||||
core.statusBar[item].innerHTML = core.getStatus(item);
|
core.statusBar[item].innerHTML = core.getStatus(item);
|
||||||
});
|
});
|
||||||
|
// 进阶
|
||||||
|
if (core.flags.enableLevelUp && core.status.hero.lv<core.firstData.levelUp.length) {
|
||||||
|
core.statusBar.up.innerHTML = core.firstData.levelUp[core.status.hero.lv].need || " ";
|
||||||
|
}
|
||||||
|
else core.statusBar.up.innerHTML = " ";
|
||||||
|
|
||||||
var keys = ['yellowKey', 'blueKey', 'redKey'];
|
var keys = ['yellowKey', 'blueKey', 'redKey'];
|
||||||
keys.forEach(function (key) {
|
keys.forEach(function (key) {
|
||||||
core.statusBar[key].innerHTML = core.setTwoDigits(core.status.hero.items.keys[key]);
|
core.statusBar[key].innerHTML = core.setTwoDigits(core.status.hero.items.keys[key]);
|
||||||
@ -3374,6 +3397,27 @@ core.prototype.updateStatusBar = function () {
|
|||||||
core.updateFg();
|
core.updateFg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.prototype.checkLvUp = function () {
|
||||||
|
if (!core.flags.enableLevelUp || core.status.hero.lv>=core.firstData.levelUp.length) return;
|
||||||
|
// 计算下一个所需要的数值
|
||||||
|
var need=core.firstData.levelUp[core.status.hero.lv].need;
|
||||||
|
if (!core.isset(need)) return;
|
||||||
|
if (core.status.hero.experience>=need) {
|
||||||
|
// 升级
|
||||||
|
core.status.hero.lv++;
|
||||||
|
var effect = core.firstData.levelUp[core.status.hero.lv-1].effect;
|
||||||
|
if (typeof effect == "string") {
|
||||||
|
effect.split(";").forEach(function (t) {
|
||||||
|
core.doEffect(t);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (effect instanceof Function) {
|
||||||
|
effect();
|
||||||
|
}
|
||||||
|
core.checkLvUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.prototype.resize = function(clientWidth, clientHeight) {
|
core.prototype.resize = function(clientWidth, clientHeight) {
|
||||||
|
|
||||||
// 默认画布大小
|
// 默认画布大小
|
||||||
|
|||||||
27
libs/data.js
27
libs/data.js
@ -7,7 +7,7 @@ data.prototype.init = function() {
|
|||||||
"title": "魔塔样板", // 游戏名,将显示在标题页面以及切换楼层的界面中
|
"title": "魔塔样板", // 游戏名,将显示在标题页面以及切换楼层的界面中
|
||||||
"name": "template", // 游戏的唯一英文标识符。由英文、数字、下划线组成,不能超过20个字符。
|
"name": "template", // 游戏的唯一英文标识符。由英文、数字、下划线组成,不能超过20个字符。
|
||||||
"version": "Ver 1.0.0 (Beta)", // 当前游戏版本;版本不一致的存档不能通用。
|
"version": "Ver 1.0.0 (Beta)", // 当前游戏版本;版本不一致的存档不能通用。
|
||||||
"floorId": "sample0", // 初始楼层ID
|
"floorId": "test", // 初始楼层ID
|
||||||
"hero": { // 勇士初始数据
|
"hero": { // 勇士初始数据
|
||||||
"name": "阳光", // 勇士名;可以改成喜欢的
|
"name": "阳光", // 勇士名;可以改成喜欢的
|
||||||
'lv': 1, // 初始等级,该项必须为正整数
|
'lv': 1, // 初始等级,该项必须为正整数
|
||||||
@ -27,7 +27,7 @@ data.prototype.init = function() {
|
|||||||
"tools": {}
|
"tools": {}
|
||||||
},
|
},
|
||||||
"flyRange": [], // 初始可飞的楼层;一般留空数组即可
|
"flyRange": [], // 初始可飞的楼层;一般留空数组即可
|
||||||
"loc": {"direction": "up", "x": 6, "y": 10}, // 勇士初始位置
|
"loc": {"direction": "up", "x": 6, "y": 12}, // 勇士初始位置
|
||||||
"flags": { // 游戏过程中的变量或flags
|
"flags": { // 游戏过程中的变量或flags
|
||||||
"poison": false, // 毒
|
"poison": false, // 毒
|
||||||
"weak": false, // 衰
|
"weak": false, // 衰
|
||||||
@ -84,13 +84,22 @@ data.prototype.init = function() {
|
|||||||
},
|
},
|
||||||
"levelUp": [ // 经验升级所需要的数值,是一个数组
|
"levelUp": [ // 经验升级所需要的数值,是一个数组
|
||||||
{}, // 第一项为初始等级,可以简单留空,也可以写name
|
{}, // 第一项为初始等级,可以简单留空,也可以写name
|
||||||
{"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍;再将攻击+10,防御+10
|
|
||||||
// 每一个里面可以含有三个参数 name, need, effect
|
// 每一个里面可以含有三个参数 name, need, effect
|
||||||
// need为所需要的经验数值,是一个正整数。请确保need所需的依次递增
|
// need为所需要的经验数值,是一个正整数。请确保need所需的依次递增
|
||||||
// name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中
|
// name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中
|
||||||
// effect为本次升级所执行的操作,可由若干项组成,由分号分开;
|
// effect为本次升级所执行的操作,可由若干项组成,由分号分开
|
||||||
// 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数
|
// 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数
|
||||||
{"need": 40, "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"},
|
{"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍;再将攻击+10,防御+10
|
||||||
|
|
||||||
|
// effect也允许写一个function,代表本次升级将会执行的操作
|
||||||
|
{"need": 40, "effect": function () {
|
||||||
|
core.drawText("恭喜升级!");
|
||||||
|
core.status.hero.hp *= 2;
|
||||||
|
core.status.hero.atk += 100;
|
||||||
|
core.status.hero.def += 100;
|
||||||
|
}},
|
||||||
|
|
||||||
// 依次往下写需要的数值即可
|
// 依次往下写需要的数值即可
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -132,13 +141,13 @@ data.prototype.init = function() {
|
|||||||
this.flags = {
|
this.flags = {
|
||||||
/****** 角色状态相关 ******/
|
/****** 角色状态相关 ******/
|
||||||
"enableNegativeDamage": true, // 是否支持负伤害(回血)
|
"enableNegativeDamage": true, // 是否支持负伤害(回血)
|
||||||
"enableFloor": true, // 是否在状态栏显示当前楼层
|
"enableFloor": false, // 是否在状态栏显示当前楼层
|
||||||
"enableLv": false, // 是否在状态栏显示当前等级
|
"enableLv": true, // 是否在状态栏显示当前等级
|
||||||
"enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾)
|
"enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾)
|
||||||
"enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币
|
"enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币
|
||||||
"enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验
|
"enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验
|
||||||
"enableLevelUp": false, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false
|
"enableLevelUp": true, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false
|
||||||
"enableDebuff": true, // 是否涉及毒衰咒;如果此项为false则不会在状态栏中显示毒衰咒的debuff
|
"enableDebuff": false, // 是否涉及毒衰咒;如果此项为false则不会在状态栏中显示毒衰咒的debuff
|
||||||
////// 上述的几个开关将直接影响状态栏的显示效果 //////
|
////// 上述的几个开关将直接影响状态栏的显示效果 //////
|
||||||
/****** 道具相关 ******/
|
/****** 道具相关 ******/
|
||||||
"flyNearStair": true, // 是否需要在楼梯边使用传送器
|
"flyNearStair": true, // 是否需要在楼梯边使用传送器
|
||||||
|
|||||||
@ -5,7 +5,7 @@ function enemys() {
|
|||||||
enemys.prototype.init = function () {
|
enemys.prototype.init = function () {
|
||||||
// 怪物属性初始化定义:
|
// 怪物属性初始化定义:
|
||||||
this.enemys = {
|
this.enemys = {
|
||||||
'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 0, 'special': 0},
|
'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 1, 'special': 0},
|
||||||
'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||||
'blackSlime': {'name': '青头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
'blackSlime': {'name': '青头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0},
|
||||||
'slimelord': {'name': '怪王', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 9},
|
'slimelord': {'name': '怪王', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 9},
|
||||||
|
|||||||
@ -329,7 +329,6 @@ events.prototype.doAction = function() {
|
|||||||
core.status.hero.hp=0;
|
core.status.hero.hp=0;
|
||||||
core.updateStatusBar();
|
core.updateStatusBar();
|
||||||
core.events.lose('damage');
|
core.events.lose('damage');
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.updateStatusBar();
|
core.updateStatusBar();
|
||||||
@ -817,12 +816,7 @@ events.prototype.clickShop = function(x,y) {
|
|||||||
|
|
||||||
// 更新属性
|
// 更新属性
|
||||||
choice.effect.split(";").forEach(function (t) {
|
choice.effect.split(";").forEach(function (t) {
|
||||||
if (t.indexOf("status:")==0) {
|
core.doEffect(t);
|
||||||
eval(t.replace("status:", "core.status.hero."));
|
|
||||||
}
|
|
||||||
else if (t.indexOf("item:")==0) {
|
|
||||||
eval(t.replace("item:", "core.getItem('").replace("+=", "', ")+")");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
core.updateStatusBar();
|
core.updateStatusBar();
|
||||||
shop.times++;
|
shop.times++;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
main.floors.MT0 = {
|
main.floors.MT0 = {
|
||||||
"floorId": "MT0", // 楼层唯一标识符,需要和名字完全一致
|
"floorId": "MT0", // 楼层唯一标识符,需要和名字完全一致
|
||||||
"title": "主塔 0 层", // 楼层中文名
|
"title": "主塔 0 层", // 楼层中文名
|
||||||
"name": 0, // 显示在状态栏中的层数
|
"name": "0", // 显示在状态栏中的层数
|
||||||
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||||
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||||
"defaultGround": "ground", // 默认地面的图块ID(terrains中)
|
"defaultGround": "ground", // 默认地面的图块ID(terrains中)
|
||||||
|
|||||||
45
libs/floors/test.js
Normal file
45
libs/floors/test.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// 这里需要改楼层名,请和文件名及下面的floorId保持完全一致
|
||||||
|
// 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头
|
||||||
|
// 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等
|
||||||
|
main.floors.test = {
|
||||||
|
"floorId": "test", // 楼层唯一标识符,需要和名字完全一致
|
||||||
|
"title": "test", // 楼层中文名
|
||||||
|
"name": "", // 显示在状态栏中的层数
|
||||||
|
"canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器)
|
||||||
|
"canUseQuickShop": true, // 该层是否允许使用快捷商店
|
||||||
|
"defaultGround": "ground", // 默认地面的图块ID(terrains中)
|
||||||
|
"map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201,201,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201, 45,201,201,201,201,201,201],
|
||||||
|
[201,201,201,201,201,201, 0,201,201,201,201,201,201]
|
||||||
|
],
|
||||||
|
"firstArrive": [ // 第一次到该楼层触发的事件
|
||||||
|
|
||||||
|
],
|
||||||
|
"events": { // 该楼的所有可能事件列表
|
||||||
|
|
||||||
|
},
|
||||||
|
"changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖
|
||||||
|
|
||||||
|
},
|
||||||
|
"afterBattle": { // 战斗后可能触发的事件列表
|
||||||
|
|
||||||
|
},
|
||||||
|
"afterGetItem": { // 获得道具后可能触发的事件列表
|
||||||
|
|
||||||
|
},
|
||||||
|
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
2
main.js
2
main.js
@ -97,7 +97,7 @@ function main() {
|
|||||||
// 如果要进行剧本的修改请务必将其改成false。
|
// 如果要进行剧本的修改请务必将其改成false。
|
||||||
|
|
||||||
this.floorIds = [ // 在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器的顺序和上楼器/下楼器的顺序
|
this.floorIds = [ // 在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器的顺序和上楼器/下楼器的顺序
|
||||||
"sample0", "sample1", "sample2"
|
"sample0", "sample1", "sample2", "test"
|
||||||
]
|
]
|
||||||
//------------------------ 用户修改内容 END ------------------------//
|
//------------------------ 用户修改内容 END ------------------------//
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user