Skip to content

Commit 59f6a90

Browse files
committed
update
1 parent df7af7d commit 59f6a90

11 files changed

+213
-1233
lines changed

editor.html

+9-615
Large diffs are not rendered by default.

index.html

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<meta name="x5-page-mode" content="app">
1616
</head>
1717
<body>
18-
<div id='startImageBackgroundDiv'>
18+
<!-- <div id='startImageBackgroundDiv'>
1919
<div id='startImageDiv'></div>
2020
<img id='startImageLogo' />
21-
</div>
21+
</div> -->
2222
<div id='gameGroup'>
23-
<p id='mainTips'>请稍后...</p>
23+
<p id='mainTips'></p>
2424
<img id='musicBtn'>
2525
<div id='startPanel'>
2626
<div id='startTop'>
@@ -41,10 +41,11 @@
4141
<div id='levelChooseButtons'></div>
4242
</div>
4343
</div>
44+
</div>
4445
<!-- <div id="gameDraw">
4546
<canvas class='gameCanvas' id='animate' width='416' height='416'></canvas>
4647
<canvas class='gameCanvas' id='curtain' width='416' height='416'></canvas>
47-
</div> -->
48+
</div>
4849
</div>
4950
<div id='inputDiv'>
5051
<div id='inputDialog'>
@@ -53,8 +54,8 @@
5354
<button id='inputYes'>确定</button>
5455
<button id='inputNo'>取消</button>
5556
</div>
56-
</div>
57+
</div> -->
5758
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
58-
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
59+
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
5960
</body>
6061
</html>

libs/control.js

