Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
e29e32b9
Commit
e29e32b9
authored
Aug 04, 2020
by
zjz1994
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人保财险消消乐暂存
parent
76315174
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
4509 additions
and
0 deletions
+4509
-0
rbcxiaoxiaole.json
dist/customs/rbcxiaoxiaole.json
+139
-0
app.js
src/custom/rbcxiaoxiaole/debug/app.js
+66
-0
index.html
src/custom/rbcxiaoxiaole/debug/index.html
+45
-0
load-assets.js
src/custom/rbcxiaoxiaole/debug/load-assets.js
+11
-0
main.js
src/custom/rbcxiaoxiaole/debug/main.js
+1887
-0
main.js.map
src/custom/rbcxiaoxiaole/debug/main.js.map
+1
-0
props.js
src/custom/rbcxiaoxiaole/debug/props.js
+7
-0
meta.json
src/custom/rbcxiaoxiaole/meta.json
+141
-0
GameView.ts
src/custom/rbcxiaoxiaole/src/game/GameView.ts
+1695
-0
GameWrapper.ts
src/custom/rbcxiaoxiaole/src/game/GameWrapper.ts
+51
-0
MapData.ts
src/custom/rbcxiaoxiaole/src/game/MapData.ts
+272
-0
Element.ts
src/custom/rbcxiaoxiaole/src/game/ele/Element.ts
+145
-0
utils.ts
src/custom/rbcxiaoxiaole/src/game/utils.ts
+20
-0
index.ts
src/custom/rbcxiaoxiaole/src/index.ts
+14
-0
props.ts
src/custom/rbcxiaoxiaole/src/props.ts
+15
-0
No files found.
dist/customs/rbcxiaoxiaole.json
0 → 100644
View file @
e29e32b9
{
"name"
:
"消消乐"
,
"desc"
:
"消消乐模块"
,
"props"
:
{
"threeEscore"
:
{
"alias"
:
"三消加分"
,
"type"
:
"number"
,
"default"
:
1
},
"fourEscore"
:
{
"alias"
:
"四消加分"
,
"type"
:
"number"
,
"default"
:
2
},
"moreEscore"
:
{
"alias"
:
"多消加分"
,
"type"
:
"number"
,
"default"
:
3
}
},
"assets"
:
[
{
"name"
:
"底图"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png"
,
"uuid"
:
"map"
,
"ext"
:
".png"
},
{
"name"
:
"狗"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png"
,
"uuid"
:
"gdog"
,
"ext"
:
".png"
},
{
"name"
:
"鸟"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png"
,
"uuid"
:
"pbird"
,
"ext"
:
".png"
},
{
"name"
:
"牛"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png"
,
"uuid"
:
"hniu"
,
"ext"
:
".png"
},
{
"name"
:
"兔子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png"
,
"uuid"
:
"bribbit"
,
"ext"
:
".png"
},
{
"name"
:
"猪"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png"
,
"uuid"
:
"rpig"
,
"ext"
:
".png"
},
{
"name"
:
"选中框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png"
,
"uuid"
:
"selected"
,
"ext"
:
".png"
},
{
"name"
:
"交换箭头"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png"
,
"uuid"
:
"jiantou"
,
"ext"
:
".png"
},
{
"name"
:
"房子动画"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga"
,
"uuid"
:
"homeani"
,
"ext"
:
".svga"
},
{
"name"
:
"夜晚房子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/aa9261273423b4b9343b4526b7e5f71a6a35a345.svga"
,
"uuid"
:
"homenight"
,
"ext"
:
".svga"
}
],
"events"
:
{
"in"
:
{
"game-init"
:
{
"alias"
:
"初始化第一关"
,
"data"
:
{}
},
"game-reset"
:
{
"alias"
:
"关卡通过重玩之类的重置关卡"
,
"data"
:
{}
},
"game-start"
:
{
"alias"
:
"开始"
},
"game-pause"
:
{
"alias"
:
"暂停"
},
"game-resume"
:
{
"alias"
:
"继续"
},
"game-recordcomp"
:
{
"alias"
:
"记录完毕"
}
},
"out"
:
{
"game-score-update"
:
{
"alias"
:
"分数更新"
,
"data"
:
{
"score"
:
"分数"
}
},
"game-time-update"
:
{
"alias"
:
"倒计时更新"
,
"data"
:
{
"time"
:
"剩余时间"
}
},
"game-over"
:
{
"alias"
:
"游戏结束"
,
"data"
:
{
"score"
:
"分数"
,
"reason"
:
"结束原因(1:时间到了,2:过关)"
}
},
"game-record"
:
{
"alias"
:
"游戏记录"
,
"data"
:
{
"score"
:
"操作得分"
,
"seq"
:
"操作步骤号"
,
"sptime"
:
"操纵开始时间"
,
"eptime"
:
"操作结束时间"
}
}
}
},
"id"
:
"rbcxiaoxiaole"
,
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n\t
(global = global || self, global.rbcxiaoxiaole = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\r\n\t
function prepareProps() {
\r\n\t
var metaProps = getProps();
\r\n\t
engine.injectProp(props, metaProps);
\r\n\t
}
\r\n\t
function injectProps(p) {
\r\n\t
engine.injectProp(props, p);
\r\n\t
}
\r\n\t
//# sourceMappingURL=props.js.map
\n\n\t
function getTexture(uuid) {
\r\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\r\n\t
}
\r\n\t
function getTextureByName(name) {
\r\n\t
return getTexture(engine.getAssetByName(name).uuid);
\r\n\t
}
\r\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var Element = (function (_super) {
\r\n\t
tslib.__extends(Element, _super);
\r\n\t
function Element() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this.width = MapData.itemsize;
\r\n\t
_this.height = MapData.itemsize;
\r\n\t
_this.anchorX = MapData.itemsize / 2;
\r\n\t
_this.eimage = new engine.Image();
\r\n\t
_this.addChild(_this.eimage);
\r\n\t
_this.touch = true;
\r\n\t
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.selectele, _this);
\r\n\t
_this.addEventListener(engine.MouseEvent.MOUSE_MOVE, _this.changemove, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
Object.defineProperty(Element.prototype,
\"
touch
\"
, {
\r\n\t
set: function (touch) {
\r\n\t
this.mouseEnabled = touch;
\r\n\t
this.mouseChildren = touch;
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
Element.prototype.init = function (type) {
\r\n\t
this.anchorY = MapData.itemsize;
\r\n\t
this.scaleX = 1;
\r\n\t
this.scaleY = 1;
\r\n\t
this.alpha = 1;
\r\n\t
this.type = type;
\r\n\t
var ename = MapData.getEtypeImgName(type);
\r\n\t
this.eimage.texture = MapData.getEtypeImgTex(type);
\r\n\t
var imgwid = this.eimage.texture.width;
\r\n\t
var imghei = this.eimage.texture.height;
\r\n\t
this.eimage.x = (this.width - imgwid) / 2;
\r\n\t
this.eimage.y = (this.height - imghei) / 2;
\r\n\t
};
\r\n\t
Element.prototype.setrc = function (r, c) {
\r\n\t
this.inrow = r;
\r\n\t
this.incol = c;
\r\n\t
};
\r\n\t
Element.prototype.selectele = function (e) {
\r\n\t
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
\r\n\t
r: this.inrow,
\r\n\t
c: this.incol,
\r\n\t
type:
\"
mouse_down
\"\r\n\t
});
\r\n\t
};
\r\n\t
Element.prototype.changemove = function (e) {
\r\n\t
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
\r\n\t
r: this.inrow,
\r\n\t
c: this.incol,
\r\n\t
type:
\"
mouse_move
\"\r\n\t
});
\r\n\t
};
\r\n\t
Object.defineProperty(Element.prototype,
\"
factor
\"
, {
\r\n\t
get: function () {
\r\n\t
return 0;
\r\n\t
},
\r\n\t
set: function (value) {
\r\n\t
this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;
\r\n\t
this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;
\r\n\t
var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;
\r\n\t
this.scaleX = mscale;
\r\n\t
this.scaleY = mscale;
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
Element.prototype.flyToHome = function (tx, ty, time) {
\r\n\t
var _this = this;
\r\n\t
this.p1x = this.x;
\r\n\t
this.p1y = this.y + 20;
\r\n\t
this.c1x = (this.p1x - tx) / 4 + tx;
\r\n\t
this.c1y = ty;
\r\n\t
this.p2x = tx;
\r\n\t
this.p2y = ty;
\r\n\t
engine.Tween.removeTweens(this);
\r\n\t
engine.Tween.get(this).to({
\r\n\t
scaleX: 1.1,
\r\n\t
scaleY: 1.1
\r\n\t
}, 200)
\r\n\t
.to({
\r\n\t
scaleX: 1.1,
\r\n\t
scaleY: 0.88
\r\n\t
}, 100)
\r\n\t
.to({
\r\n\t
scaleX: 0.98,
\r\n\t
scaleY: 0.98,
\r\n\t
y: this.y + 20
\r\n\t
}, 100)
\r\n\t
.call(function () {
\r\n\t
_this.factor = 0;
\r\n\t
engine.Tween.get(_this).to({
\r\n\t
factor: 1
\r\n\t
}, 450)
\r\n\t
.call(function () {
\r\n\t
var nodeparent = _this.parent;
\r\n\t
nodeparent && nodeparent.removeChild(_this);
\r\n\t
MapData.recoverEle(_this, _this.type);
\r\n\t
});
\r\n\t
});
\r\n\t
};
\r\n\t
Element.prototype.changePos = function (tpos) {
\r\n\t
var _this = this;
\r\n\t
var nx = this.x;
\r\n\t
var ny = this.y;
\r\n\t
var tx = tpos[0];
\r\n\t
var ty = tpos[1];
\r\n\t
var dis = MapData.getDistance([nx, ny], tpos);
\r\n\t
var time = Math.ceil(dis / MapData.anispeed * 1000);
\r\n\t
engine.Tween.removeTweens(this);
\r\n\t
var pro = new Promise(function (res) {
\r\n\t
engine.Tween.get(_this, { loop: false }).to({
\r\n\t
x: tx,
\r\n\t
y: ty
\r\n\t
}, time)
\r\n\t
.call(function () {
\r\n\t
res();
\r\n\t
});
\r\n\t
});
\r\n\t
return pro;
\r\n\t
};
\r\n\t
return Element;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=Element.js.map
\n\n\t
var ElementType;
\r\n\t
(function (ElementType) {
\r\n\t
ElementType[ElementType[
\"
gdog
\"
] = 1] =
\"
gdog
\"
;
\r\n\t
ElementType[ElementType[
\"
pbird
\"
] = 2] =
\"
pbird
\"
;
\r\n\t
ElementType[ElementType[
\"
hniu
\"
] = 3] =
\"
hniu
\"
;
\r\n\t
ElementType[ElementType[
\"
bribbit
\"
] = 4] =
\"
bribbit
\"
;
\r\n\t
ElementType[ElementType[
\"
rpig
\"
] = 5] =
\"
rpig
\"
;
\r\n\t
})(ElementType || (ElementType = {}));
\r\n\t
var GameEvent;
\r\n\t
(function (GameEvent) {
\r\n\t
GameEvent[
\"
SelectEle
\"
] =
\"
SelectEle
\"
;
\r\n\t
})(GameEvent || (GameEvent = {}));
\r\n\t
var MapData = (function () {
\r\n\t
function MapData() {
\r\n\t
}
\r\n\t
MapData.getRy = function (r) {
\r\n\t
return this.paddingh + r * (this.itemsize + this.paddinghi);
\r\n\t
};
\r\n\t
MapData.getCx = function (c) {
\r\n\t
return this.paddingw + c * (this.itemsize + this.paddingwi);
\r\n\t
};
\r\n\t
MapData.getRCPos = function (r, c) {
\r\n\t
var x = this.getCx(c);
\r\n\t
var y = this.getRy(r);
\r\n\t
return [x, y];
\r\n\t
};
\r\n\t
MapData.adaptElePos = function (pos, wid, hei) {
\r\n\t
var x = pos[0] + (this.itemsize - wid) / 2;
\r\n\t
var y = pos[1] + (this.itemsize - hei) / 2;
\r\n\t
return [x, y];
\r\n\t
};
\r\n\t
MapData.getEtypeImgName = function (type) {
\r\n\t
var ename;
\r\n\t
switch (type) {
\r\n\t
case ElementType.gdog:
\r\n\t
ename =
\"
狗
\"
;
\r\n\t
break;
\r\n\t
case ElementType.pbird:
\r\n\t
ename =
\"
鸟
\"
;
\r\n\t
break;
\r\n\t
case ElementType.hniu:
\r\n\t
ename =
\"
牛
\"
;
\r\n\t
break;
\r\n\t
case ElementType.bribbit:
\r\n\t
ename =
\"
兔子
\"
;
\r\n\t
break;
\r\n\t
case ElementType.rpig:
\r\n\t
ename =
\"
猪
\"
;
\r\n\t
break;
\r\n\t
default:
\r\n\t
console.error(
\"
未定义元素类型
\"
);
\r\n\t
break;
\r\n\t
}
\r\n\t
return ename;
\r\n\t
};
\r\n\t
MapData.getEtypeImgTex = function (type) {
\r\n\t
var etex;
\r\n\t
switch (type) {
\r\n\t
case ElementType.gdog:
\r\n\t
if (!this.gdotTex) {
\r\n\t
this.gdotTex = getTextureByName(
\"
狗
\"
);
\r\n\t
console.log(
\"
新素材加载---狗
\"
);
\r\n\t
}
\r\n\t
etex = this.gdotTex;
\r\n\t
break;
\r\n\t
case ElementType.pbird:
\r\n\t
if (!this.pbirdTex) {
\r\n\t
this.pbirdTex = getTextureByName(
\"
鸟
\"
);
\r\n\t
console.log(
\"
新素材加载---鸟
\"
);
\r\n\t
}
\r\n\t
etex = this.pbirdTex;
\r\n\t
break;
\r\n\t
case ElementType.hniu:
\r\n\t
if (!this.hniuTex) {
\r\n\t
this.hniuTex = getTextureByName(
\"
牛
\"
);
\r\n\t
console.log(
\"
新素材加载---牛
\"
);
\r\n\t
}
\r\n\t
etex = this.hniuTex;
\r\n\t
break;
\r\n\t
case ElementType.bribbit:
\r\n\t
if (!this.bribbitTex) {
\r\n\t
this.bribbitTex = getTextureByName(
\"
兔子
\"
);
\r\n\t
console.log(
\"
新素材加载---兔子
\"
);
\r\n\t
}
\r\n\t
etex = this.bribbitTex;
\r\n\t
break;
\r\n\t
case ElementType.rpig:
\r\n\t
if (!this.rpigTex) {
\r\n\t
this.rpigTex = getTextureByName(
\"
猪
\"
);
\r\n\t
console.log(
\"
新素材加载---猪
\"
);
\r\n\t
}
\r\n\t
etex = this.rpigTex;
\r\n\t
break;
\r\n\t
default:
\r\n\t
console.error(
\"
未定义元素类型
\"
);
\r\n\t
break;
\r\n\t
}
\r\n\t
return etex;
\r\n\t
};
\r\n\t
MapData.getRandEtype = function () {
\r\n\t
var eletypeArr = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
\r\n\t
var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];
\r\n\t
return etype;
\r\n\t
};
\r\n\t
MapData.initPoolEle = function () {
\r\n\t
this.gdotTex = getTextureByName(
\"
狗
\"
);
\r\n\t
this.pbirdTex = getTextureByName(
\"
鸟
\"
);
\r\n\t
this.hniuTex = getTextureByName(
\"
牛
\"
);
\r\n\t
this.bribbitTex = getTextureByName(
\"
兔子
\"
);
\r\n\t
this.rpigTex = getTextureByName(
\"
猪
\"
);
\r\n\t
var eletypes = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
\r\n\t
this.elePool[
\"
ele
\"
] = new Array();
\r\n\t
for (var i = 0; i < eletypes.length; i++) {
\r\n\t
for (var a = 0; a < 5; a++) {
\r\n\t
var iele = new Element();
\r\n\t
this.elePool[
\"
ele
\"
].push(iele);
\r\n\t
}
\r\n\t
}
\r\n\t
this.elePool[
\"
score
\"
] = new Array();
\r\n\t
for (var t = 0; t < 8; t++) {
\r\n\t
var itxt = new engine.Label();
\r\n\t
itxt.size = 66;
\r\n\t
itxt.width = 200;
\r\n\t
itxt.height = 70;
\r\n\t
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
\r\n\t
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
\r\n\t
itxt.anchorY = 35;
\r\n\t
itxt.anchorX = 100;
\r\n\t
itxt.bold = true;
\r\n\t
this.elePool[
\"
score
\"
].push(itxt);
\r\n\t
}
\r\n\t
};
\r\n\t
MapData.getOneEle = function (type) {
\r\n\t
var ele;
\r\n\t
if (this.elePool[
\"
ele
\"
]) {
\r\n\t
if (this.elePool[
\"
ele
\"
].length > 0) {
\r\n\t
ele = this.elePool[
\"
ele
\"
].shift();
\r\n\t
}
\r\n\t
}
\r\n\t
else {
\r\n\t
this.elePool[
\"
ele
\"
] = new Array();
\r\n\t
}
\r\n\t
if (!ele) {
\r\n\t
console.error(
\"
创建了新的了ele
\"
);
\r\n\t
ele = new Element();
\r\n\t
}
\r\n\t
ele.name =
\"
ele_
\"
+ this.eleidx;
\r\n\t
this.eleidx += 1;
\r\n\t
ele.init(type);
\r\n\t
return ele;
\r\n\t
};
\r\n\t
MapData.getOneTxt = function () {
\r\n\t
var itxt;
\r\n\t
if (this.elePool[
\"
score
\"
]) {
\r\n\t
if (this.elePool[
\"
score
\"
].length > 0) {
\r\n\t
itxt = this.elePool[
\"
score
\"
].shift();
\r\n\t
}
\r\n\t
}
\r\n\t
else {
\r\n\t
this.elePool[
\"
score
\"
] = new Array();
\r\n\t
}
\r\n\t
if (!itxt) {
\r\n\t
itxt = new engine.Label();
\r\n\t
itxt.size = 66;
\r\n\t
itxt.width = 200;
\r\n\t
itxt.height = 70;
\r\n\t
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
\r\n\t
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
\r\n\t
itxt.anchorY = 35;
\r\n\t
itxt.anchorX = 100;
\r\n\t
itxt.bold = true;
\r\n\t
}
\r\n\t
itxt.mouseEnabled = false;
\r\n\t
return itxt;
\r\n\t
};
\r\n\t
MapData.recoverEle = function (ele, type) {
\r\n\t
if (ele.eimage) {
\r\n\t
ele.eimage.texture = null;
\r\n\t
}
\r\n\t
this.elePool[
\"
ele
\"
].push(ele);
\r\n\t
};
\r\n\t
MapData.recoverTxt = function (txt) {
\r\n\t
this.elePool[
\"
score
\"
].push(txt);
\r\n\t
};
\r\n\t
MapData.getDistance = function (p1, p2) {
\r\n\t
var p1x = p1[0];
\r\n\t
var p1y = p1[1];
\r\n\t
var p2x = p2[0];
\r\n\t
var p2y = p2[1];
\r\n\t
var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));
\r\n\t
return dis;
\r\n\t
};
\r\n\t
MapData.itemsize = 116;
\r\n\t
MapData.paddingw = 7;
\r\n\t
MapData.paddingh = 7;
\r\n\t
MapData.paddingwi = 4;
\r\n\t
MapData.paddinghi = 2;
\r\n\t
MapData.row = 5;
\r\n\t
MapData.col = 5;
\r\n\t
MapData.posData = {};
\r\n\t
MapData.eleidx = 1;
\r\n\t
MapData.elePool = {};
\r\n\t
MapData.anispeed = 1000;
\r\n\t
MapData.levelData = [
\r\n\t
[
\r\n\t
[1, 2, 5, 3, 4],
\r\n\t
[3, 1, 2, 4, 5],
\r\n\t
[2, 5, 3, 4, 1],
\r\n\t
[5, 4, 1, 2, 3],
\r\n\t
[4, 1, 3, 5, 2],
\r\n\t
],
\r\n\t
[
\r\n\t
[5, 2, 1, 2, 1],
\r\n\t
[3, 1, 4, 5, 4],
\r\n\t
[2, 5, 3, 5, 1],
\r\n\t
[5, 4, 1, 2, 3],
\r\n\t
[4, 1, 3, 1, 2],
\r\n\t
],
\r\n\t
[
\r\n\t
[2, 4, 1, 5, 2],
\r\n\t
[2, 3, 4, 1, 3],
\r\n\t
[4, 1, 3, 2, 3],
\r\n\t
[3, 2, 1, 1, 4],
\r\n\t
[1, 1, 3, 5, 4],
\r\n\t
],
\r\n\t
[
\r\n\t
[3, 2, 1, 4, 5],
\r\n\t
[2, 4, 1, 2, 3],
\r\n\t
[2, 3, 2, 3, 3],
\r\n\t
[4, 4, 5, 5, 4],
\r\n\t
[3, 3, 1, 2, 4],
\r\n\t
],
\r\n\t
[
\r\n\t
[4, 5, 1, 2, 4],
\r\n\t
[3, 2, 3, 4, 2],
\r\n\t
[1, 5, 2, 3, 5],
\r\n\t
[4, 5, 5, 1, 3],
\r\n\t
[1, 2, 3, 2, 4],
\r\n\t
]
\r\n\t
];
\r\n\t
return MapData;
\r\n\t
}());
\r\n\t
//# sourceMappingURL=MapData.js.map
\n\n\t
var GameView = (function (_super) {
\r\n\t
tslib.__extends(GameView, _super);
\r\n\t
function GameView() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this.lattices = {};
\r\n\t
_this.eliminateArr = [];
\r\n\t
_this.selectArr = [];
\r\n\t
_this.conty = 140;
\r\n\t
_this.homex = 562;
\r\n\t
_this.homey = -20;
\r\n\t
_this.ination = false;
\r\n\t
_this.canation = true;
\r\n\t
_this._gametime = 60;
\r\n\t
_this._gamestat = 2;
\r\n\t
_this.ingameover = false;
\r\n\t
_this.ingame = true;
\r\n\t
_this.level = 0;
\r\n\t
_this.inrecord = false;
\r\n\t
_this.requestGameOver = false;
\r\n\t
_this.elitype = 1;
\r\n\t
_this._seq = 1;
\r\n\t
_this.sptime = Date.now();
\r\n\t
_this.useBoom = false;
\r\n\t
_this._score = 0;
\r\n\t
_this.inEliminate = false;
\r\n\t
_this.newSelect = false;
\r\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
Object.defineProperty(GameView.prototype,
\"
gamestat
\"
, {
\r\n\t
get: function () {
\r\n\t
return this._gamestat;
\r\n\t
},
\r\n\t
set: function (stat) {
\r\n\t
this._gamestat = stat;
\r\n\t
if (stat == 2) {
\r\n\t
this.changeEnable(false);
\r\n\t
}
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
Object.defineProperty(GameView.prototype,
\"
seq
\"
, {
\r\n\t
get: function () {
\r\n\t
return this._seq;
\r\n\t
},
\r\n\t
set: function (num) {
\r\n\t
this._seq = num;
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
GameView.prototype.setup = function () {
\r\n\t
MapData.initPoolEle();
\r\n\t
this.selectimg = new engine.Image(getTextureByName(
\"
选中框
\"
));
\r\n\t
this.selectimg.mouseEnabled = false;
\r\n\t
this.selectw = this.selectimg.texture.width;
\r\n\t
this.selecth = this.selectimg.texture.height;
\r\n\t
this.selectimg.anchorX = this.selectw / 2;
\r\n\t
this.selectimg.anchorY = this.selecth / 2;
\r\n\t
this.jiantou1 = new engine.Image(getTextureByName(
\"
交换箭头
\"
));
\r\n\t
this.jiantou2 = new engine.Image(getTextureByName(
\"
交换箭头
\"
));
\r\n\t
this.jiantou1.mouseEnabled = false;
\r\n\t
this.jiantou2.mouseEnabled = false;
\r\n\t
var jiantwid = 31;
\r\n\t
var jianthei = 24;
\r\n\t
this.jiantou1.anchorX = jiantwid / 2;
\r\n\t
this.jiantou1.anchorY = jianthei / 2;
\r\n\t
this.jiantou2.anchorX = jiantwid / 2;
\r\n\t
this.jiantou2.anchorY = jianthei / 2;
\r\n\t
this.jiantoucont = new engine.Container();
\r\n\t
this.jiantoucont.width = MapData.itemsize;
\r\n\t
this.jiantoucont.height = MapData.itemsize;
\r\n\t
this.jtsx1 = MapData.itemsize / 2 - jiantwid / 2;
\r\n\t
this.jtsx2 = MapData.itemsize / 2 - jiantwid / 2;
\r\n\t
this.jtsy1 = MapData.itemsize / 2 - jianthei;
\r\n\t
this.jtsy2 = MapData.itemsize / 2;
\r\n\t
this.jtex1 = this.jtsx1 - 10;
\r\n\t
this.jtex2 = this.jtsx2 + 10;
\r\n\t
this.jtey1 = this.jtsy1;
\r\n\t
this.jtey2 = this.jtsy2;
\r\n\t
this.jiantou1.x = this.jtsx1;
\r\n\t
this.jiantou2.rotation = 180;
\r\n\t
this.jiantou2.x = this.jtsx2;
\r\n\t
this.jiantou1.y = this.jtsy1;
\r\n\t
this.jiantou2.y = this.jtsy2;
\r\n\t
this.jiantoucont.addChild(this.jiantou1);
\r\n\t
this.jiantoucont.addChild(this.jiantou2);
\r\n\t
var row = MapData.row;
\r\n\t
var col = MapData.col;
\r\n\t
this.container = new engine.Container();
\r\n\t
this.addChild(this.container);
\r\n\t
this.container.y = this.conty;
\r\n\t
var maskimg = new engine.Graphics();
\r\n\t
this.container.addChild(maskimg);
\r\n\t
this.container.mask = maskimg;
\r\n\t
maskimg.moveTo(0, 0);
\r\n\t
maskimg.beginFill(0);
\r\n\t
maskimg.lineTo(681, 0);
\r\n\t
maskimg.lineTo(681, 679);
\r\n\t
maskimg.lineTo(0, 679);
\r\n\t
maskimg.lineTo(0, 0);
\r\n\t
maskimg.endFill();
\r\n\t
this.anicontainer = new engine.Container();
\r\n\t
this.addChild(this.anicontainer);
\r\n\t
this.anicontainer.mouseEnabled = false;
\r\n\t
this.anicontainer.mouseChildren = false;
\r\n\t
this.txtcontainer = new engine.Container();
\r\n\t
this.addChild(this.txtcontainer);
\r\n\t
var map = new engine.Image(getTextureByName(
\"
底图
\"
));
\r\n\t
this.container.addChild(map);
\r\n\t
for (var r = 0; r < row; r++) {
\r\n\t
for (var c = 0; c < col; c++) {
\r\n\t
var rcpos = MapData.getRCPos(r, c);
\r\n\t
MapData.posData[r +
\"
_
\"
+ c] = rcpos;
\r\n\t
}
\r\n\t
}
\r\n\t
this.tanix = this.homex + 30;
\r\n\t
this.taniy = this.homey;
\r\n\t
engine.globalEvent.addEventListener(GameEvent.SelectEle, this.selectele, this);
\r\n\t
this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);
\r\n\t
this.lastframeTime = Date.now();
\r\n\t
this.lastatime = Date.now();
\r\n\t
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
\r\n\t
var zhadanbtn = new engine.Label();
\r\n\t
zhadanbtn.text =
\"
炸弹
\"
;
\r\n\t
zhadanbtn.size = 56;
\r\n\t
zhadanbtn.width = 200;
\r\n\t
zhadanbtn.height = 100;
\r\n\t
this.addChild(zhadanbtn);
\r\n\t
zhadanbtn.y = 900;
\r\n\t
zhadanbtn.fillColor =
\"
red
\"
;
\r\n\t
zhadanbtn.addEventListener(engine.MouseEvent.CLICK, this.zhadanFunc, this);
\r\n\t
var timebtn = new engine.Label();
\r\n\t
timebtn.text =
\"
加时
\"
;
\r\n\t
timebtn.size = 56;
\r\n\t
timebtn.width = 200;
\r\n\t
timebtn.height = 100;
\r\n\t
this.addChild(timebtn);
\r\n\t
timebtn.y = 900;
\r\n\t
timebtn.x = 500;
\r\n\t
timebtn.fillColor =
\"
red
\"
;
\r\n\t
timebtn.addEventListener(engine.MouseEvent.CLICK, this.addTimeFunc, this);
\r\n\t
};
\r\n\t
GameView.prototype.zhadanFunc = function () {
\r\n\t
this.useBoom = true;
\r\n\t
};
\r\n\t
GameView.prototype.addTimeFunc = function () {
\r\n\t
console.log(
\"
加时间
\"
);
\r\n\t
};
\r\n\t
GameView.prototype.changeAni = function () {
\r\n\t
this.changeHomeShow(
\"
night
\"
);
\r\n\t
};
\r\n\t
GameView.prototype.playComp = function () {
\r\n\t
};
\r\n\t
GameView.prototype.init = function (time, level, mode) {
\r\n\t
this.score = 0;
\r\n\t
this.gametime = time;
\r\n\t
this.seq = 1;
\r\n\t
this.level = level;
\r\n\t
this.ingameover = false;
\r\n\t
this.changeHomeShow(mode);
\r\n\t
this.initContainer();
\r\n\t
this.sptime = Date.now();
\r\n\t
};
\r\n\t
Object.defineProperty(GameView.prototype,
\"
score
\"
, {
\r\n\t
get: function () {
\r\n\t
return this._score;
\r\n\t
},
\r\n\t
set: function (num) {
\r\n\t
this._score = num;
\r\n\t
engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
Object.defineProperty(GameView.prototype,
\"
gametime
\"
, {
\r\n\t
get: function () {
\r\n\t
return this._gametime;
\r\n\t
},
\r\n\t
set: function (time) {
\r\n\t
var lshowtime = Math.round(this._gametime);
\r\n\t
var nshowtime = Math.round(time);
\r\n\t
if (lshowtime != nshowtime) {
\r\n\t
if (this.gamestat == 1 && nshowtime < 1) {
\r\n\t
this.gameOver();
\r\n\t
}
\r\n\t
if (nshowtime < 0) {
\r\n\t
nshowtime = 0;
\r\n\t
}
\r\n\t
engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });
\r\n\t
}
\r\n\t
if (time < 0) {
\r\n\t
time = 0;
\r\n\t
}
\r\n\t
this._gametime = time;
\r\n\t
},
\r\n\t
enumerable: true,
\r\n\t
configurable: true
\r\n\t
});
\r\n\t
GameView.prototype.gameOver = function () {
\r\n\t
this.gamestat = 2;
\r\n\t
this.unShowEleAttion();
\r\n\t
this.anicontainer.removeChild(this.selectimg);
\r\n\t
this.ingameover = true;
\r\n\t
console.log(
\"
倒计时结束1=============
\"
, this.ingameover, this.inEliminate, this.inrecord);
\r\n\t
this.checkGameOver(
\"
time-over
\"
);
\r\n\t
};
\r\n\t
GameView.prototype.checkGameOver = function (type) {
\r\n\t
if (this.ingameover) {
\r\n\t
console.log(
\"
倒计时已结束2==========
\"
, this.inEliminate, this.inrecord, type);
\r\n\t
}
\r\n\t
if (this.ingameover && !this.inEliminate && !this.inrecord && !this.requestGameOver) {
\r\n\t
this.requestGameOver = true;
\r\n\t
this.unShowEleAttion();
\r\n\t
this.anicontainer.removeChild(this.jiantoucont);
\r\n\t
engine.globalEvent.dispatchEvent(
\"
game-over
\"
, {
\r\n\t
score: this.score
\r\n\t
});
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.reset = function (time, level, mode) {
\r\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\r\n\t
var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata;
\r\n\t
return tslib.__generator(this, function (_a) {
\r\n\t
switch (_a.label) {
\r\n\t
case 0:
\r\n\t
this.anicontainer.removeChild(this.selectimg);
\r\n\t
this.selectArr = new Array();
\r\n\t
this.gametime = time;
\r\n\t
this.level = level;
\r\n\t
this.ingameover = false;
\r\n\t
this.requestGameOver = false;
\r\n\t
this.seq = 1;
\r\n\t
this.changeHomeShow(mode);
\r\n\t
this.changeEnable(false);
\r\n\t
for (key in this.lattices) {
\r\n\t
rcname = this.lattices[key];
\r\n\t
rcele = this.container.getChildByName(rcname);
\r\n\t
if (rcele) {
\r\n\t
rcelex = rcele.x;
\r\n\t
rceley = rcele.y;
\r\n\t
rcetype = rcele.type;
\r\n\t
this.lattices[key] =
\"
empty
\"
;
\r\n\t
this.goDisplayAni1(rcele, rcetype, rcelex, rceley);
\r\n\t
}
\r\n\t
}
\r\n\t
fallpro = new Promise(function (res) {
\r\n\t
setTimeout(function () {
\r\n\t
res();
\r\n\t
}, 400);
\r\n\t
});
\r\n\t
return [4, fallpro];
\r\n\t
case 1:
\r\n\t
_a.sent();
\r\n\t
testdata = MapData.levelData[this.level];
\r\n\t
this.levelData = testdata;
\r\n\t
this.fall(
\"
newlevel
\"
);
\r\n\t
return [2];
\r\n\t
}
\r\n\t
});
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.start = function () {
\r\n\t
this.gamestat = 1;
\r\n\t
this.requestGameOver = false;
\r\n\t
this.selectArr = new Array();
\r\n\t
this.changeEnable(true);
\r\n\t
};
\r\n\t
GameView.prototype.pause = function () {
\r\n\t
this.ingame = false;
\r\n\t
};
\r\n\t
GameView.prototype.resume = function () {
\r\n\t
this.lastframeTime = Date.now();
\r\n\t
this.ingame = true;
\r\n\t
};
\r\n\t
GameView.prototype.onUpdate = function () {
\r\n\t
var ntime = Date.now();
\r\n\t
if (this.gamestat == 1 && this.ingame) {
\r\n\t
var passtime = ntime - this.lastframeTime;
\r\n\t
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
\r\n\t
this.attionEliShow();
\r\n\t
}
\r\n\t
if (this.gametime && this.gametime > 0) {
\r\n\t
var ngtime = this.gametime - (passtime / 1000);
\r\n\t
this.gametime = ngtime;
\r\n\t
}
\r\n\t
}
\r\n\t
this.lastframeTime = ntime;
\r\n\t
};
\r\n\t
GameView.prototype.initContainer = function () {
\r\n\t
if (this.lattices) {
\r\n\t
for (var key in this.lattices) {
\r\n\t
var rcname = this.lattices[key];
\r\n\t
var rcele = this.container.getChildByName(rcname);
\r\n\t
if (rcele) {
\r\n\t
var rcetype = rcele.type;
\r\n\t
this.container.removeChild(rcele);
\r\n\t
this.lattices[key] =
\"
empty
\"
;
\r\n\t
MapData.recoverEle(rcele, rcetype);
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
else {
\r\n\t
this.lattices = {};
\r\n\t
}
\r\n\t
var testdata = MapData.levelData[this.level];
\r\n\t
this.levelData = testdata;
\r\n\t
for (var r = 0; r < testdata.length; r++) {
\r\n\t
var rdata = testdata[r];
\r\n\t
for (var c = 0; c < rdata.length; c++) {
\r\n\t
var rctype = rdata[c];
\r\n\t
var rcele = MapData.getOneEle(rctype);
\r\n\t
var rcpos = MapData.getRCPos(r, c);
\r\n\t
this.container.addChild(rcele);
\r\n\t
rcele.x = rcpos[0];
\r\n\t
rcele.y = rcpos[1];
\r\n\t
var rcidx = r +
\"
_
\"
+ c;
\r\n\t
this.lattices[rcidx] = rcele.name;
\r\n\t
this.setLatticeEleRc(rcidx);
\r\n\t
}
\r\n\t
}
\r\n\t
this.checkInit();
\r\n\t
};
\r\n\t
GameView.prototype.checkInit = function () {
\r\n\t
this.checkEliminate();
\r\n\t
if (this.eliminateArr.length > 0) {
\r\n\t
return this.eliminate();
\r\n\t
}
\r\n\t
else {
\r\n\t
this.selectArr = new Array();
\r\n\t
var isdiedata = this.attionEliminate();
\r\n\t
if (isdiedata && isdiedata.length == 3) {
\r\n\t
this.changeEnable(true);
\r\n\t
}
\r\n\t
else {
\r\n\t
this.solveDieMap();
\r\n\t
}
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.setLatticeEleRc = function (rcidx) {
\r\n\t
var rename = this.lattices[rcidx];
\r\n\t
var rcnode = this.container.getChildByName(rename);
\r\n\t
if (rcnode) {
\r\n\t
var er = Number(rcidx.split(
\"
_
\"
)[0]);
\r\n\t
var ec = Number(rcidx.split(
\"
_
\"
)[1]);
\r\n\t
rcnode.setrc(er, ec);
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.unShowEleAttion = function () {
\r\n\t
if (this.ination) {
\r\n\t
this.ination = false;
\r\n\t
this.lastatime = Date.now();
\r\n\t
var arrcidx1 = this.attiondata[0];
\r\n\t
var arrcidx2 = this.attiondata[1];
\r\n\t
var atname1 = this.lattices[arrcidx1];
\r\n\t
var atname2 = this.lattices[arrcidx2];
\r\n\t
var atnode1 = this.container.getChildByName(atname1);
\r\n\t
var atnode2 = this.container.getChildByName(atname2);
\r\n\t
var aboutnames = this.attiondata[2];
\r\n\t
if (!atnode1 || !atnode2) {
\r\n\t
this.attiondata = new Array();
\r\n\t
return;
\r\n\t
}
\r\n\t
var atpos1 = MapData.getRCPos(arrcidx1.split(
\"
_
\"
)[0], arrcidx1.split(
\"
_
\"
)[1]);
\r\n\t
var atpos2 = MapData.getRCPos(arrcidx2.split(
\"
_
\"
)[0], arrcidx2.split(
\"
_
\"
)[1]);
\r\n\t
engine.Tween.removeTweens(atnode1);
\r\n\t
engine.Tween.removeTweens(atnode2);
\r\n\t
atnode1.x = atpos1[0];
\r\n\t
atnode1.y = atpos1[1];
\r\n\t
atnode2.x = atpos2[0];
\r\n\t
atnode2.y = atpos2[1];
\r\n\t
for (var i = 0; i < aboutnames.length; i++) {
\r\n\t
var ircidx = aboutnames[i];
\r\n\t
var iname1 = this.lattices[ircidx];
\r\n\t
var inode1 = this.container.getChildByName(iname1);
\r\n\t
if (inode1) {
\r\n\t
engine.Tween.removeTweens(inode1);
\r\n\t
var ipos1 = MapData.getRCPos(ircidx.split(
\"
_
\"
)[0], ircidx.split(
\"
_
\"
)[1]);
\r\n\t
inode1.x = ipos1[0];
\r\n\t
inode1.y = ipos1[1];
\r\n\t
}
\r\n\t
}
\r\n\t
this.anicontainer.removeChild(this.jiantoucont);
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.selectele = function (e) {
\r\n\t
var data = e.data;
\r\n\t
var sr = data.r;
\r\n\t
var sc = data.c;
\r\n\t
var type = data.type;
\r\n\t
var sname = sr +
\"
_
\"
+ sc;
\r\n\t
if (this.useBoom) {
\r\n\t
if (type ==
\"
mouse_down
\"
) {
\r\n\t
this.unShowEleAttion();
\r\n\t
this.boomeEle(sr, sc);
\r\n\t
}
\r\n\t
return;
\r\n\t
}
\r\n\t
var lnewSelect = this.newSelect;
\r\n\t
var newCanSel = false;
\r\n\t
if (this.selectArr.length == 0) {
\r\n\t
newCanSel = true;
\r\n\t
}
\r\n\t
else if (this.selectArr.length == 1) {
\r\n\t
var nname = this.selectArr[0];
\r\n\t
if (sname == nname) {
\r\n\t
newCanSel = false;
\r\n\t
}
\r\n\t
else {
\r\n\t
newCanSel = true;
\r\n\t
}
\r\n\t
}
\r\n\t
if (type ==
\"
mouse_down
\"
) {
\r\n\t
this.newSelect = true;
\r\n\t
}
\r\n\t
else if (type ==
\"
mouse_move
\"
) {
\r\n\t
if (newCanSel) {
\r\n\t
this.newSelect = false;
\r\n\t
}
\r\n\t
}
\r\n\t
if ((lnewSelect || this.newSelect) && newCanSel) ;
\r\n\t
else {
\r\n\t
return;
\r\n\t
}
\r\n\t
this.unShowEleAttion();
\r\n\t
if (this.selectArr.length == 0) {
\r\n\t
this.sptime = Date.now();
\r\n\t
this.seqscore = 0;
\r\n\t
this.selectArr.push(sname);
\r\n\t
}
\r\n\t
else if (this.selectArr.length == 1) {
\r\n\t
var aselect = this.selectArr[0];
\r\n\t
var asr = aselect.split(
\"
_
\"
)[0];
\r\n\t
var asc = aselect.split(
\"
_
\"
)[1];
\r\n\t
if ((sr == asr && Math.abs(sc - asc) == 1) || (sc == asc && Math.abs(sr - asr) == 1)) {
\r\n\t
this.selectArr.push(sname);
\r\n\t
}
\r\n\t
else {
\r\n\t
if (sr == asr && sc == asc) {
\r\n\t
this.selectArr = new Array();
\r\n\t
this.anicontainer.removeChild(this.selectimg);
\r\n\t
}
\r\n\t
else {
\r\n\t
this.selectArr[0] = sname;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (this.selectArr.length == 1) {
\r\n\t
this.setSelectShow();
\r\n\t
}
\r\n\t
else if (this.selectArr.length == 2) {
\r\n\t
this.changeElePos();
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.setSelectShow = function () {
\r\n\t
var rcname = this.selectArr[0];
\r\n\t
var r = rcname.split(
\"
_
\"
)[0];
\r\n\t
var c = rcname.split(
\"
_
\"
)[1];
\r\n\t
var rcpos = MapData.getRCPos(r, c);
\r\n\t
engine.Tween.removeTweens(this.selectimg);
\r\n\t
this.anicontainer.addChild(this.selectimg);
\r\n\t
this.selectimg.x = rcpos[0] - 3;
\r\n\t
this.selectimg.y = rcpos[1] + this.conty - 3;
\r\n\t
this.startTweenSelectImg();
\r\n\t
};
\r\n\t
GameView.prototype.startTweenSelectImg = function () {
\r\n\t
this.selectimg.scaleX = 1;
\r\n\t
this.selectimg.scaleY = 1;
\r\n\t
engine.Tween.get(this.selectimg, { loop: true })
\r\n\t
.to({
\r\n\t
scaleX: 0.9,
\r\n\t
scaleY: 0.9
\r\n\t
}, 500)
\r\n\t
.to({
\r\n\t
scaleX: 1,
\r\n\t
scaleY: 1
\r\n\t
}, 500);
\r\n\t
};
\r\n\t
GameView.prototype.changeElePos = function () {
\r\n\t
var _this = this;
\r\n\t
this.anicontainer.removeChild(this.selectimg);
\r\n\t
this.changeEnable(false);
\r\n\t
var sname1 = this.selectArr[0];
\r\n\t
var sname2 = this.selectArr[1];
\r\n\t
var sename1 = this.lattices[sname1];
\r\n\t
var sename2 = this.lattices[sname2];
\r\n\t
this.lattices[sname1] = sename2;
\r\n\t
this.lattices[sname2] = sename1;
\r\n\t
this.setLatticeEleRc(sname1);
\r\n\t
this.setLatticeEleRc(sname2);
\r\n\t
this.checkEliminate();
\r\n\t
var snode1 = this.container.getChildByName(sename1);
\r\n\t
var snode2 = this.container.getChildByName(sename2);
\r\n\t
if (!snode1 || !snode2) {
\r\n\t
this.selectArr = new Array();
\r\n\t
return;
\r\n\t
}
\r\n\t
var snode1x = snode1.x;
\r\n\t
var snode1y = snode1.y;
\r\n\t
var snode2x = snode2.x;
\r\n\t
var snode2y = snode2.y;
\r\n\t
var changetime = Math.ceil((MapData.itemsize / MapData.anispeed) * 2 * 1000);
\r\n\t
engine.Tween.removeTweens(snode1);
\r\n\t
engine.Tween.removeTweens(snode2);
\r\n\t
if (this.eliminateArr.length > 0) {
\r\n\t
this.inEliminate = true;
\r\n\t
engine.Tween.get(snode1).to({
\r\n\t
x: snode2x,
\r\n\t
y: snode2y
\r\n\t
}, changetime);
\r\n\t
engine.Tween.get(snode2).to({
\r\n\t
x: snode1x,
\r\n\t
y: snode1y
\r\n\t
}, changetime)
\r\n\t
.call(function () {
\r\n\t
_this.eliminate();
\r\n\t
});
\r\n\t
}
\r\n\t
else {
\r\n\t
engine.Tween.get(snode1).to({
\r\n\t
x: snode2x,
\r\n\t
y: snode2y
\r\n\t
}, changetime)
\r\n\t
.wait(100)
\r\n\t
.to({
\r\n\t
x: snode1x,
\r\n\t
y: snode1y
\r\n\t
}, changetime);
\r\n\t
engine.Tween.get(snode2).to({
\r\n\t
x: snode1x,
\r\n\t
y: snode1y
\r\n\t
}, changetime)
\r\n\t
.wait(100)
\r\n\t
.to({
\r\n\t
x: snode2x,
\r\n\t
y: snode2y
\r\n\t
}, changetime)
\r\n\t
.call(function () {
\r\n\t
_this.lattices[sname1] = sename1;
\r\n\t
_this.lattices[sname2] = sename2;
\r\n\t
_this.setLatticeEleRc(sname1);
\r\n\t
_this.setLatticeEleRc(sname2);
\r\n\t
_this.selectArr = new Array();
\r\n\t
_this.recordGame();
\r\n\t
_this.changeEnable(true);
\r\n\t
_this.checkGameOver(
\"
changeElePos
\"
);
\r\n\t
});
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.eliminate = function () {
\r\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\r\n\t
var i, ielidata1, ielileng, addscore, j, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;
\r\n\t
return tslib.__generator(this, function (_a) {
\r\n\t
switch (_a.label) {
\r\n\t
case 0:
\r\n\t
this.inEliminate = true;
\r\n\t
for (i = 0; i < this.eliminateArr.length; i++) {
\r\n\t
ielidata1 = this.eliminateArr[i];
\r\n\t
ielileng = ielidata1.length;
\r\n\t
addscore = 0;
\r\n\t
if (ielileng <= 3) {
\r\n\t
addscore = props.threeEscore;
\r\n\t
}
\r\n\t
else if (ielileng == 4) {
\r\n\t
addscore = props.fourEscore;
\r\n\t
}
\r\n\t
else {
\r\n\t
addscore = props.moreEscore;
\r\n\t
}
\r\n\t
this.seqscore += addscore * ielileng;
\r\n\t
for (j = 0; j < ielidata1.length; j++) {
\r\n\t
ielidata = ielidata1[j];
\r\n\t
ielidxname = ielidata.idxname;
\r\n\t
ielitype = ielidata.type;
\r\n\t
ieliname = this.lattices[ielidxname];
\r\n\t
ielinode = this.container.getChildByName(ieliname);
\r\n\t
if (!ielinode) {
\r\n\t
continue;
\r\n\t
}
\r\n\t
ielix = ielinode.x;
\r\n\t
ieliy = ielinode.y;
\r\n\t
ietype = ielinode.type;
\r\n\t
if (this.elitype == 1) {
\r\n\t
this.lattices[ielidxname] =
\"
empty
\"
;
\r\n\t
this.addScoreAni(ielix, ieliy, ietype, addscore);
\r\n\t
this.goDisplayAni1(ielinode, ietype, ielix, ieliy);
\r\n\t
}
\r\n\t
else {
\r\n\t
this.container.removeChild(ielinode);
\r\n\t
MapData.recoverEle(ielinode, ietype);
\r\n\t
this.addScoreAni(ielix, ieliy, ietype, addscore);
\r\n\t
this.lattices[ielidxname] =
\"
empty
\"
;
\r\n\t
this.goHomeAni(ielitype, ielix, ieliy);
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
return [4, new Promise(function (res) {
\r\n\t
setTimeout(function () {
\r\n\t
res();
\r\n\t
}, 400);
\r\n\t
})];
\r\n\t
case 1:
\r\n\t
_a.sent();
\r\n\t
this.fall();
\r\n\t
return [4, new Promise(function (res1) {
\r\n\t
setTimeout(function () {
\r\n\t
res1();
\r\n\t
}, 500);
\r\n\t
})];
\r\n\t
case 2:
\r\n\t
_a.sent();
\r\n\t
return [2];
\r\n\t
}
\r\n\t
});
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.fall = function (type) {
\r\n\t
if (type === void 0) { type =
\"
normal
\"
; }
\r\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\r\n\t
var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;
\r\n\t
return tslib.__generator(this, function (_a) {
\r\n\t
switch (_a.label) {
\r\n\t
case 0:
\r\n\t
fallData = new Array();
\r\n\t
fcutr = new Array();
\r\n\t
for (fc = 0; fc < MapData.col; fc++) {
\r\n\t
fcutr.push(-1);
\r\n\t
}
\r\n\t
for (r = MapData.row - 1; r > -1; r--) {
\r\n\t
for (c = MapData.col - 1; c > -1; c--) {
\r\n\t
idxname = r +
\"
_
\"
+ c;
\r\n\t
elename = this.lattices[idxname];
\r\n\t
if (elename ==
\"
empty
\"
) {
\r\n\t
frcname = this.getFallRcEle(r, c);
\r\n\t
if (!frcname) {
\r\n\t
fetype = void 0;
\r\n\t
if (type ==
\"
normal
\"
) {
\r\n\t
fetype = MapData.getRandEtype();
\r\n\t
}
\r\n\t
else {
\r\n\t
fetype = this.levelData[r][c];
\r\n\t
}
\r\n\t
fele = MapData.getOneEle(fetype);
\r\n\t
cutr = fcutr[c];
\r\n\t
fepos = MapData.getRCPos(cutr, c);
\r\n\t
fcutr[c] = cutr - 1;
\r\n\t
this.container.addChild(fele);
\r\n\t
fele.x = fepos[0];
\r\n\t
fele.y = fepos[1];
\r\n\t
frcname = fele.name;
\r\n\t
}
\r\n\t
this.lattices[idxname] = frcname;
\r\n\t
this.setLatticeEleRc(idxname);
\r\n\t
fallData.push({
\r\n\t
rcname: frcname,
\r\n\t
trow: r,
\r\n\t
tcol: c
\r\n\t
});
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
fallPromise = new Array();
\r\n\t
_loop_1 = function (f) {
\r\n\t
var fdata = fallData[f];
\r\n\t
var frcname = fdata.rcname;
\r\n\t
var ftrow = fdata.trow;
\r\n\t
var ftcol = fdata.tcol;
\r\n\t
var ftpos = MapData.getRCPos(ftrow, ftcol);
\r\n\t
var frcnode = this_1.container.getChildByName(frcname);
\r\n\t
if (!frcnode) {
\r\n\t
return
\"
continue
\"
;
\r\n\t
}
\r\n\t
var nepos = [frcnode.x, frcnode.y];
\r\n\t
var fdis = MapData.getDistance(ftpos, nepos);
\r\n\t
var ftime = Math.ceil((fdis / MapData.anispeed) * 1000);
\r\n\t
engine.Tween.removeTweens(frcnode);
\r\n\t
var ifallpromise = new Promise(function (res) {
\r\n\t
engine.Tween.get(frcnode)
\r\n\t
.to({
\r\n\t
x: ftpos[0],
\r\n\t
y: ftpos[1]
\r\n\t
}, ftime)
\r\n\t
.to({
\r\n\t
scaleY: 0.85
\r\n\t
}, 80)
\r\n\t
.to({
\r\n\t
scaleY: 1
\r\n\t
}, 80)
\r\n\t
.call(function () {
\r\n\t
res();
\r\n\t
});
\r\n\t
});
\r\n\t
fallPromise.push(ifallpromise);
\r\n\t
};
\r\n\t
this_1 = this;
\r\n\t
for (f = 0; f < fallData.length; f++) {
\r\n\t
_loop_1(f);
\r\n\t
}
\r\n\t
return [4, Promise.all(fallPromise)];
\r\n\t
case 1:
\r\n\t
_a.sent();
\r\n\t
if (type ==
\"
newlevel
\"
) {
\r\n\t
this.sptime = Date.now();
\r\n\t
}
\r\n\t
this.checkEliminate();
\r\n\t
if (this.eliminateArr.length > 0) {
\r\n\t
return [2, this.eliminate()];
\r\n\t
}
\r\n\t
else {
\r\n\t
this.selectArr = new Array();
\r\n\t
isdiedata = this.attionEliminate();
\r\n\t
if (isdiedata && isdiedata.length == 3) {
\r\n\t
this.inEliminate = false;
\r\n\t
if (type !=
\"
newlevel
\"
) {
\r\n\t
this.recordGame();
\r\n\t
}
\r\n\t
this.changeEnable(true);
\r\n\t
this.checkGameOver(
\"
fall
\"
);
\r\n\t
}
\r\n\t
else {
\r\n\t
this.solveDieMap(
\"
fall
\"
);
\r\n\t
}
\r\n\t
}
\r\n\t
return [2];
\r\n\t
}
\r\n\t
});
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.goDisplayAni1 = function (rcele, rcetype, rcelex, rceley) {
\r\n\t
var _this = this;
\r\n\t
rcele.touch = false;
\r\n\t
engine.Tween.removeTweens(rcele);
\r\n\t
rcele.x = rcelex;
\r\n\t
rcele.y = rceley;
\r\n\t
rcele.anchorY = MapData.itemsize / 2;
\r\n\t
engine.Tween.get(rcele)
\r\n\t
.to({
\r\n\t
scaleX: 0,
\r\n\t
scaleY: 0,
\r\n\t
alpha: 0
\r\n\t
}, 300)
\r\n\t
.call(function () {
\r\n\t
_this.container.removeChild(rcele);
\r\n\t
MapData.recoverEle(rcele, rcetype);
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {
\r\n\t
var _this = this;
\r\n\t
var aniele = MapData.getOneEle(ielitype);
\r\n\t
aniele.alpha = 0;
\r\n\t
var anix = ielix;
\r\n\t
var aniy = ieliy + this.conty;
\r\n\t
this.anicontainer.addChild(aniele);
\r\n\t
aniele.touch = false;
\r\n\t
aniele.x = anix;
\r\n\t
aniele.y = aniy;
\r\n\t
aniele.alpha = 1;
\r\n\t
aniele.anchorY = MapData.itemsize / 2;
\r\n\t
engine.Tween.removeTweens(aniele);
\r\n\t
engine.Tween.get(aniele)
\r\n\t
.to({
\r\n\t
scaleX: 0,
\r\n\t
scaleY: 0,
\r\n\t
alpha: 0
\r\n\t
}, 300)
\r\n\t
.call(function () {
\r\n\t
_this.anicontainer.removeChild(aniele);
\r\n\t
MapData.recoverEle(aniele, ielitype);
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {
\r\n\t
var aniele = MapData.getOneEle(ielitype);
\r\n\t
aniele.alpha = 0;
\r\n\t
var anix = ielix;
\r\n\t
var aniy = ieliy + this.conty;
\r\n\t
this.anicontainer.addChild(aniele);
\r\n\t
aniele.touch = false;
\r\n\t
aniele.x = anix;
\r\n\t
aniele.y = aniy;
\r\n\t
aniele.alpha = 1;
\r\n\t
var anidis = MapData.getDistance([this.tanix, this.taniy], [anix, aniy]);
\r\n\t
var anitime = Math.ceil((anidis / MapData.anispeed) * 1000);
\r\n\t
aniele.flyToHome(this.tanix, this.taniy, anitime);
\r\n\t
};
\r\n\t
GameView.prototype.changeEnable = function (v) {
\r\n\t
var changeable = false;
\r\n\t
if (this.gamestat == 1) {
\r\n\t
changeable = true;
\r\n\t
}
\r\n\t
else {
\r\n\t
if (!v) {
\r\n\t
changeable = true;
\r\n\t
}
\r\n\t
}
\r\n\t
if (changeable) {
\r\n\t
for (var key in this.lattices) {
\r\n\t
var kname = this.lattices[key];
\r\n\t
var ele = this.container.getChildByName(kname);
\r\n\t
if (ele) {
\r\n\t
ele.touch = v;
\r\n\t
}
\r\n\t
}
\r\n\t
if (v) {
\r\n\t
this.lastatime = Date.now();
\r\n\t
this.ination = false;
\r\n\t
}
\r\n\t
}
\r\n\t
this.canation = v;
\r\n\t
};
\r\n\t
GameView.prototype.attionEliShow = function () {
\r\n\t
var attiondata = this.attionEliminate();
\r\n\t
if (attiondata && attiondata.length == 3) {
\r\n\t
this.ination = true;
\r\n\t
this.attiondata = [attiondata[0], attiondata[1], attiondata[2]];
\r\n\t
var atname1 = this.lattices[attiondata[0]];
\r\n\t
var atname2 = this.lattices[attiondata[1]];
\r\n\t
var aboutnames = attiondata[2];
\r\n\t
var atnode1 = this.container.getChildByName(atname1);
\r\n\t
var atnode2 = this.container.getChildByName(atname2);
\r\n\t
if (!atnode1 || !atnode2) {
\r\n\t
return;
\r\n\t
}
\r\n\t
var atx1 = atnode1.x;
\r\n\t
var aty1 = atnode1.y;
\r\n\t
var atx2 = atnode2.x;
\r\n\t
var aty2 = atnode2.y;
\r\n\t
var lerpnum = 0.1;
\r\n\t
var atpos1 = [(atx2 - atx1) * lerpnum + atx1, (aty2 - aty1) * lerpnum + aty1];
\r\n\t
engine.Tween.removeTweens(atnode1);
\r\n\t
engine.Tween.removeTweens(atnode2);
\r\n\t
engine.Tween.get(atnode1, {
\r\n\t
loop: true
\r\n\t
}).to({
\r\n\t
x: atpos1[0],
\r\n\t
y: atpos1[1]
\r\n\t
}, 500)
\r\n\t
.to({
\r\n\t
x: atx1,
\r\n\t
y: aty1
\r\n\t
}, 500);
\r\n\t
var jtx = (atx2 - atx1) * 0.5 + atx1;
\r\n\t
var jty = (aty2 - aty1) * 0.5 + aty1 + this.conty;
\r\n\t
var chax1 = atx1 - atpos1[0];
\r\n\t
var chay1 = aty1 - atpos1[1];
\r\n\t
var roa1 = 0;
\r\n\t
var movex1 = 0;
\r\n\t
var movey1 = 0;
\r\n\t
if (Math.abs(chax1) > Math.abs(chay1)) {
\r\n\t
jty += 25;
\r\n\t
movex1 = chax1;
\r\n\t
}
\r\n\t
else {
\r\n\t
jtx += MapData.itemsize;
\r\n\t
roa1 = 90;
\r\n\t
movey1 = chay1;
\r\n\t
}
\r\n\t
for (var i = 0; i < aboutnames.length; i++) {
\r\n\t
var iname1 = this.lattices[aboutnames[i]];
\r\n\t
var inode1 = this.container.getChildByName(iname1);
\r\n\t
engine.Tween.removeTweens(inode1);
\r\n\t
var iatx1 = inode1.x;
\r\n\t
var iaty1 = inode1.y;
\r\n\t
if (inode1) {
\r\n\t
engine.Tween.get(inode1, { loop: true })
\r\n\t
.to({
\r\n\t
x: iatx1 + movex1,
\r\n\t
y: iaty1 + movey1
\r\n\t
}, 500)
\r\n\t
.to({
\r\n\t
x: iatx1,
\r\n\t
y: iaty1
\r\n\t
}, 500);
\r\n\t
}
\r\n\t
}
\r\n\t
this.anicontainer.addChild(this.jiantoucont);
\r\n\t
this.jiantoucont.x = jtx;
\r\n\t
this.jiantoucont.y = jty;
\r\n\t
this.jiantoucont.rotation = roa1;
\r\n\t
this.startJtAni();
\r\n\t
}
\r\n\t
else {
\r\n\t
this.solveDieMap();
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.startJtAni = function () {
\r\n\t
engine.Tween.removeTweens(this.jiantou1);
\r\n\t
engine.Tween.removeTweens(this.jiantou2);
\r\n\t
this.jiantou1.x = this.jtex1;
\r\n\t
this.jiantou1.y = this.jtey1;
\r\n\t
this.jiantou2.x = this.jtex2;
\r\n\t
this.jiantou2.y = this.jtey2;
\r\n\t
this.jiantou1.alpha = 1;
\r\n\t
this.jiantou2.alpha = 1;
\r\n\t
engine.Tween.get(this.jiantou1, { loop: true })
\r\n\t
.to({
\r\n\t
x: this.jtsx1,
\r\n\t
y: this.jtsy1,
\r\n\t
alpha: 0
\r\n\t
}, 500)
\r\n\t
.to({
\r\n\t
x: this.jtex1,
\r\n\t
y: this.jtey1,
\r\n\t
alpha: 1
\r\n\t
}, 500);
\r\n\t
engine.Tween.get(this.jiantou2, { loop: true })
\r\n\t
.to({
\r\n\t
x: this.jtsx2,
\r\n\t
y: this.jtsy2,
\r\n\t
alpha: 0
\r\n\t
}, 500)
\r\n\t
.to({
\r\n\t
x: this.jtex2,
\r\n\t
y: this.jtey2,
\r\n\t
alpha: 1
\r\n\t
}, 500);
\r\n\t
};
\r\n\t
GameView.prototype.solveDieMap = function (type) {
\r\n\t
if (type === void 0) { type =
\"
normal
\"
; }
\r\n\t
if (this.gamestat != 1) {
\r\n\t
if (this.ingameover) {
\r\n\t
this.inEliminate = false;
\r\n\t
this.checkGameOver(
\"
changeToFuHuoPos222
\"
);
\r\n\t
}
\r\n\t
return;
\r\n\t
}
\r\n\t
this.changeEnable(false);
\r\n\t
var elearr = new Array();
\r\n\t
for (var key in this.lattices) {
\r\n\t
var keyval = this.lattices[key];
\r\n\t
elearr.push(keyval);
\r\n\t
}
\r\n\t
for (var key in this.lattices) {
\r\n\t
var changeval = elearr.splice(Math.floor(Math.random() * elearr.length), 1)[0];
\r\n\t
this.lattices[key] = changeval;
\r\n\t
}
\r\n\t
var isdiedata = this.attionEliminate();
\r\n\t
if (isdiedata && isdiedata.length == 3) {
\r\n\t
this.changeToFuHuoPos(type);
\r\n\t
}
\r\n\t
else {
\r\n\t
return this.solveDieMap();
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.changeToFuHuoPos = function (type) {
\r\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\r\n\t
var prolist, key, keyval, keynode, keynodex, keynodey, tpos, ipro;
\r\n\t
return tslib.__generator(this, function (_a) {
\r\n\t
switch (_a.label) {
\r\n\t
case 0:
\r\n\t
prolist = new Array();
\r\n\t
for (key in this.lattices) {
\r\n\t
keyval = this.lattices[key];
\r\n\t
keynode = this.container.getChildByName(keyval);
\r\n\t
if (!keynode) {
\r\n\t
continue;
\r\n\t
}
\r\n\t
keynodex = keynode.x;
\r\n\t
keynodey = keynode.y;
\r\n\t
tpos = MapData.getRCPos(key.split(
\"
_
\"
)[0], key.split(
\"
_
\"
)[1]);
\r\n\t
ipro = keynode.changePos(tpos);
\r\n\t
prolist.push(ipro);
\r\n\t
this.setLatticeEleRc(key);
\r\n\t
}
\r\n\t
return [4, Promise.all(prolist)];
\r\n\t
case 1:
\r\n\t
_a.sent();
\r\n\t
this.checkEliminate();
\r\n\t
if (this.eliminateArr.length > 0) {
\r\n\t
this.eliminate();
\r\n\t
}
\r\n\t
else {
\r\n\t
if (type ==
\"
fall
\"
) {
\r\n\t
this.recordGame();
\r\n\t
}
\r\n\t
this.changeEnable(true);
\r\n\t
this.inEliminate = false;
\r\n\t
this.checkGameOver(
\"
changeToFuHuoPos
\"
);
\r\n\t
}
\r\n\t
return [2];
\r\n\t
}
\r\n\t
});
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.recordcomp = function () {
\r\n\t
this.inrecord = false;
\r\n\t
this.checkGameOver(
\"
recordcomp
\"
);
\r\n\t
};
\r\n\t
GameView.prototype.recordGame = function () {
\r\n\t
if (!this.requestGameOver) {
\r\n\t
this.inrecord = true;
\r\n\t
this.eptime = Date.now();
\r\n\t
engine.globalEvent.dispatchEvent('game-record', {
\r\n\t
score: this.seqscore,
\r\n\t
seq: this.seq,
\r\n\t
sptime: this.sptime,
\r\n\t
eptime: this.eptime
\r\n\t
});
\r\n\t
this.seq += 1;
\r\n\t
this.seqscore = 0;
\r\n\t
this.sptime = Date.now();
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.attionEliminate = function () {
\r\n\t
var attiondata;
\r\n\t
for (var r = MapData.row - 1; r > -1; r--) {
\r\n\t
if (attiondata && attiondata.length == 3) {
\r\n\t
break;
\r\n\t
}
\r\n\t
for (var c = MapData.col - 1; c > -1; c--) {
\r\n\t
var checktype = this.getEleTypeByRc(r, c);
\r\n\t
var edatarow = this.getEliminateRow(r, c);
\r\n\t
var edatacol = this.getEliminateCol(r, c);
\r\n\t
if (edatarow.length > 2 || edatacol.length > 2) ;
\r\n\t
if (edatarow.length == 2) {
\r\n\t
var releidx1 = edatarow[0];
\r\n\t
var releidx2 = edatarow[1];
\r\n\t
var relerow1 = Number(releidx1.split(
\"
_
\"
)[0]);
\r\n\t
var relerow2 = Number(releidx2.split(
\"
_
\"
)[0]);
\r\n\t
var relecol = Number(releidx1.split(
\"
_
\"
)[1]);
\r\n\t
var downrow = relerow1 + 1;
\r\n\t
var uprow = relerow2 - 1;
\r\n\t
var rightcol = relecol + 1;
\r\n\t
var leftcol = relecol - 1;
\r\n\t
var uprow1 = relerow2 - 2;
\r\n\t
var downrow1 = relerow1 + 2;
\r\n\t
if (downrow < MapData.row) {
\r\n\t
if (rightcol < MapData.col) {
\r\n\t
var nexttype = this.getEleTypeByRc(downrow, rightcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [downrow +
\"
_
\"
+ rightcol, downrow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (leftcol > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(downrow, leftcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [downrow +
\"
_
\"
+ leftcol, downrow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (uprow > -1) {
\r\n\t
if (rightcol < MapData.col) {
\r\n\t
var nexttype = this.getEleTypeByRc(uprow, rightcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [uprow +
\"
_
\"
+ rightcol, uprow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (leftcol > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(uprow, leftcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [uprow +
\"
_
\"
+ leftcol, uprow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (uprow1 > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(uprow1, relecol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [uprow1 +
\"
_
\"
+ relecol, uprow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (downrow1 < MapData.row) {
\r\n\t
var nexttype = this.getEleTypeByRc(downrow1, relecol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [downrow1 +
\"
_
\"
+ relecol, downrow +
\"
_
\"
+ relecol, edatarow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (edatacol.length == 2) {
\r\n\t
var releidx1 = edatacol[0];
\r\n\t
var releidx2 = edatacol[1];
\r\n\t
var relerow = Number(releidx1.split(
\"
_
\"
)[0]);
\r\n\t
var relecol1 = Number(releidx1.split(
\"
_
\"
)[1]);
\r\n\t
var relecol2 = Number(releidx2.split(
\"
_
\"
)[1]);
\r\n\t
var rightcol = relecol1 + 1;
\r\n\t
var leftcol = relecol2 - 1;
\r\n\t
var uprow = relerow - 1;
\r\n\t
var downrow = relerow + 1;
\r\n\t
var rightcol1 = relecol1 + 2;
\r\n\t
var leftcol1 = relecol2 - 2;
\r\n\t
if (leftcol > -1) {
\r\n\t
if (uprow > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(uprow, leftcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [uprow +
\"
_
\"
+ leftcol, relerow +
\"
_
\"
+ leftcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (downrow < MapData.row) {
\r\n\t
var nexttype = this.getEleTypeByRc(downrow, leftcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [downrow +
\"
_
\"
+ leftcol, relerow +
\"
_
\"
+ leftcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (rightcol < MapData.col) {
\r\n\t
if (uprow > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(uprow, rightcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [uprow +
\"
_
\"
+ rightcol, relerow +
\"
_
\"
+ rightcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (downrow < MapData.row) {
\r\n\t
var nexttype = this.getEleTypeByRc(downrow, rightcol);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [downrow +
\"
_
\"
+ rightcol, relerow +
\"
_
\"
+ rightcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
if (rightcol1 < MapData.col) {
\r\n\t
var nexttype = this.getEleTypeByRc(relerow, rightcol1);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [relerow +
\"
_
\"
+ rightcol1, relerow +
\"
_
\"
+ rightcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (leftcol1 > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(relerow, leftcol1);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [relerow +
\"
_
\"
+ leftcol1, relerow +
\"
_
\"
+ leftcol, edatacol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
var jianrow = this.getEliminateRowR(r, c);
\r\n\t
if (jianrow.length == 2) {
\r\n\t
var jianr = Number(jianrow[0].split(
\"
_
\"
)[0]) - 1;
\r\n\t
var jianc = Number(jianrow[0].split(
\"
_
\"
)[1]);
\r\n\t
var ljianc = jianc - 1;
\r\n\t
if (ljianc > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(jianr, ljianc);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [jianr +
\"
_
\"
+ ljianc, jianr +
\"
_
\"
+ jianc, jianrow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
var rjianc = jianc + 1;
\r\n\t
if (rjianc < MapData.col) {
\r\n\t
var nexttype = this.getEleTypeByRc(jianr, rjianc);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [jianr +
\"
_
\"
+ rjianc, jianr +
\"
_
\"
+ jianc, jianrow];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
var jiancol = this.getEliminateRowC(r, c);
\r\n\t
if (jiancol.length == 2) {
\r\n\t
var jianr = Number(jiancol[0].split(
\"
_
\"
)[0]);
\r\n\t
var jianc = Number(jianrow[0].split(
\"
_
\"
)[1]) - 1;
\r\n\t
var ujianr = jianr - 1;
\r\n\t
if (ujianr > -1) {
\r\n\t
var nexttype = this.getEleTypeByRc(ujianr, jianc);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [ujianr +
\"
_
\"
+ jianc, jianr +
\"
_
\"
+ jianc, jiancol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
var djianr = jianr + 1;
\r\n\t
if (djianr < MapData.row) {
\r\n\t
var nexttype = this.getEleTypeByRc(djianr, jianc);
\r\n\t
if (nexttype == checktype) {
\r\n\t
attiondata = [djianr +
\"
_
\"
+ jianc, jianr +
\"
_
\"
+ jianc, jiancol];
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
return attiondata;
\r\n\t
};
\r\n\t
GameView.prototype.checkEliminate = function () {
\r\n\t
this.eliminateArr = new Array();
\r\n\t
for (var r = MapData.row - 1; r > -1; r--) {
\r\n\t
for (var c = MapData.col - 1; c > -1; c--) {
\r\n\t
var edata = this.getEliminate(r, c);
\r\n\t
if (edata) {
\r\n\t
var etype = edata.etype;
\r\n\t
var earr = edata.arr;
\r\n\t
this.checkAddEli(etype, earr);
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.getEliminateRowR = function (x, y) {
\r\n\t
var checktype = this.getEleTypeByRc(x, y);
\r\n\t
var jianrow = x - 2;
\r\n\t
var relearr = new Array();
\r\n\t
relearr.push(x +
\"
_
\"
+ y);
\r\n\t
if (jianrow > -1) {
\r\n\t
var jiantype = this.getEleTypeByRc(jianrow, y);
\r\n\t
if (jiantype == checktype) {
\r\n\t
relearr.push(jianrow +
\"
_
\"
+ y);
\r\n\t
}
\r\n\t
}
\r\n\t
return relearr;
\r\n\t
};
\r\n\t
GameView.prototype.getEliminateRowC = function (x, y) {
\r\n\t
var checktype = this.getEleTypeByRc(x, y);
\r\n\t
var jiancol = y - 2;
\r\n\t
var relearr = new Array();
\r\n\t
relearr.push(x +
\"
_
\"
+ y);
\r\n\t
if (jiancol > -1) {
\r\n\t
var jiantype = this.getEleTypeByRc(x, jiancol);
\r\n\t
if (jiantype == checktype) {
\r\n\t
relearr.push(x +
\"
_
\"
+ jiancol);
\r\n\t
}
\r\n\t
}
\r\n\t
return relearr;
\r\n\t
};
\r\n\t
GameView.prototype.getEliminateRow = function (x, y) {
\r\n\t
var checktype = this.getEleTypeByRc(x, y);
\r\n\t
var relearr = new Array();
\r\n\t
relearr.push(x +
\"
_
\"
+ y);
\r\n\t
for (var r = x - 1; r > -1; r--) {
\r\n\t
var reletype = this.getEleTypeByRc(r, y);
\r\n\t
if (checktype == reletype) {
\r\n\t
relearr.push(r +
\"
_
\"
+ y);
\r\n\t
}
\r\n\t
else {
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
return relearr;
\r\n\t
};
\r\n\t
GameView.prototype.getEliminateCol = function (x, y) {
\r\n\t
var checktype = this.getEleTypeByRc(x, y);
\r\n\t
var celearr = new Array();
\r\n\t
celearr.push(x +
\"
_
\"
+ y);
\r\n\t
for (var c = y - 1; c > -1; c--) {
\r\n\t
var celetype = this.getEleTypeByRc(x, c);
\r\n\t
if (checktype == celetype) {
\r\n\t
celearr.push(x +
\"
_
\"
+ c);
\r\n\t
}
\r\n\t
else {
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
return celearr;
\r\n\t
};
\r\n\t
GameView.prototype.getEliminate = function (x, y) {
\r\n\t
var checktype = this.getEleTypeByRc(x, y);
\r\n\t
var relearr = this.getEliminateRow(x, y);
\r\n\t
var celearr = this.getEliminateCol(x, y);
\r\n\t
var eliminatearr = new Array();
\r\n\t
if (relearr.length >= 3) {
\r\n\t
eliminatearr.push.apply(eliminatearr, relearr);
\r\n\t
}
\r\n\t
if (celearr.length >= 3) {
\r\n\t
eliminatearr.push.apply(eliminatearr, celearr);
\r\n\t
}
\r\n\t
if (eliminatearr.length > 0) {
\r\n\t
return {
\r\n\t
etype: checktype,
\r\n\t
arr: eliminatearr
\r\n\t
};
\r\n\t
}
\r\n\t
else {
\r\n\t
return false;
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.getEleTypeByRc = function (r, c) {
\r\n\t
var rc = r +
\"
_
\"
+ c;
\r\n\t
var elename = this.lattices[rc];
\r\n\t
var ele = this.container.getChildByName(elename);
\r\n\t
if (ele) {
\r\n\t
var eletype = ele.type;
\r\n\t
return eletype;
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.checkAddEli = function (etype, earr) {
\r\n\t
var addnew = true;
\r\n\t
var inaidx;
\r\n\t
for (var i1 = 0; i1 < this.eliminateArr.length; i1++) {
\r\n\t
var i1data = this.eliminateArr[i1];
\r\n\t
for (var i2 = 0; i2 < i1data.length; i2++) {
\r\n\t
var i2data = i1data[i2];
\r\n\t
var i2eliname = i2data.idxname;
\r\n\t
var inidx = earr.indexOf(i2eliname);
\r\n\t
if (inidx != -1) {
\r\n\t
addnew = false;
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (!addnew) {
\r\n\t
inaidx = i1;
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (addnew) {
\r\n\t
var addarr = new Array();
\r\n\t
for (var i1 = 0; i1 < earr.length; i1++) {
\r\n\t
var i1name = earr[i1];
\r\n\t
addarr.push({
\r\n\t
idxname: i1name,
\r\n\t
type: etype
\r\n\t
});
\r\n\t
}
\r\n\t
this.eliminateArr.push(addarr);
\r\n\t
}
\r\n\t
else {
\r\n\t
for (var i4 = 0; i4 < earr.length; i4++) {
\r\n\t
var i4name = earr[i4];
\r\n\t
var addele = true;
\r\n\t
for (var i3 = 0; i3 < this.eliminateArr[inaidx].length; i3++) {
\r\n\t
var i3data = this.eliminateArr[inaidx][i3];
\r\n\t
var i3eliname = i3data.idxname;
\r\n\t
if (i3eliname == i4name) {
\r\n\t
addele = false;
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (addele) {
\r\n\t
this.eliminateArr[inaidx].push({
\r\n\t
idxname: i4name,
\r\n\t
type: etype
\r\n\t
});
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.getFallRcEle = function (r, c) {
\r\n\t
for (var fr = r - 1; fr > -1; fr--) {
\r\n\t
var frc = fr +
\"
_
\"
+ c;
\r\n\t
var frcname = this.lattices[frc];
\r\n\t
if (frcname !=
\"
empty
\"
) {
\r\n\t
this.lattices[frc] =
\"
empty
\"
;
\r\n\t
return frcname;
\r\n\t
}
\r\n\t
}
\r\n\t
return false;
\r\n\t
};
\r\n\t
GameView.prototype.addScoreAni = function (ielix, ieliy, ietype, addscore) {
\r\n\t
var _this = this;
\r\n\t
var anitxt = MapData.getOneTxt();
\r\n\t
anitxt.alpha = 0;
\r\n\t
var txtcolor =
\"
#bd882f
\"
;
\r\n\t
switch (ietype) {
\r\n\t
case ElementType.gdog:
\r\n\t
txtcolor =
\"
#d3ff6d
\"
;
\r\n\t
break;
\r\n\t
case ElementType.pbird:
\r\n\t
txtcolor =
\"
#ff51d4
\"
;
\r\n\t
break;
\r\n\t
case ElementType.hniu:
\r\n\t
txtcolor =
\"
#ffab55
\"
;
\r\n\t
break;
\r\n\t
case ElementType.bribbit:
\r\n\t
txtcolor =
\"
#b3d4ff
\"
;
\r\n\t
break;
\r\n\t
case ElementType.rpig:
\r\n\t
txtcolor =
\"
#f2453b
\"
;
\r\n\t
break;
\r\n\t
default:
\r\n\t
console.error(
\"
未定义类型,检查
\"
);
\r\n\t
break;
\r\n\t
}
\r\n\t
anitxt.fillColor = txtcolor;
\r\n\t
var anix = ielix + MapData.itemsize / 2 - 100;
\r\n\t
var aniy = ieliy + this.conty + MapData.itemsize / 2 - 35;
\r\n\t
anitxt.text =
\"
+
\"
+ addscore;
\r\n\t
this.txtcontainer.addChild(anitxt);
\r\n\t
anitxt.x = anix;
\r\n\t
anitxt.y = aniy;
\r\n\t
anitxt.scaleX = 0;
\r\n\t
anitxt.scaleY = 0;
\r\n\t
anitxt.alpha = 1;
\r\n\t
engine.Tween.get(anitxt, { loop: false }).set({
\r\n\t
x: anix,
\r\n\t
y: aniy,
\r\n\t
scaleX: 0,
\r\n\t
scaleY: 0
\r\n\t
})
\r\n\t
.to({
\r\n\t
y: aniy - 50,
\r\n\t
scaleX: 1,
\r\n\t
scaleY: 1,
\r\n\t
}, 300)
\r\n\t
.to({
\r\n\t
y: aniy - 120,
\r\n\t
alpha: 0
\r\n\t
}, 500)
\r\n\t
.call(function () {
\r\n\t
_this.txtcontainer.removeChild(anitxt);
\r\n\t
_this.score += addscore;
\r\n\t
MapData.recoverTxt(anitxt);
\r\n\t
});
\r\n\t
};
\r\n\t
GameView.prototype.changeHomeShow = function (mode) {
\r\n\t
};
\r\n\t
GameView.prototype.boomeEle = function (row, col) {
\r\n\t
this.useBoom = false;
\r\n\t
this.anicontainer.removeChild(this.selectimg);
\r\n\t
this.changeEnable(false);
\r\n\t
this.selectArr = new Array();
\r\n\t
this.eliminateArr = new Array();
\r\n\t
for (var r = 0; r < MapData.row; r++) {
\r\n\t
var irc = r +
\"
_
\"
+ col;
\r\n\t
var ielename = this.lattices[irc];
\r\n\t
var iele = this.container.getChildByName(ielename);
\r\n\t
if (iele) {
\r\n\t
var eletype = iele.type;
\r\n\t
this.eliminateArr.push([
\r\n\t
{
\r\n\t
idxname: irc,
\r\n\t
type: eletype
\r\n\t
}
\r\n\t
]);
\r\n\t
}
\r\n\t
}
\r\n\t
for (var c = 0; c < MapData.col; c++) {
\r\n\t
if (c != col) {
\r\n\t
var irc = row +
\"
_
\"
+ c;
\r\n\t
var ielename = this.lattices[irc];
\r\n\t
var iele = this.container.getChildByName(ielename);
\r\n\t
if (iele) {
\r\n\t
var eletype = iele.type;
\r\n\t
this.eliminateArr.push([
\r\n\t
{
\r\n\t
idxname: irc,
\r\n\t
type: eletype
\r\n\t
}
\r\n\t
]);
\r\n\t
}
\r\n\t
}
\r\n\t
}
\r\n\t
this.eliminate();
\r\n\t
};
\r\n\t
return GameView;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var GameWrapper = (function (_super) {
\r\n\t
tslib.__extends(GameWrapper, _super);
\r\n\t
function GameWrapper() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this._gameView = new GameView();
\r\n\t
_this.addChild(_this._gameView);
\r\n\t
engine.globalEvent.addEventListener('game-init', _this.init, _this);
\r\n\t
engine.globalEvent.addEventListener('game-reset', _this.reset, _this);
\r\n\t
engine.globalEvent.addEventListener('game-start', _this.start, _this);
\r\n\t
engine.globalEvent.addEventListener('game-pause', _this.pause, _this);
\r\n\t
engine.globalEvent.addEventListener('game-resume', _this.resume, _this);
\r\n\t
engine.globalEvent.addEventListener('game-recordcomp', _this.recordcomp, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameWrapper.prototype.init = function (event) {
\r\n\t
var time = event.data.time;
\r\n\t
var level = event.data.level;
\r\n\t
var mode = event.data.mode;
\r\n\t
this._gameView.init(time, level, mode);
\r\n\t
};
\r\n\t
GameWrapper.prototype.reset = function (event) {
\r\n\t
var time = event.data.time;
\r\n\t
var level = event.data.level;
\r\n\t
var mode = event.data.mode;
\r\n\t
this._gameView.reset(time, level, mode);
\r\n\t
};
\r\n\t
GameWrapper.prototype.start = function () {
\r\n\t
this._gameView.start();
\r\n\t
};
\r\n\t
GameWrapper.prototype.pause = function () {
\r\n\t
this._gameView.pause();
\r\n\t
};
\r\n\t
GameWrapper.prototype.resume = function () {
\r\n\t
this._gameView.resume();
\r\n\t
};
\r\n\t
GameWrapper.prototype.recordcomp = function () {
\r\n\t
this._gameView.recordcomp();
\r\n\t
};
\r\n\t
return GameWrapper;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=GameWrapper.js.map
\n\n\t
function index (props) {
\r\n\t
prepareProps();
\r\n\t
injectProps(props);
\r\n\t
var instance = new GameWrapper();
\r\n\t
return instance;
\r\n\t
}
\r\n\t
//# sourceMappingURL=index.js.map
\n\n\t
return index;
\n\n
})));
\n
"
}
src/custom/rbcxiaoxiaole/debug/app.js
0 → 100644
View file @
e29e32b9
/**
* Created by renjianfeng on 2020-03-13.
*/
const
customId
=
'rbcxiaoxiaole'
;
(
async
function
()
{
let
customModule
=
await
fetch
(
`../meta.json`
);
customModule
=
await
customModule
.
json
();
console
.
log
(
customModule
);
await
loadAssets
(
customModule
.
assets
);
launchWithCustomModule
(
customModule
);
})();
function
launchWithCustomModule
(
customModule
)
{
//engine.registerCustomCodeModule(customModule);
engine
.
registerCustomModule
(
customId
,
window
[
customId
]);
const
{
props
:
propsOption
,
assets
}
=
customModule
;
let
props
=
engine
.
computeProps
(
customModuleProps
,
propsOption
);
const
customModuleIns
=
{
id
:
customId
,
props
,
assets
,
};
engine
.
registerCustomModules
([
customModuleIns
]);
engine
.
launchWithConfig
({
options
:
{
entrySceneView
:
'entry'
,
},
assets
:
[],
views
:
[{
name
:
'entry'
,
type
:
'node'
,
properties
:
{
x
:
0
,
y
:
0
,
}
}],
},
null
,
function
()
{
setTimeout
(()
=>
{
engine
.
addCustomModule
(
customId
,
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
));
},
100
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'game-init'
,{
time
:
100000
,
level
:
1
,
mode
:
"day"
});
},
500
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'game-start'
);
},
700
);
});
}
function
getAssetByUUID
(
uuid
)
{
return
engine
.
resolveCustomAsset
(
customId
,
uuid
);
}
function
getProps
()
{
return
engine
.
getProps
(
customId
);
}
src/custom/rbcxiaoxiaole/debug/index.html
0 → 100644
View file @
e29e32b9
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
人保财险消消乐
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"full-screen"
content=
"true"
/>
<meta
name=
"screen-orientation"
content=
"portrait"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"360-fullscreen"
content=
"true"
/>
<style>
html
,
body
{
padding
:
0
;
margin
:
0
;
border
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
absolute
;
/* background-color: red; */
}
</style>
</head>
<body>
<div
id=
"game-container"
style=
"line-height:0;font-size:0"
></div>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"
></script>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"
></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script
src=
"app.js"
></script>
<script
src=
"props.js"
></script>
<script
src=
"load-assets.js"
></script>
<script
src=
"main.js"
></script>
<script>
</script>
</body>
\ No newline at end of file
src/custom/rbcxiaoxiaole/debug/load-assets.js
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2020-01-21.
*/
const
assets
=
[
];
function
loadAssets
(
customModuleAssets
,
onProgress
,
onComplete
){
return
engine
.
loadAssets
(
assets
.
concat
(...
customModuleAssets
),
onProgress
,
onComplete
);
}
src/custom/rbcxiaoxiaole/debug/main.js
0 → 100644
View file @
e29e32b9
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
(
require
(
'tslib'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'tslib'
],
factory
)
:
(
global
=
global
||
self
,
global
.
rbcxiaoxiaole
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
//# sourceMappingURL=utils.js.map
var
Element
=
(
function
(
_super
)
{
tslib
.
__extends
(
Element
,
_super
);
function
Element
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
width
=
MapData
.
itemsize
;
_this
.
height
=
MapData
.
itemsize
;
_this
.
anchorX
=
MapData
.
itemsize
/
2
;
_this
.
eimage
=
new
engine
.
Image
();
_this
.
addChild
(
_this
.
eimage
);
_this
.
touch
=
true
;
_this
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
_this
.
selectele
,
_this
);
_this
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
_this
.
changemove
,
_this
);
return
_this
;
}
Object
.
defineProperty
(
Element
.
prototype
,
"touch"
,
{
set
:
function
(
touch
)
{
this
.
mouseEnabled
=
touch
;
this
.
mouseChildren
=
touch
;
},
enumerable
:
true
,
configurable
:
true
});
Element
.
prototype
.
init
=
function
(
type
)
{
this
.
anchorY
=
MapData
.
itemsize
;
this
.
scaleX
=
1
;
this
.
scaleY
=
1
;
this
.
alpha
=
1
;
this
.
type
=
type
;
var
ename
=
MapData
.
getEtypeImgName
(
type
);
this
.
eimage
.
texture
=
MapData
.
getEtypeImgTex
(
type
);
var
imgwid
=
this
.
eimage
.
texture
.
width
;
var
imghei
=
this
.
eimage
.
texture
.
height
;
this
.
eimage
.
x
=
(
this
.
width
-
imgwid
)
/
2
;
this
.
eimage
.
y
=
(
this
.
height
-
imghei
)
/
2
;
};
Element
.
prototype
.
setrc
=
function
(
r
,
c
)
{
this
.
inrow
=
r
;
this
.
incol
=
c
;
};
Element
.
prototype
.
selectele
=
function
(
e
)
{
engine
.
globalEvent
.
dispatchEvent
(
GameEvent
.
SelectEle
,
{
r
:
this
.
inrow
,
c
:
this
.
incol
,
type
:
"mouse_down"
});
};
Element
.
prototype
.
changemove
=
function
(
e
)
{
engine
.
globalEvent
.
dispatchEvent
(
GameEvent
.
SelectEle
,
{
r
:
this
.
inrow
,
c
:
this
.
incol
,
type
:
"mouse_move"
});
};
Object
.
defineProperty
(
Element
.
prototype
,
"factor"
,
{
get
:
function
()
{
return
0
;
},
set
:
function
(
value
)
{
this
.
x
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1x
+
2
*
value
*
(
1
-
value
)
*
this
.
c1x
+
value
*
value
*
this
.
p2x
;
this
.
y
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1y
+
2
*
value
*
(
1
-
value
)
*
this
.
c1y
+
value
*
value
*
this
.
p2y
;
var
mscale
=
(
1
-
value
)
*
(
1
-
value
)
*
1
+
2
*
value
*
(
1
-
value
)
*
0.6
+
value
*
value
*
0.35
;
this
.
scaleX
=
mscale
;
this
.
scaleY
=
mscale
;
},
enumerable
:
true
,
configurable
:
true
});
Element
.
prototype
.
flyToHome
=
function
(
tx
,
ty
,
time
)
{
var
_this
=
this
;
this
.
p1x
=
this
.
x
;
this
.
p1y
=
this
.
y
+
20
;
this
.
c1x
=
(
this
.
p1x
-
tx
)
/
4
+
tx
;
this
.
c1y
=
ty
;
this
.
p2x
=
tx
;
this
.
p2y
=
ty
;
engine
.
Tween
.
removeTweens
(
this
);
engine
.
Tween
.
get
(
this
).
to
({
scaleX
:
1.1
,
scaleY
:
1.1
},
200
)
.
to
({
scaleX
:
1.1
,
scaleY
:
0.88
},
100
)
.
to
({
scaleX
:
0.98
,
scaleY
:
0.98
,
y
:
this
.
y
+
20
},
100
)
.
call
(
function
()
{
_this
.
factor
=
0
;
engine
.
Tween
.
get
(
_this
).
to
({
factor
:
1
},
450
)
.
call
(
function
()
{
var
nodeparent
=
_this
.
parent
;
nodeparent
&&
nodeparent
.
removeChild
(
_this
);
MapData
.
recoverEle
(
_this
,
_this
.
type
);
});
});
};
Element
.
prototype
.
changePos
=
function
(
tpos
)
{
var
_this
=
this
;
var
nx
=
this
.
x
;
var
ny
=
this
.
y
;
var
tx
=
tpos
[
0
];
var
ty
=
tpos
[
1
];
var
dis
=
MapData
.
getDistance
([
nx
,
ny
],
tpos
);
var
time
=
Math
.
ceil
(
dis
/
MapData
.
anispeed
*
1000
);
engine
.
Tween
.
removeTweens
(
this
);
var
pro
=
new
Promise
(
function
(
res
)
{
engine
.
Tween
.
get
(
_this
,
{
loop
:
false
}).
to
({
x
:
tx
,
y
:
ty
},
time
)
.
call
(
function
()
{
res
();
});
});
return
pro
;
};
return
Element
;
}(
engine
.
Container
));
//# sourceMappingURL=Element.js.map
var
ElementType
;
(
function
(
ElementType
)
{
ElementType
[
ElementType
[
"gdog"
]
=
1
]
=
"gdog"
;
ElementType
[
ElementType
[
"pbird"
]
=
2
]
=
"pbird"
;
ElementType
[
ElementType
[
"hniu"
]
=
3
]
=
"hniu"
;
ElementType
[
ElementType
[
"bribbit"
]
=
4
]
=
"bribbit"
;
ElementType
[
ElementType
[
"rpig"
]
=
5
]
=
"rpig"
;
})(
ElementType
||
(
ElementType
=
{}));
var
GameEvent
;
(
function
(
GameEvent
)
{
GameEvent
[
"SelectEle"
]
=
"SelectEle"
;
})(
GameEvent
||
(
GameEvent
=
{}));
var
MapData
=
(
function
()
{
function
MapData
()
{
}
MapData
.
getRy
=
function
(
r
)
{
return
this
.
paddingh
+
r
*
(
this
.
itemsize
+
this
.
paddinghi
);
};
MapData
.
getCx
=
function
(
c
)
{
return
this
.
paddingw
+
c
*
(
this
.
itemsize
+
this
.
paddingwi
);
};
MapData
.
getRCPos
=
function
(
r
,
c
)
{
var
x
=
this
.
getCx
(
c
);
var
y
=
this
.
getRy
(
r
);
return
[
x
,
y
];
};
MapData
.
adaptElePos
=
function
(
pos
,
wid
,
hei
)
{
var
x
=
pos
[
0
]
+
(
this
.
itemsize
-
wid
)
/
2
;
var
y
=
pos
[
1
]
+
(
this
.
itemsize
-
hei
)
/
2
;
return
[
x
,
y
];
};
MapData
.
getEtypeImgName
=
function
(
type
)
{
var
ename
;
switch
(
type
)
{
case
ElementType
.
gdog
:
ename
=
"狗"
;
break
;
case
ElementType
.
pbird
:
ename
=
"鸟"
;
break
;
case
ElementType
.
hniu
:
ename
=
"牛"
;
break
;
case
ElementType
.
bribbit
:
ename
=
"兔子"
;
break
;
case
ElementType
.
rpig
:
ename
=
"猪"
;
break
;
default
:
console
.
error
(
"未定义元素类型"
);
break
;
}
return
ename
;
};
MapData
.
getEtypeImgTex
=
function
(
type
)
{
var
etex
;
switch
(
type
)
{
case
ElementType
.
gdog
:
if
(
!
this
.
gdotTex
)
{
this
.
gdotTex
=
getTextureByName
(
"狗"
);
console
.
log
(
"新素材加载---狗"
);
}
etex
=
this
.
gdotTex
;
break
;
case
ElementType
.
pbird
:
if
(
!
this
.
pbirdTex
)
{
this
.
pbirdTex
=
getTextureByName
(
"鸟"
);
console
.
log
(
"新素材加载---鸟"
);
}
etex
=
this
.
pbirdTex
;
break
;
case
ElementType
.
hniu
:
if
(
!
this
.
hniuTex
)
{
this
.
hniuTex
=
getTextureByName
(
"牛"
);
console
.
log
(
"新素材加载---牛"
);
}
etex
=
this
.
hniuTex
;
break
;
case
ElementType
.
bribbit
:
if
(
!
this
.
bribbitTex
)
{
this
.
bribbitTex
=
getTextureByName
(
"兔子"
);
console
.
log
(
"新素材加载---兔子"
);
}
etex
=
this
.
bribbitTex
;
break
;
case
ElementType
.
rpig
:
if
(
!
this
.
rpigTex
)
{
this
.
rpigTex
=
getTextureByName
(
"猪"
);
console
.
log
(
"新素材加载---猪"
);
}
etex
=
this
.
rpigTex
;
break
;
default
:
console
.
error
(
"未定义元素类型"
);
break
;
}
return
etex
;
};
MapData
.
getRandEtype
=
function
()
{
var
eletypeArr
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
var
etype
=
eletypeArr
[
Math
.
floor
(
Math
.
random
()
*
eletypeArr
.
length
)];
return
etype
;
};
MapData
.
initPoolEle
=
function
()
{
this
.
gdotTex
=
getTextureByName
(
"狗"
);
this
.
pbirdTex
=
getTextureByName
(
"鸟"
);
this
.
hniuTex
=
getTextureByName
(
"牛"
);
this
.
bribbitTex
=
getTextureByName
(
"兔子"
);
this
.
rpigTex
=
getTextureByName
(
"猪"
);
var
eletypes
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
this
.
elePool
[
"ele"
]
=
new
Array
();
for
(
var
i
=
0
;
i
<
eletypes
.
length
;
i
++
)
{
for
(
var
a
=
0
;
a
<
5
;
a
++
)
{
var
iele
=
new
Element
();
this
.
elePool
[
"ele"
].
push
(
iele
);
}
}
this
.
elePool
[
"score"
]
=
new
Array
();
for
(
var
t
=
0
;
t
<
8
;
t
++
)
{
var
itxt
=
new
engine
.
Label
();
itxt
.
size
=
66
;
itxt
.
width
=
200
;
itxt
.
height
=
70
;
itxt
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
itxt
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
;
itxt
.
anchorY
=
35
;
itxt
.
anchorX
=
100
;
itxt
.
bold
=
true
;
this
.
elePool
[
"score"
].
push
(
itxt
);
}
};
MapData
.
getOneEle
=
function
(
type
)
{
var
ele
;
if
(
this
.
elePool
[
"ele"
])
{
if
(
this
.
elePool
[
"ele"
].
length
>
0
)
{
ele
=
this
.
elePool
[
"ele"
].
shift
();
}
}
else
{
this
.
elePool
[
"ele"
]
=
new
Array
();
}
if
(
!
ele
)
{
console
.
error
(
"创建了新的了ele"
);
ele
=
new
Element
();
}
ele
.
name
=
"ele_"
+
this
.
eleidx
;
this
.
eleidx
+=
1
;
ele
.
init
(
type
);
return
ele
;
};
MapData
.
getOneTxt
=
function
()
{
var
itxt
;
if
(
this
.
elePool
[
"score"
])
{
if
(
this
.
elePool
[
"score"
].
length
>
0
)
{
itxt
=
this
.
elePool
[
"score"
].
shift
();
}
}
else
{
this
.
elePool
[
"score"
]
=
new
Array
();
}
if
(
!
itxt
)
{
itxt
=
new
engine
.
Label
();
itxt
.
size
=
66
;
itxt
.
width
=
200
;
itxt
.
height
=
70
;
itxt
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
itxt
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
;
itxt
.
anchorY
=
35
;
itxt
.
anchorX
=
100
;
itxt
.
bold
=
true
;
}
itxt
.
mouseEnabled
=
false
;
return
itxt
;
};
MapData
.
recoverEle
=
function
(
ele
,
type
)
{
if
(
ele
.
eimage
)
{
ele
.
eimage
.
texture
=
null
;
}
this
.
elePool
[
"ele"
].
push
(
ele
);
};
MapData
.
recoverTxt
=
function
(
txt
)
{
this
.
elePool
[
"score"
].
push
(
txt
);
};
MapData
.
getDistance
=
function
(
p1
,
p2
)
{
var
p1x
=
p1
[
0
];
var
p1y
=
p1
[
1
];
var
p2x
=
p2
[
0
];
var
p2y
=
p2
[
1
];
var
dis
=
Math
.
sqrt
(
Math
.
pow
(
p1x
-
p2x
,
2
)
+
Math
.
pow
(
p1y
-
p2y
,
2
));
return
dis
;
};
MapData
.
itemsize
=
116
;
MapData
.
paddingw
=
7
;
MapData
.
paddingh
=
7
;
MapData
.
paddingwi
=
4
;
MapData
.
paddinghi
=
2
;
MapData
.
row
=
5
;
MapData
.
col
=
5
;
MapData
.
posData
=
{};
MapData
.
eleidx
=
1
;
MapData
.
elePool
=
{};
MapData
.
anispeed
=
1000
;
MapData
.
levelData
=
[
[
[
1
,
2
,
5
,
3
,
4
],
[
3
,
1
,
2
,
4
,
5
],
[
2
,
5
,
3
,
4
,
1
],
[
5
,
4
,
1
,
2
,
3
],
[
4
,
1
,
3
,
5
,
2
],
],
[
[
5
,
2
,
1
,
2
,
1
],
[
3
,
1
,
4
,
5
,
4
],
[
2
,
5
,
3
,
5
,
1
],
[
5
,
4
,
1
,
2
,
3
],
[
4
,
1
,
3
,
1
,
2
],
],
[
[
2
,
4
,
1
,
5
,
2
],
[
2
,
3
,
4
,
1
,
3
],
[
4
,
1
,
3
,
2
,
3
],
[
3
,
2
,
1
,
1
,
4
],
[
1
,
1
,
3
,
5
,
4
],
],
[
[
3
,
2
,
1
,
4
,
5
],
[
2
,
4
,
1
,
2
,
3
],
[
2
,
3
,
2
,
3
,
3
],
[
4
,
4
,
5
,
5
,
4
],
[
3
,
3
,
1
,
2
,
4
],
],
[
[
4
,
5
,
1
,
2
,
4
],
[
3
,
2
,
3
,
4
,
2
],
[
1
,
5
,
2
,
3
,
5
],
[
4
,
5
,
5
,
1
,
3
],
[
1
,
2
,
3
,
2
,
4
],
]
];
return
MapData
;
}());
//# sourceMappingURL=MapData.js.map
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
lattices
=
{};
_this
.
eliminateArr
=
[];
_this
.
selectArr
=
[];
_this
.
conty
=
140
;
_this
.
homex
=
562
;
_this
.
homey
=
-
20
;
_this
.
ination
=
false
;
_this
.
canation
=
true
;
_this
.
_gametime
=
60
;
_this
.
_gamestat
=
2
;
_this
.
ingameover
=
false
;
_this
.
ingame
=
true
;
_this
.
level
=
0
;
_this
.
inrecord
=
false
;
_this
.
requestGameOver
=
false
;
_this
.
elitype
=
1
;
_this
.
_seq
=
1
;
_this
.
sptime
=
Date
.
now
();
_this
.
useBoom
=
false
;
_this
.
_score
=
0
;
_this
.
inEliminate
=
false
;
_this
.
newSelect
=
false
;
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
return
_this
;
}
Object
.
defineProperty
(
GameView
.
prototype
,
"gamestat"
,
{
get
:
function
()
{
return
this
.
_gamestat
;
},
set
:
function
(
stat
)
{
this
.
_gamestat
=
stat
;
if
(
stat
==
2
)
{
this
.
changeEnable
(
false
);
}
},
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
GameView
.
prototype
,
"seq"
,
{
get
:
function
()
{
return
this
.
_seq
;
},
set
:
function
(
num
)
{
this
.
_seq
=
num
;
},
enumerable
:
true
,
configurable
:
true
});
GameView
.
prototype
.
setup
=
function
()
{
MapData
.
initPoolEle
();
this
.
selectimg
=
new
engine
.
Image
(
getTextureByName
(
"选中框"
));
this
.
selectimg
.
mouseEnabled
=
false
;
this
.
selectw
=
this
.
selectimg
.
texture
.
width
;
this
.
selecth
=
this
.
selectimg
.
texture
.
height
;
this
.
selectimg
.
anchorX
=
this
.
selectw
/
2
;
this
.
selectimg
.
anchorY
=
this
.
selecth
/
2
;
this
.
jiantou1
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
this
.
jiantou2
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
this
.
jiantou1
.
mouseEnabled
=
false
;
this
.
jiantou2
.
mouseEnabled
=
false
;
var
jiantwid
=
31
;
var
jianthei
=
24
;
this
.
jiantou1
.
anchorX
=
jiantwid
/
2
;
this
.
jiantou1
.
anchorY
=
jianthei
/
2
;
this
.
jiantou2
.
anchorX
=
jiantwid
/
2
;
this
.
jiantou2
.
anchorY
=
jianthei
/
2
;
this
.
jiantoucont
=
new
engine
.
Container
();
this
.
jiantoucont
.
width
=
MapData
.
itemsize
;
this
.
jiantoucont
.
height
=
MapData
.
itemsize
;
this
.
jtsx1
=
MapData
.
itemsize
/
2
-
jiantwid
/
2
;
this
.
jtsx2
=
MapData
.
itemsize
/
2
-
jiantwid
/
2
;
this
.
jtsy1
=
MapData
.
itemsize
/
2
-
jianthei
;
this
.
jtsy2
=
MapData
.
itemsize
/
2
;
this
.
jtex1
=
this
.
jtsx1
-
10
;
this
.
jtex2
=
this
.
jtsx2
+
10
;
this
.
jtey1
=
this
.
jtsy1
;
this
.
jtey2
=
this
.
jtsy2
;
this
.
jiantou1
.
x
=
this
.
jtsx1
;
this
.
jiantou2
.
rotation
=
180
;
this
.
jiantou2
.
x
=
this
.
jtsx2
;
this
.
jiantou1
.
y
=
this
.
jtsy1
;
this
.
jiantou2
.
y
=
this
.
jtsy2
;
this
.
jiantoucont
.
addChild
(
this
.
jiantou1
);
this
.
jiantoucont
.
addChild
(
this
.
jiantou2
);
var
row
=
MapData
.
row
;
var
col
=
MapData
.
col
;
this
.
container
=
new
engine
.
Container
();
this
.
addChild
(
this
.
container
);
this
.
container
.
y
=
this
.
conty
;
var
maskimg
=
new
engine
.
Graphics
();
this
.
container
.
addChild
(
maskimg
);
this
.
container
.
mask
=
maskimg
;
maskimg
.
moveTo
(
0
,
0
);
maskimg
.
beginFill
(
0
);
maskimg
.
lineTo
(
681
,
0
);
maskimg
.
lineTo
(
681
,
679
);
maskimg
.
lineTo
(
0
,
679
);
maskimg
.
lineTo
(
0
,
0
);
maskimg
.
endFill
();
this
.
anicontainer
=
new
engine
.
Container
();
this
.
addChild
(
this
.
anicontainer
);
this
.
anicontainer
.
mouseEnabled
=
false
;
this
.
anicontainer
.
mouseChildren
=
false
;
this
.
txtcontainer
=
new
engine
.
Container
();
this
.
addChild
(
this
.
txtcontainer
);
var
map
=
new
engine
.
Image
(
getTextureByName
(
"底图"
));
this
.
container
.
addChild
(
map
);
for
(
var
r
=
0
;
r
<
row
;
r
++
)
{
for
(
var
c
=
0
;
c
<
col
;
c
++
)
{
var
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
MapData
.
posData
[
r
+
"_"
+
c
]
=
rcpos
;
}
}
this
.
tanix
=
this
.
homex
+
30
;
this
.
taniy
=
this
.
homey
;
engine
.
globalEvent
.
addEventListener
(
GameEvent
.
SelectEle
,
this
.
selectele
,
this
);
this
.
removeEventListener
(
engine
.
Event
.
ADDED_TO_STAGE
,
this
.
setup
,
this
);
this
.
lastframeTime
=
Date
.
now
();
this
.
lastatime
=
Date
.
now
();
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onUpdate
,
this
);
var
zhadanbtn
=
new
engine
.
Label
();
zhadanbtn
.
text
=
"炸弹"
;
zhadanbtn
.
size
=
56
;
zhadanbtn
.
width
=
200
;
zhadanbtn
.
height
=
100
;
this
.
addChild
(
zhadanbtn
);
zhadanbtn
.
y
=
900
;
zhadanbtn
.
fillColor
=
"red"
;
zhadanbtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
zhadanFunc
,
this
);
var
timebtn
=
new
engine
.
Label
();
timebtn
.
text
=
"加时"
;
timebtn
.
size
=
56
;
timebtn
.
width
=
200
;
timebtn
.
height
=
100
;
this
.
addChild
(
timebtn
);
timebtn
.
y
=
900
;
timebtn
.
x
=
500
;
timebtn
.
fillColor
=
"red"
;
timebtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
addTimeFunc
,
this
);
};
GameView
.
prototype
.
zhadanFunc
=
function
()
{
this
.
useBoom
=
true
;
};
GameView
.
prototype
.
addTimeFunc
=
function
()
{
console
.
log
(
"加时间"
);
};
GameView
.
prototype
.
changeAni
=
function
()
{
this
.
changeHomeShow
(
"night"
);
};
GameView
.
prototype
.
playComp
=
function
()
{
};
GameView
.
prototype
.
init
=
function
(
time
,
level
,
mode
)
{
this
.
score
=
0
;
this
.
gametime
=
time
;
this
.
seq
=
1
;
this
.
level
=
level
;
this
.
ingameover
=
false
;
this
.
changeHomeShow
(
mode
);
this
.
initContainer
();
this
.
sptime
=
Date
.
now
();
};
Object
.
defineProperty
(
GameView
.
prototype
,
"score"
,
{
get
:
function
()
{
return
this
.
_score
;
},
set
:
function
(
num
)
{
this
.
_score
=
num
;
engine
.
globalEvent
.
dispatchEvent
(
'game-score-update'
,
{
score
:
this
.
_score
});
},
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
GameView
.
prototype
,
"gametime"
,
{
get
:
function
()
{
return
this
.
_gametime
;
},
set
:
function
(
time
)
{
var
lshowtime
=
Math
.
round
(
this
.
_gametime
);
var
nshowtime
=
Math
.
round
(
time
);
if
(
lshowtime
!=
nshowtime
)
{
if
(
this
.
gamestat
==
1
&&
nshowtime
<
1
)
{
this
.
gameOver
();
}
if
(
nshowtime
<
0
)
{
nshowtime
=
0
;
}
engine
.
globalEvent
.
dispatchEvent
(
'game-time-update'
,
{
time
:
nshowtime
});
}
if
(
time
<
0
)
{
time
=
0
;
}
this
.
_gametime
=
time
;
},
enumerable
:
true
,
configurable
:
true
});
GameView
.
prototype
.
gameOver
=
function
()
{
this
.
gamestat
=
2
;
this
.
unShowEleAttion
();
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
ingameover
=
true
;
console
.
log
(
"倒计时结束1============="
,
this
.
ingameover
,
this
.
inEliminate
,
this
.
inrecord
);
this
.
checkGameOver
(
"time-over"
);
};
GameView
.
prototype
.
checkGameOver
=
function
(
type
)
{
if
(
this
.
ingameover
)
{
console
.
log
(
"倒计时已结束2=========="
,
this
.
inEliminate
,
this
.
inrecord
,
type
);
}
if
(
this
.
ingameover
&&
!
this
.
inEliminate
&&
!
this
.
inrecord
&&
!
this
.
requestGameOver
)
{
this
.
requestGameOver
=
true
;
this
.
unShowEleAttion
();
this
.
anicontainer
.
removeChild
(
this
.
jiantoucont
);
engine
.
globalEvent
.
dispatchEvent
(
"game-over"
,
{
score
:
this
.
score
});
}
};
GameView
.
prototype
.
reset
=
function
(
time
,
level
,
mode
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
key
,
rcname
,
rcele
,
rcelex
,
rceley
,
rcetype
,
fallpro
,
testdata
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
selectArr
=
new
Array
();
this
.
gametime
=
time
;
this
.
level
=
level
;
this
.
ingameover
=
false
;
this
.
requestGameOver
=
false
;
this
.
seq
=
1
;
this
.
changeHomeShow
(
mode
);
this
.
changeEnable
(
false
);
for
(
key
in
this
.
lattices
)
{
rcname
=
this
.
lattices
[
key
];
rcele
=
this
.
container
.
getChildByName
(
rcname
);
if
(
rcele
)
{
rcelex
=
rcele
.
x
;
rceley
=
rcele
.
y
;
rcetype
=
rcele
.
type
;
this
.
lattices
[
key
]
=
"empty"
;
this
.
goDisplayAni1
(
rcele
,
rcetype
,
rcelex
,
rceley
);
}
}
fallpro
=
new
Promise
(
function
(
res
)
{
setTimeout
(
function
()
{
res
();
},
400
);
});
return
[
4
,
fallpro
];
case
1
:
_a
.
sent
();
testdata
=
MapData
.
levelData
[
this
.
level
];
this
.
levelData
=
testdata
;
this
.
fall
(
"newlevel"
);
return
[
2
];
}
});
});
};
GameView
.
prototype
.
start
=
function
()
{
this
.
gamestat
=
1
;
this
.
requestGameOver
=
false
;
this
.
selectArr
=
new
Array
();
this
.
changeEnable
(
true
);
};
GameView
.
prototype
.
pause
=
function
()
{
this
.
ingame
=
false
;
};
GameView
.
prototype
.
resume
=
function
()
{
this
.
lastframeTime
=
Date
.
now
();
this
.
ingame
=
true
;
};
GameView
.
prototype
.
onUpdate
=
function
()
{
var
ntime
=
Date
.
now
();
if
(
this
.
gamestat
==
1
&&
this
.
ingame
)
{
var
passtime
=
ntime
-
this
.
lastframeTime
;
if
(
ntime
-
this
.
lastatime
>=
5000
&&
!
this
.
ination
&&
this
.
canation
&&
this
.
selectArr
.
length
==
0
)
{
this
.
attionEliShow
();
}
if
(
this
.
gametime
&&
this
.
gametime
>
0
)
{
var
ngtime
=
this
.
gametime
-
(
passtime
/
1000
);
this
.
gametime
=
ngtime
;
}
}
this
.
lastframeTime
=
ntime
;
};
GameView
.
prototype
.
initContainer
=
function
()
{
if
(
this
.
lattices
)
{
for
(
var
key
in
this
.
lattices
)
{
var
rcname
=
this
.
lattices
[
key
];
var
rcele
=
this
.
container
.
getChildByName
(
rcname
);
if
(
rcele
)
{
var
rcetype
=
rcele
.
type
;
this
.
container
.
removeChild
(
rcele
);
this
.
lattices
[
key
]
=
"empty"
;
MapData
.
recoverEle
(
rcele
,
rcetype
);
}
}
}
else
{
this
.
lattices
=
{};
}
var
testdata
=
MapData
.
levelData
[
this
.
level
];
this
.
levelData
=
testdata
;
for
(
var
r
=
0
;
r
<
testdata
.
length
;
r
++
)
{
var
rdata
=
testdata
[
r
];
for
(
var
c
=
0
;
c
<
rdata
.
length
;
c
++
)
{
var
rctype
=
rdata
[
c
];
var
rcele
=
MapData
.
getOneEle
(
rctype
);
var
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
this
.
container
.
addChild
(
rcele
);
rcele
.
x
=
rcpos
[
0
];
rcele
.
y
=
rcpos
[
1
];
var
rcidx
=
r
+
"_"
+
c
;
this
.
lattices
[
rcidx
]
=
rcele
.
name
;
this
.
setLatticeEleRc
(
rcidx
);
}
}
this
.
checkInit
();
};
GameView
.
prototype
.
checkInit
=
function
()
{
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
)
{
return
this
.
eliminate
();
}
else
{
this
.
selectArr
=
new
Array
();
var
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
)
{
this
.
changeEnable
(
true
);
}
else
{
this
.
solveDieMap
();
}
}
};
GameView
.
prototype
.
setLatticeEleRc
=
function
(
rcidx
)
{
var
rename
=
this
.
lattices
[
rcidx
];
var
rcnode
=
this
.
container
.
getChildByName
(
rename
);
if
(
rcnode
)
{
var
er
=
Number
(
rcidx
.
split
(
"_"
)[
0
]);
var
ec
=
Number
(
rcidx
.
split
(
"_"
)[
1
]);
rcnode
.
setrc
(
er
,
ec
);
}
};
GameView
.
prototype
.
unShowEleAttion
=
function
()
{
if
(
this
.
ination
)
{
this
.
ination
=
false
;
this
.
lastatime
=
Date
.
now
();
var
arrcidx1
=
this
.
attiondata
[
0
];
var
arrcidx2
=
this
.
attiondata
[
1
];
var
atname1
=
this
.
lattices
[
arrcidx1
];
var
atname2
=
this
.
lattices
[
arrcidx2
];
var
atnode1
=
this
.
container
.
getChildByName
(
atname1
);
var
atnode2
=
this
.
container
.
getChildByName
(
atname2
);
var
aboutnames
=
this
.
attiondata
[
2
];
if
(
!
atnode1
||
!
atnode2
)
{
this
.
attiondata
=
new
Array
();
return
;
}
var
atpos1
=
MapData
.
getRCPos
(
arrcidx1
.
split
(
"_"
)[
0
],
arrcidx1
.
split
(
"_"
)[
1
]);
var
atpos2
=
MapData
.
getRCPos
(
arrcidx2
.
split
(
"_"
)[
0
],
arrcidx2
.
split
(
"_"
)[
1
]);
engine
.
Tween
.
removeTweens
(
atnode1
);
engine
.
Tween
.
removeTweens
(
atnode2
);
atnode1
.
x
=
atpos1
[
0
];
atnode1
.
y
=
atpos1
[
1
];
atnode2
.
x
=
atpos2
[
0
];
atnode2
.
y
=
atpos2
[
1
];
for
(
var
i
=
0
;
i
<
aboutnames
.
length
;
i
++
)
{
var
ircidx
=
aboutnames
[
i
];
var
iname1
=
this
.
lattices
[
ircidx
];
var
inode1
=
this
.
container
.
getChildByName
(
iname1
);
if
(
inode1
)
{
engine
.
Tween
.
removeTweens
(
inode1
);
var
ipos1
=
MapData
.
getRCPos
(
ircidx
.
split
(
"_"
)[
0
],
ircidx
.
split
(
"_"
)[
1
]);
inode1
.
x
=
ipos1
[
0
];
inode1
.
y
=
ipos1
[
1
];
}
}
this
.
anicontainer
.
removeChild
(
this
.
jiantoucont
);
}
};
GameView
.
prototype
.
selectele
=
function
(
e
)
{
var
data
=
e
.
data
;
var
sr
=
data
.
r
;
var
sc
=
data
.
c
;
var
type
=
data
.
type
;
var
sname
=
sr
+
"_"
+
sc
;
if
(
this
.
useBoom
)
{
if
(
type
==
"mouse_down"
)
{
this
.
unShowEleAttion
();
this
.
boomeEle
(
sr
,
sc
);
}
return
;
}
var
lnewSelect
=
this
.
newSelect
;
var
newCanSel
=
false
;
if
(
this
.
selectArr
.
length
==
0
)
{
newCanSel
=
true
;
}
else
if
(
this
.
selectArr
.
length
==
1
)
{
var
nname
=
this
.
selectArr
[
0
];
if
(
sname
==
nname
)
{
newCanSel
=
false
;
}
else
{
newCanSel
=
true
;
}
}
if
(
type
==
"mouse_down"
)
{
this
.
newSelect
=
true
;
}
else
if
(
type
==
"mouse_move"
)
{
if
(
newCanSel
)
{
this
.
newSelect
=
false
;
}
}
if
((
lnewSelect
||
this
.
newSelect
)
&&
newCanSel
)
;
else
{
return
;
}
this
.
unShowEleAttion
();
if
(
this
.
selectArr
.
length
==
0
)
{
this
.
sptime
=
Date
.
now
();
this
.
seqscore
=
0
;
this
.
selectArr
.
push
(
sname
);
}
else
if
(
this
.
selectArr
.
length
==
1
)
{
var
aselect
=
this
.
selectArr
[
0
];
var
asr
=
aselect
.
split
(
"_"
)[
0
];
var
asc
=
aselect
.
split
(
"_"
)[
1
];
if
((
sr
==
asr
&&
Math
.
abs
(
sc
-
asc
)
==
1
)
||
(
sc
==
asc
&&
Math
.
abs
(
sr
-
asr
)
==
1
))
{
this
.
selectArr
.
push
(
sname
);
}
else
{
if
(
sr
==
asr
&&
sc
==
asc
)
{
this
.
selectArr
=
new
Array
();
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
}
else
{
this
.
selectArr
[
0
]
=
sname
;
}
}
}
if
(
this
.
selectArr
.
length
==
1
)
{
this
.
setSelectShow
();
}
else
if
(
this
.
selectArr
.
length
==
2
)
{
this
.
changeElePos
();
}
};
GameView
.
prototype
.
setSelectShow
=
function
()
{
var
rcname
=
this
.
selectArr
[
0
];
var
r
=
rcname
.
split
(
"_"
)[
0
];
var
c
=
rcname
.
split
(
"_"
)[
1
];
var
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
engine
.
Tween
.
removeTweens
(
this
.
selectimg
);
this
.
anicontainer
.
addChild
(
this
.
selectimg
);
this
.
selectimg
.
x
=
rcpos
[
0
]
-
3
;
this
.
selectimg
.
y
=
rcpos
[
1
]
+
this
.
conty
-
3
;
this
.
startTweenSelectImg
();
};
GameView
.
prototype
.
startTweenSelectImg
=
function
()
{
this
.
selectimg
.
scaleX
=
1
;
this
.
selectimg
.
scaleY
=
1
;
engine
.
Tween
.
get
(
this
.
selectimg
,
{
loop
:
true
})
.
to
({
scaleX
:
0.9
,
scaleY
:
0.9
},
500
)
.
to
({
scaleX
:
1
,
scaleY
:
1
},
500
);
};
GameView
.
prototype
.
changeElePos
=
function
()
{
var
_this
=
this
;
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
changeEnable
(
false
);
var
sname1
=
this
.
selectArr
[
0
];
var
sname2
=
this
.
selectArr
[
1
];
var
sename1
=
this
.
lattices
[
sname1
];
var
sename2
=
this
.
lattices
[
sname2
];
this
.
lattices
[
sname1
]
=
sename2
;
this
.
lattices
[
sname2
]
=
sename1
;
this
.
setLatticeEleRc
(
sname1
);
this
.
setLatticeEleRc
(
sname2
);
this
.
checkEliminate
();
var
snode1
=
this
.
container
.
getChildByName
(
sename1
);
var
snode2
=
this
.
container
.
getChildByName
(
sename2
);
if
(
!
snode1
||
!
snode2
)
{
this
.
selectArr
=
new
Array
();
return
;
}
var
snode1x
=
snode1
.
x
;
var
snode1y
=
snode1
.
y
;
var
snode2x
=
snode2
.
x
;
var
snode2y
=
snode2
.
y
;
var
changetime
=
Math
.
ceil
((
MapData
.
itemsize
/
MapData
.
anispeed
)
*
2
*
1000
);
engine
.
Tween
.
removeTweens
(
snode1
);
engine
.
Tween
.
removeTweens
(
snode2
);
if
(
this
.
eliminateArr
.
length
>
0
)
{
this
.
inEliminate
=
true
;
engine
.
Tween
.
get
(
snode1
).
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
);
engine
.
Tween
.
get
(
snode2
).
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
)
.
call
(
function
()
{
_this
.
eliminate
();
});
}
else
{
engine
.
Tween
.
get
(
snode1
).
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
)
.
wait
(
100
)
.
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
);
engine
.
Tween
.
get
(
snode2
).
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
)
.
wait
(
100
)
.
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
)
.
call
(
function
()
{
_this
.
lattices
[
sname1
]
=
sename1
;
_this
.
lattices
[
sname2
]
=
sename2
;
_this
.
setLatticeEleRc
(
sname1
);
_this
.
setLatticeEleRc
(
sname2
);
_this
.
selectArr
=
new
Array
();
_this
.
recordGame
();
_this
.
changeEnable
(
true
);
_this
.
checkGameOver
(
"changeElePos"
);
});
}
};
GameView
.
prototype
.
eliminate
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
i
,
ielidata1
,
ielileng
,
addscore
,
j
,
ielidata
,
ielidxname
,
ielitype
,
ieliname
,
ielinode
,
ielix
,
ieliy
,
ietype
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
this
.
inEliminate
=
true
;
for
(
i
=
0
;
i
<
this
.
eliminateArr
.
length
;
i
++
)
{
ielidata1
=
this
.
eliminateArr
[
i
];
ielileng
=
ielidata1
.
length
;
addscore
=
0
;
if
(
ielileng
<=
3
)
{
addscore
=
props
.
threeEscore
;
}
else
if
(
ielileng
==
4
)
{
addscore
=
props
.
fourEscore
;
}
else
{
addscore
=
props
.
moreEscore
;
}
this
.
seqscore
+=
addscore
*
ielileng
;
for
(
j
=
0
;
j
<
ielidata1
.
length
;
j
++
)
{
ielidata
=
ielidata1
[
j
];
ielidxname
=
ielidata
.
idxname
;
ielitype
=
ielidata
.
type
;
ieliname
=
this
.
lattices
[
ielidxname
];
ielinode
=
this
.
container
.
getChildByName
(
ieliname
);
if
(
!
ielinode
)
{
continue
;
}
ielix
=
ielinode
.
x
;
ieliy
=
ielinode
.
y
;
ietype
=
ielinode
.
type
;
if
(
this
.
elitype
==
1
)
{
this
.
lattices
[
ielidxname
]
=
"empty"
;
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
goDisplayAni1
(
ielinode
,
ietype
,
ielix
,
ieliy
);
}
else
{
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
,
ietype
);
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
lattices
[
ielidxname
]
=
"empty"
;
this
.
goHomeAni
(
ielitype
,
ielix
,
ieliy
);
}
}
}
return
[
4
,
new
Promise
(
function
(
res
)
{
setTimeout
(
function
()
{
res
();
},
400
);
})];
case
1
:
_a
.
sent
();
this
.
fall
();
return
[
4
,
new
Promise
(
function
(
res1
)
{
setTimeout
(
function
()
{
res1
();
},
500
);
})];
case
2
:
_a
.
sent
();
return
[
2
];
}
});
});
};
GameView
.
prototype
.
fall
=
function
(
type
)
{
if
(
type
===
void
0
)
{
type
=
"normal"
;
}
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
fallData
,
fcutr
,
fc
,
r
,
c
,
idxname
,
elename
,
frcname
,
fetype
,
fele
,
cutr
,
fepos
,
fallPromise
,
_loop_1
,
this_1
,
f
,
isdiedata
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
fallData
=
new
Array
();
fcutr
=
new
Array
();
for
(
fc
=
0
;
fc
<
MapData
.
col
;
fc
++
)
{
fcutr
.
push
(
-
1
);
}
for
(
r
=
MapData
.
row
-
1
;
r
>
-
1
;
r
--
)
{
for
(
c
=
MapData
.
col
-
1
;
c
>
-
1
;
c
--
)
{
idxname
=
r
+
"_"
+
c
;
elename
=
this
.
lattices
[
idxname
];
if
(
elename
==
"empty"
)
{
frcname
=
this
.
getFallRcEle
(
r
,
c
);
if
(
!
frcname
)
{
fetype
=
void
0
;
if
(
type
==
"normal"
)
{
fetype
=
MapData
.
getRandEtype
();
}
else
{
fetype
=
this
.
levelData
[
r
][
c
];
}
fele
=
MapData
.
getOneEle
(
fetype
);
cutr
=
fcutr
[
c
];
fepos
=
MapData
.
getRCPos
(
cutr
,
c
);
fcutr
[
c
]
=
cutr
-
1
;
this
.
container
.
addChild
(
fele
);
fele
.
x
=
fepos
[
0
];
fele
.
y
=
fepos
[
1
];
frcname
=
fele
.
name
;
}
this
.
lattices
[
idxname
]
=
frcname
;
this
.
setLatticeEleRc
(
idxname
);
fallData
.
push
({
rcname
:
frcname
,
trow
:
r
,
tcol
:
c
});
}
}
}
fallPromise
=
new
Array
();
_loop_1
=
function
(
f
)
{
var
fdata
=
fallData
[
f
];
var
frcname
=
fdata
.
rcname
;
var
ftrow
=
fdata
.
trow
;
var
ftcol
=
fdata
.
tcol
;
var
ftpos
=
MapData
.
getRCPos
(
ftrow
,
ftcol
);
var
frcnode
=
this_1
.
container
.
getChildByName
(
frcname
);
if
(
!
frcnode
)
{
return
"continue"
;
}
var
nepos
=
[
frcnode
.
x
,
frcnode
.
y
];
var
fdis
=
MapData
.
getDistance
(
ftpos
,
nepos
);
var
ftime
=
Math
.
ceil
((
fdis
/
MapData
.
anispeed
)
*
1000
);
engine
.
Tween
.
removeTweens
(
frcnode
);
var
ifallpromise
=
new
Promise
(
function
(
res
)
{
engine
.
Tween
.
get
(
frcnode
)
.
to
({
x
:
ftpos
[
0
],
y
:
ftpos
[
1
]
},
ftime
)
.
to
({
scaleY
:
0.85
},
80
)
.
to
({
scaleY
:
1
},
80
)
.
call
(
function
()
{
res
();
});
});
fallPromise
.
push
(
ifallpromise
);
};
this_1
=
this
;
for
(
f
=
0
;
f
<
fallData
.
length
;
f
++
)
{
_loop_1
(
f
);
}
return
[
4
,
Promise
.
all
(
fallPromise
)];
case
1
:
_a
.
sent
();
if
(
type
==
"newlevel"
)
{
this
.
sptime
=
Date
.
now
();
}
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
)
{
return
[
2
,
this
.
eliminate
()];
}
else
{
this
.
selectArr
=
new
Array
();
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
)
{
this
.
inEliminate
=
false
;
if
(
type
!=
"newlevel"
)
{
this
.
recordGame
();
}
this
.
changeEnable
(
true
);
this
.
checkGameOver
(
"fall"
);
}
else
{
this
.
solveDieMap
(
"fall"
);
}
}
return
[
2
];
}
});
});
};
GameView
.
prototype
.
goDisplayAni1
=
function
(
rcele
,
rcetype
,
rcelex
,
rceley
)
{
var
_this
=
this
;
rcele
.
touch
=
false
;
engine
.
Tween
.
removeTweens
(
rcele
);
rcele
.
x
=
rcelex
;
rcele
.
y
=
rceley
;
rcele
.
anchorY
=
MapData
.
itemsize
/
2
;
engine
.
Tween
.
get
(
rcele
)
.
to
({
scaleX
:
0
,
scaleY
:
0
,
alpha
:
0
},
300
)
.
call
(
function
()
{
_this
.
container
.
removeChild
(
rcele
);
MapData
.
recoverEle
(
rcele
,
rcetype
);
});
};
GameView
.
prototype
.
goDisplayAni
=
function
(
ielitype
,
ielix
,
ieliy
)
{
var
_this
=
this
;
var
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
alpha
=
0
;
var
anix
=
ielix
;
var
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
aniele
.
alpha
=
1
;
aniele
.
anchorY
=
MapData
.
itemsize
/
2
;
engine
.
Tween
.
removeTweens
(
aniele
);
engine
.
Tween
.
get
(
aniele
)
.
to
({
scaleX
:
0
,
scaleY
:
0
,
alpha
:
0
},
300
)
.
call
(
function
()
{
_this
.
anicontainer
.
removeChild
(
aniele
);
MapData
.
recoverEle
(
aniele
,
ielitype
);
});
};
GameView
.
prototype
.
goHomeAni
=
function
(
ielitype
,
ielix
,
ieliy
)
{
var
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
alpha
=
0
;
var
anix
=
ielix
;
var
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
aniele
.
alpha
=
1
;
var
anidis
=
MapData
.
getDistance
([
this
.
tanix
,
this
.
taniy
],
[
anix
,
aniy
]);
var
anitime
=
Math
.
ceil
((
anidis
/
MapData
.
anispeed
)
*
1000
);
aniele
.
flyToHome
(
this
.
tanix
,
this
.
taniy
,
anitime
);
};
GameView
.
prototype
.
changeEnable
=
function
(
v
)
{
var
changeable
=
false
;
if
(
this
.
gamestat
==
1
)
{
changeable
=
true
;
}
else
{
if
(
!
v
)
{
changeable
=
true
;
}
}
if
(
changeable
)
{
for
(
var
key
in
this
.
lattices
)
{
var
kname
=
this
.
lattices
[
key
];
var
ele
=
this
.
container
.
getChildByName
(
kname
);
if
(
ele
)
{
ele
.
touch
=
v
;
}
}
if
(
v
)
{
this
.
lastatime
=
Date
.
now
();
this
.
ination
=
false
;
}
}
this
.
canation
=
v
;
};
GameView
.
prototype
.
attionEliShow
=
function
()
{
var
attiondata
=
this
.
attionEliminate
();
if
(
attiondata
&&
attiondata
.
length
==
3
)
{
this
.
ination
=
true
;
this
.
attiondata
=
[
attiondata
[
0
],
attiondata
[
1
],
attiondata
[
2
]];
var
atname1
=
this
.
lattices
[
attiondata
[
0
]];
var
atname2
=
this
.
lattices
[
attiondata
[
1
]];
var
aboutnames
=
attiondata
[
2
];
var
atnode1
=
this
.
container
.
getChildByName
(
atname1
);
var
atnode2
=
this
.
container
.
getChildByName
(
atname2
);
if
(
!
atnode1
||
!
atnode2
)
{
return
;
}
var
atx1
=
atnode1
.
x
;
var
aty1
=
atnode1
.
y
;
var
atx2
=
atnode2
.
x
;
var
aty2
=
atnode2
.
y
;
var
lerpnum
=
0.1
;
var
atpos1
=
[(
atx2
-
atx1
)
*
lerpnum
+
atx1
,
(
aty2
-
aty1
)
*
lerpnum
+
aty1
];
engine
.
Tween
.
removeTweens
(
atnode1
);
engine
.
Tween
.
removeTweens
(
atnode2
);
engine
.
Tween
.
get
(
atnode1
,
{
loop
:
true
}).
to
({
x
:
atpos1
[
0
],
y
:
atpos1
[
1
]
},
500
)
.
to
({
x
:
atx1
,
y
:
aty1
},
500
);
var
jtx
=
(
atx2
-
atx1
)
*
0.5
+
atx1
;
var
jty
=
(
aty2
-
aty1
)
*
0.5
+
aty1
+
this
.
conty
;
var
chax1
=
atx1
-
atpos1
[
0
];
var
chay1
=
aty1
-
atpos1
[
1
];
var
roa1
=
0
;
var
movex1
=
0
;
var
movey1
=
0
;
if
(
Math
.
abs
(
chax1
)
>
Math
.
abs
(
chay1
))
{
jty
+=
25
;
movex1
=
chax1
;
}
else
{
jtx
+=
MapData
.
itemsize
;
roa1
=
90
;
movey1
=
chay1
;
}
for
(
var
i
=
0
;
i
<
aboutnames
.
length
;
i
++
)
{
var
iname1
=
this
.
lattices
[
aboutnames
[
i
]];
var
inode1
=
this
.
container
.
getChildByName
(
iname1
);
engine
.
Tween
.
removeTweens
(
inode1
);
var
iatx1
=
inode1
.
x
;
var
iaty1
=
inode1
.
y
;
if
(
inode1
)
{
engine
.
Tween
.
get
(
inode1
,
{
loop
:
true
})
.
to
({
x
:
iatx1
+
movex1
,
y
:
iaty1
+
movey1
},
500
)
.
to
({
x
:
iatx1
,
y
:
iaty1
},
500
);
}
}
this
.
anicontainer
.
addChild
(
this
.
jiantoucont
);
this
.
jiantoucont
.
x
=
jtx
;
this
.
jiantoucont
.
y
=
jty
;
this
.
jiantoucont
.
rotation
=
roa1
;
this
.
startJtAni
();
}
else
{
this
.
solveDieMap
();
}
};
GameView
.
prototype
.
startJtAni
=
function
()
{
engine
.
Tween
.
removeTweens
(
this
.
jiantou1
);
engine
.
Tween
.
removeTweens
(
this
.
jiantou2
);
this
.
jiantou1
.
x
=
this
.
jtex1
;
this
.
jiantou1
.
y
=
this
.
jtey1
;
this
.
jiantou2
.
x
=
this
.
jtex2
;
this
.
jiantou2
.
y
=
this
.
jtey2
;
this
.
jiantou1
.
alpha
=
1
;
this
.
jiantou2
.
alpha
=
1
;
engine
.
Tween
.
get
(
this
.
jiantou1
,
{
loop
:
true
})
.
to
({
x
:
this
.
jtsx1
,
y
:
this
.
jtsy1
,
alpha
:
0
},
500
)
.
to
({
x
:
this
.
jtex1
,
y
:
this
.
jtey1
,
alpha
:
1
},
500
);
engine
.
Tween
.
get
(
this
.
jiantou2
,
{
loop
:
true
})
.
to
({
x
:
this
.
jtsx2
,
y
:
this
.
jtsy2
,
alpha
:
0
},
500
)
.
to
({
x
:
this
.
jtex2
,
y
:
this
.
jtey2
,
alpha
:
1
},
500
);
};
GameView
.
prototype
.
solveDieMap
=
function
(
type
)
{
if
(
type
===
void
0
)
{
type
=
"normal"
;
}
if
(
this
.
gamestat
!=
1
)
{
if
(
this
.
ingameover
)
{
this
.
inEliminate
=
false
;
this
.
checkGameOver
(
"changeToFuHuoPos222"
);
}
return
;
}
this
.
changeEnable
(
false
);
var
elearr
=
new
Array
();
for
(
var
key
in
this
.
lattices
)
{
var
keyval
=
this
.
lattices
[
key
];
elearr
.
push
(
keyval
);
}
for
(
var
key
in
this
.
lattices
)
{
var
changeval
=
elearr
.
splice
(
Math
.
floor
(
Math
.
random
()
*
elearr
.
length
),
1
)[
0
];
this
.
lattices
[
key
]
=
changeval
;
}
var
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
)
{
this
.
changeToFuHuoPos
(
type
);
}
else
{
return
this
.
solveDieMap
();
}
};
GameView
.
prototype
.
changeToFuHuoPos
=
function
(
type
)
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
prolist
,
key
,
keyval
,
keynode
,
keynodex
,
keynodey
,
tpos
,
ipro
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
prolist
=
new
Array
();
for
(
key
in
this
.
lattices
)
{
keyval
=
this
.
lattices
[
key
];
keynode
=
this
.
container
.
getChildByName
(
keyval
);
if
(
!
keynode
)
{
continue
;
}
keynodex
=
keynode
.
x
;
keynodey
=
keynode
.
y
;
tpos
=
MapData
.
getRCPos
(
key
.
split
(
"_"
)[
0
],
key
.
split
(
"_"
)[
1
]);
ipro
=
keynode
.
changePos
(
tpos
);
prolist
.
push
(
ipro
);
this
.
setLatticeEleRc
(
key
);
}
return
[
4
,
Promise
.
all
(
prolist
)];
case
1
:
_a
.
sent
();
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
)
{
this
.
eliminate
();
}
else
{
if
(
type
==
"fall"
)
{
this
.
recordGame
();
}
this
.
changeEnable
(
true
);
this
.
inEliminate
=
false
;
this
.
checkGameOver
(
"changeToFuHuoPos"
);
}
return
[
2
];
}
});
});
};
GameView
.
prototype
.
recordcomp
=
function
()
{
this
.
inrecord
=
false
;
this
.
checkGameOver
(
"recordcomp"
);
};
GameView
.
prototype
.
recordGame
=
function
()
{
if
(
!
this
.
requestGameOver
)
{
this
.
inrecord
=
true
;
this
.
eptime
=
Date
.
now
();
engine
.
globalEvent
.
dispatchEvent
(
'game-record'
,
{
score
:
this
.
seqscore
,
seq
:
this
.
seq
,
sptime
:
this
.
sptime
,
eptime
:
this
.
eptime
});
this
.
seq
+=
1
;
this
.
seqscore
=
0
;
this
.
sptime
=
Date
.
now
();
}
};
GameView
.
prototype
.
attionEliminate
=
function
()
{
var
attiondata
;
for
(
var
r
=
MapData
.
row
-
1
;
r
>
-
1
;
r
--
)
{
if
(
attiondata
&&
attiondata
.
length
==
3
)
{
break
;
}
for
(
var
c
=
MapData
.
col
-
1
;
c
>
-
1
;
c
--
)
{
var
checktype
=
this
.
getEleTypeByRc
(
r
,
c
);
var
edatarow
=
this
.
getEliminateRow
(
r
,
c
);
var
edatacol
=
this
.
getEliminateCol
(
r
,
c
);
if
(
edatarow
.
length
>
2
||
edatacol
.
length
>
2
)
;
if
(
edatarow
.
length
==
2
)
{
var
releidx1
=
edatarow
[
0
];
var
releidx2
=
edatarow
[
1
];
var
relerow1
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
var
relerow2
=
Number
(
releidx2
.
split
(
"_"
)[
0
]);
var
relecol
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
var
downrow
=
relerow1
+
1
;
var
uprow
=
relerow2
-
1
;
var
rightcol
=
relecol
+
1
;
var
leftcol
=
relecol
-
1
;
var
uprow1
=
relerow2
-
2
;
var
downrow1
=
relerow1
+
2
;
if
(
downrow
<
MapData
.
row
)
{
if
(
rightcol
<
MapData
.
col
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
rightcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
downrow
+
"_"
+
rightcol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
leftcol
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
leftcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
downrow
+
"_"
+
leftcol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
uprow
>
-
1
)
{
if
(
rightcol
<
MapData
.
col
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
rightcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
uprow
+
"_"
+
rightcol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
leftcol
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
leftcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
uprow
+
"_"
+
leftcol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
uprow1
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
uprow1
,
relecol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
uprow1
+
"_"
+
relecol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
downrow1
<
MapData
.
row
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
downrow1
,
relecol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
downrow1
+
"_"
+
relecol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
edatacol
.
length
==
2
)
{
var
releidx1
=
edatacol
[
0
];
var
releidx2
=
edatacol
[
1
];
var
relerow
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
var
relecol1
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
var
relecol2
=
Number
(
releidx2
.
split
(
"_"
)[
1
]);
var
rightcol
=
relecol1
+
1
;
var
leftcol
=
relecol2
-
1
;
var
uprow
=
relerow
-
1
;
var
downrow
=
relerow
+
1
;
var
rightcol1
=
relecol1
+
2
;
var
leftcol1
=
relecol2
-
2
;
if
(
leftcol
>
-
1
)
{
if
(
uprow
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
leftcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
uprow
+
"_"
+
leftcol
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
if
(
downrow
<
MapData
.
row
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
leftcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
downrow
+
"_"
+
leftcol
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
}
if
(
rightcol
<
MapData
.
col
)
{
if
(
uprow
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
rightcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
uprow
+
"_"
+
rightcol
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
if
(
downrow
<
MapData
.
row
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
rightcol
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
downrow
+
"_"
+
rightcol
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
}
if
(
rightcol1
<
MapData
.
col
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
relerow
,
rightcol1
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
relerow
+
"_"
+
rightcol1
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
if
(
leftcol1
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
relerow
,
leftcol1
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
relerow
+
"_"
+
leftcol1
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
}
var
jianrow
=
this
.
getEliminateRowR
(
r
,
c
);
if
(
jianrow
.
length
==
2
)
{
var
jianr
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
0
])
-
1
;
var
jianc
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
1
]);
var
ljianc
=
jianc
-
1
;
if
(
ljianc
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
jianr
,
ljianc
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
jianr
+
"_"
+
ljianc
,
jianr
+
"_"
+
jianc
,
jianrow
];
break
;
}
}
var
rjianc
=
jianc
+
1
;
if
(
rjianc
<
MapData
.
col
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
jianr
,
rjianc
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
jianr
+
"_"
+
rjianc
,
jianr
+
"_"
+
jianc
,
jianrow
];
break
;
}
}
}
var
jiancol
=
this
.
getEliminateRowC
(
r
,
c
);
if
(
jiancol
.
length
==
2
)
{
var
jianr
=
Number
(
jiancol
[
0
].
split
(
"_"
)[
0
]);
var
jianc
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
1
])
-
1
;
var
ujianr
=
jianr
-
1
;
if
(
ujianr
>
-
1
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
ujianr
,
jianc
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
ujianr
+
"_"
+
jianc
,
jianr
+
"_"
+
jianc
,
jiancol
];
break
;
}
}
var
djianr
=
jianr
+
1
;
if
(
djianr
<
MapData
.
row
)
{
var
nexttype
=
this
.
getEleTypeByRc
(
djianr
,
jianc
);
if
(
nexttype
==
checktype
)
{
attiondata
=
[
djianr
+
"_"
+
jianc
,
jianr
+
"_"
+
jianc
,
jiancol
];
break
;
}
}
}
}
}
return
attiondata
;
};
GameView
.
prototype
.
checkEliminate
=
function
()
{
this
.
eliminateArr
=
new
Array
();
for
(
var
r
=
MapData
.
row
-
1
;
r
>
-
1
;
r
--
)
{
for
(
var
c
=
MapData
.
col
-
1
;
c
>
-
1
;
c
--
)
{
var
edata
=
this
.
getEliminate
(
r
,
c
);
if
(
edata
)
{
var
etype
=
edata
.
etype
;
var
earr
=
edata
.
arr
;
this
.
checkAddEli
(
etype
,
earr
);
}
}
}
};
GameView
.
prototype
.
getEliminateRowR
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
jianrow
=
x
-
2
;
var
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
if
(
jianrow
>
-
1
)
{
var
jiantype
=
this
.
getEleTypeByRc
(
jianrow
,
y
);
if
(
jiantype
==
checktype
)
{
relearr
.
push
(
jianrow
+
"_"
+
y
);
}
}
return
relearr
;
};
GameView
.
prototype
.
getEliminateRowC
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
jiancol
=
y
-
2
;
var
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
if
(
jiancol
>
-
1
)
{
var
jiantype
=
this
.
getEleTypeByRc
(
x
,
jiancol
);
if
(
jiantype
==
checktype
)
{
relearr
.
push
(
x
+
"_"
+
jiancol
);
}
}
return
relearr
;
};
GameView
.
prototype
.
getEliminateRow
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
for
(
var
r
=
x
-
1
;
r
>
-
1
;
r
--
)
{
var
reletype
=
this
.
getEleTypeByRc
(
r
,
y
);
if
(
checktype
==
reletype
)
{
relearr
.
push
(
r
+
"_"
+
y
);
}
else
{
break
;
}
}
return
relearr
;
};
GameView
.
prototype
.
getEliminateCol
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
celearr
=
new
Array
();
celearr
.
push
(
x
+
"_"
+
y
);
for
(
var
c
=
y
-
1
;
c
>
-
1
;
c
--
)
{
var
celetype
=
this
.
getEleTypeByRc
(
x
,
c
);
if
(
checktype
==
celetype
)
{
celearr
.
push
(
x
+
"_"
+
c
);
}
else
{
break
;
}
}
return
celearr
;
};
GameView
.
prototype
.
getEliminate
=
function
(
x
,
y
)
{
var
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
var
relearr
=
this
.
getEliminateRow
(
x
,
y
);
var
celearr
=
this
.
getEliminateCol
(
x
,
y
);
var
eliminatearr
=
new
Array
();
if
(
relearr
.
length
>=
3
)
{
eliminatearr
.
push
.
apply
(
eliminatearr
,
relearr
);
}
if
(
celearr
.
length
>=
3
)
{
eliminatearr
.
push
.
apply
(
eliminatearr
,
celearr
);
}
if
(
eliminatearr
.
length
>
0
)
{
return
{
etype
:
checktype
,
arr
:
eliminatearr
};
}
else
{
return
false
;
}
};
GameView
.
prototype
.
getEleTypeByRc
=
function
(
r
,
c
)
{
var
rc
=
r
+
"_"
+
c
;
var
elename
=
this
.
lattices
[
rc
];
var
ele
=
this
.
container
.
getChildByName
(
elename
);
if
(
ele
)
{
var
eletype
=
ele
.
type
;
return
eletype
;
}
};
GameView
.
prototype
.
checkAddEli
=
function
(
etype
,
earr
)
{
var
addnew
=
true
;
var
inaidx
;
for
(
var
i1
=
0
;
i1
<
this
.
eliminateArr
.
length
;
i1
++
)
{
var
i1data
=
this
.
eliminateArr
[
i1
];
for
(
var
i2
=
0
;
i2
<
i1data
.
length
;
i2
++
)
{
var
i2data
=
i1data
[
i2
];
var
i2eliname
=
i2data
.
idxname
;
var
inidx
=
earr
.
indexOf
(
i2eliname
);
if
(
inidx
!=
-
1
)
{
addnew
=
false
;
break
;
}
}
if
(
!
addnew
)
{
inaidx
=
i1
;
break
;
}
}
if
(
addnew
)
{
var
addarr
=
new
Array
();
for
(
var
i1
=
0
;
i1
<
earr
.
length
;
i1
++
)
{
var
i1name
=
earr
[
i1
];
addarr
.
push
({
idxname
:
i1name
,
type
:
etype
});
}
this
.
eliminateArr
.
push
(
addarr
);
}
else
{
for
(
var
i4
=
0
;
i4
<
earr
.
length
;
i4
++
)
{
var
i4name
=
earr
[
i4
];
var
addele
=
true
;
for
(
var
i3
=
0
;
i3
<
this
.
eliminateArr
[
inaidx
].
length
;
i3
++
)
{
var
i3data
=
this
.
eliminateArr
[
inaidx
][
i3
];
var
i3eliname
=
i3data
.
idxname
;
if
(
i3eliname
==
i4name
)
{
addele
=
false
;
break
;
}
}
if
(
addele
)
{
this
.
eliminateArr
[
inaidx
].
push
({
idxname
:
i4name
,
type
:
etype
});
}
}
}
};
GameView
.
prototype
.
getFallRcEle
=
function
(
r
,
c
)
{
for
(
var
fr
=
r
-
1
;
fr
>
-
1
;
fr
--
)
{
var
frc
=
fr
+
"_"
+
c
;
var
frcname
=
this
.
lattices
[
frc
];
if
(
frcname
!=
"empty"
)
{
this
.
lattices
[
frc
]
=
"empty"
;
return
frcname
;
}
}
return
false
;
};
GameView
.
prototype
.
addScoreAni
=
function
(
ielix
,
ieliy
,
ietype
,
addscore
)
{
var
_this
=
this
;
var
anitxt
=
MapData
.
getOneTxt
();
anitxt
.
alpha
=
0
;
var
txtcolor
=
"#bd882f"
;
switch
(
ietype
)
{
case
ElementType
.
gdog
:
txtcolor
=
"#d3ff6d"
;
break
;
case
ElementType
.
pbird
:
txtcolor
=
"#ff51d4"
;
break
;
case
ElementType
.
hniu
:
txtcolor
=
"#ffab55"
;
break
;
case
ElementType
.
bribbit
:
txtcolor
=
"#b3d4ff"
;
break
;
case
ElementType
.
rpig
:
txtcolor
=
"#f2453b"
;
break
;
default
:
console
.
error
(
"未定义类型,检查"
);
break
;
}
anitxt
.
fillColor
=
txtcolor
;
var
anix
=
ielix
+
MapData
.
itemsize
/
2
-
100
;
var
aniy
=
ieliy
+
this
.
conty
+
MapData
.
itemsize
/
2
-
35
;
anitxt
.
text
=
"+"
+
addscore
;
this
.
txtcontainer
.
addChild
(
anitxt
);
anitxt
.
x
=
anix
;
anitxt
.
y
=
aniy
;
anitxt
.
scaleX
=
0
;
anitxt
.
scaleY
=
0
;
anitxt
.
alpha
=
1
;
engine
.
Tween
.
get
(
anitxt
,
{
loop
:
false
}).
set
({
x
:
anix
,
y
:
aniy
,
scaleX
:
0
,
scaleY
:
0
})
.
to
({
y
:
aniy
-
50
,
scaleX
:
1
,
scaleY
:
1
,
},
300
)
.
to
({
y
:
aniy
-
120
,
alpha
:
0
},
500
)
.
call
(
function
()
{
_this
.
txtcontainer
.
removeChild
(
anitxt
);
_this
.
score
+=
addscore
;
MapData
.
recoverTxt
(
anitxt
);
});
};
GameView
.
prototype
.
changeHomeShow
=
function
(
mode
)
{
};
GameView
.
prototype
.
boomeEle
=
function
(
row
,
col
)
{
this
.
useBoom
=
false
;
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
changeEnable
(
false
);
this
.
selectArr
=
new
Array
();
this
.
eliminateArr
=
new
Array
();
for
(
var
r
=
0
;
r
<
MapData
.
row
;
r
++
)
{
var
irc
=
r
+
"_"
+
col
;
var
ielename
=
this
.
lattices
[
irc
];
var
iele
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
)
{
var
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
]);
}
}
for
(
var
c
=
0
;
c
<
MapData
.
col
;
c
++
)
{
if
(
c
!=
col
)
{
var
irc
=
row
+
"_"
+
c
;
var
ielename
=
this
.
lattices
[
irc
];
var
iele
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
)
{
var
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
]);
}
}
}
this
.
eliminate
();
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
function
GameWrapper
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_gameView
=
new
GameView
();
_this
.
addChild
(
_this
.
_gameView
);
engine
.
globalEvent
.
addEventListener
(
'game-init'
,
_this
.
init
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'game-reset'
,
_this
.
reset
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'game-start'
,
_this
.
start
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'game-pause'
,
_this
.
pause
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'game-resume'
,
_this
.
resume
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'game-recordcomp'
,
_this
.
recordcomp
,
_this
);
return
_this
;
}
GameWrapper
.
prototype
.
init
=
function
(
event
)
{
var
time
=
event
.
data
.
time
;
var
level
=
event
.
data
.
level
;
var
mode
=
event
.
data
.
mode
;
this
.
_gameView
.
init
(
time
,
level
,
mode
);
};
GameWrapper
.
prototype
.
reset
=
function
(
event
)
{
var
time
=
event
.
data
.
time
;
var
level
=
event
.
data
.
level
;
var
mode
=
event
.
data
.
mode
;
this
.
_gameView
.
reset
(
time
,
level
,
mode
);
};
GameWrapper
.
prototype
.
start
=
function
()
{
this
.
_gameView
.
start
();
};
GameWrapper
.
prototype
.
pause
=
function
()
{
this
.
_gameView
.
pause
();
};
GameWrapper
.
prototype
.
resume
=
function
()
{
this
.
_gameView
.
resume
();
};
GameWrapper
.
prototype
.
recordcomp
=
function
()
{
this
.
_gameView
.
recordcomp
();
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/rbcxiaoxiaole/debug/main.js.map
0 → 100644
View file @
e29e32b9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/rbcxiaoxiaole/debug/props.js
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2020-01-21.
*/
let
customModuleProps
=
{
};
src/custom/rbcxiaoxiaole/meta.json
0 → 100644
View file @
e29e32b9
{
"name"
:
"消消乐"
,
"desc"
:
"消消乐模块"
,
"props"
:
{
"threeEscore"
:{
"alias"
:
"三消加分"
,
"type"
:
"number"
,
"default"
:
1
},
"fourEscore"
:{
"alias"
:
"四消加分"
,
"type"
:
"number"
,
"default"
:
2
},
"moreEscore"
:{
"alias"
:
"多消加分"
,
"type"
:
"number"
,
"default"
:
3
}
},
"assets"
:
[
{
"name"
:
"底图"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png"
,
"uuid"
:
"map"
,
"ext"
:
".png"
},
{
"name"
:
"狗"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png"
,
"uuid"
:
"gdog"
,
"ext"
:
".png"
},
{
"name"
:
"鸟"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png"
,
"uuid"
:
"pbird"
,
"ext"
:
".png"
},
{
"name"
:
"牛"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png"
,
"uuid"
:
"hniu"
,
"ext"
:
".png"
},
{
"name"
:
"兔子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png"
,
"uuid"
:
"bribbit"
,
"ext"
:
".png"
},
{
"name"
:
"猪"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png"
,
"uuid"
:
"rpig"
,
"ext"
:
".png"
},
{
"name"
:
"选中框"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png"
,
"uuid"
:
"selected"
,
"ext"
:
".png"
},
{
"name"
:
"交换箭头"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png"
,
"uuid"
:
"jiantou"
,
"ext"
:
".png"
},
{
"name"
:
"房子动画"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga"
,
"uuid"
:
"homeani"
,
"ext"
:
".svga"
},
{
"name"
:
"夜晚房子"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/aa9261273423b4b9343b4526b7e5f71a6a35a345.svga"
,
"uuid"
:
"homenight"
,
"ext"
:
".svga"
}
],
"events"
:
{
"in"
:
{
"game-init"
:{
"alias"
:
"初始化第一关"
,
"data"
:
{
}
},
"game-reset"
:
{
"alias"
:
"关卡通过重玩之类的重置关卡"
,
"data"
:
{
}
},
"game-start"
:
{
"alias"
:
"开始"
},
"game-pause"
:
{
"alias"
:
"暂停"
},
"game-resume"
:
{
"alias"
:
"继续"
},
"game-recordcomp"
:
{
"alias"
:
"记录完毕"
}
},
"out"
:
{
"game-score-update"
:
{
"alias"
:
"分数更新"
,
"data"
:
{
"score"
:
"分数"
}
},
"game-time-update"
:
{
"alias"
:
"倒计时更新"
,
"data"
:
{
"time"
:
"剩余时间"
}
},
"game-over"
:
{
"alias"
:
"游戏结束"
,
"data"
:
{
"score"
:
"分数"
,
"reason"
:
"结束原因(1:时间到了,2:过关)"
}
},
"game-record"
:
{
"alias"
:
"游戏记录"
,
"data"
:
{
"score"
:
"操作得分"
,
"seq"
:
"操作步骤号"
,
"sptime"
:
"操纵开始时间"
,
"eptime"
:
"操作结束时间"
}
}
}
}
}
\ No newline at end of file
src/custom/rbcxiaoxiaole/src/game/GameView.ts
0 → 100644
View file @
e29e32b9
/**
* Created by zjz on 2020/7/10.
*/
import
{
props
}
from
"../props"
;
import
{
playSound
,
createSvga
,
getTextureByName
}
from
"./utils"
;
import
ObjectPool
=
engine
.
ObjectPool
;
import
MapData
,
{
GameEvent
,
ElementType
}
from
"./MapData"
;
import
Element
from
"./ele/Element"
;
import
CountDownGroup
from
"../../../recycling/src/game/views/CountDownGroup"
;
export
default
class
GameView
extends
engine
.
Container
{
constructor
()
{
super
();
this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
this
.
setup
,
this
);
}
//元素容器
container
:
engine
.
Container
;
//动画层
anicontainer
:
engine
.
Container
;
//加分文字层
txtcontainer
:
engine
.
Container
;
//格子,位置-name
lattices
=
{};
//一次消除组
eliminateArr
=
[];
//选中
selectArr
=
[];
selectimg
:
engine
.
Image
;
selectw
:
number
;
selecth
:
number
;
//屋子
// homeimgday;
// homeimgnight;
conty
=
140
;
homex
=
562
;
homey
=
-
20
;
tanix
;
taniy
;
//5秒不操作,给提示
lastframeTime
;
attiondata
;
lastatime
;
ination
=
false
;
canation
=
true
;
_gametime
=
60
;
_gamestat
=
2
;
ingameover
=
false
;
jiantou1
:
engine
.
Image
;
jiantou2
:
engine
.
Image
;
jiantoucont
:
engine
.
Container
;
jtsx1
;
jtsy1
;
jtsx2
;
jtsy2
;
jtex1
;
jtey1
;
jtex2
;
jtey2
;
ingame
=
true
;
level
=
0
;
inrecord
=
false
;
requestGameOver
=
false
;
elitype
=
1
;
//1原地消失,2飞到目标位置
set
gamestat
(
stat
){
//1游戏中,2,游戏外
this
.
_gamestat
=
stat
;
if
(
stat
==
2
){
this
.
changeEnable
(
false
);
}
}
get
gamestat
(){
return
this
.
_gamestat
;
}
_seq
=
1
;
set
seq
(
num
){
this
.
_seq
=
num
;
}
get
seq
(){
return
this
.
_seq
;
}
sptime
=
Date
.
now
();
eptime
;
seqscore
;
//使用炸弹
useBoom
:
boolean
=
false
;
setup
()
{
MapData
.
initPoolEle
();
this
.
selectimg
=
new
engine
.
Image
(
getTextureByName
(
"选中框"
));
this
.
selectimg
.
mouseEnabled
=
false
;
this
.
selectw
=
this
.
selectimg
.
texture
.
width
;
this
.
selecth
=
this
.
selectimg
.
texture
.
height
;
this
.
selectimg
.
anchorX
=
this
.
selectw
/
2
;
this
.
selectimg
.
anchorY
=
this
.
selecth
/
2
;
//箭头cont
this
.
jiantou1
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
this
.
jiantou2
=
new
engine
.
Image
(
getTextureByName
(
"交换箭头"
));
this
.
jiantou1
.
mouseEnabled
=
false
;
this
.
jiantou2
.
mouseEnabled
=
false
;
let
jiantwid
=
31
;
let
jianthei
=
24
;
this
.
jiantou1
.
anchorX
=
jiantwid
/
2
;
this
.
jiantou1
.
anchorY
=
jianthei
/
2
;
this
.
jiantou2
.
anchorX
=
jiantwid
/
2
;
this
.
jiantou2
.
anchorY
=
jianthei
/
2
;
this
.
jiantoucont
=
new
engine
.
Container
();
this
.
jiantoucont
.
width
=
MapData
.
itemsize
;
this
.
jiantoucont
.
height
=
MapData
.
itemsize
;
this
.
jtsx1
=
MapData
.
itemsize
/
2
-
jiantwid
/
2
;
this
.
jtsx2
=
MapData
.
itemsize
/
2
-
jiantwid
/
2
;
this
.
jtsy1
=
MapData
.
itemsize
/
2
-
jianthei
;
this
.
jtsy2
=
MapData
.
itemsize
/
2
;
this
.
jtex1
=
this
.
jtsx1
-
10
;
this
.
jtex2
=
this
.
jtsx2
+
10
;
this
.
jtey1
=
this
.
jtsy1
;
this
.
jtey2
=
this
.
jtsy2
;
this
.
jiantou1
.
x
=
this
.
jtsx1
;
this
.
jiantou2
.
rotation
=
180
;
this
.
jiantou2
.
x
=
this
.
jtsx2
;
this
.
jiantou1
.
y
=
this
.
jtsy1
;
this
.
jiantou2
.
y
=
this
.
jtsy2
;
this
.
jiantoucont
.
addChild
(
this
.
jiantou1
);
this
.
jiantoucont
.
addChild
(
this
.
jiantou2
);
let
row
=
MapData
.
row
;
let
col
=
MapData
.
col
;
// this.homeimgday = createSvga("房子动画");
// this.homeimgday.x = this.homex;
// this.homeimgday.y = this.homey;
// this.homeimgday.stop();
// this.homeimgday.visible = false;
// this.addChild(this.homeimgday);
// this.homeimgnight = createSvga("夜晚房子");
// this.homeimgnight.x = this.homex;
// this.homeimgnight.y = this.homey;
// this.homeimgnight.stop();
// this.homeimgnight.visible = false;
// this.addChild(this.homeimgnight);
this
.
container
=
new
engine
.
Container
();
this
.
addChild
(
this
.
container
);
this
.
container
.
y
=
this
.
conty
;
let
maskimg
=
new
engine
.
Graphics
();
this
.
container
.
addChild
(
maskimg
);
this
.
container
.
mask
=
maskimg
;
maskimg
.
moveTo
(
0
,
0
);
maskimg
.
beginFill
(
0
);
maskimg
.
lineTo
(
681
,
0
);
maskimg
.
lineTo
(
681
,
679
);
maskimg
.
lineTo
(
0
,
679
);
maskimg
.
lineTo
(
0
,
0
);
maskimg
.
endFill
();
this
.
anicontainer
=
new
engine
.
Container
();
this
.
addChild
(
this
.
anicontainer
);
this
.
anicontainer
.
mouseEnabled
=
false
;
this
.
anicontainer
.
mouseChildren
=
false
;
this
.
txtcontainer
=
new
engine
.
Container
();
this
.
addChild
(
this
.
txtcontainer
);
let
map
=
new
engine
.
Image
(
getTextureByName
(
"底图"
));
this
.
container
.
addChild
(
map
);
//初始化底图
for
(
let
r
=
0
;
r
<
row
;
r
++
){
for
(
let
c
=
0
;
c
<
col
;
c
++
){
let
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
MapData
.
posData
[
r
+
"_"
+
c
]
=
rcpos
;
}
}
this
.
tanix
=
this
.
homex
+
30
;
this
.
taniy
=
this
.
homey
;
// - MapData.itemsize/2;
engine
.
globalEvent
.
addEventListener
(
GameEvent
.
SelectEle
,
this
.
selectele
,
this
);
this
.
removeEventListener
(
engine
.
Event
.
ADDED_TO_STAGE
,
this
.
setup
,
this
);
this
.
lastframeTime
=
Date
.
now
();
this
.
lastatime
=
Date
.
now
();
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onUpdate
,
this
);
// //测试
// let testbtn = new engine.Label();
// testbtn.text = "reset";
// testbtn.size = 56;
// testbtn.width = 200;
// testbtn.height = 100;
// this.addChild(testbtn);
// testbtn.y = 900;
// testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
//炸弹道具
let
zhadanbtn
=
new
engine
.
Label
();
zhadanbtn
.
text
=
"炸弹"
;
zhadanbtn
.
size
=
56
;
zhadanbtn
.
width
=
200
;
zhadanbtn
.
height
=
100
;
this
.
addChild
(
zhadanbtn
);
zhadanbtn
.
y
=
900
;
zhadanbtn
.
fillColor
=
"red"
;
zhadanbtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
zhadanFunc
,
this
);
//加时间道具
let
timebtn
=
new
engine
.
Label
();
timebtn
.
text
=
"加时"
;
timebtn
.
size
=
56
;
timebtn
.
width
=
200
;
timebtn
.
height
=
100
;
this
.
addChild
(
timebtn
);
timebtn
.
y
=
900
;
timebtn
.
x
=
500
;
timebtn
.
fillColor
=
"red"
;
timebtn
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
addTimeFunc
,
this
);
}
//炸弹
zhadanFunc
(){
this
.
useBoom
=
true
;
}
//加时间
addTimeFunc
(){
console
.
log
(
"加时间"
);
}
changeAni
(){
this
.
changeHomeShow
(
"night"
);
}
playComp
(){
// this.homeimgday.stop(1);
// this.homeimgnight.stop(1);
}
init
(
time
,
level
,
mode
){
this
.
score
=
0
;
this
.
gametime
=
time
;
this
.
seq
=
1
;
this
.
level
=
level
;
this
.
ingameover
=
false
;
this
.
changeHomeShow
(
mode
);
this
.
initContainer
();
this
.
sptime
=
Date
.
now
();
}
_score
=
0
;
set
score
(
num
){
this
.
_score
=
num
;
engine
.
globalEvent
.
dispatchEvent
(
'game-score-update'
,{
score
:
this
.
_score
});
}
get
score
(){
return
this
.
_score
;
}
set
gametime
(
time
){
let
lshowtime
=
Math
.
round
(
this
.
_gametime
);
let
nshowtime
=
Math
.
round
(
time
);
if
(
lshowtime
!=
nshowtime
){
// console.log("倒计时更新",nshowtime);
if
(
this
.
gamestat
==
1
&&
nshowtime
<
1
){
this
.
gameOver
();
}
if
(
nshowtime
<
0
){
nshowtime
=
0
;
}
engine
.
globalEvent
.
dispatchEvent
(
'game-time-update'
,{
time
:
nshowtime
});
}
if
(
time
<
0
){
time
=
0
;
}
this
.
_gametime
=
time
;
}
get
gametime
(){
return
this
.
_gametime
;
}
inEliminate
:
boolean
=
false
;
gameOver
(){
this
.
gamestat
=
2
;
this
.
unShowEleAttion
();
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
ingameover
=
true
;
console
.
log
(
"倒计时结束1============="
,
this
.
ingameover
,
this
.
inEliminate
,
this
.
inrecord
);
this
.
checkGameOver
(
"time-over"
);
};
checkGameOver
(
type
){
if
(
this
.
ingameover
){
console
.
log
(
"倒计时已结束2=========="
,
this
.
inEliminate
,
this
.
inrecord
,
type
);
}
if
(
this
.
ingameover
&&!
this
.
inEliminate
&&!
this
.
inrecord
&&!
this
.
requestGameOver
){
this
.
requestGameOver
=
true
;
this
.
unShowEleAttion
();
this
.
anicontainer
.
removeChild
(
this
.
jiantoucont
);
engine
.
globalEvent
.
dispatchEvent
(
"game-over"
,{
score
:
this
.
score
})
}
}
levelData
;
async
reset
(
time
,
level
,
mode
){
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
selectArr
=
new
Array
();
this
.
gametime
=
time
;
this
.
level
=
level
;
this
.
ingameover
=
false
;
this
.
requestGameOver
=
false
;
this
.
seq
=
1
;
this
.
changeHomeShow
(
mode
);
this
.
changeEnable
(
false
);
for
(
let
key
in
this
.
lattices
){
let
rcname
=
this
.
lattices
[
key
];
let
rcele
:
Element
=
this
.
container
.
getChildByName
(
rcname
);
if
(
rcele
){
let
rcelex
=
rcele
.
x
;
let
rceley
=
rcele
.
y
;
let
rcetype
=
rcele
.
type
;
// this.container.removeChild(rcele);
// MapData.recoverEle(rcele,rcetype);
this
.
lattices
[
key
]
=
"empty"
;
// this.goDisplayAni(rcetype,rcelex,rceley);
this
.
goDisplayAni1
(
rcele
,
rcetype
,
rcelex
,
rceley
);
}
}
let
fallpro
=
new
Promise
(
res
=>
{
setTimeout
(
function
(){
res
();
},
400
);
})
await
fallpro
;
let
testdata
=
MapData
.
levelData
[
this
.
level
];
this
.
levelData
=
testdata
;
this
.
fall
(
"newlevel"
);
}
start
(){
this
.
gamestat
=
1
;
this
.
requestGameOver
=
false
;
this
.
selectArr
=
new
Array
();
this
.
changeEnable
(
true
);
}
pause
(){
// console.log("游戏暂停");
this
.
ingame
=
false
;
}
resume
(){
// console.log("游戏继续");
this
.
lastframeTime
=
Date
.
now
();
this
.
ingame
=
true
;
}
onUpdate
(){
let
ntime
=
Date
.
now
();
if
(
this
.
gamestat
==
1
&&
this
.
ingame
){
let
passtime
=
ntime
-
this
.
lastframeTime
;
if
(
ntime
-
this
.
lastatime
>=
5000
&&!
this
.
ination
&&
this
.
canation
&&
this
.
selectArr
.
length
==
0
){
this
.
attionEliShow
();
}
if
(
this
.
gametime
&&
this
.
gametime
>
0
){
let
ngtime
=
this
.
gametime
-
(
passtime
/
1000
);
this
.
gametime
=
ngtime
;
}
}
// if(this.homeimgday&&this.homeimgday.visible){
// let curframe = this.homeimgday.currentFrame;
// if(curframe==this.homeimgday.totalFrames){
// this.homeimgday.gotoAndStop(1);
// }
// }
// if(this.homeimgnight&&this.homeimgnight.visible){
// let curframe = this.homeimgnight.currentFrame;
// if(curframe==this.homeimgnight.totalFrames){
// this.homeimgnight.gotoAndStop(1);
// }
// }
this
.
lastframeTime
=
ntime
;
}
initContainer
(){
if
(
this
.
lattices
){
for
(
let
key
in
this
.
lattices
){
let
rcname
=
this
.
lattices
[
key
];
let
rcele
:
Element
=
this
.
container
.
getChildByName
(
rcname
);
if
(
rcele
){
let
rcetype
=
rcele
.
type
;
this
.
container
.
removeChild
(
rcele
);
this
.
lattices
[
key
]
=
"empty"
;
MapData
.
recoverEle
(
rcele
,
rcetype
);
}
}
}
else
{
this
.
lattices
=
{};
}
let
testdata
=
MapData
.
levelData
[
this
.
level
];
this
.
levelData
=
testdata
;
for
(
let
r
=
0
;
r
<
testdata
.
length
;
r
++
){
let
rdata
=
testdata
[
r
];
for
(
let
c
=
0
;
c
<
rdata
.
length
;
c
++
){
let
rctype
=
rdata
[
c
];
let
rcele
=
MapData
.
getOneEle
(
rctype
);
let
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
this
.
container
.
addChild
(
rcele
);
rcele
.
x
=
rcpos
[
0
];
rcele
.
y
=
rcpos
[
1
];
let
rcidx
=
r
+
"_"
+
c
;
this
.
lattices
[
rcidx
]
=
rcele
.
name
;
this
.
setLatticeEleRc
(
rcidx
);
}
}
//初始化,检测消除,死图
this
.
checkInit
();
}
checkInit
(){
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
){
return
this
.
eliminate
();
}
else
{
//一次操作完毕
this
.
selectArr
=
new
Array
();
let
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
){
//没死
this
.
changeEnable
(
true
);
}
else
{
//死图处理
this
.
solveDieMap
();
}
//检查死图
}
}
//关联
setLatticeEleRc
(
rcidx
){
let
rename
=
this
.
lattices
[
rcidx
];
let
rcnode
:
Element
=
this
.
container
.
getChildByName
(
rename
);
if
(
rcnode
){
let
er
=
Number
(
rcidx
.
split
(
"_"
)[
0
]);
let
ec
=
Number
(
rcidx
.
split
(
"_"
)[
1
]);
rcnode
.
setrc
(
er
,
ec
);
}
}
//取消提示选择
unShowEleAttion
(){
if
(
this
.
ination
){
this
.
ination
=
false
;
this
.
lastatime
=
Date
.
now
();
let
arrcidx1
=
this
.
attiondata
[
0
];
let
arrcidx2
=
this
.
attiondata
[
1
];
let
atname1
=
this
.
lattices
[
arrcidx1
];
let
atname2
=
this
.
lattices
[
arrcidx2
];
let
atnode1
:
Element
=
this
.
container
.
getChildByName
(
atname1
);
let
atnode2
:
Element
=
this
.
container
.
getChildByName
(
atname2
);
let
aboutnames
=
this
.
attiondata
[
2
];
if
(
!
atnode1
||!
atnode2
){
this
.
attiondata
=
new
Array
();
return
;
}
let
atpos1
=
MapData
.
getRCPos
(
arrcidx1
.
split
(
"_"
)[
0
],
arrcidx1
.
split
(
"_"
)[
1
]);
let
atpos2
=
MapData
.
getRCPos
(
arrcidx2
.
split
(
"_"
)[
0
],
arrcidx2
.
split
(
"_"
)[
1
]);
engine
.
Tween
.
removeTweens
(
atnode1
);
engine
.
Tween
.
removeTweens
(
atnode2
);
atnode1
.
x
=
atpos1
[
0
];
atnode1
.
y
=
atpos1
[
1
];
atnode2
.
x
=
atpos2
[
0
];
atnode2
.
y
=
atpos2
[
1
];
for
(
let
i
=
0
;
i
<
aboutnames
.
length
;
i
++
){
let
ircidx
=
aboutnames
[
i
];
let
iname1
=
this
.
lattices
[
ircidx
];
let
inode1
:
Element
=
this
.
container
.
getChildByName
(
iname1
);
if
(
inode1
){
engine
.
Tween
.
removeTweens
(
inode1
);
let
ipos1
=
MapData
.
getRCPos
(
ircidx
.
split
(
"_"
)[
0
],
ircidx
.
split
(
"_"
)[
1
]);
inode1
.
x
=
ipos1
[
0
];
inode1
.
y
=
ipos1
[
1
];
}
}
this
.
anicontainer
.
removeChild
(
this
.
jiantoucont
);
}
}
newSelect
:
boolean
=
false
;
//选择元素
selectele
(
e
:
engine
.
Event
){
let
data
=
e
.
data
;
let
sr
=
data
.
r
;
let
sc
=
data
.
c
;
let
type
=
data
.
type
;
let
sname
=
sr
+
"_"
+
sc
;
//使用炸弹
if
(
this
.
useBoom
){
if
(
type
==
"mouse_down"
){
this
.
unShowEleAttion
();
this
.
boomeEle
(
sr
,
sc
);
}
return
;
}
//新增滑动操作
let
lnewSelect
=
this
.
newSelect
;
let
newCanSel
=
false
;
if
(
this
.
selectArr
.
length
==
0
){
newCanSel
=
true
;
}
else
if
(
this
.
selectArr
.
length
==
1
){
let
nname
=
this
.
selectArr
[
0
];
if
(
sname
==
nname
){
newCanSel
=
false
}
else
{
newCanSel
=
true
;
}
}
if
(
type
==
"mouse_down"
){
this
.
newSelect
=
true
;
}
else
if
(
type
==
"mouse_move"
){
if
(
newCanSel
){
this
.
newSelect
=
false
;
}
}
// console.log(lnewSelect,this.newSelect,newCanSel,type,this.selectArr.length,sname);
if
((
lnewSelect
||
this
.
newSelect
)
&&
newCanSel
){
}
else
{
return
;
}
// console.log("continue");
this
.
unShowEleAttion
();
if
(
this
.
selectArr
.
length
==
0
){
// console.log("选中元素",data);
this
.
sptime
=
Date
.
now
();
this
.
seqscore
=
0
;
this
.
selectArr
.
push
(
sname
);
}
else
if
(
this
.
selectArr
.
length
==
1
){
let
aselect
=
this
.
selectArr
[
0
];
let
asr
=
aselect
.
split
(
"_"
)[
0
];
let
asc
=
aselect
.
split
(
"_"
)[
1
];
if
((
sr
==
asr
&&
Math
.
abs
(
sc
-
asc
)
==
1
)
||
(
sc
==
asc
&&
Math
.
abs
(
sr
-
asr
)
==
1
)){
this
.
selectArr
.
push
(
sname
);
}
else
{
//重选自己,取消选择,否则选中新的
if
(
sr
==
asr
&&
sc
==
asc
){
this
.
selectArr
=
new
Array
();
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
}
else
{
this
.
selectArr
[
0
]
=
sname
;
}
}
}
if
(
this
.
selectArr
.
length
==
1
){
this
.
setSelectShow
();
}
else
if
(
this
.
selectArr
.
length
==
2
){
this
.
changeElePos
();
}
}
setSelectShow
(){
let
rcname
=
this
.
selectArr
[
0
];
let
r
=
rcname
.
split
(
"_"
)[
0
];
let
c
=
rcname
.
split
(
"_"
)[
1
];
let
rcpos
=
MapData
.
getRCPos
(
r
,
c
);
engine
.
Tween
.
removeTweens
(
this
.
selectimg
);
this
.
anicontainer
.
addChild
(
this
.
selectimg
);
this
.
selectimg
.
x
=
rcpos
[
0
]
-
3
;
this
.
selectimg
.
y
=
rcpos
[
1
]
+
this
.
conty
-
3
;
this
.
startTweenSelectImg
()
}
startTweenSelectImg
(){
this
.
selectimg
.
scaleX
=
1
;
this
.
selectimg
.
scaleY
=
1
;
engine
.
Tween
.
get
(
this
.
selectimg
,{
loop
:
true
})
.
to
({
scaleX
:
0.9
,
scaleY
:
0.9
},
500
)
.
to
({
scaleX
:
1
,
scaleY
:
1
},
500
);
}
changeElePos
(){
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
changeEnable
(
false
);
let
sname1
=
this
.
selectArr
[
0
];
let
sname2
=
this
.
selectArr
[
1
];
let
sename1
=
this
.
lattices
[
sname1
];
let
sename2
=
this
.
lattices
[
sname2
];
// console.log("交换测试",sname1,sname2,this.lattices);
this
.
lattices
[
sname1
]
=
sename2
;
this
.
lattices
[
sname2
]
=
sename1
;
this
.
setLatticeEleRc
(
sname1
);
this
.
setLatticeEleRc
(
sname2
);
this
.
checkEliminate
();
let
snode1
=
this
.
container
.
getChildByName
(
sename1
);
let
snode2
=
this
.
container
.
getChildByName
(
sename2
);
if
(
!
snode1
||!
snode2
){
this
.
selectArr
=
new
Array
();
return
;
}
let
snode1x
=
snode1
.
x
;
let
snode1y
=
snode1
.
y
;
let
snode2x
=
snode2
.
x
;
let
snode2y
=
snode2
.
y
;
let
changetime
=
Math
.
ceil
((
MapData
.
itemsize
/
MapData
.
anispeed
)
*
2
*
1000
);
engine
.
Tween
.
removeTweens
(
snode1
);
engine
.
Tween
.
removeTweens
(
snode2
);
if
(
this
.
eliminateArr
.
length
>
0
){
this
.
inEliminate
=
true
;
engine
.
Tween
.
get
(
snode1
).
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
)
engine
.
Tween
.
get
(
snode2
).
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
)
.
call
(()
=>
{
this
.
eliminate
();
})
}
else
{
engine
.
Tween
.
get
(
snode1
).
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
)
.
wait
(
100
)
.
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
)
engine
.
Tween
.
get
(
snode2
).
to
({
x
:
snode1x
,
y
:
snode1y
},
changetime
)
.
wait
(
100
)
.
to
({
x
:
snode2x
,
y
:
snode2y
},
changetime
)
.
call
(()
=>
{
this
.
lattices
[
sname1
]
=
sename1
;
this
.
lattices
[
sname2
]
=
sename2
;
this
.
setLatticeEleRc
(
sname1
);
this
.
setLatticeEleRc
(
sname2
);
this
.
selectArr
=
new
Array
();
this
.
recordGame
();
this
.
changeEnable
(
true
);
this
.
checkGameOver
(
"changeElePos"
);
})
}
}
//消除
async
eliminate
(){
this
.
inEliminate
=
true
;
for
(
let
i
=
0
;
i
<
this
.
eliminateArr
.
length
;
i
++
){
let
ielidata1
=
this
.
eliminateArr
[
i
];
let
ielileng
=
ielidata1
.
length
;
let
addscore
=
0
;
if
(
ielileng
<=
3
){
addscore
=
props
.
threeEscore
;
}
else
if
(
ielileng
==
4
){
addscore
=
props
.
fourEscore
;
}
else
{
addscore
=
props
.
moreEscore
;
}
// console.log("消除单个加分",addscore);
this
.
seqscore
+=
addscore
*
ielileng
;
for
(
let
j
=
0
;
j
<
ielidata1
.
length
;
j
++
){
let
ielidata
=
ielidata1
[
j
];
let
ielidxname
=
ielidata
.
idxname
;
let
ielitype
=
ielidata
.
type
;
let
ieliname
=
this
.
lattices
[
ielidxname
];
let
ielinode
:
Element
=
this
.
container
.
getChildByName
(
ieliname
);
if
(
!
ielinode
){
continue
;
}
let
ielix
=
ielinode
.
x
;
let
ieliy
=
ielinode
.
y
;
let
ietype
=
ielinode
.
type
;
if
(
this
.
elitype
==
1
){
//原地消失
this
.
lattices
[
ielidxname
]
=
"empty"
;
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
goDisplayAni1
(
ielinode
,
ietype
,
ielix
,
ieliy
);
}
else
{
//飞到目标位置
this
.
container
.
removeChild
(
ielinode
);
MapData
.
recoverEle
(
ielinode
,
ietype
);
this
.
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
);
this
.
lattices
[
ielidxname
]
=
"empty"
;
//元素层消除,动画层添加
this
.
goHomeAni
(
ielitype
,
ielix
,
ieliy
);
}
}
}
await
new
Promise
(
res
=>
{
setTimeout
(
function
(){
res
();
},
400
);
})
this
.
fall
();
await
new
Promise
(
res1
=>
{
setTimeout
(
function
(){
res1
();
},
500
)
})
// this.homeimgday.play(1,1);
// this.homeimgnight.play(1,1);
}
//掉落
async
fall
(
type
=
"normal"
){
let
fallData
=
new
Array
();
let
fcutr
=
new
Array
();
for
(
let
fc
=
0
;
fc
<
MapData
.
col
;
fc
++
){
fcutr
.
push
(
-
1
);
}
for
(
let
r
=
MapData
.
row
-
1
;
r
>-
1
;
r
--
){
for
(
let
c
=
MapData
.
col
-
1
;
c
>-
1
;
c
--
){
let
idxname
=
r
+
"_"
+
c
;
let
elename
=
this
.
lattices
[
idxname
];
if
(
elename
==
"empty"
){
let
frcname
=
this
.
getFallRcEle
(
r
,
c
);
if
(
!
frcname
){
let
fetype
;
if
(
type
==
"normal"
){
fetype
=
MapData
.
getRandEtype
();
}
else
{
fetype
=
this
.
levelData
[
r
][
c
];
}
let
fele
=
MapData
.
getOneEle
(
fetype
);
let
cutr
=
fcutr
[
c
];
let
fepos
=
MapData
.
getRCPos
(
cutr
,
c
);
fcutr
[
c
]
=
cutr
-
1
;
this
.
container
.
addChild
(
fele
);
fele
.
x
=
fepos
[
0
];
fele
.
y
=
fepos
[
1
];
frcname
=
fele
.
name
;
}
this
.
lattices
[
idxname
]
=
frcname
;
this
.
setLatticeEleRc
(
idxname
);
fallData
.
push
({
rcname
:
frcname
,
trow
:
r
,
tcol
:
c
});
}
}
}
// return;
// console.log("动画掉落组准备完毕",fallData);
let
fallPromise
=
new
Array
();
for
(
let
f
=
0
;
f
<
fallData
.
length
;
f
++
){
let
fdata
=
fallData
[
f
];
let
frcname
=
fdata
.
rcname
;
let
ftrow
=
fdata
.
trow
;
let
ftcol
=
fdata
.
tcol
;
let
ftpos
=
MapData
.
getRCPos
(
ftrow
,
ftcol
);
let
frcnode
=
this
.
container
.
getChildByName
(
frcname
);
if
(
!
frcnode
){
continue
;
}
let
nepos
=
[
frcnode
.
x
,
frcnode
.
y
];
let
fdis
=
MapData
.
getDistance
(
ftpos
,
nepos
);
let
ftime
=
Math
.
ceil
((
fdis
/
MapData
.
anispeed
)
*
1000
);
engine
.
Tween
.
removeTweens
(
frcnode
);
let
ifallpromise
=
new
Promise
(
res
=>
{
engine
.
Tween
.
get
(
frcnode
)
.
to
({
x
:
ftpos
[
0
],
y
:
ftpos
[
1
]
},
ftime
)
.
to
({
scaleY
:
0.85
},
80
)
.
to
({
scaleY
:
1
},
80
)
.
call
(()
=>
{
res
();
})
})
fallPromise
.
push
(
ifallpromise
);
}
await
Promise
.
all
(
fallPromise
);
if
(
type
==
"newlevel"
){
this
.
sptime
=
Date
.
now
();
}
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
){
return
this
.
eliminate
();
}
else
{
//一次操作完毕
this
.
selectArr
=
new
Array
();
let
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
){
//没死
this
.
inEliminate
=
false
;
if
(
type
!=
"newlevel"
){
this
.
recordGame
();
}
this
.
changeEnable
(
true
);
this
.
checkGameOver
(
"fall"
);
}
else
{
//死图处理
this
.
solveDieMap
(
"fall"
);
}
//检查死图
}
}
//原地显示改
goDisplayAni1
(
rcele
:
Element
,
rcetype
:
ElementType
,
rcelex
,
rceley
){
rcele
.
touch
=
false
;
engine
.
Tween
.
removeTweens
(
rcele
);
rcele
.
x
=
rcelex
;
rcele
.
y
=
rceley
;
rcele
.
anchorY
=
MapData
.
itemsize
/
2
;
engine
.
Tween
.
get
(
rcele
)
.
to
({
scaleX
:
0
,
scaleY
:
0
,
alpha
:
0
},
300
)
.
call
(()
=>
{
this
.
container
.
removeChild
(
rcele
);
MapData
.
recoverEle
(
rcele
,
rcetype
);
})
}
//原地消失
goDisplayAni
(
ielitype
,
ielix
,
ieliy
){
// console.log("老原地消失");
let
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
alpha
=
0
;
let
anix
=
ielix
;
let
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
aniele
.
alpha
=
1
;
aniele
.
anchorY
=
MapData
.
itemsize
/
2
;
engine
.
Tween
.
removeTweens
(
aniele
);
engine
.
Tween
.
get
(
aniele
)
.
to
({
scaleX
:
0
,
scaleY
:
0
,
alpha
:
0
},
300
)
.
call
(()
=>
{
this
.
anicontainer
.
removeChild
(
aniele
);
MapData
.
recoverEle
(
aniele
,
ielitype
);
})
}
//飞到小屋
goHomeAni
(
ielitype
,
ielix
,
ieliy
){
let
aniele
=
MapData
.
getOneEle
(
ielitype
);
aniele
.
alpha
=
0
;
let
anix
=
ielix
;
let
aniy
=
ieliy
+
this
.
conty
;
this
.
anicontainer
.
addChild
(
aniele
);
aniele
.
touch
=
false
;
aniele
.
x
=
anix
;
aniele
.
y
=
aniy
;
aniele
.
alpha
=
1
;
let
anidis
=
MapData
.
getDistance
([
this
.
tanix
,
this
.
taniy
],[
anix
,
aniy
]);
let
anitime
=
Math
.
ceil
((
anidis
/
MapData
.
anispeed
)
*
1000
);
aniele
.
flyToHome
(
this
.
tanix
,
this
.
taniy
,
anitime
);
}
//修改元素点击
changeEnable
(
v
:
boolean
){
let
changeable
=
false
;
if
(
this
.
gamestat
==
1
){
changeable
=
true
;
}
else
{
if
(
!
v
){
changeable
=
true
;
}
}
if
(
changeable
){
for
(
let
key
in
this
.
lattices
){
let
kname
=
this
.
lattices
[
key
];
let
ele
:
Element
=
this
.
container
.
getChildByName
(
kname
);
if
(
ele
){
ele
.
touch
=
v
;
}
}
if
(
v
){
this
.
lastatime
=
Date
.
now
();
this
.
ination
=
false
;
}
}
this
.
canation
=
v
;
}
//相邻显性提示
attionEliShow
(){
let
attiondata
=
this
.
attionEliminate
();
// console.log("测试333",attiondata);
if
(
attiondata
&&
attiondata
.
length
==
3
){
this
.
ination
=
true
;
this
.
attiondata
=
[
attiondata
[
0
],
attiondata
[
1
],
attiondata
[
2
]];
let
atname1
=
this
.
lattices
[
attiondata
[
0
]];
let
atname2
=
this
.
lattices
[
attiondata
[
1
]];
let
aboutnames
=
attiondata
[
2
];
let
atnode1
:
Element
=
this
.
container
.
getChildByName
(
atname1
);
let
atnode2
:
Element
=
this
.
container
.
getChildByName
(
atname2
);
if
(
!
atnode1
||!
atnode2
){
return
;
}
let
atx1
=
atnode1
.
x
;
let
aty1
=
atnode1
.
y
;
let
atx2
=
atnode2
.
x
;
let
aty2
=
atnode2
.
y
;
let
lerpnum
=
0.1
;
let
atpos1
=
[(
atx2
-
atx1
)
*
lerpnum
+
atx1
,(
aty2
-
aty1
)
*
lerpnum
+
aty1
];
let
atpos2
=
[(
atx1
-
atx2
)
*
lerpnum
+
atx2
,(
aty1
-
aty2
)
*
lerpnum
+
aty2
];
engine
.
Tween
.
removeTweens
(
atnode1
);
engine
.
Tween
.
removeTweens
(
atnode2
);
engine
.
Tween
.
get
(
atnode1
,{
loop
:
true
}).
to
({
x
:
atpos1
[
0
],
y
:
atpos1
[
1
]
},
500
)
.
to
({
x
:
atx1
,
y
:
aty1
},
500
);
//箭头动画
let
jtx
=
(
atx2
-
atx1
)
*
0.5
+
atx1
;
let
jty
=
(
aty2
-
aty1
)
*
0.5
+
aty1
+
this
.
conty
;
let
chax1
=
atx1
-
atpos1
[
0
];
let
chay1
=
aty1
-
atpos1
[
1
];
let
roa1
=
0
;
let
movex1
=
0
;
let
movey1
=
0
;
if
(
Math
.
abs
(
chax1
)
>
Math
.
abs
(
chay1
)){
jty
+=
25
;
// console.log("横向移动");
movex1
=
chax1
;
}
else
{
jtx
+=
MapData
.
itemsize
;
roa1
=
90
;
movey1
=
chay1
;
// console.log("竖向移动");
}
// console.log("位移llll",aboutnames);
for
(
let
i
=
0
;
i
<
aboutnames
.
length
;
i
++
){
let
iname1
=
this
.
lattices
[
aboutnames
[
i
]];
let
inode1
:
Element
=
this
.
container
.
getChildByName
(
iname1
);
engine
.
Tween
.
removeTweens
(
inode1
);
let
iatx1
=
inode1
.
x
;
let
iaty1
=
inode1
.
y
;
if
(
inode1
){
engine
.
Tween
.
get
(
inode1
,{
loop
:
true
})
.
to
({
x
:
iatx1
+
movex1
,
y
:
iaty1
+
movey1
},
500
)
.
to
({
x
:
iatx1
,
y
:
iaty1
},
500
)
}
}
// engine.Tween.get(atnode2,{loop:true})
// .to({
// x:atpos2[0],
// y:atpos2[1]
// },500)
// .to({
// x:atx2,
// y:aty2
// },500);
this
.
anicontainer
.
addChild
(
this
.
jiantoucont
);
this
.
jiantoucont
.
x
=
jtx
;
this
.
jiantoucont
.
y
=
jty
;
this
.
jiantoucont
.
rotation
=
roa1
;
this
.
startJtAni
();
}
else
{
//死图处理
this
.
solveDieMap
();
}
}
startJtAni
(){
engine
.
Tween
.
removeTweens
(
this
.
jiantou1
);
engine
.
Tween
.
removeTweens
(
this
.
jiantou2
);
this
.
jiantou1
.
x
=
this
.
jtex1
;
this
.
jiantou1
.
y
=
this
.
jtey1
;
this
.
jiantou2
.
x
=
this
.
jtex2
;
this
.
jiantou2
.
y
=
this
.
jtey2
;
this
.
jiantou1
.
alpha
=
1
;
this
.
jiantou2
.
alpha
=
1
;
// console.log("欢动测试",this.jtsx1,this.jtsy1,this.jtex1,this.jtey1);
// return;
engine
.
Tween
.
get
(
this
.
jiantou1
,{
loop
:
true
})
.
to
({
x
:
this
.
jtsx1
,
y
:
this
.
jtsy1
,
alpha
:
0
},
500
)
.
to
({
x
:
this
.
jtex1
,
y
:
this
.
jtey1
,
alpha
:
1
},
500
)
engine
.
Tween
.
get
(
this
.
jiantou2
,{
loop
:
true
})
.
to
({
x
:
this
.
jtsx2
,
y
:
this
.
jtsy2
,
alpha
:
0
},
500
)
.
to
({
x
:
this
.
jtex2
,
y
:
this
.
jtey2
,
alpha
:
1
},
500
)
}
//死图调整
solveDieMap
(
type
=
"normal"
){
if
(
this
.
gamestat
!=
1
){
if
(
this
.
ingameover
){
this
.
inEliminate
=
false
;
this
.
checkGameOver
(
"changeToFuHuoPos222"
);
}
return
;
}
this
.
changeEnable
(
false
);
// console.error("死图调整");
// console.log(this.lattices);
// return false;
let
elearr
=
new
Array
();
for
(
let
key
in
this
.
lattices
){
let
keyval
=
this
.
lattices
[
key
];
elearr
.
push
(
keyval
);
}
for
(
let
key
in
this
.
lattices
){
let
changeval
=
elearr
.
splice
(
Math
.
floor
(
Math
.
random
()
*
elearr
.
length
),
1
)[
0
];
this
.
lattices
[
key
]
=
changeval
;
}
let
isdiedata
=
this
.
attionEliminate
();
if
(
isdiedata
&&
isdiedata
.
length
==
3
){
// console.error("可以复活了,转移位置");
this
.
changeToFuHuoPos
(
type
);
}
else
{
// console.error("依然死亡,寻求复活");
return
this
.
solveDieMap
();
}
}
//转移到复活pos
async
changeToFuHuoPos
(
type
){
let
prolist
=
new
Array
();
for
(
let
key
in
this
.
lattices
){
let
keyval
=
this
.
lattices
[
key
];
var
keynode
:
Element
=
this
.
container
.
getChildByName
(
keyval
);
if
(
!
keynode
){
continue
;
}
let
keynodex
=
keynode
.
x
;
let
keynodey
=
keynode
.
y
;
let
tpos
=
MapData
.
getRCPos
(
key
.
split
(
"_"
)[
0
],
key
.
split
(
"_"
)[
1
]);
let
ipro
=
keynode
.
changePos
(
tpos
);
prolist
.
push
(
ipro
);
this
.
setLatticeEleRc
(
key
);
}
await
Promise
.
all
(
prolist
)
this
.
checkEliminate
();
if
(
this
.
eliminateArr
.
length
>
0
){
this
.
eliminate
();
}
else
{
if
(
type
==
"fall"
){
this
.
recordGame
();
}
this
.
changeEnable
(
true
);
this
.
inEliminate
=
false
;
this
.
checkGameOver
(
"changeToFuHuoPos"
);
}
}
recordcomp
(){
this
.
inrecord
=
false
;
this
.
checkGameOver
(
"recordcomp"
);
}
//游戏记录
recordGame
(){
if
(
!
this
.
requestGameOver
){
//操作记录
this
.
inrecord
=
true
;
this
.
eptime
=
Date
.
now
();
engine
.
globalEvent
.
dispatchEvent
(
'game-record'
,
{
score
:
this
.
seqscore
,
seq
:
this
.
seq
,
sptime
:
this
.
sptime
,
eptime
:
this
.
eptime
}
);
this
.
seq
+=
1
;
this
.
seqscore
=
0
;
this
.
sptime
=
Date
.
now
();
}
}
//相邻检测
attionEliminate
(){
let
attiondata
;
for
(
let
r
=
MapData
.
row
-
1
;
r
>-
1
;
r
--
){
if
(
attiondata
&&
attiondata
.
length
==
3
){
break
;
}
for
(
let
c
=
MapData
.
col
-
1
;
c
>-
1
;
c
--
){
let
checktype
=
this
.
getEleTypeByRc
(
r
,
c
);
let
edatarow
=
this
.
getEliminateRow
(
r
,
c
);
let
edatacol
=
this
.
getEliminateCol
(
r
,
c
);
if
(
edatarow
.
length
>
2
||
edatacol
.
length
>
2
){
// console.error("啥情况,检查----------------");
}
if
(
edatarow
.
length
==
2
){
// console.log("横向查找",edatarow,checktype);
let
releidx1
=
edatarow
[
0
];
let
releidx2
=
edatarow
[
1
];
let
relerow1
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
let
relerow2
=
Number
(
releidx2
.
split
(
"_"
)[
0
]);
let
relecol
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
let
downrow
=
relerow1
+
1
;
let
uprow
=
relerow2
-
1
;
let
rightcol
=
relecol
+
1
;
let
leftcol
=
relecol
-
1
;
let
uprow1
=
relerow2
-
2
;
let
downrow1
=
relerow1
+
2
;
if
(
downrow
<
MapData
.
row
){
if
(
rightcol
<
MapData
.
col
){
let
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
rightcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
downrow
+
"_"
+
rightcol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
leftcol
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
leftcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
downrow
+
"_"
+
leftcol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
uprow
>-
1
){
if
(
rightcol
<
MapData
.
col
){
let
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
rightcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
uprow
+
"_"
+
rightcol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
leftcol
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
leftcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
uprow
+
"_"
+
leftcol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
uprow1
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
uprow1
,
relecol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
uprow1
+
"_"
+
relecol
,
uprow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
if
(
downrow1
<
MapData
.
row
){
let
nexttype
=
this
.
getEleTypeByRc
(
downrow1
,
relecol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
downrow1
+
"_"
+
relecol
,
downrow
+
"_"
+
relecol
,
edatarow
];
break
;
}
}
}
if
(
edatacol
.
length
==
2
){
// console.log("竖向查找",edatacol,checktype);
let
releidx1
=
edatacol
[
0
];
let
releidx2
=
edatacol
[
1
];
let
relerow
=
Number
(
releidx1
.
split
(
"_"
)[
0
]);
let
relecol1
=
Number
(
releidx1
.
split
(
"_"
)[
1
]);
let
relecol2
=
Number
(
releidx2
.
split
(
"_"
)[
1
]);
let
rightcol
=
relecol1
+
1
;
let
leftcol
=
relecol2
-
1
;
let
uprow
=
relerow
-
1
;
let
downrow
=
relerow
+
1
;
let
rightcol1
=
relecol1
+
2
;
let
leftcol1
=
relecol2
-
2
;
if
(
leftcol
>-
1
){
if
(
uprow
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
leftcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
uprow
+
"_"
+
leftcol
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
if
(
downrow
<
MapData
.
row
){
let
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
leftcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
downrow
+
"_"
+
leftcol
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
}
if
(
rightcol
<
MapData
.
col
){
if
(
uprow
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
uprow
,
rightcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
uprow
+
"_"
+
rightcol
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
if
(
downrow
<
MapData
.
row
){
let
nexttype
=
this
.
getEleTypeByRc
(
downrow
,
rightcol
);
if
(
nexttype
==
checktype
){
attiondata
=
[
downrow
+
"_"
+
rightcol
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
}
if
(
rightcol1
<
MapData
.
col
){
let
nexttype
=
this
.
getEleTypeByRc
(
relerow
,
rightcol1
);
if
(
nexttype
==
checktype
){
attiondata
=
[
relerow
+
"_"
+
rightcol1
,
relerow
+
"_"
+
rightcol
,
edatacol
];
break
;
}
}
if
(
leftcol1
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
relerow
,
leftcol1
);
if
(
nexttype
==
checktype
){
attiondata
=
[
relerow
+
"_"
+
leftcol1
,
relerow
+
"_"
+
leftcol
,
edatacol
];
break
;
}
}
// console.log("竖向检查啦啦啦",relerow,relecol1,relecol2);
}
//中间插的,俩边一样的这种
let
jianrow
=
this
.
getEliminateRowR
(
r
,
c
);
if
(
jianrow
.
length
==
2
){
// console.log("中间插入33",jianrow);
let
jianr
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
0
])
-
1
;
let
jianc
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
1
]);
let
ljianc
=
jianc
-
1
;
if
(
ljianc
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
jianr
,
ljianc
);
if
(
nexttype
==
checktype
){
attiondata
=
[
jianr
+
"_"
+
ljianc
,
jianr
+
"_"
+
jianc
,
jianrow
];
break
;
}
}
let
rjianc
=
jianc
+
1
;
if
(
rjianc
<
MapData
.
col
){
let
nexttype
=
this
.
getEleTypeByRc
(
jianr
,
rjianc
);
if
(
nexttype
==
checktype
){
attiondata
=
[
jianr
+
"_"
+
rjianc
,
jianr
+
"_"
+
jianc
,
jianrow
];
break
;
}
}
}
let
jiancol
=
this
.
getEliminateRowC
(
r
,
c
);
if
(
jiancol
.
length
==
2
){
// console.log("中间插入44",jiancol);
let
jianr
=
Number
(
jiancol
[
0
].
split
(
"_"
)[
0
]);
let
jianc
=
Number
(
jianrow
[
0
].
split
(
"_"
)[
1
])
-
1
;
let
ujianr
=
jianr
-
1
;
if
(
ujianr
>-
1
){
let
nexttype
=
this
.
getEleTypeByRc
(
ujianr
,
jianc
);
if
(
nexttype
==
checktype
){
attiondata
=
[
ujianr
+
"_"
+
jianc
,
jianr
+
"_"
+
jianc
,
jiancol
];
break
;
}
}
let
djianr
=
jianr
+
1
;
if
(
djianr
<
MapData
.
row
){
let
nexttype
=
this
.
getEleTypeByRc
(
djianr
,
jianc
);
if
(
nexttype
==
checktype
){
attiondata
=
[
djianr
+
"_"
+
jianc
,
jianr
+
"_"
+
jianc
,
jiancol
];
break
;
}
}
}
}
}
// console.log("相邻检测--------------",attiondata);
return
attiondata
;
}
//检测消除
checkEliminate
(){
this
.
eliminateArr
=
new
Array
();
for
(
let
r
=
MapData
.
row
-
1
;
r
>-
1
;
r
--
){
for
(
let
c
=
MapData
.
col
-
1
;
c
>-
1
;
c
--
){
let
edata
=
this
.
getEliminate
(
r
,
c
);
if
(
edata
){
let
etype
=
edata
.
etype
;
let
earr
=
edata
.
arr
;
this
.
checkAddEli
(
etype
,
earr
);
}
}
}
}
//两边一样,中间插入,row
getEliminateRowR
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
jianrow
=
x
-
2
;
let
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
if
(
jianrow
>-
1
){
let
jiantype
=
this
.
getEleTypeByRc
(
jianrow
,
y
);
if
(
jiantype
==
checktype
){
relearr
.
push
(
jianrow
+
"_"
+
y
);
}
}
return
relearr
;
}
//两边一样,中间插入,col
getEliminateRowC
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
jiancol
=
y
-
2
;
let
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
if
(
jiancol
>-
1
){
let
jiantype
=
this
.
getEleTypeByRc
(
x
,
jiancol
);
if
(
jiantype
==
checktype
){
relearr
.
push
(
x
+
"_"
+
jiancol
);
}
}
return
relearr
;
}
getEliminateRow
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
relearr
=
new
Array
();
relearr
.
push
(
x
+
"_"
+
y
);
for
(
let
r
=
x
-
1
;
r
>-
1
;
r
--
){
let
reletype
=
this
.
getEleTypeByRc
(
r
,
y
);
if
(
checktype
==
reletype
){
relearr
.
push
(
r
+
"_"
+
y
);
}
else
{
break
;
}
}
return
relearr
;
}
getEliminateCol
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
celearr
=
new
Array
();
celearr
.
push
(
x
+
"_"
+
y
);
for
(
let
c
=
y
-
1
;
c
>-
1
;
c
--
){
let
celetype
=
this
.
getEleTypeByRc
(
x
,
c
);
if
(
checktype
==
celetype
){
celearr
.
push
(
x
+
"_"
+
c
);
}
else
{
break
;
}
}
return
celearr
;
}
getEliminate
(
x
,
y
){
let
checktype
=
this
.
getEleTypeByRc
(
x
,
y
);
let
relearr
=
this
.
getEliminateRow
(
x
,
y
);
let
celearr
=
this
.
getEliminateCol
(
x
,
y
);
let
eliminatearr
=
new
Array
();
if
(
relearr
.
length
>=
3
){
eliminatearr
.
push
(...
relearr
);
}
if
(
celearr
.
length
>=
3
){
eliminatearr
.
push
(...
celearr
);
}
if
(
eliminatearr
.
length
>
0
){
return
{
etype
:
checktype
,
arr
:
eliminatearr
}
}
else
{
return
false
;
}
}
getEleTypeByRc
(
r
,
c
){
let
rc
=
r
+
"_"
+
c
;
let
elename
=
this
.
lattices
[
rc
];
let
ele
:
Element
=
this
.
container
.
getChildByName
(
elename
);
if
(
ele
){
let
eletype
=
ele
.
type
;
return
eletype
;
}
}
checkAddEli
(
etype
,
earr
:
Array
<
string
>
){
let
addnew
=
true
;
let
inaidx
;
for
(
let
i1
=
0
;
i1
<
this
.
eliminateArr
.
length
;
i1
++
){
let
i1data
=
this
.
eliminateArr
[
i1
];
for
(
let
i2
=
0
;
i2
<
i1data
.
length
;
i2
++
){
let
i2data
=
i1data
[
i2
];
let
i2eliname
=
i2data
.
idxname
;
let
inidx
=
earr
.
indexOf
(
i2eliname
);
if
(
inidx
!=-
1
){
addnew
=
false
;
break
;
}
}
if
(
!
addnew
){
inaidx
=
i1
;
break
;
}
}
if
(
addnew
){
let
addarr
=
new
Array
();
for
(
let
i1
=
0
;
i1
<
earr
.
length
;
i1
++
){
let
i1name
=
earr
[
i1
];
addarr
.
push
({
idxname
:
i1name
,
type
:
etype
})
}
this
.
eliminateArr
.
push
(
addarr
);
}
else
{
for
(
let
i4
=
0
;
i4
<
earr
.
length
;
i4
++
){
let
i4name
=
earr
[
i4
];
let
addele
=
true
;
for
(
let
i3
=
0
;
i3
<
this
.
eliminateArr
[
inaidx
].
length
;
i3
++
){
let
i3data
=
this
.
eliminateArr
[
inaidx
][
i3
];
let
i3eliname
=
i3data
.
idxname
;
if
(
i3eliname
==
i4name
){
addele
=
false
;
break
;
}
}
if
(
addele
){
this
.
eliminateArr
[
inaidx
].
push
({
idxname
:
i4name
,
type
:
etype
})
}
}
}
}
//获得这个位置掉落的元素
getFallRcEle
(
r
,
c
){
for
(
let
fr
=
r
-
1
;
fr
>-
1
;
fr
--
){
let
frc
=
fr
+
"_"
+
c
;
let
frcname
=
this
.
lattices
[
frc
];
if
(
frcname
!=
"empty"
){
this
.
lattices
[
frc
]
=
"empty"
;
return
frcname
;
}
}
return
false
;
}
addScoreAni
(
ielix
,
ieliy
,
ietype
,
addscore
){
let
anitxt
=
MapData
.
getOneTxt
();
anitxt
.
alpha
=
0
;
let
txtcolor
=
"#bd882f"
;
switch
(
ietype
){
case
ElementType
.
gdog
:
txtcolor
=
"#d3ff6d"
;
break
;
case
ElementType
.
pbird
:
txtcolor
=
"#ff51d4"
;
break
;
case
ElementType
.
hniu
:
txtcolor
=
"#ffab55"
;
break
;
case
ElementType
.
bribbit
:
txtcolor
=
"#b3d4ff"
;
break
;
case
ElementType
.
rpig
:
txtcolor
=
"#f2453b"
;
break
;
default
:
console
.
error
(
"未定义类型,检查"
);
break
;
}
anitxt
.
fillColor
=
txtcolor
;
let
anix
=
ielix
+
MapData
.
itemsize
/
2
-
100
;
let
aniy
=
ieliy
+
this
.
conty
+
MapData
.
itemsize
/
2
-
35
;
anitxt
.
text
=
"+"
+
addscore
;
this
.
txtcontainer
.
addChild
(
anitxt
);
anitxt
.
x
=
anix
;
anitxt
.
y
=
aniy
;
anitxt
.
scaleX
=
0
;
anitxt
.
scaleY
=
0
;
anitxt
.
alpha
=
1
;
engine
.
Tween
.
get
(
anitxt
,{
loop
:
false
}).
set
({
x
:
anix
,
y
:
aniy
,
scaleX
:
0
,
scaleY
:
0
})
.
to
({
y
:
aniy
-
50
,
scaleX
:
1
,
scaleY
:
1
,
},
300
)
.
to
({
y
:
aniy
-
120
,
alpha
:
0
},
500
)
.
call
(()
=>
{
this
.
txtcontainer
.
removeChild
(
anitxt
);
this
.
score
+=
addscore
;
MapData
.
recoverTxt
(
anitxt
);
})
}
changeHomeShow
(
mode
=
"day"
){
let
_v
=
true
;
if
(
mode
==
"day"
){
_v
=
true
;
}
else
{
_v
=
false
;
}
// this.homeimgday.visible = _v;
// this.homeimgnight.visible = !_v;
}
//使用炸弹
boomeEle
(
row
,
col
){
this
.
useBoom
=
false
;
this
.
anicontainer
.
removeChild
(
this
.
selectimg
);
this
.
changeEnable
(
false
);
this
.
selectArr
=
new
Array
();
// console.log("使用炸弹rc",row,col);
this
.
eliminateArr
=
new
Array
();
for
(
let
r
=
0
;
r
<
MapData
.
row
;
r
++
){
let
irc
=
r
+
"_"
+
col
;
let
ielename
=
this
.
lattices
[
irc
];
let
iele
:
Element
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
){
let
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
])
}
}
for
(
let
c
=
0
;
c
<
MapData
.
col
;
c
++
){
if
(
c
!=
col
){
let
irc
=
row
+
"_"
+
c
;
let
ielename
=
this
.
lattices
[
irc
];
let
iele
:
Element
=
this
.
container
.
getChildByName
(
ielename
);
if
(
iele
){
let
eletype
=
iele
.
type
;
this
.
eliminateArr
.
push
([
{
idxname
:
irc
,
type
:
eletype
}
])
}
}
}
// console.log("使用炸弹消除的元素",this.eliminateArr);
this
.
eliminate
();
}
}
src/custom/rbcxiaoxiaole/src/game/GameWrapper.ts
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2020-01-09.
*/
import
GameView
from
"./GameView"
;
import
{
injectProps
}
from
"../props"
;
export
class
GameWrapper
extends
engine
.
Container
{
private
_gameView
:
GameView
;
constructor
()
{
super
();
this
.
_gameView
=
new
GameView
();
this
.
addChild
(
this
.
_gameView
);
engine
.
globalEvent
.
addEventListener
(
'game-init'
,
this
.
init
,
this
);
engine
.
globalEvent
.
addEventListener
(
'game-reset'
,
this
.
reset
,
this
);
engine
.
globalEvent
.
addEventListener
(
'game-start'
,
this
.
start
,
this
);
engine
.
globalEvent
.
addEventListener
(
'game-pause'
,
this
.
pause
,
this
);
engine
.
globalEvent
.
addEventListener
(
'game-resume'
,
this
.
resume
,
this
);
engine
.
globalEvent
.
addEventListener
(
'game-recordcomp'
,
this
.
recordcomp
,
this
);
}
init
(
event
:
engine
.
Event
){
// console.log("gamewrapper-init",event);
let
time
=
event
.
data
.
time
;
let
level
=
event
.
data
.
level
;
let
mode
=
event
.
data
.
mode
;
this
.
_gameView
.
init
(
time
,
level
,
mode
);
}
reset
(
event
:
engine
.
Event
){
// console.log("gamewrapper-reset",event);
let
time
=
event
.
data
.
time
;
let
level
=
event
.
data
.
level
;
let
mode
=
event
.
data
.
mode
;
this
.
_gameView
.
reset
(
time
,
level
,
mode
);;
}
start
(){
this
.
_gameView
.
start
();
}
pause
(){
this
.
_gameView
.
pause
();
}
resume
(){
this
.
_gameView
.
resume
();
}
recordcomp
(){
this
.
_gameView
.
recordcomp
();
}
}
src/custom/rbcxiaoxiaole/src/game/MapData.ts
0 → 100644
View file @
e29e32b9
import
Element
from
"./ele/Element"
;
import
{
getTextureByName
}
from
"./utils"
;
export
enum
ElementType
{
gdog
=
1
,
pbird
,
hniu
,
bribbit
,
rpig
}
export
enum
GameEvent
{
SelectEle
=
"SelectEle"
,
}
export
default
class
MapData
{
//单格大小
static
itemsize
=
116
;
//
static
paddingw
=
7
;
static
paddingh
=
7
;
static
paddingwi
=
4
;
static
paddinghi
=
2
;
//
static
row
=
5
;
static
col
=
5
;
//行-列,对应位置
static
posData
=
{
};
static
eleidx
=
1
;
static
elePool
=
{};
static
anispeed
=
1000
;
static
gdotTex
:
engine
.
Texture
;
static
pbirdTex
:
engine
.
Texture
;
static
hniuTex
:
engine
.
Texture
;
static
bribbitTex
:
engine
.
Texture
;
static
rpigTex
:
engine
.
Texture
;
static
levelData
:
Array
<
Array
<
Array
<
number
>>>
=
[
[
[
1
,
2
,
5
,
3
,
4
],
[
3
,
1
,
2
,
4
,
5
],
[
2
,
5
,
3
,
4
,
1
],
[
5
,
4
,
1
,
2
,
3
],
[
4
,
1
,
3
,
5
,
2
],
],
[
[
5
,
2
,
1
,
2
,
1
],
[
3
,
1
,
4
,
5
,
4
],
[
2
,
5
,
3
,
5
,
1
],
[
5
,
4
,
1
,
2
,
3
],
[
4
,
1
,
3
,
1
,
2
],
],
[
[
2
,
4
,
1
,
5
,
2
],
[
2
,
3
,
4
,
1
,
3
],
[
4
,
1
,
3
,
2
,
3
],
[
3
,
2
,
1
,
1
,
4
],
[
1
,
1
,
3
,
5
,
4
],
],
[
[
3
,
2
,
1
,
4
,
5
],
[
2
,
4
,
1
,
2
,
3
],
[
2
,
3
,
2
,
3
,
3
],
[
4
,
4
,
5
,
5
,
4
],
[
3
,
3
,
1
,
2
,
4
],
],
[
[
4
,
5
,
1
,
2
,
4
],
[
3
,
2
,
3
,
4
,
2
],
[
1
,
5
,
2
,
3
,
5
],
[
4
,
5
,
5
,
1
,
3
],
[
1
,
2
,
3
,
2
,
4
],
]
]
static
getRy
(
r
){
return
this
.
paddingh
+
r
*
(
this
.
itemsize
+
this
.
paddinghi
);
}
static
getCx
(
c
){
return
this
.
paddingw
+
c
*
(
this
.
itemsize
+
this
.
paddingwi
);
}
static
getRCPos
(
r
,
c
){
let
x
=
this
.
getCx
(
c
);
let
y
=
this
.
getRy
(
r
);
return
[
x
,
y
];
}
static
adaptElePos
(
pos
,
wid
,
hei
){
let
x
=
pos
[
0
]
+
(
this
.
itemsize
-
wid
)
/
2
;
let
y
=
pos
[
1
]
+
(
this
.
itemsize
-
hei
)
/
2
;
return
[
x
,
y
];
}
static
getEtypeImgName
(
type
:
ElementType
){
let
ename
:
string
;
switch
(
type
){
case
ElementType
.
gdog
:
ename
=
"狗"
;
break
;
case
ElementType
.
pbird
:
ename
=
"鸟"
;
break
;
case
ElementType
.
hniu
:
ename
=
"牛"
;
break
;
case
ElementType
.
bribbit
:
ename
=
"兔子"
;
break
;
case
ElementType
.
rpig
:
ename
=
"猪"
;
break
;
default
:
console
.
error
(
"未定义元素类型"
);
break
;
}
return
ename
;
}
static
getEtypeImgTex
(
type
:
ElementType
){
let
etex
:
engine
.
Texture
;
switch
(
type
){
case
ElementType
.
gdog
:
if
(
!
this
.
gdotTex
){
this
.
gdotTex
=
getTextureByName
(
"狗"
);
console
.
log
(
"新素材加载---狗"
);
}
etex
=
this
.
gdotTex
;
break
;
case
ElementType
.
pbird
:
if
(
!
this
.
pbirdTex
){
this
.
pbirdTex
=
getTextureByName
(
"鸟"
);
console
.
log
(
"新素材加载---鸟"
);
}
etex
=
this
.
pbirdTex
;
break
;
case
ElementType
.
hniu
:
if
(
!
this
.
hniuTex
){
this
.
hniuTex
=
getTextureByName
(
"牛"
);
console
.
log
(
"新素材加载---牛"
);
}
etex
=
this
.
hniuTex
;
break
;
case
ElementType
.
bribbit
:
if
(
!
this
.
bribbitTex
){
this
.
bribbitTex
=
getTextureByName
(
"兔子"
);
console
.
log
(
"新素材加载---兔子"
);
}
etex
=
this
.
bribbitTex
;
break
;
case
ElementType
.
rpig
:
if
(
!
this
.
rpigTex
){
this
.
rpigTex
=
getTextureByName
(
"猪"
);
console
.
log
(
"新素材加载---猪"
);
}
etex
=
this
.
rpigTex
;
break
;
default
:
console
.
error
(
"未定义元素类型"
);
break
;
}
return
etex
;
}
static
getRandEtype
(){
let
eletypeArr
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
let
etype
=
eletypeArr
[
Math
.
floor
(
Math
.
random
()
*
eletypeArr
.
length
)];
return
etype
;
}
static
initPoolEle
(){
// console.error("初始化元素池");
this
.
gdotTex
=
getTextureByName
(
"狗"
);
this
.
pbirdTex
=
getTextureByName
(
"鸟"
);
this
.
hniuTex
=
getTextureByName
(
"牛"
);
this
.
bribbitTex
=
getTextureByName
(
"兔子"
);
this
.
rpigTex
=
getTextureByName
(
"猪"
);
let
eletypes
=
[
ElementType
.
gdog
,
ElementType
.
pbird
,
ElementType
.
hniu
,
ElementType
.
bribbit
,
ElementType
.
rpig
];
this
.
elePool
[
"ele"
]
=
new
Array
();
//初始5*5个元素备用;
for
(
let
i
=
0
;
i
<
eletypes
.
length
;
i
++
){
let
itype
=
eletypes
[
i
];
// this.elePool[itype] = new Array();
for
(
let
a
=
0
;
a
<
5
;
a
++
){
let
iele
=
new
Element
();
// iele.eimage.texture = this.getEtypeImgTex(itype);
this
.
elePool
[
"ele"
].
push
(
iele
);
}
}
//得分得txt
this
.
elePool
[
"score"
]
=
new
Array
();
for
(
let
t
=
0
;
t
<
8
;
t
++
){
let
itxt
=
new
engine
.
Label
();
itxt
.
size
=
66
;
itxt
.
width
=
200
;
itxt
.
height
=
70
;
itxt
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
itxt
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
;
itxt
.
anchorY
=
35
;
itxt
.
anchorX
=
100
;
itxt
.
bold
=
true
;
this
.
elePool
[
"score"
].
push
(
itxt
);
}
}
static
getOneEle
(
type
:
ElementType
):
Element
{
let
ele
:
Element
;
if
(
this
.
elePool
[
"ele"
]){
if
(
this
.
elePool
[
"ele"
].
length
>
0
){
ele
=
this
.
elePool
[
"ele"
].
shift
();
}
}
else
{
this
.
elePool
[
"ele"
]
=
new
Array
();
}
if
(
!
ele
){
console
.
error
(
"创建了新的了ele"
);
ele
=
new
Element
();
// ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
}
ele
.
name
=
"ele_"
+
this
.
eleidx
;
this
.
eleidx
+=
1
;
ele
.
init
(
type
)
return
ele
;
}
static
getOneTxt
():
engine
.
Label
{
let
itxt
:
engine
.
Label
;
if
(
this
.
elePool
[
"score"
]){
if
(
this
.
elePool
[
"score"
].
length
>
0
){
itxt
=
this
.
elePool
[
"score"
].
shift
();
}
}
else
{
this
.
elePool
[
"score"
]
=
new
Array
();
}
if
(
!
itxt
){
itxt
=
new
engine
.
Label
();
itxt
.
size
=
66
;
itxt
.
width
=
200
;
itxt
.
height
=
70
;
itxt
.
textAlign
=
engine
.
TEXT_ALIGN
.
CENTER
;
itxt
.
verticalAlign
=
engine
.
VERTICAL_ALIGN
.
MIDDLE
;
itxt
.
anchorY
=
35
;
itxt
.
anchorX
=
100
;
itxt
.
bold
=
true
;
// console.log("创建了新的txt");
}
itxt
.
mouseEnabled
=
false
;
return
itxt
;
}
static
recoverEle
(
ele
:
Element
,
type
:
ElementType
){
if
(
ele
.
eimage
){
ele
.
eimage
.
texture
=
null
;
}
this
.
elePool
[
"ele"
].
push
(
ele
);
}
static
recoverTxt
(
txt
:
engine
.
Label
){
this
.
elePool
[
"score"
].
push
(
txt
);
}
static
getDistance
(
p1
,
p2
){
let
p1x
=
p1
[
0
];
let
p1y
=
p1
[
1
];
let
p2x
=
p2
[
0
];
let
p2y
=
p2
[
1
];
let
dis
=
Math
.
sqrt
(
Math
.
pow
(
p1x
-
p2x
,
2
)
+
Math
.
pow
(
p1y
-
p2y
,
2
));
return
dis
;
}
}
\ No newline at end of file
src/custom/rbcxiaoxiaole/src/game/ele/Element.ts
0 → 100644
View file @
e29e32b9
import
MapData
,
{
ElementType
,
GameEvent
}
from
"../MapData"
;
import
{
getTextureByName
}
from
"../utils"
;
export
default
class
Element
extends
engine
.
Container
{
type
:
ElementType
;
eimage
:
engine
.
Image
;
inrow
;
incol
;
set
touch
(
touch
){
this
.
mouseEnabled
=
touch
;
this
.
mouseChildren
=
touch
;
}
constructor
(){
super
();
this
.
width
=
MapData
.
itemsize
;
this
.
height
=
MapData
.
itemsize
;
this
.
anchorX
=
MapData
.
itemsize
/
2
;
this
.
eimage
=
new
engine
.
Image
();
this
.
addChild
(
this
.
eimage
);
this
.
touch
=
true
;
// this.addEventListener(engine.MouseEvent.CLICK,this.selectele,this);
this
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
selectele
,
this
);
this
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
changemove
,
this
);
}
init
(
type
:
ElementType
){
this
.
anchorY
=
MapData
.
itemsize
;
this
.
scaleX
=
1
;
this
.
scaleY
=
1
;
this
.
alpha
=
1
;
this
.
type
=
type
;
let
ename
=
MapData
.
getEtypeImgName
(
type
);
this
.
eimage
.
texture
=
MapData
.
getEtypeImgTex
(
type
);
let
imgwid
=
this
.
eimage
.
texture
.
width
;
let
imghei
=
this
.
eimage
.
texture
.
height
;
// console.log("大小",imgwid,imghei);
this
.
eimage
.
x
=
(
this
.
width
-
imgwid
)
/
2
;
this
.
eimage
.
y
=
(
this
.
height
-
imghei
)
/
2
;
}
setrc
(
r
,
c
){
this
.
inrow
=
r
;
this
.
incol
=
c
;
}
selectele
(
e
:
engine
.
MouseEvent
){
engine
.
globalEvent
.
dispatchEvent
(
GameEvent
.
SelectEle
,{
r
:
this
.
inrow
,
c
:
this
.
incol
,
type
:
"mouse_down"
})
}
changemove
(
e
:
engine
.
MouseEvent
){
// console.log(this.inrow+":"+this.incol);
engine
.
globalEvent
.
dispatchEvent
(
GameEvent
.
SelectEle
,{
r
:
this
.
inrow
,
c
:
this
.
incol
,
type
:
"mouse_move"
})
}
public
get
factor
():
number
{
return
0
;
}
public
set
factor
(
value
:
number
)
{
this
.
x
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1x
+
2
*
value
*
(
1
-
value
)
*
this
.
c1x
+
value
*
value
*
this
.
p2x
;
this
.
y
=
(
1
-
value
)
*
(
1
-
value
)
*
this
.
p1y
+
2
*
value
*
(
1
-
value
)
*
this
.
c1y
+
value
*
value
*
this
.
p2y
;
var
mscale
=
(
1
-
value
)
*
(
1
-
value
)
*
1
+
2
*
value
*
(
1
-
value
)
*
0.6
+
value
*
value
*
0.35
;
this
.
scaleX
=
mscale
;
this
.
scaleY
=
mscale
;
}
p1x
;
p1y
;
c1x
;
c1y
;
p2x
;
p2y
;
//飞到小屋
flyToHome
(
tx
,
ty
,
time
){
this
.
p1x
=
this
.
x
;
this
.
p1y
=
this
.
y
+
20
;
this
.
c1x
=
(
this
.
p1x
-
tx
)
/
4
+
tx
;
this
.
c1y
=
ty
;
this
.
p2x
=
tx
;
this
.
p2y
=
ty
;
engine
.
Tween
.
removeTweens
(
this
);
engine
.
Tween
.
get
(
this
).
to
({
scaleX
:
1.1
,
scaleY
:
1.1
},
200
)
.
to
({
scaleX
:
1.1
,
scaleY
:
0.88
},
100
)
.
to
({
scaleX
:
0.98
,
scaleY
:
0.98
,
y
:
this
.
y
+
20
},
100
)
.
call
(()
=>
{
this
.
factor
=
0
;
engine
.
Tween
.
get
(
this
).
to
({
factor
:
1
},
450
)
.
call
(()
=>
{
let
nodeparent
:
engine
.
Container
=
this
.
parent
;
nodeparent
&&
nodeparent
.
removeChild
(
this
);
MapData
.
recoverEle
(
this
,
this
.
type
);
})
})
}
changePos
(
tpos
:
Array
<
number
>
){
let
nx
=
this
.
x
;
let
ny
=
this
.
y
;
let
tx
=
tpos
[
0
];
let
ty
=
tpos
[
1
];
let
dis
=
MapData
.
getDistance
([
nx
,
ny
],
tpos
);
let
time
=
Math
.
ceil
(
dis
/
MapData
.
anispeed
*
1000
);
engine
.
Tween
.
removeTweens
(
this
);
let
pro
=
new
Promise
(
res
=>
{
engine
.
Tween
.
get
(
this
,{
loop
:
false
}).
to
({
x
:
tx
,
y
:
ty
},
time
)
.
call
(()
=>
{
// console.log("单个移动完毕");
res
();
})
})
return
pro
;
}
}
\ No newline at end of file
src/custom/rbcxiaoxiaole/src/game/utils.ts
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2020-01-21.
*/
export
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
export
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
export
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
export
function
createSvga
(
name
,
anchorName
?)
{
let
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
return
inst
;
}
\ No newline at end of file
src/custom/rbcxiaoxiaole/src/index.ts
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2019-11-20.
*/
import
{
GameWrapper
}
from
"./game/GameWrapper"
;
import
{
injectProps
,
prepareProps
}
from
"./props"
;
export
default
function
(
props
)
{
prepareProps
();
injectProps
(
props
);
let
instance
=
new
GameWrapper
();
return
instance
;
}
src/custom/rbcxiaoxiaole/src/props.ts
0 → 100644
View file @
e29e32b9
/**
* Created by rockyl on 2020-01-21.
*/
export
let
props
:
any
=
{};
export
function
prepareProps
()
{
let
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
export
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment