Commit c9c85dee authored by zjz1994's avatar zjz1994

铺草暂存

parent 5529bfa7
......@@ -5403,9 +5403,14 @@
"name": "startscenebg_png"
},
{
"name": "startscenebg_jpg",
"url": "assets/startscenebg.jpg",
"type": "image",
"url": "assets/startscenebg.jpg"
"name": "startscenebg_jpg"
},
{
"url": "assets/mainScene/ele41.png",
"type": "image",
"name": "ele41_png"
}
]
}
\ No newline at end of file
......@@ -6204,6 +6204,53 @@ export default class MainScene extends Scene {
*
*/
solveTurf(turfidx:number,main:Array<{idx:number,canturff:boolean,canturft:boolean}>,all:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var oldneedturfarr = this.getOneElNeedPu(main,all);
//当前消除不能铺上,之前之后的消除可能铺上
if(oldneedturfarr.length>0){
var zhijepuArr:Array<number> = new Array();
var freshpuArr:Array<number> = new Array();
for(var i3=0;i3<this.recoverArr.length;i3++){
var i3data = this.recoverArr[i3];
var i3turidx = i3data.turidx;
var i3main = i3data.main;
var i3all = i3data.all;
//给all能铺的铺上
var olecanturfarr = this.getOneElCanPu(i3main,i3all);
if(olecanturfarr.length){
for(var i4=0;i4<oldneedturfarr.length;i4++){
var i4lidx = oldneedturfarr[i4];
//todo,细化下
if(olecanturfarr.indexOf(i4lidx)!=-1){
//修改小消除组的数据
var result1 = this.changeOneRecover(i4lidx,i3turidx,i3main,i3all);
var i3needfresh = result1.needfresh;
if(i3needfresh){
freshpuArr.push(i3turidx);
}
var changearr = result1.changearr;
var izhijepu = this.checkPuArr(changearr);
zhijepuArr.push(...izhijepu);
}
}
}
}
//todo
// this.pu
}
}
/**
*
* @param main
* @param all
*/
getOneElNeedPu(main:Array<{idx:number,canturff:boolean,canturft:boolean}>,all:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var canturff = false;
for(var i1=0;i1<main.length;i1++){
var i1data = main[i1];
......@@ -6222,19 +6269,106 @@ export default class MainScene extends Scene {
}
}
}
return oldneedturfarr;
}
var zhijepuArr:Array<number> = new Array();
var freshpuArr:Array<number> = new Array();
for(var i3=0;i3<this.recoverArr.length;i3++){
var i3data = this.recoverArr[i3];
var i3idx = i3data.turidx;
var i3main = i3data.main;
var i3all = i3data.all;
/**
*
* @param main
* @param all
*/
getOneElCanPu(main:Array<{idx:number,canturff:boolean,canturft:boolean}>,all:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var canturff = false;
for(var i1=0;i1<main.length;i1++){
var i1data = main[i1];
if(i1data.canturff){
canturff = true;
break;
}
}
var oldneedturfarr:Array<number> = new Array();
if(!canturff){
for(var i2=0;i2<all.length;i2++){
var i2data = all[i2];
if(i2data.canturft){
oldneedturfarr.push(i2data.idx);
}
}
}
return oldneedturfarr;
}
/**
* 修改小消除组
* @param lidx
* @param turidx
* @param main
* @param all
*/
changeOneRecover(lidx:number,turidx:number,main:Array<{idx:number,canturff:boolean,canturft:boolean}>,all:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var changemainidxarr = new Array();
var changeallidxarr = new Array();
var result1:{
needfresh:boolean,
changearr:Array<number>,
arridx:number
} = {
needfresh:false,
changearr:[],
arridx:turidx
}
//判断是否需要fresh
var canturff = false;
for(var i1=0;i1<main.length;i1++){
var i1data = main[i1];
if(i1data.canturff){
canturff = true;
}
if(lidx==i1data.idx&&i1data.canturft){
i1data.canturft = false;
i1data.canturff = true;
changemainidxarr.push(i1data.idx);
}
}
//不需要刷新本次小消除的铺草
if(canturff){
result1.needfresh = false;
}else{//需要刷新
if(changemainidxarr.length>0){
result1.needfresh = true;
}
}
for(var i2=0;i2<all.length;i2++){
var i2data = all[i2];
if(i2data.idx&&i2data.canturft){
i2data.canturft = false;
i2data.canturff = true;
changeallidxarr.push(i2data.idx);
}
}
if(changeallidxarr.length>0){
result1.changearr = changeallidxarr;
}
return result1;
}
/**
* 是否直接铺草,或是等待元素消除时铺草
* @param changearr
*/
checkPuArr(changearr:Array<number>){
var zhijepuArr:Array<number> = new Array();
for(var i=0;i<changearr.length;i++){
var ilidx = changearr[i];
//直接铺草
if(this.eliminatedElements.indexOf(ilidx)==-1){
zhijepuArr.push(ilidx);
}else{
}
}
return zhijepuArr;
}
}
\ No newline at end of file
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