+23-64
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default control;
22
import {functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a} from '../project/functions'
33
import localforage from './thirdparty/localforage.min.js';
4+
import route from '../../pixi/scenes/route';
45
/*
56
control.js:游戏主要逻辑控制
67
主要负责status相关内容,以及各种变量获取/存储
@@ -21,11 +22,11 @@ control.prototype._init = function () {
2122
// --- 注册系统的animationFrame
2223
this.registerAnimationFrame("totalTime", false, this._animationFrame_totalTime);
2324
this.registerAnimationFrame("autoSave", true, this._animationFrame_autoSave);
24-
this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
25-
this.registerAnimationFrame("animate", true, this._animationFrame_animate);
25+
// this.registerAnimationFrame("globalAnimate", true, this._animationFrame_globalAnimate);
26+
// this.registerAnimationFrame("animate", true, this._animationFrame_animate);
2627
this.registerAnimationFrame("heroMoving", true, this._animationFrame_heroMoving);
27-
this.registerAnimationFrame("weather", true, this._animationFrame_weather);
28-
this.registerAnimationFrame("tips", true, this._animateFrame_tips);
28+
// this.registerAnimationFrame("weather", true, this._animationFrame_weather);
29+
// this.registerAnimationFrame("tips", true, this._animateFrame_tips);
2930
this.registerAnimationFrame("parallelDo", false, this._animationFrame_parallelDo);
3031
this.registerAnimationFrame("checkConsoleOpened", true, this._animationFrame_checkConsoleOpened);
3132
// --- 注册系统的replay
@@ -416,9 +417,7 @@ control.prototype._initStatistics = function (totalTime) {
416417
// ------ 自动寻路,人物行走 ------ //
417418

418419
////// 清除自动寻路路线 //////
419-
control.prototype.clearAutomaticRouteNode = function (x, y) {
420-
core.clearMap('route', x * 32 + 5 - core.status.automaticRoute.offsetX, y * 32 + 5 - core.status.automaticRoute.offsetY, 27, 27);
421-
}
420+
422421

423422
////// 停止自动寻路操作 //////
424423
control.prototype.stopAutomaticRoute = function () {
@@ -433,7 +432,7 @@ control.prototype.stopAutomaticRoute = function () {
433432
core.status.automaticRoute.lastDirection = null;
434433
core.status.heroStop = true;
435434
if (core.status.automaticRoute.moveStepBeforeStop.length==0)
436-
core.deleteCanvas('route');
435+
route.clear();
437436
}
438437

439438
////// 保存剩下的寻路,并停止 //////
@@ -463,19 +462,22 @@ control.prototype.continueAutomaticRoute = function () {
463462
////// 清空剩下的自动寻路列表 //////
464463
control.prototype.clearContinueAutomaticRoute = function (callback) {
465464
//TODO
466-
core.deleteCanvas('route');
465+
route.clear();
467466
core.status.automaticRoute.moveStepBeforeStop=[];
468467
if (callback) callback();
469468
}
470469

471470
////// 显示离散的寻路点 //////
472471
// TODO
473472
control.prototype.fillPosWithPoint = function (pos) {
474-
core.fillRect('ui', pos.x*32+12,pos.y*32+12,8,8, '#bfbfbf');
473+
// core.fillRect('ui', pos.x*32+12,pos.y*32+12,8,8, '#bfbfbf');
474+
route.fillPosWithPoint(pos);
475475
}
476476

477477
////// 设置自动寻路路线 //////
478478
control.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
479+
// 清空寻路node和 点选node
480+
route.clear();
479481
if (!core.status.played || core.status.lockControl) return;
480482
if (this._setAutomaticRoute_isMoving(destX, destY)) return;
481483
if (this._setAutomaticRoute_isTurning(destX, destY, stepPostfix)) return;
@@ -490,7 +492,7 @@ control.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
490492
this._setAutomaticRoute_drawRoute(moveStep);
491493
this._setAutomaticRoute_setAutoSteps(moveStep);
492494
// 立刻移动
493-
core.setAutoHeroMove();
495+
this.setAutoHeroMove();
494496
}
495497

496498
control.prototype._setAutomaticRoute_isMoving = function (destX, destY) {
@@ -544,32 +546,7 @@ control.prototype._setAutomaticRoute_clickMoveDirectly = function (destX, destY,
544546
control.prototype._setAutomaticRoute_drawRoute = function (moveStep) {
545547
// 计算绘制区域的宽高,并尽可能小的创建route层
546548
// TODO
547-
pixi.ui.drawRoute(moveStep);
548-
var sx = core.bigmap.width * 32, sy = core.bigmap.height * 32, dx = 0, dy = 0;
549-
moveStep.forEach(function (t) {
550-
sx = Math.min(sx, t.x * 32); dx = Math.max(dx, t.x * 32);
551-
sy = Math.min(sy, t.y * 32); dy = Math.max(dy, t.y * 32);
552-
});
553-
core.status.automaticRoute.offsetX = sx;
554-
core.status.automaticRoute.offsetY = sy;
555-
var ctx = core.createCanvas('route', sx-core.bigmap.offsetX, sy-core.bigmap.offsetY, dx-sx+32, dy-sy+32, 95);
556-
ctx.fillStyle = '#bfbfbf';
557-
ctx.strokeStyle = '#bfbfbf';
558-
ctx.lineWidth = 8;
559-
for (var m = 0; m < moveStep.length; m++) {
560-
if (m == moveStep.length - 1) {
561-
ctx.fillRect(moveStep[m].x * 32 + 10 - sx, moveStep[m].y * 32 + 10 - sy, 12, 12);
562-
}
563-
else {
564-
ctx.beginPath();
565-
var cx = moveStep[m].x*32 +16 - sx, cy = moveStep[m].y*32+16 - sy;
566-
var currDir = moveStep[m].direction, nextDir = moveStep[m+1].direction;
567-
ctx.moveTo(cx-core.utils.scan[currDir].x*11, cy-core.utils.scan[currDir].y*11);
568-
ctx.lineTo(cx, cy);
569-
ctx.lineTo(cx+core.utils.scan[nextDir].x*11, cy+core.utils.scan[nextDir].y*11);
570-
ctx.stroke();
571-
}
572-
}
549+
route.drawRoute(moveStep);
573550
}
574551

575552
control.prototype._setAutomaticRoute_setAutoSteps = function (moveStep) {
@@ -596,7 +573,7 @@ control.prototype.setAutoHeroMove = function (steps) {
596573
core.status.automaticRoute.autoHeroMove = true;
597574
core.status.automaticRoute.autoStep = 1;
598575
core.status.automaticRoute.destStep = steps[0].step;
599-
core.moveHero(steps[0].direction);
576+
this.moveHero(steps[0].direction);
600577
}
601578

602579
////// 设置行走的效果动画 //////
@@ -648,7 +625,7 @@ control.prototype._moveAction_noPass = function (canMove, callback) {
648625
core.drawHero();
649626

650627
if (core.status.automaticRoute.moveStepBeforeStop.length==0) {
651-
core.clearContinueAutomaticRoute();
628+
this.clearContinueAutomaticRoute();
652629
core.stopAutomaticRoute();
653630
}
654631
if (callback) callback();
@@ -662,6 +639,7 @@ control.prototype._moveAction_moving = function (callback) {
662639

663640
// 无事件的道具(如血瓶)需要优先于阻激夹域判定
664641
var nowx = core.getHeroLoc('x'), nowy = core.getHeroLoc('y');
642+
route.clearAutomaticRouteNode(nowx, nowy);
665643
var block = core.getBlock(nowx,nowy);
666644
var hasTrigger = false;
667645
if (block!=null && block.block.event.trigger=='getItem' &&
@@ -817,7 +795,6 @@ control.prototype.drawHero = function (status, offset) {
817795
var dx = way.x, dy = way.y, offsetX = dx * offset, offsetY = dy * offset;
818796
core.bigmap.offsetX = core.clamp((x - core.__HALF_SIZE__) * 32 + offsetX, 0, 32*core.bigmap.width-core.__PIXELS__);
819797
core.bigmap.offsetY = core.clamp((y - core.__HALF_SIZE__) * 32 + offsetY, 0, 32*core.bigmap.height-core.__PIXELS__);
820-
core.clearAutomaticRouteNode(x+dx, y+dy);
821798
core.status.heroCenter.px = 32 * x + offsetX + 16;
822799
core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2;
823800
const heroSprite = core.status.heroSprite;
@@ -833,9 +810,7 @@ control.prototype.drawHero = function (status, offset) {
833810
, block.posy+32-block.height + core.bigmap.offsetY);
834811
});
835812
}
836-
837-
core.control.updateViewport();
838-
core.setGameCanvasTranslate('hero', 0, 0);
813+
this.updateViewport();
839814
}
840815

841816
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) {
@@ -870,22 +845,6 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
870845
// ------ 画布、位置、阻激夹域,显伤 ------ //
871846

872847
////// 设置画布偏移
873-
control.prototype.setGameCanvasTranslate = function(canvas,x,y){
874-
return;
875-
var c=core.dom.gameCanvas[canvas];
876-
x=x*core.domStyle.scale;
877-
y=y*core.domStyle.scale;
878-
c.style.transform='translate('+x+'px,'+y+'px)';
879-
c.style.webkitTransform='translate('+x+'px,'+y+'px)';
880-
c.style.OTransform='translate('+x+'px,'+y+'px)';
881-
c.style.MozTransform='translate('+x+'px,'+y+'px)';
882-
if(main.mode==='editor' && editor.isMobile){
883-
c.style.transform='translate('+(x/core.__PIXELS__*96)+'vw,'+(y/core.__PIXELS__*96)+'vw)';
884-
c.style.webkitTransform='translate('+(x/core.__PIXELS__*96)+'vw,'+(y/core.__PIXELS__*96)+'vw)';
885-
c.style.OTransform='translate('+(x/core.__PIXELS__*96)+'vw,'+(y/core.__PIXELS__*96)+'vw)';
886-
c.style.MozTransform='translate('+(x/core.__PIXELS__*96)+'vw,'+(y/core.__PIXELS__*96)+'vw)';
887-
}
888-
};
889848

890849
////// 加减画布偏移
891850
control.prototype.addGameCanvasTranslate = function (x, y) {
@@ -909,9 +868,12 @@ control.prototype.updateViewport = function() {
909868
//pixi.game.container.setTransform(- core.bigmap.offsetX,- core.bigmap.offsetY);
910869
const container = pixi.game.container;
911870
const [offsetX, offsetY] = container.zone;
912-
pixi.game.container.setTransform(offsetX - core.bigmap.offsetX, offsetY - core.bigmap.offsetY);
871+
const x = offsetX - core.bigmap.offsetX;
872+
const y =offsetY - core.bigmap.offsetY;
873+
if (container.x !== x || container.y !== y) {
874+
container.position.set(x, y);
875+
}
913876
// ------ 路线
914-
core.relocateCanvas('route', core.status.automaticRoute.offsetX - core.bigmap.offsetX, core.status.automaticRoute.offsetY - core.bigmap.offsetY);
915877
}
916878

917879
////// 设置视野范围 //////
@@ -920,9 +882,6 @@ control.prototype.setViewport = function (x, y) {
920882
core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__);
921883
this.updateViewport();
922884
// ------ hero层也需要!
923-
var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__);
924-
var hero_y = core.clamp((core.getHeroLoc('y') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.height-core.__PIXELS__);
925-
core.control.setGameCanvasTranslate('hero', hero_x - core.bigmap.offsetX, hero_y - core.bigmap.offsetY);
926885
}
927886

928887
////// 移动视野范围 //////

libs/core.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ _core.prototype._init_flags = function () {
247247
// core.dom.versionLabel.innerText = core.firstData.version;
248248
// core.dom.logoLabel.innerText = core.firstData.title;
249249
document.title = core.firstData.title + " - HTML5魔塔";
250-
document.getElementById("startLogo").innerText = core.firstData.title;
250+
// document.getElementById("startLogo").innerText = core.firstData.title;
251251
(core.firstData.shops||[]).forEach(function (t) { core.initStatus.shops[t.id] = t; });
252252
// 初始化自动事件
253253
for (var floorId in core.floors) {

libs/events.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default events;
22
import {functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a} from '../project/functions'
33
import {events_c12a15a8_c380_4b28_8144_256cba95f760} from '../project/events'
4+
import route from '../../pixi/scenes/route';
45
"use strict";
56

67
function events() {
@@ -24,15 +25,15 @@ events.prototype.resetGame = function (hero, hard, floorId, maps, values) {
2425

2526
////// 游戏开始事件 //////
2627
events.prototype.startGame = function (hard, seed, route, callback) {
27-
main.dom.levelChooseButtons.style.display = 'none';
28-
main.dom.startButtonGroup.style.display = 'none';
28+
// main.dom.levelChooseButtons.style.display = 'none';
29+
// main.dom.startButtonGroup.style.display = 'none';
2930
hard = hard || "";
3031

3132
if (main.mode != 'play') return;
3233

3334
// 无动画的开始游戏
3435
if (core.flags.startUsingCanvas || route != null) {
35-
core.dom.startPanel.style.display = 'none';
36+
// core.dom.startPanel.style.display = 'none';
3637
this._startGame_start(hard, seed, route, callback);
3738
}
3839
else {
@@ -333,7 +334,7 @@ events.prototype._trigger = function (x, y) {
333334

334335
if (block.event.trigger) {
335336
var noPass = block.event.noPass, trigger = block.event.trigger;
336-
if (noPass) core.clearAutomaticRouteNode(x, y);
337+
if (noPass) route.clear();
337338

338339
// 转换楼层能否穿透
339340
if (trigger == 'changeFloor' && !noPass && this._trigger_ignoreChangeFloor(block))

libs/loader.js

+27-24
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ loader.prototype._setStartProgressVal = function (val) {
2121

2222
////// 设置加载进度条提示文字 //////
2323
loader.prototype._setStartLoadTipText = function (text) {
24-
core.dom.startTopLoadTips.innerText = text;
24+
// core.dom.startTopLoadTips.innerText = text;
2525
}
2626

2727
loader.prototype._load = function (callback) {
28-
pixi.event.once('loadComplete',(textures)=>{
28+
const cb = (textures)=>{
2929
const data = Object.keys(main.statusBar.icons);
3030
const temp = { };
3131
data.forEach((name) => {
@@ -37,10 +37,13 @@ loader.prototype._load = function (callback) {
3737
core.statusBar.icons = temp;
3838
callback();
3939
// this._loadAnimates(textures);
40-
})
40+
}
41+
this._loadMusic();
42+
if (pixi.loader.complete) cb(pixi.loader.textures);
43+
else pixi.event.once('loadComplete', cb);
4144
// this._loadIcons();
4245
// this._loadAnimates();
43-
this._loadMusic();
46+
4447

4548
// core.loader._loadMaterialImages(function () {
4649
// core.loader._loadExtraImages(function () {
@@ -207,30 +210,30 @@ loader.prototype.loadImagesFromZip = function (url, names, toSave, callback) {
207210
});
208211
}
209212
loader.prototype.loadImage = function (imgName, callback) {
210-
let images=main.loadFile.images;
211-
try {
212-
var name = imgName;
213-
if (name.indexOf(".") < 0)
214-
name = name + ".png";
215-
var image = new Image();
213+
// let images=main.loadFile.images;
214+
// try {
215+
// var name = imgName;
216+
// if (name.indexOf(".") < 0)
217+
// name = name + ".png";
218+
// var image = new Image();
216219

217-
var src=images('./'+name).default;
220+
// var src=images('./'+name).default;
218221

219222

220-
image.onload = function () {
221-
callback(imgName, image);
222-
}
223-
image.onerror = function () {
224-
callback(imgName, null);
225-
}
226-
image.src = src;
223+
// image.onload = function () {
224+
// callback(imgName, image);
225+
// }
226+
// image.onerror = function () {
227+
// callback(imgName, null);
228+
// }
229+
// image.src = src;
227230

228-
if (name.endsWith('.gif'))
229-
callback(imgName, null);
230-
}
231-
catch (e) {
232-
main.log(e);
233-
}
231+
// if (name.endsWith('.gif'))
232+
// callback(imgName, null);
233+
// }
234+
// catch (e) {
235+
// main.log(e);
236+
// }
234237
}
235238

236239
loader.prototype._loadAnimates = function (textures) {

0 commit comments

Comments
 (0)