Commit 76315174 authored by zjz1994's avatar zjz1994

人保财险消消乐

parent f0f9841e
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -19,11 +20,7 @@ ...@@ -19,11 +20,7 @@
function getTextureByName(name) { function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
function createSvga(name, anchorName) { //# sourceMappingURL=utils.js.map
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
var Element = (function (_super) { var Element = (function (_super) {
tslib.__extends(Element, _super); tslib.__extends(Element, _super);
...@@ -44,7 +41,7 @@ ...@@ -44,7 +41,7 @@
this.mouseEnabled = touch; this.mouseEnabled = touch;
this.mouseChildren = touch; this.mouseChildren = touch;
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
Element.prototype.init = function (type) { Element.prototype.init = function (type) {
...@@ -89,7 +86,7 @@ ...@@ -89,7 +86,7 @@
this.scaleX = mscale; this.scaleX = mscale;
this.scaleY = mscale; this.scaleY = mscale;
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
Element.prototype.flyToHome = function (tx, ty, time) { Element.prototype.flyToHome = function (tx, ty, time) {
...@@ -148,14 +145,15 @@ ...@@ -148,14 +145,15 @@
}; };
return Element; return Element;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Element.js.map
var ElementType; var ElementType;
(function (ElementType) { (function (ElementType) {
ElementType[ElementType["btiger"] = 1] = "btiger"; ElementType[ElementType["gdog"] = 1] = "gdog";
ElementType[ElementType["gtiger"] = 2] = "gtiger"; ElementType[ElementType["pbird"] = 2] = "pbird";
ElementType[ElementType["monkey"] = 3] = "monkey"; ElementType[ElementType["hniu"] = 3] = "hniu";
ElementType[ElementType["bird"] = 4] = "bird"; ElementType[ElementType["bribbit"] = 4] = "bribbit";
ElementType[ElementType["koala"] = 5] = "koala"; ElementType[ElementType["rpig"] = 5] = "rpig";
})(ElementType || (ElementType = {})); })(ElementType || (ElementType = {}));
var GameEvent; var GameEvent;
(function (GameEvent) { (function (GameEvent) {
...@@ -165,10 +163,10 @@ ...@@ -165,10 +163,10 @@
function MapData() { function MapData() {
} }
MapData.getRy = function (r) { MapData.getRy = function (r) {
return this.paddingb + r * (this.itemsize + this.paddingi); return this.paddingh + r * (this.itemsize + this.paddinghi);
}; };
MapData.getCx = function (c) { MapData.getCx = function (c) {
return this.paddingb + c * (this.itemsize + this.paddingi); return this.paddingw + c * (this.itemsize + this.paddingwi);
}; };
MapData.getRCPos = function (r, c) { MapData.getRCPos = function (r, c) {
var x = this.getCx(c); var x = this.getCx(c);
...@@ -183,20 +181,20 @@ ...@@ -183,20 +181,20 @@
MapData.getEtypeImgName = function (type) { MapData.getEtypeImgName = function (type) {
var ename; var ename;
switch (type) { switch (type) {
case ElementType.btiger: case ElementType.gdog:
ename = "白虎"; ename = "";
break; break;
case ElementType.gtiger: case ElementType.pbird:
ename = "雌虎"; ename = "";
break; break;
case ElementType.monkey: case ElementType.hniu:
ename = "猴子"; ename = "";
break; break;
case ElementType.bird: case ElementType.bribbit:
ename = ""; ename = "兔子";
break; break;
case ElementType.koala: case ElementType.rpig:
ename = "树熊"; ename = "";
break; break;
default: default:
console.error("未定义元素类型"); console.error("未定义元素类型");
...@@ -207,40 +205,40 @@ ...@@ -207,40 +205,40 @@
MapData.getEtypeImgTex = function (type) { MapData.getEtypeImgTex = function (type) {
var etex; var etex;
switch (type) { switch (type) {
case ElementType.btiger: case ElementType.gdog:
if (!this.btigerTex) { if (!this.gdotTex) {
this.btigerTex = getTextureByName("白虎"); this.gdotTex = getTextureByName("狗");
console.log("新素材加载---白虎"); console.log("新素材加载---");
} }
etex = this.btigerTex; etex = this.gdotTex;
break; break;
case ElementType.gtiger: case ElementType.pbird:
if (!this.gtigerTex) { if (!this.pbirdTex) {
this.gtigerTex = getTextureByName("雌虎"); this.pbirdTex = getTextureByName("鸟");
console.log("新素材加载---雌虎"); console.log("新素材加载---");
} }
etex = this.gtigerTex; etex = this.pbirdTex;
break; break;
case ElementType.monkey: case ElementType.hniu:
if (!this.monkeyTex) { if (!this.hniuTex) {
this.monkeyTex = getTextureByName("猴子"); this.hniuTex = getTextureByName("牛");
console.log("新素材加载---猴子"); console.log("新素材加载---");
} }
etex = this.monkeyTex; etex = this.hniuTex;
break; break;
case ElementType.bird: case ElementType.bribbit:
if (!this.birdTex) { if (!this.bribbitTex) {
this.birdTex = getTextureByName("鸟"); this.bribbitTex = getTextureByName("兔子");
console.log("新素材加载---"); console.log("新素材加载---兔子");
} }
etex = this.birdTex; etex = this.bribbitTex;
break; break;
case ElementType.koala: case ElementType.rpig:
if (!this.koalaTex) { if (!this.rpigTex) {
this.koalaTex = getTextureByName("树熊"); this.rpigTex = getTextureByName("猪");
console.log("新素材加载---树熊"); console.log("新素材加载---");
} }
etex = this.koalaTex; etex = this.rpigTex;
break; break;
default: default:
console.error("未定义元素类型"); console.error("未定义元素类型");
...@@ -249,17 +247,17 @@ ...@@ -249,17 +247,17 @@
return etex; return etex;
}; };
MapData.getRandEtype = function () { MapData.getRandEtype = function () {
var eletypeArr = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala]; var eletypeArr = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)]; var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];
return etype; return etype;
}; };
MapData.initPoolEle = function () { MapData.initPoolEle = function () {
this.btigerTex = getTextureByName("白虎"); this.gdotTex = getTextureByName("狗");
this.gtigerTex = getTextureByName("雌虎"); this.pbirdTex = getTextureByName("鸟");
this.monkeyTex = getTextureByName("猴子"); this.hniuTex = getTextureByName("牛");
this.birdTex = getTextureByName("鸟"); this.bribbitTex = getTextureByName("兔子");
this.koalaTex = getTextureByName("树熊"); this.rpigTex = getTextureByName("猪");
var eletypes = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala]; var eletypes = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
this.elePool["ele"] = new Array(); this.elePool["ele"] = new Array();
for (var i = 0; i < eletypes.length; i++) { for (var i = 0; i < eletypes.length; i++) {
for (var a = 0; a < 5; a++) { for (var a = 0; a < 5; a++) {
...@@ -341,9 +339,11 @@ ...@@ -341,9 +339,11 @@
var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2)); var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));
return dis; return dis;
}; };
MapData.itemsize = 129; MapData.itemsize = 116;
MapData.paddingb = 10; MapData.paddingw = 7;
MapData.paddingi = 5; MapData.paddingh = 7;
MapData.paddingwi = 4;
MapData.paddinghi = 2;
MapData.row = 5; MapData.row = 5;
MapData.col = 5; MapData.col = 5;
MapData.posData = {}; MapData.posData = {};
...@@ -389,6 +389,7 @@ ...@@ -389,6 +389,7 @@
]; ];
return MapData; return MapData;
}()); }());
//# sourceMappingURL=MapData.js.map
var GameView = (function (_super) { var GameView = (function (_super) {
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
...@@ -409,8 +410,10 @@ ...@@ -409,8 +410,10 @@
_this.level = 0; _this.level = 0;
_this.inrecord = false; _this.inrecord = false;
_this.requestGameOver = false; _this.requestGameOver = false;
_this.elitype = 1;
_this._seq = 1; _this._seq = 1;
_this.sptime = Date.now(); _this.sptime = Date.now();
_this.useBoom = false;
_this._score = 0; _this._score = 0;
_this.inEliminate = false; _this.inEliminate = false;
_this.newSelect = false; _this.newSelect = false;
...@@ -427,7 +430,7 @@ ...@@ -427,7 +430,7 @@
this.changeEnable(false); this.changeEnable(false);
} }
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
Object.defineProperty(GameView.prototype, "seq", { Object.defineProperty(GameView.prototype, "seq", {
...@@ -437,13 +440,17 @@ ...@@ -437,13 +440,17 @@
set: function (num) { set: function (num) {
this._seq = num; this._seq = num;
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
GameView.prototype.setup = function () { GameView.prototype.setup = function () {
MapData.initPoolEle(); MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; 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.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou2 = new engine.Image(getTextureByName("交换箭头")); this.jiantou2 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou1.mouseEnabled = false; this.jiantou1.mouseEnabled = false;
...@@ -474,18 +481,6 @@ ...@@ -474,18 +481,6 @@
this.jiantoucont.addChild(this.jiantou2); this.jiantoucont.addChild(this.jiantou2);
var row = MapData.row; var row = MapData.row;
var col = MapData.col; var 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.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
this.container.y = this.conty; this.container.y = this.conty;
...@@ -520,13 +515,36 @@ ...@@ -520,13 +515,36 @@
this.lastframeTime = Date.now(); this.lastframeTime = Date.now();
this.lastatime = Date.now(); this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this); 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 () { GameView.prototype.changeAni = function () {
this.changeHomeShow("night"); this.changeHomeShow("night");
}; };
GameView.prototype.playComp = function () { GameView.prototype.playComp = function () {
this.homeimgday.stop(1);
this.homeimgnight.stop(1);
}; };
GameView.prototype.init = function (time, level, mode) { GameView.prototype.init = function (time, level, mode) {
this.score = 0; this.score = 0;
...@@ -546,7 +564,7 @@ ...@@ -546,7 +564,7 @@
this._score = num; this._score = num;
engine.globalEvent.dispatchEvent('game-score-update', { score: this._score }); engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
Object.defineProperty(GameView.prototype, "gametime", { Object.defineProperty(GameView.prototype, "gametime", {
...@@ -570,7 +588,7 @@ ...@@ -570,7 +588,7 @@
} }
this._gametime = time; this._gametime = time;
}, },
enumerable: false, enumerable: true,
configurable: true configurable: true
}); });
GameView.prototype.gameOver = function () { GameView.prototype.gameOver = function () {
...@@ -661,18 +679,6 @@ ...@@ -661,18 +679,6 @@
this.gametime = ngtime; this.gametime = ngtime;
} }
} }
if (this.homeimgday && this.homeimgday.visible) {
var curframe = this.homeimgday.currentFrame;
if (curframe == this.homeimgday.totalFrames) {
this.homeimgday.gotoAndStop(1);
}
}
if (this.homeimgnight && this.homeimgnight.visible) {
var curframe = this.homeimgnight.currentFrame;
if (curframe == this.homeimgnight.totalFrames) {
this.homeimgnight.gotoAndStop(1);
}
}
this.lastframeTime = ntime; this.lastframeTime = ntime;
}; };
GameView.prototype.initContainer = function () { GameView.prototype.initContainer = function () {
...@@ -777,6 +783,13 @@ ...@@ -777,6 +783,13 @@
var sc = data.c; var sc = data.c;
var type = data.type; var type = data.type;
var sname = sr + "_" + sc; var sname = sr + "_" + sc;
if (this.useBoom) {
if (type == "mouse_down") {
this.unShowEleAttion();
this.boomeEle(sr, sc);
}
return;
}
var lnewSelect = this.newSelect; var lnewSelect = this.newSelect;
var newCanSel = false; var newCanSel = false;
if (this.selectArr.length == 0) { if (this.selectArr.length == 0) {
...@@ -838,9 +851,24 @@ ...@@ -838,9 +851,24 @@
var r = rcname.split("_")[0]; var r = rcname.split("_")[0];
var c = rcname.split("_")[1]; var c = rcname.split("_")[1];
var rcpos = MapData.getRCPos(r, c); var rcpos = MapData.getRCPos(r, c);
engine.Tween.removeTweens(this.selectimg);
this.anicontainer.addChild(this.selectimg); this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0]; this.selectimg.x = rcpos[0] - 3;
this.selectimg.y = rcpos[1] + this.conty; 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 () { GameView.prototype.changeElePos = function () {
var _this = this; var _this = this;
...@@ -924,7 +952,7 @@ ...@@ -924,7 +952,7 @@
ielidata1 = this.eliminateArr[i]; ielidata1 = this.eliminateArr[i];
ielileng = ielidata1.length; ielileng = ielidata1.length;
addscore = 0; addscore = 0;
if (ielileng == 3) { if (ielileng <= 3) {
addscore = props.threeEscore; addscore = props.threeEscore;
} }
else if (ielileng == 4) { else if (ielileng == 4) {
...@@ -946,11 +974,18 @@ ...@@ -946,11 +974,18 @@
ielix = ielinode.x; ielix = ielinode.x;
ieliy = ielinode.y; ieliy = ielinode.y;
ietype = ielinode.type; ietype = ielinode.type;
this.container.removeChild(ielinode); if (this.elitype == 1) {
MapData.recoverEle(ielinode, ietype); this.lattices[ielidxname] = "empty";
this.addScoreAni(ielix, ieliy, ietype, addscore); this.addScoreAni(ielix, ieliy, ietype, addscore);
this.lattices[ielidxname] = "empty"; this.goDisplayAni1(ielinode, ietype, ielix, ieliy);
this.goHomeAni(ielitype, 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) { return [4, new Promise(function (res) {
...@@ -968,8 +1003,6 @@ ...@@ -968,8 +1003,6 @@
})]; })];
case 2: case 2:
_a.sent(); _a.sent();
this.homeimgday.play(1, 1);
this.homeimgnight.play(1, 1);
return [2]; return [2];
} }
}); });
...@@ -1107,7 +1140,6 @@ ...@@ -1107,7 +1140,6 @@
}; };
GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) { GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {
var _this = this; var _this = this;
console.log("老原地消失");
var aniele = MapData.getOneEle(ielitype); var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0; aniele.alpha = 0;
var anix = ielix; var anix = ielix;
...@@ -1704,20 +1736,20 @@ ...@@ -1704,20 +1736,20 @@
anitxt.alpha = 0; anitxt.alpha = 0;
var txtcolor = "#bd882f"; var txtcolor = "#bd882f";
switch (ietype) { switch (ietype) {
case ElementType.btiger: case ElementType.gdog:
txtcolor = "#ffffff"; txtcolor = "#d3ff6d";
break; break;
case ElementType.gtiger: case ElementType.pbird:
txtcolor = "#f5a900"; txtcolor = "#ff51d4";
break; break;
case ElementType.monkey: case ElementType.hniu:
txtcolor = "#bd882f"; txtcolor = "#ffab55";
break; break;
case ElementType.bird: case ElementType.bribbit:
txtcolor = "#54c1ef"; txtcolor = "#b3d4ff";
break; break;
case ElementType.koala: case ElementType.rpig:
txtcolor = "#c7c8c9"; txtcolor = "#f2453b";
break; break;
default: default:
console.error("未定义类型,检查"); console.error("未定义类型,检查");
...@@ -1755,19 +1787,48 @@ ...@@ -1755,19 +1787,48 @@
}); });
}; };
GameView.prototype.changeHomeShow = function (mode) { GameView.prototype.changeHomeShow = function (mode) {
if (mode === void 0) { mode = "day"; } };
var _v = true; GameView.prototype.boomeEle = function (row, col) {
if (mode == "day") { this.useBoom = false;
_v = true; 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
}
]);
}
} }
else { for (var c = 0; c < MapData.col; c++) {
_v = false; 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.homeimgday.visible = _v; this.eliminate();
this.homeimgnight.visible = !_v;
}; };
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
...@@ -1810,6 +1871,7 @@ ...@@ -1810,6 +1871,7 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -1817,6 +1879,7 @@ ...@@ -1817,6 +1879,7 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -21,43 +21,43 @@ ...@@ -21,43 +21,43 @@
"assets": [ "assets": [
{ {
"name": "底图", "name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/109e30fa662276e0ee4f2e2c35b85bee6f300050.png", "url": "//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png",
"uuid": "map", "uuid": "map",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "白虎", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/b486b4a72c58850bbd1930b994e08802e34fb3e3.png", "url": "//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png",
"uuid": "btiger", "uuid": "gdog",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "雌虎", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/c41afceb285432ed2c17c643df96efc20893adc8.png", "url": "//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png",
"uuid": "gtiger", "uuid": "pbird",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "猴子", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/ef7bc5d1fc38267adba71e07d517330f249d23ba.png", "url": "//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png",
"uuid": "monkey", "uuid": "hniu",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "", "name": "兔子",
"url": "//yun.duiba.com.cn/aurora/assets/9ad18dfa34e1729e9893ac362975f9e062263f70.png", "url": "//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png",
"uuid": "bird", "uuid": "bribbit",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "树熊", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/277aa43d9f1bf3dd7a18e627335a166f0509684c.png", "url": "//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png",
"uuid": "koala", "uuid": "rpig",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "选中框", "name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/a3ce52a41ed53ccfa7ce404dbc10102961c4a805.png", "url": "//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png",
"uuid": "selected", "uuid": "selected",
"ext": ".png" "ext": ".png"
}, },
......
...@@ -31,10 +31,12 @@ export default class GameView extends engine.Container { ...@@ -31,10 +31,12 @@ export default class GameView extends engine.Container {
//选中 //选中
selectArr = []; selectArr = [];
selectimg:engine.Image; selectimg:engine.Image;
selectw:number;
selecth:number;
//屋子 //屋子
homeimgday; // homeimgday;
homeimgnight; // homeimgnight;
conty = 140; conty = 140;
homex = 562; homex = 562;
...@@ -73,6 +75,8 @@ export default class GameView extends engine.Container { ...@@ -73,6 +75,8 @@ export default class GameView extends engine.Container {
level = 0; level = 0;
inrecord = false; inrecord = false;
requestGameOver = false; requestGameOver = false;
elitype = 1;//1原地消失,2飞到目标位置
set gamestat(stat){//1游戏中,2,游戏外 set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat; this._gamestat = stat;
if(stat==2){ if(stat==2){
...@@ -92,12 +96,18 @@ export default class GameView extends engine.Container { ...@@ -92,12 +96,18 @@ export default class GameView extends engine.Container {
sptime = Date.now(); sptime = Date.now();
eptime; eptime;
seqscore; seqscore;
//使用炸弹
useBoom:boolean = false;
setup() { setup() {
MapData.initPoolEle(); MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; 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 //箭头cont
this.jiantou1 = new engine.Image(getTextureByName("交换箭头")); this.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
...@@ -143,21 +153,21 @@ export default class GameView extends engine.Container { ...@@ -143,21 +153,21 @@ export default class GameView extends engine.Container {
let row = MapData.row; let row = MapData.row;
let col = MapData.col; let col = MapData.col;
this.homeimgday = createSvga("房子动画"); // this.homeimgday = createSvga("房子动画");
this.homeimgday.x = this.homex; // this.homeimgday.x = this.homex;
this.homeimgday.y = this.homey; // this.homeimgday.y = this.homey;
this.homeimgday.stop(); // this.homeimgday.stop();
this.homeimgday.visible = false; // this.homeimgday.visible = false;
this.addChild(this.homeimgday); // this.addChild(this.homeimgday);
this.homeimgnight = createSvga("夜晚房子"); // this.homeimgnight = createSvga("夜晚房子");
this.homeimgnight.x = this.homex; // this.homeimgnight.x = this.homex;
this.homeimgnight.y = this.homey; // this.homeimgnight.y = this.homey;
this.homeimgnight.stop(); // this.homeimgnight.stop();
this.homeimgnight.visible = false; // this.homeimgnight.visible = false;
this.addChild(this.homeimgnight); // this.addChild(this.homeimgnight);
...@@ -214,13 +224,45 @@ export default class GameView extends engine.Container { ...@@ -214,13 +224,45 @@ export default class GameView extends engine.Container {
// testbtn.y = 900; // testbtn.y = 900;
// testbtn.fillColor = "red"; // testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this); // 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(){ changeAni(){
this.changeHomeShow("night"); this.changeHomeShow("night");
} }
playComp(){ playComp(){
this.homeimgday.stop(1); // this.homeimgday.stop(1);
this.homeimgnight.stop(1); // this.homeimgnight.stop(1);
} }
init(time,level,mode){ init(time,level,mode){
...@@ -352,18 +394,18 @@ export default class GameView extends engine.Container { ...@@ -352,18 +394,18 @@ export default class GameView extends engine.Container {
this.gametime = ngtime; this.gametime = ngtime;
} }
} }
if(this.homeimgday&&this.homeimgday.visible){ // if(this.homeimgday&&this.homeimgday.visible){
let curframe = this.homeimgday.currentFrame; // let curframe = this.homeimgday.currentFrame;
if(curframe==this.homeimgday.totalFrames){ // if(curframe==this.homeimgday.totalFrames){
this.homeimgday.gotoAndStop(1); // this.homeimgday.gotoAndStop(1);
} // }
} // }
if(this.homeimgnight&&this.homeimgnight.visible){ // if(this.homeimgnight&&this.homeimgnight.visible){
let curframe = this.homeimgnight.currentFrame; // let curframe = this.homeimgnight.currentFrame;
if(curframe==this.homeimgnight.totalFrames){ // if(curframe==this.homeimgnight.totalFrames){
this.homeimgnight.gotoAndStop(1); // this.homeimgnight.gotoAndStop(1);
} // }
} // }
this.lastframeTime = ntime; this.lastframeTime = ntime;
} }
...@@ -487,6 +529,14 @@ export default class GameView extends engine.Container { ...@@ -487,6 +529,14 @@ export default class GameView extends engine.Container {
let sc = data.c; let sc = data.c;
let type = data.type; let type = data.type;
let sname = sr+"_"+sc; let sname = sr+"_"+sc;
//使用炸弹
if(this.useBoom){
if(type=="mouse_down"){
this.unShowEleAttion();
this.boomeEle(sr,sc);
}
return;
}
//新增滑动操作 //新增滑动操作
let lnewSelect = this.newSelect; let lnewSelect = this.newSelect;
...@@ -557,11 +607,25 @@ export default class GameView extends engine.Container { ...@@ -557,11 +607,25 @@ export default class GameView extends engine.Container {
let r = rcname.split("_")[0]; let r = rcname.split("_")[0];
let c = rcname.split("_")[1]; let c = rcname.split("_")[1];
let rcpos = MapData.getRCPos(r,c); let rcpos = MapData.getRCPos(r,c);
engine.Tween.removeTweens(this.selectimg);
this.anicontainer.addChild(this.selectimg); this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0]; this.selectimg.x = rcpos[0]-3;
this.selectimg.y = rcpos[1]+this.conty; 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(){ changeElePos(){
...@@ -655,7 +719,7 @@ export default class GameView extends engine.Container { ...@@ -655,7 +719,7 @@ export default class GameView extends engine.Container {
let ielidata1 = this.eliminateArr[i]; let ielidata1 = this.eliminateArr[i];
let ielileng = ielidata1.length; let ielileng = ielidata1.length;
let addscore = 0; let addscore = 0;
if(ielileng==3){ if(ielileng<=3){
addscore = props.threeEscore; addscore = props.threeEscore;
}else if(ielileng==4){ }else if(ielileng==4){
addscore = props.fourEscore; addscore = props.fourEscore;
...@@ -679,13 +743,20 @@ export default class GameView extends engine.Container { ...@@ -679,13 +743,20 @@ export default class GameView extends engine.Container {
let ielix = ielinode.x; let ielix = ielinode.x;
let ieliy = ielinode.y; let ieliy = ielinode.y;
let ietype = ielinode.type; let ietype = ielinode.type;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode,ietype);
this.addScoreAni(ielix,ieliy,ietype,addscore);
this.lattices[ielidxname] = "empty"; if(this.elitype==1){//原地消失
//元素层消除,动画层添加 this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype,ielix,ieliy); 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);
}
} }
} }
...@@ -701,8 +772,8 @@ export default class GameView extends engine.Container { ...@@ -701,8 +772,8 @@ export default class GameView extends engine.Container {
res1(); res1();
},500) },500)
}) })
this.homeimgday.play(1,1); // this.homeimgday.play(1,1);
this.homeimgnight.play(1,1); // this.homeimgnight.play(1,1);
} }
//掉落 //掉落
async fall(type="normal"){ async fall(type="normal"){
...@@ -833,7 +904,7 @@ export default class GameView extends engine.Container { ...@@ -833,7 +904,7 @@ export default class GameView extends engine.Container {
} }
//原地消失 //原地消失
goDisplayAni(ielitype,ielix,ieliy){ goDisplayAni(ielitype,ielix,ieliy){
console.log("老原地消失"); // console.log("老原地消失");
let aniele = MapData.getOneEle(ielitype); let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0; aniele.alpha = 0;
...@@ -1513,22 +1584,21 @@ export default class GameView extends engine.Container { ...@@ -1513,22 +1584,21 @@ export default class GameView extends engine.Container {
let txtcolor = "#bd882f"; let txtcolor = "#bd882f";
switch(ietype){ switch(ietype){
case ElementType.btiger: case ElementType.gdog:
txtcolor = "#ffffff"; txtcolor = "#d3ff6d";
break; break;
case ElementType.gtiger: case ElementType.pbird:
txtcolor = "#f5a900"; txtcolor = "#ff51d4";
break; break;
case ElementType.monkey: case ElementType.hniu:
txtcolor = "#bd882f"; txtcolor = "#ffab55";
break; break;
case ElementType.bird: case ElementType.bribbit:
txtcolor = "#54c1ef"; txtcolor = "#b3d4ff";
break; break;
case ElementType.koala: case ElementType.rpig:
txtcolor = "#c7c8c9"; txtcolor = "#f2453b";
break; break;
default: default:
console.error("未定义类型,检查"); console.error("未定义类型,检查");
break; break;
...@@ -1574,7 +1644,52 @@ export default class GameView extends engine.Container { ...@@ -1574,7 +1644,52 @@ export default class GameView extends engine.Container {
}else{ }else{
_v = false; _v = false;
} }
this.homeimgday.visible = _v; // this.homeimgday.visible = _v;
this.homeimgnight.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();
} }
} }
import Element from "./ele/Element"; import Element from "./ele/Element";
import { getTextureByName } from "./utils"; import { getTextureByName } from "./utils";
export enum ElementType{ export enum ElementType{
btiger = 1, gdog = 1,
gtiger, pbird,
monkey, hniu,
bird, bribbit,
koala rpig
} }
export enum GameEvent{ export enum GameEvent{
SelectEle = "SelectEle", SelectEle = "SelectEle",
} }
export default class MapData{ export default class MapData{
//单格大小 //单格大小
static itemsize = 129; static itemsize = 116;
// //
static paddingb = 10; static paddingw = 7;
static paddingi = 5; static paddingh = 7;
static paddingwi = 4;
static paddinghi = 2;
// //
static row = 5; static row = 5;
static col = 5; static col = 5;
...@@ -28,11 +30,11 @@ export default class MapData{ ...@@ -28,11 +30,11 @@ export default class MapData{
static anispeed = 1000; static anispeed = 1000;
static btigerTex:engine.Texture; static gdotTex:engine.Texture;
static gtigerTex:engine.Texture; static pbirdTex:engine.Texture;
static monkeyTex:engine.Texture; static hniuTex:engine.Texture;
static birdTex:engine.Texture; static bribbitTex:engine.Texture;
static koalaTex:engine.Texture; static rpigTex:engine.Texture;
static levelData:Array<Array<Array<number>>> = [ static levelData:Array<Array<Array<number>>> = [
[ [
...@@ -73,10 +75,10 @@ export default class MapData{ ...@@ -73,10 +75,10 @@ export default class MapData{
] ]
static getRy(r){ static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi); return this.paddingh+r*(this.itemsize+this.paddinghi);
} }
static getCx(c){ static getCx(c){
return this.paddingb+c*(this.itemsize+this.paddingi); return this.paddingw+c*(this.itemsize+this.paddingwi);
} }
static getRCPos(r,c){ static getRCPos(r,c){
let x = this.getCx(c); let x = this.getCx(c);
...@@ -92,20 +94,20 @@ export default class MapData{ ...@@ -92,20 +94,20 @@ export default class MapData{
static getEtypeImgName(type:ElementType){ static getEtypeImgName(type:ElementType){
let ename:string; let ename:string;
switch(type){ switch(type){
case ElementType.btiger: case ElementType.gdog:
ename = "白虎"; ename = "";
break; break;
case ElementType.gtiger: case ElementType.pbird:
ename = "雌虎"; ename = "";
break; break;
case ElementType.monkey: case ElementType.hniu:
ename = "猴子"; ename = "";
break; break;
case ElementType.bird: case ElementType.bribbit:
ename = ""; ename = "兔子";
break; break;
case ElementType.koala: case ElementType.rpig:
ename = "树熊"; ename = "";
break; break;
default: default:
console.error("未定义元素类型"); console.error("未定义元素类型");
...@@ -116,40 +118,40 @@ export default class MapData{ ...@@ -116,40 +118,40 @@ export default class MapData{
static getEtypeImgTex(type:ElementType){ static getEtypeImgTex(type:ElementType){
let etex:engine.Texture; let etex:engine.Texture;
switch(type){ switch(type){
case ElementType.btiger: case ElementType.gdog:
if(!this.btigerTex){ if(!this.gdotTex){
this.btigerTex = getTextureByName("白虎"); this.gdotTex = getTextureByName("狗");
console.log("新素材加载---白虎"); console.log("新素材加载---");
} }
etex = this.btigerTex; etex = this.gdotTex;
break; break;
case ElementType.gtiger: case ElementType.pbird:
if(!this.gtigerTex){ if(!this.pbirdTex){
this.gtigerTex = getTextureByName("雌虎"); this.pbirdTex = getTextureByName("鸟");
console.log("新素材加载---雌虎"); console.log("新素材加载---");
} }
etex = this.gtigerTex; etex = this.pbirdTex;
break; break;
case ElementType.monkey: case ElementType.hniu:
if(!this.monkeyTex){ if(!this.hniuTex){
this.monkeyTex = getTextureByName("猴子"); this.hniuTex = getTextureByName("牛");
console.log("新素材加载---猴子"); console.log("新素材加载---");
} }
etex = this.monkeyTex; etex = this.hniuTex;
break; break;
case ElementType.bird: case ElementType.bribbit:
if(!this.birdTex){ if(!this.bribbitTex){
this.birdTex = getTextureByName("鸟"); this.bribbitTex = getTextureByName("兔子");
console.log("新素材加载---"); console.log("新素材加载---兔子");
} }
etex = this.birdTex; etex = this.bribbitTex;
break; break;
case ElementType.koala: case ElementType.rpig:
if(!this.koalaTex){ if(!this.rpigTex){
this.koalaTex = getTextureByName("树熊"); this.rpigTex = getTextureByName("猪");
console.log("新素材加载---树熊"); console.log("新素材加载---");
} }
etex = this.koalaTex; etex = this.rpigTex;
break; break;
default: default:
console.error("未定义元素类型"); console.error("未定义元素类型");
...@@ -159,22 +161,22 @@ export default class MapData{ ...@@ -159,22 +161,22 @@ export default class MapData{
} }
static getRandEtype(){ static getRandEtype(){
let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala]; let eletypeArr = [ElementType.gdog,ElementType.pbird,ElementType.hniu,ElementType.bribbit,ElementType.rpig];
let etype = eletypeArr[Math.floor(Math.random()*eletypeArr.length)]; let etype = eletypeArr[Math.floor(Math.random()*eletypeArr.length)];
return etype; return etype;
} }
static initPoolEle(){ static initPoolEle(){
// console.error("初始化元素池"); // console.error("初始化元素池");
this.btigerTex = getTextureByName("白虎"); this.gdotTex = getTextureByName("狗");
this.gtigerTex = getTextureByName("雌虎"); this.pbirdTex = getTextureByName("鸟");
this.monkeyTex = getTextureByName("猴子"); this.hniuTex = getTextureByName("牛");
this.birdTex = getTextureByName("鸟"); this.bribbitTex = getTextureByName("兔子");
this.koalaTex = getTextureByName("树熊"); this.rpigTex = getTextureByName("猪");
let eletypes = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala]; let eletypes = [ElementType.gdog,ElementType.pbird,ElementType.hniu,ElementType.bribbit,ElementType.rpig];
this.elePool["ele"] = new Array(); this.elePool["ele"] = new Array();
//初始5*5个元素备用; //初始5*5个元素备用;
for(let i=0;i<eletypes.length;i++){ for(let i=0;i<eletypes.length;i++){
......
...@@ -40,8 +40,6 @@ export default class Element extends engine.Container{ ...@@ -40,8 +40,6 @@ export default class Element extends engine.Container{
// console.log("大小",imgwid,imghei); // console.log("大小",imgwid,imghei);
this.eimage.x = (this.width - imgwid)/2; this.eimage.x = (this.width - imgwid)/2;
this.eimage.y = (this.height-imghei)/2; this.eimage.y = (this.height-imghei)/2;
} }
setrc(r,c){ setrc(r,c){
this.inrow = r; this.inrow = r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment