Commit 53c5c73d authored by zjz1994's avatar zjz1994

代码暂存

parent 24ead12f
......@@ -497,6 +497,7 @@ export default class MainScene extends Scene {
this.lollipopCount = 0;
this.hasPassed = false;
this.isCountingTime = false;
this.initTurf();
......@@ -1939,16 +1940,13 @@ export default class MainScene extends Scene {
// }
// }
// }
var grassArr = new Array();
var canturgrass = this.judgeTurfing(index);
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
//新增石头阻挡
var elimitarr = this.getEliPassCannoStone(rc[0],rc[1]);
for(var j=0;j<elimitarr.length;j++){
var jelidx = elimitarr[j];
var jlat = this.lattices[jelidx];
if(canturgrass&&Tool.judgeTurfto(jlat)){
grassArr.push(jelidx);
}
if(this.eliminatedElements.indexOf(jelidx)==-1){
this.eliminatedElements.push(jelidx);
if(jlat.element.type == ElementType.FISH){
......@@ -1960,11 +1958,14 @@ export default class MainScene extends Scene {
}
}
}
mainidxs.push(index);
allidxs.push(index);
this.turfEliPassCp(rc[0],rc[1],allidxs);
//特效铺草把炮台和猩猩加进去
var turfCp = new Array();
if(canturgrass){
this.turfEliPassCp(rc[0],rc[1],turfCp);
}
// var turfCp = new Array();
// if(canturgrass){
// this.turfEliPassCp(rc[0],rc[1],turfCp);
// }
//新大炮充能
......@@ -1995,12 +1996,7 @@ export default class MainScene extends Scene {
setTimeout(() => {
this.initOneElmtTag();
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
this.addNewTurf(mainidxs,allidxs);
this.eliminate(pcannostatArr);
}, 200)
break;
......@@ -2012,7 +2008,12 @@ export default class MainScene extends Scene {
Tool.getPositionByIndex(index)
)
}
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs.push(index);
allidxs.push(index);
this.initOneElmtTag();
this.addNewTurf(mainidxs,allidxs);
this.eliminate();
break;
case PropType.CHANCE_NUM:
......@@ -2232,7 +2233,7 @@ export default class MainScene extends Scene {
* 比如在一次性fallVerticalEx每列加上斜落元素,必须自身下方是空,无连通的情况
* @param callback 所有fall完成后的回调,检查三消,
*/
fall(callback: Function) {
fall(callback: Function) {///TODO
//去重一次
Tool.removeReapty(this.emptys);
......@@ -6066,7 +6067,7 @@ export default class MainScene extends Scene {
}
}
}
//炮台,猩猩,特效铺草
//炮台,猩猩,特效铺草,直接铺草
changeGroGrassCp(arr:Array<number>){
for(let p=0;p<arr.length;p++){
let pidx = arr[p];
......@@ -6076,7 +6077,8 @@ export default class MainScene extends Scene {
//新增铺草地
turfing(index:number){
var lat = this.lattices[index];
if(lat&&lat.element&&!lat.grass){//消除元素铺草坪
if(lat&&!lat.grass){//lat.element&&
//消除元素铺草坪
//存在冰块和流沙时,草坪铺不上去
// if(lat.ice&&lat.ice.alpha!=0){
// return;
......@@ -6112,25 +6114,62 @@ export default class MainScene extends Scene {
//判断草坪能否蔓延
judgeTurfing(idx:number){
if(this.turfingArr.indexOf(idx)!=-1){
var canturff = false;
for(var i=0;i<this.recoverArr.length;i++){
var irecoverdata = this.recoverArr[i];
var imaindata = irecoverdata.main;
var ialldata = irecoverdata.all;
var canturarr = this.getOneElNorPu(imaindata,ialldata);
if(canturarr.indexOf(idx)!=-1){
canturff = true;
break;
}
}
if(canturff){
return true;
}
return Tool.judgeTurfing(this.lattices[idx]);
}
//判断草坪能否铺上
judgeTurfto(idx:number){
var canturft = false;
for(var i=0;i<this.recoverArr.length;i++){
var irecoverdata = this.recoverArr[i];
var ialldata = irecoverdata.all;
for(var i1=0;i1<ialldata.length;i1++){
var i1data = ialldata[i1];
var i1idx = i1data.idx;
if(i1idx==idx){
if(i1data.canturft){
canturft = true;
break;
}
}
}
}
if(canturft){
return true;
}
return Tool.judgeTurfto(this.lattices[idx]);
}
//特效铺炮台和猩猩
turfEliHorPassCp(row:number,col:number,turfCp:Array<number>){
turfEliHorPassCp(row:number,col:number,allidxs:Array<number>){
//向左
for(var i=col;i>=0;i--){
var iemitidx = Tool.rcToIndex(row,i);
var lat = this.lattices[iemitidx];
var iscannoblock = Tool.judgeIscannoBlock(lat);
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(iemitidx);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(iemitidx);
}
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(iemitidx);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(iemitidx);
// }
// }
if(lat){
allidxs.push(iemitidx);
}
if(iscannoblock){
break;
......@@ -6141,30 +6180,36 @@ export default class MainScene extends Scene {
var iemitidx = Tool.rcToIndex(row,i);
var lat = this.lattices[iemitidx];
var iscannoblock = Tool.judgeIscannoBlock(lat);
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(iemitidx);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(iemitidx);
}
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(iemitidx);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(iemitidx);
// }
// }
if(lat){
allidxs.push(iemitidx);
}
if(iscannoblock){
break;
}
}
}
turfEliVerPassCp(row:number,col:number,turfCp:Array<number>){
turfEliVerPassCp(row:number,col:number,allidxs:Array<number>){
//向上
for(var i=row;i>=0;i--){
var iemitidx = Tool.rcToIndex(i,col);
var lat = this.lattices[iemitidx];
var iscannoblock = Tool.judgeIscannoBlock(lat);
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(iemitidx);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(iemitidx);
}
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(iemitidx);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(iemitidx);
// }
// }
if(lat){
allidxs.push(iemitidx);
}
if(iscannoblock){
break;
......@@ -6175,27 +6220,66 @@ export default class MainScene extends Scene {
var iemitidx = Tool.rcToIndex(i,col);
var lat = this.lattices[iemitidx];
var iscannoblock = Tool.judgeIscannoBlock(lat);
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(iemitidx);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(iemitidx);
}
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(iemitidx);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(iemitidx);
// }
// }
if(lat){
allidxs.push(iemitidx);
}
if(iscannoblock){
break;
}
}
}
turfEliPassCp(row:number,col:number,turfCp:Array<number>){
this.turfEliHorPassCp(row,col,turfCp);
this.turfEliVerPassCp(row,col,turfCp);
turfEliPassCp(row:number,col:number,allidxs:Array<number>){
this.turfEliHorPassCp(row,col,allidxs);
this.turfEliVerPassCp(row,col,allidxs);
}
//铺草在一次掉落前,不分先后顺序
initTurf(){
// this.turfingArr = new Array();
this.recoverArr = new Array();
}
//添加新的小消除组
addNewTurf(mainidxs:Array<number>,allidxs:Array<number>){
Tool.removeReapty(mainidxs);
Tool.removeReapty(allidxs);
var maindata = new Array();
var alldata = new Array();
for(var i1=0;i1<mainidxs.length;i1++){
var i1idx = mainidxs[i1];
var i1canturff = this.judgeTurfing(i1idx);
var i1canturft = this.judgeTurfto(i1idx);
var i1data = {
idx:i1idx,
canturff:i1canturff,
canturft:i1canturft
}
maindata.push(i1data);
}
for(var i2=0;i2<allidxs.length;i2++){
var i2idx = allidxs[i2];
var i2canturff = this.judgeTurfing(i2idx);
var i2canturft = this.judgeTurfto(i2idx);
var i2data = {
idx:i2idx,
canturff:i2canturff,
canturft:i2canturft
}
alldata.push(i2data);
}
var turidx = this.recoverArr.length;
this.recoverArr.push({
turidx:turidx,
main:maindata,
all:alldata
})
this.solveTurf(turidx,maindata,alldata);
}
/**
*
* idx---格子坐标
......@@ -6216,7 +6300,9 @@ export default class MainScene extends Scene {
var i3turidx = i3data.turidx;
var i3main = i3data.main;
var i3all = i3data.all;
if(i3turidx==turfidx){
continue;
}
//给all能铺的铺上
var olecanturfarr = this.getOneElCanPu(i3main,i3all);
if(olecanturfarr.length){
......@@ -6238,11 +6324,25 @@ export default class MainScene extends Scene {
}
}
}
//todo
// this.pu
this.changeGroGrass(zhijepuArr);
//注意检查下,应该有问题
if(freshpuArr.length>0){
console.log("其他小组重新铺草");
for(var i5=0;i5<freshpuArr.length;i5++){
var i5turidx = freshpuArr[i5];
var i5coverdata = this.recoverArr[i5turidx];
var i5main = i5coverdata.main;
var i5all = i5coverdata.all;
var i5zhijepuArr1 = this.getOneElNorPu(i5main,i5all);
var i5zhijepuArr = this.checkPuArr(i5zhijepuArr1);
this.changeGroGrass(i5zhijepuArr);
this.solveTurf(i5turidx,i5main,i5all);
}
}else{
console.log("铺草完毕");
}
}
}
/**
......@@ -6298,6 +6398,33 @@ export default class MainScene extends Scene {
}
return oldneedturfarr;
}
/**
*
* @param main
* @param all
*/
getOneElNorPu(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
......
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