Commit 7f4430e2 authored by zjz1994's avatar zjz1994

消消乐暂存

parent 1c884ff1
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,6 +4,16 @@
(global = global || self, global.xiaoxiaole = 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);
}
......@@ -286,10 +296,25 @@
_this.homey = -20;
_this.ination = false;
_this.canation = true;
_this.score = 0;
_this._gametime = 60;
_this._gamestat = 2;
_this._score = 0;
_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
});
GameView.prototype.setup = function () {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框"));
......@@ -333,41 +358,75 @@
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
var 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);
};
GameView.prototype.playComp = function () {
this.homeimg.stop(1);
};
GameView.prototype.init = function () {
GameView.prototype.init = function (time, level) {
console.log("gameview-init", time, level);
this.score = 0;
this.gametime = time;
this.initContainer();
};
GameView.prototype.reset = function () {
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) {
engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });
if (nshowtime <= 0) {
this.gameOver();
}
}
this._gametime = time;
},
enumerable: true,
configurable: true
});
GameView.prototype.gameOver = function () {
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
engine.globalEvent.dispatchEvent("game-over", {
score: this.score
});
};
GameView.prototype.reset = function (time, level) {
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:
console.log("gameview-reset", time, level);
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.changeEnable(false);
for (key in this.lattices) {
rcname = this.lattices[key];
rcele = this.container.getChildByName(rcname);
rcelex = rcele.x;
rceley = rcele.y;
rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.goDisplayAni(rcetype, rcelex, rceley);
if (rcele) {
rcelex = rcele.x;
rceley = rcele.y;
rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.goDisplayAni(rcetype, rcelex, rceley);
}
}
fallpro = new Promise(function (res) {
setTimeout(function () {
......@@ -392,12 +451,18 @@
});
};
GameView.prototype.start = function () {
this.gamestat = 1;
};
GameView.prototype.onUpdate = function () {
var ntime = Date.now();
var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow();
if (this.gamestat == 1) {
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) {
this.gametime -= passtime / 1000;
}
}
if (this.homeimg) {
var curframe = this.homeimg.currentFrame;
......@@ -445,21 +510,34 @@
this.setLatticeEleRc(rcidx);
}
}
this.checkInit();
};
GameView.prototype.checkInit = function () {
this.checkEliminate();
this.fall();
if (this.eliminateArr.length > 0) {
return this.eliminate();
}
else {
this.selectArr = new Array();
var isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 2) {
this.changeEnable(true);
}
else {
this.solveDieMap();
}
}
};
GameView.prototype.setLatticeEleRc = function (rcidx) {
var rename = this.lattices[rcidx];
var rcnode = this.container.getChildByName(rename);
var er = Number(rcidx.split("_")[0]);
var ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er, ec);
if (rcnode) {
var er = Number(rcidx.split("_")[0]);
var ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er, ec);
}
};
GameView.prototype.selectele = function (e) {
var data = e.data;
var sr = data.r;
var sc = data.c;
var sname = sr + "_" + sc;
GameView.prototype.unShowEleAttion = function () {
if (this.ination) {
this.ination = false;
this.lastatime = Date.now();
......@@ -469,6 +547,10 @@
var atname2 = this.lattices[arrcidx2];
var atnode1 = this.container.getChildByName(atname1);
var atnode2 = this.container.getChildByName(atname2);
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);
......@@ -478,6 +560,13 @@
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
}
};
GameView.prototype.selectele = function (e) {
var data = e.data;
var sr = data.r;
var sc = data.c;
var sname = sr + "_" + sc;
this.unShowEleAttion();
if (this.selectArr.length == 0) {
this.selectArr.push(sname);
}
......@@ -529,6 +618,10 @@
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;
......@@ -580,24 +673,41 @@
};
GameView.prototype.eliminate = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var i, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;
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:
console.log(JSON.stringify(this.eliminateArr));
for (i = 0; i < this.eliminateArr.length; i++) {
ielidata = this.eliminateArr[i];
ielidxname = ielidata.idxname;
ielitype = ielidata.type;
ieliname = this.lattices[ielidxname];
ielinode = this.container.getChildByName(ieliname);
ielix = ielinode.x;
ieliy = ielinode.y;
ietype = ielinode.type;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode, ietype);
this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype, ielix, ieliy);
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.score += 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;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode, ietype);
this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype, ielix, ieliy);
}
}
return [4, new Promise(function (res) {
setTimeout(function () {
......@@ -673,6 +783,9 @@
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);
......@@ -760,14 +873,27 @@
aniele.flyToHome(this.tanix, this.taniy, anitime);
};
GameView.prototype.changeEnable = function (v) {
for (var key in this.lattices) {
var kname = this.lattices[key];
var ele = this.container.getChildByName(kname);
ele.touch = v;
var changeable = false;
if (this.gamestat == 1) {
changeable = true;
}
if (v) {
this.lastatime = Date.now();
this.ination = false;
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;
};
......@@ -780,6 +906,9 @@
var atname2 = this.lattices[attiondata[1]];
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;
......@@ -814,6 +943,9 @@
}
};
GameView.prototype.solveDieMap = function () {
if (this.gamestat != 1) {
return;
}
this.changeEnable(false);
var elearr = new Array();
for (var key in this.lattices) {
......@@ -843,6 +975,9 @@
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]);
......@@ -1134,28 +1269,60 @@
var rc = r + "_" + c;
var elename = this.lattices[rc];
var ele = this.container.getChildByName(elename);
var eletype = ele.type;
return eletype;
if (ele) {
var eletype = ele.type;
return eletype;
}
};
GameView.prototype.checkAddEli = function (etype, earr) {
console.log(JSON.stringify(earr));
for (var e = 0; e < earr.length; e++) {
var ename = earr[e];
var needadd = true;
for (var i = 0; i < this.eliminateArr.length; i++) {
var ielidata = this.eliminateArr[i];
var ielidxname = ielidata.idxname;
if (ielidxname == ename) {
needadd = false;
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 (needadd) {
this.eliminateArr.push({
idxname: ename,
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) {
......@@ -1184,11 +1351,13 @@
engine.globalEvent.addEventListener('game-start', _this.start, _this);
return _this;
}
GameWrapper.prototype.init = function () {
this._gameView.init();
GameWrapper.prototype.init = function (event) {
console.log("gamewrapper-init", event);
this._gameView.init(event.data.time, event.data.level);
};
GameWrapper.prototype.reset = function () {
this._gameView.reset();
GameWrapper.prototype.reset = function (event) {
console.log("gamewrapper-reset", event);
this._gameView.reset(event.data.time, event.data.level);
};
GameWrapper.prototype.start = function () {
this._gameView.start();
......@@ -1197,16 +1366,6 @@
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function index (props) {
prepareProps();
injectProps(props);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,21 @@
"name": "消消乐",
"desc": "消消乐模块",
"props": {
"threeEscore":{
"alias":"三消加分",
"type":"number",
"default":1
},
"fourEscore":{
"alias":"四消加分",
"type":"number",
"default":2
},
"moreEscore":{
"alias":"多消加分",
"type":"number",
"default":3
}
},
"assets": [
{
......
......@@ -48,7 +48,17 @@ export default class GameView extends engine.Container {
ination = false;
canation = true;
score = 0;
_gametime = 60;
_gamestat=2;
set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat;
if(stat==2){
this.changeEnable(false);
}
}
get gamestat(){
return this._gamestat;
}
setup() {
MapData.initPoolEle();
......@@ -107,42 +117,80 @@ export default class GameView extends engine.Container {
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 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);
}
playComp(){
this.homeimg.stop(1);
}
init(){
init(time,level){
console.log("gameview-init",time,level);
this.score = 0;
this.gametime = time;
this.initContainer();
}
_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);
engine.globalEvent.dispatchEvent('game-time-update',{time:nshowtime});
if(nshowtime<=0){
this.gameOver();
}
}
this._gametime = time;
}
get gametime(){
return this._gametime;
}
gameOver(){
// console.log("游戏结束");
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
engine.globalEvent.dispatchEvent("game-over",{
score:this.score
})
};
levelData;
async reset(){
async reset(time,level){
console.log("gameview-reset",time,level);
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.changeEnable(false);
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
let rcelex = rcele.x;
let rceley = rcele.y;
let rcetype = rcele.type;
if(rcele){
let rcelex = rcele.x;
let rceley = rcele.y;
let rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.container.removeChild(rcele);
this.lattices[key] = "empty";
this.goDisplayAni(rcetype,rcelex,rceley);
this.goDisplayAni(rcetype,rcelex,rceley);
}
}
let fallpro = new Promise(res=>{
setTimeout(function(){
......@@ -162,13 +210,18 @@ export default class GameView extends engine.Container {
this.fall("newlevel");
}
start(){
this.gamestat = 1;
}
onUpdate(){
let ntime = Date.now();
let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow();
if(this.gamestat==1){
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){
this.gametime -= passtime/1000;
}
}
if(this.homeimg){
let curframe = this.homeimg.currentFrame;
......@@ -176,7 +229,7 @@ export default class GameView extends engine.Container {
this.homeimg.gotoAndStop(1);
}
}
this.lastframeTime = ntime;
}
initContainer(){
......@@ -221,23 +274,36 @@ export default class GameView extends engine.Container {
}
}
//初始化,检测消除,死图
this.checkInit();
}
checkInit(){
this.checkEliminate();
this.fall();
if(this.eliminateArr.length>0){
return this.eliminate();
}else{//一次操作完毕
this.selectArr = new Array();
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==2){//没死
this.changeEnable(true);
}else{//死图处理
this.solveDieMap();
}
//检查死图
}
}
//关联
setLatticeEleRc(rcidx){
let rename = this.lattices[rcidx];
let rcnode:Element = this.container.getChildByName(rename);
let er = Number(rcidx.split("_")[0]);
let ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er,ec);
if(rcnode){
let er = Number(rcidx.split("_")[0]);
let ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er,ec);
}
}
selectele(e:engine.Event){
let data = e.data;
let sr = data.r;
let sc = data.c;
let sname = sr+"_"+sc;
//取消提示选择
unShowEleAttion(){
if(this.ination){
this.ination = false;
this.lastatime = Date.now();
......@@ -247,6 +313,10 @@ export default class GameView extends engine.Container {
let atname2 = this.lattices[arrcidx2];
let atnode1:Element = this.container.getChildByName(atname1);
let atnode2:Element = this.container.getChildByName(atname2);
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]);
......@@ -259,8 +329,16 @@ export default class GameView extends engine.Container {
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
}
}
//选择元素
selectele(e:engine.Event){
let data = e.data;
let sr = data.r;
let sc = data.c;
let sname = sr+"_"+sc;
this.unShowEleAttion();
if(this.selectArr.length==0){
// console.log("选中元素",data);
this.selectArr.push(sname);
......@@ -321,6 +399,10 @@ export default class GameView extends engine.Container {
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;
......@@ -378,23 +460,40 @@ export default class GameView extends engine.Container {
//消除
async eliminate(){
console.log(JSON.stringify(this.eliminateArr));
for(let i=0;i<this.eliminateArr.length;i++){
let ielidata = this.eliminateArr[i];
let ielidxname = ielidata.idxname;
let ielitype = ielidata.type;
let ieliname = this.lattices[ielidxname];
let ielinode:Element = this.container.getChildByName(ieliname);
let ielix = ielinode.x;
let ieliy = ielinode.y;
let ietype = ielinode.type;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode,ietype);
this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加
this.goHomeAni(ielitype,ielix,ieliy);
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.score += 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;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode,ietype);
this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加
this.goHomeAni(ielitype,ielix,ieliy);
}
}
await new Promise(res=>{
......@@ -466,7 +565,9 @@ export default class GameView extends engine.Container {
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);
......@@ -492,7 +593,7 @@ export default class GameView extends engine.Container {
fallPromise.push(ifallpromise);
}
await Promise.all(fallPromise);
this.checkEliminate();
if(this.eliminateArr.length>0){
return this.eliminate();
......@@ -558,14 +659,27 @@ export default class GameView extends engine.Container {
//修改元素点击
changeEnable(v:boolean){
for(let key in this.lattices){
let kname = this.lattices[key];
let ele:Element = this.container.getChildByName(kname);
ele.touch = v;
let changeable = false;
if(this.gamestat==1){
changeable = true;
}else{
if(!v){
changeable = true;
}
}
if(v){
this.lastatime = Date.now();
this.ination = false;
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;
}
......@@ -581,6 +695,10 @@ export default class GameView extends engine.Container {
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;
......@@ -621,6 +739,9 @@ export default class GameView extends engine.Container {
}
//死图调整
solveDieMap(){
if(this.gamestat!=1){
return;
}
this.changeEnable(false);
// console.error("死图调整");
// console.log(this.lattices);
......@@ -650,6 +771,9 @@ export default class GameView extends engine.Container {
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;
......@@ -987,30 +1111,59 @@ export default class GameView extends engine.Container {
let rc = r+"_"+c;
let elename = this.lattices[rc];
let ele:Element = this.container.getChildByName(elename);
let eletype = ele.type;
return eletype;
if(ele){
let eletype = ele.type;
return eletype;
}
}
checkAddEli(etype,earr){
console.log(JSON.stringify(earr));
for(let e=0;e<earr.length;e++){
let ename = earr[e];
let needadd = true;
for(let i=0;i<this.eliminateArr.length;i++){
let ielidata = this.eliminateArr[i];
let ielidxname = ielidata.idxname;
if(ielidxname==ename){
needadd = false;
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(needadd){
this.eliminateArr.push({
idxname:ename,
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
})
}
}
}
}
//获得这个位置掉落的元素
......
......@@ -19,11 +19,13 @@ export class GameWrapper extends engine.Container {
engine.globalEvent.addEventListener('game-start',this.start,this);
}
init(){
this._gameView.init();
init(event:engine.Event){
console.log("gamewrapper-init",event);
this._gameView.init(event.data.time,event.data.level);
}
reset(){
this._gameView.reset();
reset(event:engine.Event){
console.log("gamewrapper-reset",event);
this._gameView.reset(event.data.time,event.data.level);;
}
start(){
this._gameView.start();
......
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