Name on statusBar
This commit is contained in:
parent
806449381b
commit
3565b2256a
@ -351,6 +351,12 @@ data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
|||||||
"_bool": "bool",
|
"_bool": "bool",
|
||||||
"_data": "是否在状态栏显示当前楼层"
|
"_data": "是否在状态栏显示当前楼层"
|
||||||
},
|
},
|
||||||
|
"enableName": {
|
||||||
|
"_leaf": true,
|
||||||
|
"_type": "checkbox",
|
||||||
|
"_bool": "bool",
|
||||||
|
"_data": "是否在状态栏显示勇士名字"
|
||||||
|
},
|
||||||
"enableLv": {
|
"enableLv": {
|
||||||
"_leaf": true,
|
"_leaf": true,
|
||||||
"_type": "checkbox",
|
"_type": "checkbox",
|
||||||
|
|||||||
@ -333,6 +333,10 @@
|
|||||||
<img id="img-floor">
|
<img id="img-floor">
|
||||||
<p class='statusLabel' id='floor'></p>
|
<p class='statusLabel' id='floor'></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="status" id="nameCol">
|
||||||
|
<img id="img-name">
|
||||||
|
<p class='statusLabel' id='name'></p>
|
||||||
|
</div>
|
||||||
<div class="status" id="lvCol">
|
<div class="status" id="lvCol">
|
||||||
<img id="img-lv">
|
<img id="img-lv">
|
||||||
<p class='statusLabel' id='lv'></p>
|
<p class='statusLabel' id='lv'></p>
|
||||||
|
|||||||
@ -319,6 +319,10 @@
|
|||||||
<img id="img-floor">
|
<img id="img-floor">
|
||||||
<p class='statusLabel' id='floor'></p>
|
<p class='statusLabel' id='floor'></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="status" id="nameCol">
|
||||||
|
<img id="img-name">
|
||||||
|
<p class='statusLabel' id='name'></p>
|
||||||
|
</div>
|
||||||
<div class="status" id="lvCol">
|
<div class="status" id="lvCol">
|
||||||
<img id="img-lv">
|
<img id="img-lv">
|
||||||
<p class='statusLabel' id='lv'></p>
|
<p class='statusLabel' id='lv'></p>
|
||||||
|
|||||||
@ -46,6 +46,10 @@
|
|||||||
<img id="img-floor">
|
<img id="img-floor">
|
||||||
<p class='statusLabel' id='floor'></p>
|
<p class='statusLabel' id='floor'></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="status" id="nameCol">
|
||||||
|
<img id="img-name">
|
||||||
|
<p class='statusLabel' id='name'></p>
|
||||||
|
</div>
|
||||||
<div class="status" id="lvCol">
|
<div class="status" id="lvCol">
|
||||||
<img id="img-lv">
|
<img id="img-lv">
|
||||||
<p class='statusLabel' id='lv'></p>
|
<p class='statusLabel' id='lv'></p>
|
||||||
|
|||||||
@ -250,6 +250,8 @@ control.prototype.clearStatus = function() {
|
|||||||
}
|
}
|
||||||
core.status = {};
|
core.status = {};
|
||||||
core.clearStatusBar();
|
core.clearStatusBar();
|
||||||
|
core.status.played = false;
|
||||||
|
core.events.setHeroIcon('hero.png', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 重置游戏状态和初始数据 //////
|
////// 重置游戏状态和初始数据 //////
|
||||||
@ -266,7 +268,6 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
|||||||
|
|
||||||
// 初始化status
|
// 初始化status
|
||||||
core.status = core.clone(core.initStatus);
|
core.status = core.clone(core.initStatus);
|
||||||
core.status.played = true;
|
|
||||||
// 初始化maps
|
// 初始化maps
|
||||||
core.status.floorId = floorId;
|
core.status.floorId = floorId;
|
||||||
core.status.maps = core.clone(maps);
|
core.status.maps = core.clone(maps);
|
||||||
@ -275,6 +276,8 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
|||||||
core.material.items = core.clone(core.items.getItems());
|
core.material.items = core.clone(core.items.getItems());
|
||||||
// 初始化人物属性
|
// 初始化人物属性
|
||||||
core.status.hero = core.clone(hero);
|
core.status.hero = core.clone(hero);
|
||||||
|
// 初始化人物图标
|
||||||
|
core.events.setHeroIcon(core.getFlag('heroIcon', 'hero.png'), true);
|
||||||
// 统计数据
|
// 统计数据
|
||||||
if (!core.isset(core.status.hero.statistics))
|
if (!core.isset(core.status.hero.statistics))
|
||||||
core.status.hero.statistics = {
|
core.status.hero.statistics = {
|
||||||
@ -302,6 +305,7 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
|
|||||||
else core.values = core.clone(core.data.values);
|
else core.values = core.clone(core.data.values);
|
||||||
|
|
||||||
core.events.initGame();
|
core.events.initGame();
|
||||||
|
core.status.played = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 开始游戏 //////
|
////// 开始游戏 //////
|
||||||
@ -1022,6 +1026,8 @@ control.prototype.updateViewport = function() {
|
|||||||
////// 绘制勇士 //////
|
////// 绘制勇士 //////
|
||||||
control.prototype.drawHero = function (direction, x, y, status, offset) {
|
control.prototype.drawHero = function (direction, x, y, status, offset) {
|
||||||
|
|
||||||
|
if (!core.isPlaying()) return;
|
||||||
|
|
||||||
var scan = {
|
var scan = {
|
||||||
'up': {'x': 0, 'y': -1},
|
'up': {'x': 0, 'y': -1},
|
||||||
'left': {'x': -1, 'y': 0},
|
'left': {'x': -1, 'y': 0},
|
||||||
@ -1197,20 +1203,22 @@ control.prototype.checkBlock = function () {
|
|||||||
|
|
||||||
// 检查阻击事件
|
// 检查阻击事件
|
||||||
var snipe = [];
|
var snipe = [];
|
||||||
var scan = {
|
if (!core.hasFlag("no_snipe")) {
|
||||||
'up': {'x': 0, 'y': -1},
|
var scan = {
|
||||||
'left': {'x': -1, 'y': 0},
|
'up': {'x': 0, 'y': -1},
|
||||||
'down': {'x': 0, 'y': 1},
|
'left': {'x': -1, 'y': 0},
|
||||||
'right': {'x': 1, 'y': 0}
|
'down': {'x': 0, 'y': 1},
|
||||||
}
|
'right': {'x': 1, 'y': 0}
|
||||||
for (var direction in scan) {
|
}
|
||||||
var nx = x+scan[direction].x, ny=y+scan[direction].y;
|
for (var direction in scan) {
|
||||||
if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
|
var nx = x+scan[direction].x, ny=y+scan[direction].y;
|
||||||
var id=core.status.checkBlock.map[nx+core.bigmap.width*ny];
|
if (nx<0 || nx>=core.bigmap.width || ny<0 || ny>=core.bigmap.height) continue;
|
||||||
if (core.isset(id)) {
|
var id=core.status.checkBlock.map[nx+core.bigmap.width*ny];
|
||||||
var enemy = core.material.enemys[id];
|
if (core.isset(id)) {
|
||||||
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) {
|
var enemy = core.material.enemys[id];
|
||||||
snipe.push({'direction': direction, 'x': nx, 'y': ny});
|
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) {
|
||||||
|
snipe.push({'direction': direction, 'x': nx, 'y': ny});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2585,11 +2593,11 @@ control.prototype.playSound = function (sound) {
|
|||||||
|
|
||||||
////// 清空状态栏 //////
|
////// 清空状态栏 //////
|
||||||
control.prototype.clearStatusBar = function() {
|
control.prototype.clearStatusBar = function() {
|
||||||
var statusList = ['floor', 'lv', 'hpmax', 'hp', 'atk', 'def', 'mdef', 'money', 'experience',
|
|
||||||
'up', 'yellowKey', 'blueKey', 'redKey', 'poison', 'weak', 'curse', 'hard'];
|
Object.keys(core.statusBar).forEach(function (e) {
|
||||||
statusList.forEach(function (e) {
|
if (core.isset(core.statusBar[e].innerHTML))
|
||||||
core.statusBar[e].innerHTML = " ";
|
core.statusBar[e].innerHTML = " ";
|
||||||
});
|
})
|
||||||
core.statusBar.image.book.style.opacity = 0.3;
|
core.statusBar.image.book.style.opacity = 0.3;
|
||||||
if (!core.flags.equipboxButton) {
|
if (!core.flags.equipboxButton) {
|
||||||
core.statusBar.image.fly.style.opacity = 0.3;
|
core.statusBar.image.fly.style.opacity = 0.3;
|
||||||
@ -2645,6 +2653,27 @@ control.prototype.updateStatusBar = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
control.prototype.updateHeroIcon = function (name) {
|
||||||
|
name = name || "hero.png";
|
||||||
|
if (core.statusBar.icons.name == name) return;
|
||||||
|
core.statusBar.icons.name = name;
|
||||||
|
|
||||||
|
var image = core.material.images.hero;
|
||||||
|
|
||||||
|
var canvas = document.createElement("canvas");
|
||||||
|
var context = canvas.getContext("2d");
|
||||||
|
canvas.width = 32;
|
||||||
|
canvas.height = 32;
|
||||||
|
context.drawImage(image, 0, 0, 32, 32, 0, 0, 32, 32);
|
||||||
|
if (core.material.icons.hero.height>=48) {
|
||||||
|
context.lineWidth = 5;
|
||||||
|
context.strokeStyle = '#FFFFFF';
|
||||||
|
context.strokeRect(0, 0, 32, 32);
|
||||||
|
}
|
||||||
|
core.statusBar.image.name.src = canvas.toDataURL("image/png");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
////// 屏幕分辨率改变后重新自适应 //////
|
////// 屏幕分辨率改变后重新自适应 //////
|
||||||
control.prototype.resize = function(clientWidth, clientHeight) {
|
control.prototype.resize = function(clientWidth, clientHeight) {
|
||||||
if (main.mode=='editor')return;
|
if (main.mode=='editor')return;
|
||||||
@ -2685,8 +2714,9 @@ control.prototype.resize = function(clientWidth, clientHeight) {
|
|||||||
if (!core.flags.enableExperience) count--;
|
if (!core.flags.enableExperience) count--;
|
||||||
if (!core.flags.enableLevelUp) count--;
|
if (!core.flags.enableLevelUp) count--;
|
||||||
if (!core.flags.enableDebuff) count--;
|
if (!core.flags.enableDebuff) count--;
|
||||||
if (core.isset(core.flags.enableKeys) && !core.flags.enableKeys) count--;
|
if (!core.flags.enableKeys) count--;
|
||||||
if (!core.flags.enablePZF) count--;
|
if (!core.flags.enablePZF) count--;
|
||||||
|
if (!core.flags.enableName) count--;
|
||||||
|
|
||||||
var statusLineHeight = BASE_LINEHEIGHT * 9 / count;
|
var statusLineHeight = BASE_LINEHEIGHT * 9 / count;
|
||||||
var statusLineFontSize = DEFAULT_FONT_SIZE;
|
var statusLineFontSize = DEFAULT_FONT_SIZE;
|
||||||
@ -2940,6 +2970,12 @@ control.prototype.resize = function(clientWidth, clientHeight) {
|
|||||||
display: core.flags.enableFloor ? 'block': 'none'
|
display: core.flags.enableFloor ? 'block': 'none'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'nameCol',
|
||||||
|
rules: {
|
||||||
|
display: core.flags.enableName ? 'block': 'none'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'lvCol',
|
id: 'lvCol',
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
@ -292,8 +292,7 @@ core.prototype.init = function (coreData, callback) {
|
|||||||
core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
|
core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage);
|
||||||
core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical);
|
core.flags.displayCritical = core.getLocalStorage('critical', core.flags.displayCritical);
|
||||||
core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage);
|
core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage);
|
||||||
core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly',
|
core.flags.clickMoveDirectly = core.getLocalStorage('clickMoveDirectly', core.flags.clickMoveDirectly);
|
||||||
!(core.isset(core.flags.clickMoveDirectly) && !core.flags.clickMoveDirectly));
|
|
||||||
|
|
||||||
core.material.ground = new Image();
|
core.material.ground = new Image();
|
||||||
core.material.ground.src = "project/images/ground.png";
|
core.material.ground.src = "project/images/ground.png";
|
||||||
@ -304,6 +303,9 @@ core.prototype.init = function (coreData, callback) {
|
|||||||
console.log(core.material);
|
console.log(core.material);
|
||||||
// 设置勇士高度
|
// 设置勇士高度
|
||||||
core.material.icons.hero.height = core.material.images.hero.height/4;
|
core.material.icons.hero.height = core.material.images.hero.height/4;
|
||||||
|
// 行走图
|
||||||
|
core.control.updateHeroIcon();
|
||||||
|
|
||||||
core.initStatus.maps = core.maps.initMaps(core.floorIds);
|
core.initStatus.maps = core.maps.initMaps(core.floorIds);
|
||||||
core.setRequestAnimationFrame();
|
core.setRequestAnimationFrame();
|
||||||
core.showStartAnimate();
|
core.showStartAnimate();
|
||||||
|
|||||||
@ -1568,12 +1568,15 @@ events.prototype.canUseQuickShop = function(shopId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 设置角色行走图 //////
|
////// 设置角色行走图 //////
|
||||||
events.prototype.setHeroIcon = function (name) {
|
events.prototype.setHeroIcon = function (name, noDraw) {
|
||||||
if (core.isset(core.material.images.images[name]) && core.material.images.images[name].width==128) {
|
if (core.isset(core.material.images.images[name]) && core.material.images.images[name].width==128) {
|
||||||
core.setFlag("heroIcon", name);
|
core.setFlag("heroIcon", name);
|
||||||
|
core.material.images.hero.onload = function () {
|
||||||
|
core.material.icons.hero.height = core.material.images.images[name].height/4;
|
||||||
|
core.control.updateHeroIcon(name);
|
||||||
|
if (!noDraw) core.drawHero();
|
||||||
|
}
|
||||||
core.material.images.hero.src = core.material.images.images[name].src;
|
core.material.images.hero.src = core.material.images.images[name].src;
|
||||||
core.material.icons.hero.height = core.material.images.images[name].height/4;
|
|
||||||
core.drawHero();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
main.js
4
main.js
@ -51,6 +51,7 @@ function main() {
|
|||||||
'data': document.getElementById('data'),
|
'data': document.getElementById('data'),
|
||||||
'statusLabels': document.getElementsByClassName('statusLabel'),
|
'statusLabels': document.getElementsByClassName('statusLabel'),
|
||||||
'floorCol': document.getElementById('floorCol'),
|
'floorCol': document.getElementById('floorCol'),
|
||||||
|
'nameCol': document.getElementById('nameCol'),
|
||||||
'lvCol': document.getElementById('lvCol'),
|
'lvCol': document.getElementById('lvCol'),
|
||||||
'hpmaxCol': document.getElementById('hpmaxCol'),
|
'hpmaxCol': document.getElementById('hpmaxCol'),
|
||||||
'mdefCol': document.getElementById('mdefCol'),
|
'mdefCol': document.getElementById('mdefCol'),
|
||||||
@ -76,6 +77,7 @@ function main() {
|
|||||||
this.statusBar = {
|
this.statusBar = {
|
||||||
'image': {
|
'image': {
|
||||||
'floor': document.getElementById('img-floor'),
|
'floor': document.getElementById('img-floor'),
|
||||||
|
'name': document.getElementById('img-name'),
|
||||||
'lv': document.getElementById('img-lv'),
|
'lv': document.getElementById('img-lv'),
|
||||||
'hpmax': document.getElementById('img-hpmax'),
|
'hpmax': document.getElementById('img-hpmax'),
|
||||||
'hp': document.getElementById("img-hp"),
|
'hp': document.getElementById("img-hp"),
|
||||||
@ -95,6 +97,7 @@ function main() {
|
|||||||
},
|
},
|
||||||
'icons': {
|
'icons': {
|
||||||
'floor': 0,
|
'floor': 0,
|
||||||
|
'name': null,
|
||||||
'lv': 1,
|
'lv': 1,
|
||||||
'hpmax': 2,
|
'hpmax': 2,
|
||||||
'hp': 3,
|
'hp': 3,
|
||||||
@ -120,6 +123,7 @@ function main() {
|
|||||||
'equipbox': 23,
|
'equipbox': 23,
|
||||||
},
|
},
|
||||||
'floor': document.getElementById('floor'),
|
'floor': document.getElementById('floor'),
|
||||||
|
'name': document.getElementById('name'),
|
||||||
'lv': document.getElementById('lv'),
|
'lv': document.getElementById('lv'),
|
||||||
'hpmax': document.getElementById('hpmax'),
|
'hpmax': document.getElementById('hpmax'),
|
||||||
'hp': document.getElementById('hp'),
|
'hp': document.getElementById('hp'),
|
||||||
|
|||||||
@ -187,6 +187,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
|||||||
},
|
},
|
||||||
"flags": {
|
"flags": {
|
||||||
"enableFloor": true,
|
"enableFloor": true,
|
||||||
|
"enableName": false,
|
||||||
"enableLv": false,
|
"enableLv": false,
|
||||||
"enableHPMax": false,
|
"enableHPMax": false,
|
||||||
"enableMDef": true,
|
"enableMDef": true,
|
||||||
|
|||||||
@ -590,7 +590,10 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp')));
|
core.setStatus('hp', Math.min(core.getStatus('hpmax'), core.getStatus('hp')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置等级奴名称
|
// 设置勇士名字和图标
|
||||||
|
core.statusBar.name.innerHTML = core.getStatus('name');
|
||||||
|
|
||||||
|
// 设置等级名称
|
||||||
var lvName = core.getLvName();
|
var lvName = core.getLvName();
|
||||||
core.statusBar.lv.innerHTML = lvName;
|
core.statusBar.lv.innerHTML = lvName;
|
||||||
// 检测是不是纯数字;如果带中文等需要取消斜体(不然很难看的!)
|
// 检测是不是纯数字;如果带中文等需要取消斜体(不然很难看的!)
|
||||||
|
|||||||
@ -227,6 +227,10 @@ span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly {
|
|||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p#name {
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
.gameCanvas {
|
.gameCanvas {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user