Commit e071b49f authored by zjz1994's avatar zjz1994

铺草暂存

parent 53c5c73d
......@@ -5398,9 +5398,14 @@
"name": "wormhole_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
......@@ -394,7 +394,7 @@ export default class MainScene extends Scene {
//铺草坪
turfingArr:Array<number> = [];//当前已有草的格子
// turfingArr:Array<number> = [];//当前已有草的格子
//一次掉落前的消除集合
recoverArr:Array<{
turidx:number,
......@@ -2233,7 +2233,7 @@ export default class MainScene extends Scene {
* 比如在一次性fallVerticalEx每列加上斜落元素,必须自身下方是空,无连通的情况
* @param callback 所有fall完成后的回调,检查三消,
*/
fall(callback: Function) {///TODO
fall(callback: Function) {
//去重一次
Tool.removeReapty(this.emptys);
......@@ -2749,8 +2749,6 @@ export default class MainScene extends Scene {
* 三消判断
*/
threeMatch(s?: Element, o?: Element) {
//铺路草地检查
var grassArr = new Array();
//横排检测
for(var i = 0; i < Tool.rowNum; i++) {
//集合横排元素
......@@ -2763,11 +2761,14 @@ export default class MainScene extends Scene {
let len = re[j].length;
if(len >= 3) {
let igrassarr = new Array();
var mainidxs:Array<number> = [];
var allidxs:Array<number> = [];
for(var k = 0; k < len; k++) {
let ele = this.lattices[re[j][k]].element;
this.eliminatedElements.push(re[j][k]);
igrassarr.push(re[j][k]);
mainidxs.push(re[j][k]);
allidxs.push(re[j][k]);
//是五个的
if(len >= 5) {
......@@ -2787,7 +2788,7 @@ export default class MainScene extends Scene {
}
}
}
grassArr.push(igrassarr);
this.addNewTurf(mainidxs,allidxs);
}
}
}
......@@ -2802,11 +2803,12 @@ export default class MainScene extends Scene {
for(var j = 0; j < re.length; j++) {
let len = re[j].length;
if(len >= 3) {
let igrassarr = new Array();
var mainidxs:Array<number> = [];
var allidxs:Array<number> = [];
for(var k = 0; k < len; k++) {
let ele = this.lattices[re[j][k]].element;
igrassarr.push(re[j][k]);
//是五个的,特殊处理
if(len >= 5) {
if(k == 2) {
......@@ -2849,8 +2851,12 @@ export default class MainScene extends Scene {
if(ele.temEffectType != EffectType.MAGICLION) ele.temEffectType = EffectType.EXPLOSIVE;
}
}
mainidxs.push(re[j][k]);
allidxs.push(re[j][k]);
}
grassArr.push(igrassarr);
this.addNewTurf(mainidxs,allidxs);
}
}
}
......@@ -2863,7 +2869,6 @@ export default class MainScene extends Scene {
this.pushScoreAni(baseScore * this.commonContinuityTimes, Tool.getPositionByIndex(index))
}
}
this.checkTurfing(grassArr);
return this.eliminatedElements.length > 0;
}
......@@ -2912,7 +2917,7 @@ export default class MainScene extends Scene {
}
//如果还有消除元素,继续执行
if(this.eliminatedElements.length) {
console.log("特效产生消除元素");
// console.log("特效产生消除元素");
setTimeout(() => {
this.eliminate(pcannostatArr);
}, 200)
......@@ -3470,12 +3475,16 @@ export default class MainScene extends Scene {
}
//炮台上有草坪的处理
var grassArr = new Array();
var canturgrass = false;
var turfCp = new Array();
if(this.lattices[canno.index].grass){
canturgrass = true;
}
// var grassArr = new Array();
// var canturgrass = false;
// var turfCp = new Array();
// if(this.lattices[canno.index].grass){
// canturgrass = true;
// }
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
var canpull:boolean = true;
mainidxs.push(canno.index);
//特效消除猩猩--炮弹
var lockPongoArr:Array<{idx:number,part:string}> = new Array();
for(var j=0;j<cannoFireArr.length;j++){
......@@ -3493,25 +3502,30 @@ export default class MainScene extends Scene {
}
if(canturgrass){
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(Tool.judgeTurfto(lat)){
grassArr.push(jemitidx);
}else{
if(!lat.grass){
canturgrass = false;
}
}
// if(canturgrass){
// 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(Tool.judgeTurfto(lat)){
// grassArr.push(jemitidx);
// }else{
// if(!lat.grass){
// canturgrass = false;
// }
// }
// }
}
//todo,炮台碰到不能直接消除的就停止铺草坪
if(lat&&canpull){
allidxs.push(jemitidx);
}
//提前消除了,需要修改成炮台的消除时消除
if(lat&&lat.element){
var isbreak = this.solveOneTxPgEle(lat.element.row,lat.element.column,lockPongoArr);
......@@ -3522,14 +3536,15 @@ export default class MainScene extends Scene {
if(this.fireteamCannoArr.indexOf(firecannoidx)==-1){
this.fireteamCannoArr.push(firecannoidx);
}
this.addNewTurf(mainidxs,allidxs);
if(this.fireteamCannoArr.length==this.readyCannoArr.length){
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
// if(grassArr.length>0){
// this.changeGroGrass(grassArr);
// }
// if(turfCp.length>0){
// this.changeGroGrassCp(turfCp);
// }
this.eliminate();
for(var i=0;i<this.readyCannoArr.length;i++){
var preadyCannoIdx = this.readyCannoArr[i];
......@@ -3680,18 +3695,21 @@ export default class MainScene extends Scene {
let lat2 = this.lattices[two];
//特效铺草坪
var grassArr = new Array();
var turfCp = new Array();
// var grassArr = new Array();
// var turfCp = new Array();
var canturgrass = this.judgeTurfing(one)||this.judgeTurfing(two);
if(canturgrass){
if(Tool.judgeTurfto(lat1)){
grassArr.push(one);
}
if(Tool.judgeTurfto(lat2)){
grassArr.push(two);
}
}
// var canturgrass = this.judgeTurfing(one)||this.judgeTurfing(two);
// if(canturgrass){
// if(Tool.judgeTurfto(lat1)){
// grassArr.push(one);
// }
// if(Tool.judgeTurfto(lat2)){
// grassArr.push(two);
// }
// }
var mainidxs:Array<number> = [one,two];
var allidxs:Array<number> = [one,two];
this.addNewTurf(mainidxs,allidxs);
......@@ -3715,25 +3733,29 @@ export default class MainScene extends Scene {
npdata.addnum = 1;
}
}
//移除
this.recoverEle(one);
this.recoverEle(two);
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs = [one,two];
//先不管特效组合时的自身的分数
//把所有元素加入
for(var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if(canturgrass&&lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(i);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(i);
}
}
// if(canturgrass&&lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(i);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(i);
// }
// }
if(Tool.judgeEliminate(lat)) {
if(canturgrass&&Tool.judgeTurfto(lat)){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(lat)){
// grassArr.push(i);
// }
//本来没必要判断特效组合时是否有重复的消除元素,但是recoverEle里会有判断石头或果冻的加入,造成重复
if(this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
if(this.lattices[i].element.type == ElementType.FISH) {
......@@ -3744,7 +3766,11 @@ export default class MainScene extends Scene {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes.MM, Tool.getPositionByIndex(i))
}
}
if(lat){
allidxs.push(i);
}
}
this.addNewTurf(mainidxs,allidxs);
}
//一个是魔力鸟,一个是其他特效或无,将所有相同元素变成同类型特效,除掉是魔力鸟的,
else if((ele1.effectType == EffectType.MAGICLION || ele2.effectType == EffectType.MAGICLION)) {
......@@ -3779,17 +3805,29 @@ export default class MainScene extends Scene {
elementsIndex: [],
type: other.type,
}
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs = [one,two];
allidxs = [one,two];
//手动触发只有一个
this.magicRotateData = [rotateData];
for(var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if(lat&&lat.element&&
lat.element.effectType != EffectType.MAGICLION && //不能是魔力鸟特效
lat.element.type == other.type //类型相等
){
allidxs.push(i);
}
if(Tool.judgeBaseEle(lat) && //是基础元素
lat.element.effectType != EffectType.MAGICLION && //不能是魔力鸟特效
lat.element.type == other.type //类型相等
) {
if(canturgrass&&Tool.judgeTurfto(lat)){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(lat)){
// grassArr.push(i);
// }
//一个魔力鸟时其实不用加,因为石头或果冻的不会进入判断
if(this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
//如果other带特效,符合的元素都加上特效,没动效,直接加吧先,
......@@ -3815,6 +3853,7 @@ export default class MainScene extends Scene {
}
}
}
this.addNewTurf(mainidxs,allidxs);
}
//两个都是方向的
else if(ele1.effectType < 2 && ele2.effectType < 2) {
......@@ -3849,15 +3888,19 @@ export default class MainScene extends Scene {
// }
// }
// }
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs = [one,two];
//新增石头阻挡
var elimitarr = this.getEliPassCannoStone(lat1.row,lat1.column);
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(canturgrass&&Tool.judgeTurfto(jlat)){
// grassArr.push(jelidx);
// }
// allidxs.push(jelidx);
if(this.eliminatedElements.indexOf(jelidx)==-1){
this.eliminatedElements.push(jelidx);
if(jlat.element.type == ElementType.FISH){
......@@ -3869,9 +3912,10 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliPassCp(lat1.row,lat1.column,turfCp);
}
// if(canturgrass){
// this.turfEliPassCp(lat1.row,lat1.column,turfCp);
// }
this.turfEliPassCp(lat1.row,lat1.column,allidxs);
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
var npdata = pcannostatArr[np];
......@@ -3886,7 +3930,7 @@ export default class MainScene extends Scene {
}
}
this.addNewTurf(mainidxs,allidxs);
//特效消除猩猩
this.checkPongoHVEle(lat1.row,lat1.column,"hor");
this.checkPongoHVEle(lat1.row,lat1.column,"vir");
......@@ -3938,14 +3982,19 @@ export default class MainScene extends Scene {
col:lat1.column+1
}
];
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs = [one,two];
for(var pr1=0;pr1<pongor.length;pr1++){
var prcdata = pongor[pr1];
var prcrow = prcdata.row;
var prccol = prcdata.col;
if(prcrow>=0&&prcrow<Tool.rowNum&&prccol>=0&&prccol<Tool.colNum){
if(canturgrass){
this.turfEliHorPassCp(prcrow,prccol,turfCp);
}
// if(canturgrass){
// this.turfEliHorPassCp(prcrow,prccol,turfCp);
// }
// this.turfEliHorPassCp(prcrow,prccol,allidxs);
this.checkPongoHVEle(prcrow,prccol,"hor");
for(var np=0;np<pcannostatArr.length;np++){
......@@ -3962,10 +4011,10 @@ export default class MainScene extends Scene {
var prcrow = prcdata.row;
var prccol = prcdata.col;
if(prcrow>=0&&prcrow<Tool.rowNum&&prccol>=0&&prccol<Tool.colNum){
if(canturgrass){
this.turfEliVerPassCp(prcrow,prccol,turfCp);
}
// if(canturgrass){
// this.turfEliVerPassCp(prcrow,prccol,turfCp);
// }
// this.turfEliVerPassCp(prcrow,prccol,allidxs);
this.checkPongoHVEle(prcrow,prccol,"vir");
for(var np=0;np<pcannostatArr.length;np++){
......@@ -3985,12 +4034,14 @@ export default class MainScene extends Scene {
//添加消除元素two,同行或同列,需要优化
for(var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if(lat&&(Math.abs(lat.row - lat1.row) < 2 || Math.abs(lat.column - lat1.column) < 2)){
allidxs.push(i);
}
if(Tool.judgeEliminate(lat) &&
(Math.abs(lat.row - lat1.row) < 2 || Math.abs(lat.column - lat1.column) < 2)) {
if(canturgrass&&Tool.judgeTurfto(lat)){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(lat)){
// grassArr.push(i);
// }
if(this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
if(this.lattices[i].element.type == ElementType.FISH) {
this.lattices[i].element.nextFishState();
......@@ -4002,7 +4053,7 @@ export default class MainScene extends Scene {
}
}
this.addNewTurf(mainidxs,allidxs);
}
//如果两个爆炸
else if(ele1.effectType == EffectType.EXPLOSIVE && ele2.effectType == EffectType.EXPLOSIVE) {
......@@ -4021,6 +4072,10 @@ export default class MainScene extends Scene {
npdata.addnum = 1;
}
}
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs = [one,two];
//回收
this.recoverEle(one)
this.recoverEle(two)
......@@ -4028,21 +4083,24 @@ export default class MainScene extends Scene {
//添加消除元素two,5*5,需要优化
for(var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if(canturgrass&&lat&&(Math.abs(lat.row - lat1.row) < 3 && Math.abs(lat.column - lat1.column) < 3)){
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(i);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(i);
}
}
if(lat&&(Math.abs(lat.row - lat1.row) < 3 && Math.abs(lat.column - lat1.column) < 3)){
allidxs.push(i);
}
// if(canturgrass&&lat&&(Math.abs(lat.row - lat1.row) < 3 && Math.abs(lat.column - lat1.column) < 3)){
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(i);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(i);
// }
// }
// }
if(Tool.judgeEliminate(lat) &&
(Math.abs(lat.row - lat1.row) < 3 && Math.abs(lat.column - lat1.column) < 3)) {
if(canturgrass&&Tool.judgeTurfto(lat)){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(lat)){
// grassArr.push(i);
// }
if(this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
if(this.lattices[i].element.type == ElementType.FISH) {
this.lattices[i].element.nextFishState();
......@@ -4053,14 +4111,14 @@ export default class MainScene extends Scene {
}
}
}
this.addNewTurf(mainidxs,allidxs);
}
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
// if(grassArr.length>0){
// this.changeGroGrass(grassArr);
// }
// if(turfCp.length>0){
// this.changeGroGrassCp(turfCp);
// }
}
/**
......@@ -4292,9 +4350,13 @@ export default class MainScene extends Scene {
let ele = lat.element;
if(!ele)continue;
var p = Tool.getPositionByIndex(index);
var canturgrass = this.judgeTurfing(index);
var grassArr = new Array();
var turfCp = new Array();
// var canturgrass = this.judgeTurfing(index);
// var grassArr = new Array();
// var turfCp = new Array();
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs.push(index);
switch(ele.effectType) {
case EffectType.MAGICLION:
if(sounds.indexOf(SoundType.magic) == -1) sounds.push(SoundType.magic)
......@@ -4328,9 +4390,10 @@ export default class MainScene extends Scene {
this.lattices[i].element.effectType != EffectType.MAGICLION && //不是魔力鸟
this.lattices[i].element.type == type //类型相等
) {
if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
grassArr.push(i);
}
allidxs.push(i);
// if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
// grassArr.push(i);
// }
if(this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
this.eliminatedElements.push(i);
......@@ -4345,6 +4408,7 @@ export default class MainScene extends Scene {
}
}
}
this.addNewTurf(mainidxs,allidxs);
break;
case EffectType.EXPLOSIVE:
if(sounds.indexOf(SoundType.boom) == -1) sounds.push(SoundType.boom)
......@@ -4362,20 +4426,23 @@ export default class MainScene extends Scene {
this.recoverEle(index);
//3*3,需要优化
for(var i = 0; i < this.lattices.length; i++) {
if(canturgrass&&this.lattices[i]&&Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2){
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(i);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(i);
}
}
if(this.lattices[i]&&Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2){
allidxs.push(i);
}
// if(canturgrass&&this.lattices[i]&&Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2){
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(i);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(i);
// }
// }
// }
if(Tool.judgeEliminate(this.lattices[i]) &&
(Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2)) {
if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
// grassArr.push(i);
// }
if(this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
this.eliminatedElements.push(i);
......@@ -4389,6 +4456,7 @@ export default class MainScene extends Scene {
}
}
}
this.addNewTurf(mainidxs,allidxs);
break;
case EffectType.HORIZONTAL:
if(sounds.indexOf(SoundType.line) == -1) sounds.push(SoundType.line)
......@@ -4424,9 +4492,9 @@ export default class MainScene extends Scene {
for(var j1=0;j1<elimitarr.length;j1++){
var jelidx = elimitarr[j1];
var jlat = this.lattices[jelidx];
if(canturgrass&&Tool.judgeTurfto(jlat)){
grassArr.push(jelidx);
}
// if(canturgrass&&Tool.judgeTurfto(jlat)){
// grassArr.push(jelidx);
// }
if(this.eliminatedElements.indexOf(jelidx)==-1&&effectIndexs.indexOf(jelidx)==-1){
this.eliminatedElements.push(jelidx);
......@@ -4438,10 +4506,10 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliHorPassCp(row,lat.column,turfCp);
}
// if(canturgrass){
// this.turfEliHorPassCp(row,lat.column,turfCp);
// }
this.turfEliHorPassCp(row,lat.column,allidxs);
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
var npdata = pcannostatArr[np];
......@@ -4450,7 +4518,7 @@ export default class MainScene extends Scene {
npdata.ineffect = true;
}
}
this.addNewTurf(mainidxs,allidxs);
//特效消除猩猩
this.checkPongoHVEle(row,lat.column,"hor");
......@@ -4488,9 +4556,9 @@ export default class MainScene extends Scene {
for(var j1=0;j1<elimitarr.length;j1++){
var jelidx = elimitarr[j1];
var jlat = this.lattices[jelidx];
if(canturgrass&&Tool.judgeTurfto(jlat)){
grassArr.push(jelidx);
}
// if(canturgrass&&Tool.judgeTurfto(jlat)){
// grassArr.push(jelidx);
// }
if(this.eliminatedElements.indexOf(jelidx)==-1&&effectIndexs.indexOf(jelidx)==-1){
this.eliminatedElements.push(jelidx);
......@@ -4502,9 +4570,10 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliVerPassCp(lat.row,col,turfCp);
}
// if(canturgrass){
// this.turfEliVerPassCp(lat.row,col,turfCp);
// }
this.turfEliVerPassCp(lat.row,col,allidxs);
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
......@@ -4514,18 +4583,19 @@ export default class MainScene extends Scene {
npdata.ineffect = true;
}
}
this.addNewTurf(mainidxs,allidxs);
//特效消除猩猩
this.checkPongoHVEle(lat.row,col,"vir");
break;
}
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
// if(grassArr.length>0){
// this.changeGroGrass(grassArr);
// }
// if(turfCp.length>0){
// this.changeGroGrassCp(turfCp);
// }
}
//播放音乐
for(var a = 0; a < sounds.length; a++) {
......@@ -5383,9 +5453,11 @@ export default class MainScene extends Scene {
*/
pongoClearScene(){
//判断清场猩猩中是否包含草坪
var canturgrass = false;
var grassArr = new Array();
var turfCp = new Array();
// var canturgrass = false;
// var grassArr = new Array();
// var turfCp = new Array();
var mainidxs = new Array();
var allidxs = new Array();
for(var p=0;p<this.freepongoArr.length;p++){
var itlpongoidx = this.freepongoArr[p];
......@@ -5393,28 +5465,35 @@ export default class MainScene extends Scene {
var iblpongoidx = itlpongoidx+Tool.colNum;
var ibrpongoidx = iblpongoidx+1;
canturgrass = this.judgeTurfing(itlpongoidx)||
this.judgeTurfing(itrpongoidx)||
this.judgeTurfing(iblpongoidx)||
this.judgeTurfing(ibrpongoidx);
if(canturgrass){
break;
}
mainidxs.push(itlpongoidx);
mainidxs.push(itrpongoidx);
mainidxs.push(iblpongoidx);
mainidxs.push(ibrpongoidx);
// canturgrass = this.judgeTurfing(itlpongoidx)||
// this.judgeTurfing(itrpongoidx)||
// this.judgeTurfing(iblpongoidx)||
// this.judgeTurfing(ibrpongoidx);
// if(canturgrass){
// break;
// }
}
for(var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if(canturgrass&&lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(i);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(i);
}
// if(canturgrass&&lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(i);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(i);
// }
// }
if(lat){
allidxs.push(i);
}
if(Tool.judgeEliminate(lat)) {
if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(this.lattices[i])){
// grassArr.push(i);
// }
//本来没必要判断特效组合时是否有重复的消除元素,但是recoverEle里会有判断石头或果冻的加入,造成重复
if(this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
if(this.lattices[i].element.type == ElementType.FISH) {
......@@ -5426,12 +5505,13 @@ export default class MainScene extends Scene {
}
}
}
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
// if(grassArr.length>0){
// this.changeGroGrass(grassArr);
// }
// if(turfCp.length>0){
// this.changeGroGrassCp(turfCp);
// }
this.addNewTurf(mainidxs,allidxs);
}
getNextIndexs(lat0:Lattice){
......@@ -5617,7 +5697,10 @@ export default class MainScene extends Scene {
if(!this.lattices[index] || !this.lattices[index].element) return null
//先赋值指向
let ele = this.lattices[index].element;
if(this.turfingArr.indexOf(index)!=-1){
// if(this.turfingArr.indexOf(index)!=-1){
// this.turfing(index);
// }
if(this.checkTurt(index)){
this.turfing(index);
}
......@@ -6012,63 +6095,99 @@ export default class MainScene extends Scene {
//元素参与消除,不消除直接转特效处理
if(ele){
var eleidx = ele.index;
if(this.turfingArr.indexOf(eleidx)!=-1){
// if(this.turfingArr.indexOf(eleidx)!=-1){
// this.turfing(eleidx);
// }
if(this.checkTurt(eleidx)){
this.turfing(eleidx);
}
}
}
checkTurfing(grassArr:Array<Array<number>>){
var turfCp = new Array();
for(let i=0;i<grassArr.length;i++){
let igrassarr = grassArr[i];
let canturgrass = false;
let needpuarr = new Array();
let cparr = new Array();
for(let j=0;j<igrassarr.length;j++){
var jlat:Lattice = this.lattices[igrassarr[j]];
if(jlat&&jlat.element){
if(jlat.element.type==ElementType.CANNO&&!jlat.grass){
cparr.push(i);
}else if(jlat.element.type==ElementType.Pongo&&!jlat.element.hasState(StateType.PongoLockState)&&!jlat.grass){
cparr.push(i);
}
}
if(this.judgeTurfing(igrassarr[j])){
canturgrass = true;
}else{
if(Tool.judgeTurfto(jlat)){
needpuarr.push(igrassarr[j]);
}
}
}
if(canturgrass&&needpuarr.length>0){
this.changeGroGrass(needpuarr);
}
if(canturgrass&&cparr.length>0){
turfCp.push(...cparr);
}
/**
* 检测铺草
* @param index
*/
checkTurt(index:number){
var canturt:boolean = false;
for(var i=0;i<this.recoverArr.length;i++){
var irecoverdata = this.recoverArr[i];
var imaindata = irecoverdata.main;
var ialldata = irecoverdata.all;
var norturarr = this.getOneElNorPu(imaindata,ialldata);
if(norturarr.indexOf(index)!=-1){
canturt = true;
break;
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
return canturt;
}
changeGroGrass(needpuarr:Array<number>){
for(let p=0;p<needpuarr.length;p++){
let pidx = needpuarr[p];
let plat = this.lattices[pidx];
if(plat&&plat.element){
if(this.turfingArr.indexOf(pidx)==-1){
this.turfingArr.push(pidx);
checkTurfing(grassArr:Array<Array<number>>){
for(var i=0;i<grassArr.length;i++){
var igrassarr = grassArr[i];
var mainidxs = igrassarr;
var allidxs = igrassarr;
for(var i1=0;i1<igrassarr.length;i1++){
if(this.lattices[igrassarr[i1]]){
mainidxs.push(igrassarr[i1]);
allidxs.push(igrassarr[i1]);
}
}
this.addNewTurf(mainidxs,allidxs);
}
// var turfCp = new Array();
// for(let i=0;i<grassArr.length;i++){
// let igrassarr = grassArr[i];
// let canturgrass = false;
// let needpuarr = new Array();
// let cparr = new Array();
// for(let j=0;j<igrassarr.length;j++){
// var jlat:Lattice = this.lattices[igrassarr[j]];
// if(jlat&&jlat.element){
// if(jlat.element.type==ElementType.CANNO&&!jlat.grass){
// cparr.push(i);
// }else if(jlat.element.type==ElementType.Pongo&&!jlat.element.hasState(StateType.PongoLockState)&&!jlat.grass){
// cparr.push(i);
// }
// }
// if(this.judgeTurfing(igrassarr[j])){
// canturgrass = true;
// }else{
// if(Tool.judgeTurfto(jlat)){
// needpuarr.push(igrassarr[j]);
// }
// }
// }
// if(canturgrass&&needpuarr.length>0){
// this.changeGroGrass(needpuarr);
// }
// if(canturgrass&&cparr.length>0){
// turfCp.push(...cparr);
// }
// }
// if(turfCp.length>0){
// this.changeGroGrassCp(turfCp);
// }
}
// changeGroGrass(needpuarr:Array<number>){
// for(let p=0;p<needpuarr.length;p++){
// let pidx = needpuarr[p];
// // let plat = this.lattices[pidx];
// // if(plat&&plat.element){
// // if(this.turfingArr.indexOf(pidx)==-1){
// // this.turfingArr.push(pidx);
// // }
// // }
// }
// }
//炮台,猩猩,特效铺草,直接铺草
changeGroGrassCp(arr:Array<number>){
// console.log("直接铺草----------",JSON.parse(JSON.stringify(arr)));
for(let p=0;p<arr.length;p++){
let pidx = arr[p];
this.turfing(pidx);
......@@ -6119,6 +6238,21 @@ export default class MainScene extends Scene {
var irecoverdata = this.recoverArr[i];
var imaindata = irecoverdata.main;
var ialldata = irecoverdata.all;
for(var i1=0;i1<imaindata.length;i1++){
var i1data = imaindata[i1];
if(idx==i1data.idx&&i1data.canturff){
canturff = true;
break;
}
}
for(var i2=0;i2<ialldata.length;i2++){
var i2data = ialldata[i2];
if(idx==i2data.idx&&i2data.canturff){
canturff = true;
break;
}
}
var canturarr = this.getOneElNorPu(imaindata,ialldata);
if(canturarr.indexOf(idx)!=-1){
......@@ -6136,18 +6270,27 @@ export default class MainScene extends Scene {
var canturft = false;
for(var i=0;i<this.recoverArr.length;i++){
var irecoverdata = this.recoverArr[i];
var imaindata = irecoverdata.main;
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){
for(var i1=0;i1<imaindata.length;i1++){
var i1data = imaindata[i1];
if(i1data.idx==idx&&i1data.canturft){
canturft = true;
break;
}
}
for(var i2=0;i2<ialldata.length;i2++){
var i2data = ialldata[i2];
var i2idx = i2data.idx;
if(i2idx==idx&&i2data.canturft){
canturft = true;
break;
}
}
}
if(canturft){
return true;
}
......@@ -6241,6 +6384,7 @@ export default class MainScene extends Scene {
}
//铺草在一次掉落前,不分先后顺序
initTurf(){
console.error("重置消除数组",JSON.parse(JSON.stringify(this.recoverArr)));
this.recoverArr = new Array();
}
//添加新的小消除组
......@@ -6273,11 +6417,13 @@ export default class MainScene extends Scene {
alldata.push(i2data);
}
var turidx = this.recoverArr.length;
this.recoverArr.push({
var newturdata = {
turidx:turidx,
main:maindata,
all:alldata
})
}
this.recoverArr.push(newturdata);
console.log("新增消除数组",JSON.parse(JSON.stringify(newturdata)));
this.solveTurf(turidx,maindata,alldata);
}
/**
......@@ -6289,12 +6435,45 @@ 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 canturfarr = this.getOneElNorPu(main,all);
// console.log("开始铺草检测");
// if(turfidx==3){
// console.log("111铺草检测--------------------------------",JSON.parse(JSON.stringify(oldneedturfarr)));
// }
var zhijepuArr:Array<number> = new Array();
var freshpuArr:Array<number> = new Array();
if(canturfarr.length>0){
for(var i6=0;i6<this.recoverArr.length;i6++){
var i6data = this.recoverArr[i6];
var i6turidx = i6data.turidx;
if(i6turidx==turfidx){
continue;
}
var i6main = i6data.main
var i6all = i6data.all;
var needftarr = this.getOneElNeedFt(i6main);
//修改main
if(needftarr.length>0){
for(var i7=0;i7<canturfarr.length;i7++){
var i7lidx = canturfarr[i7];
if(needftarr.indexOf(i7lidx)!=-1){
var result1 = this.changeOneRecover(i7lidx,i6turidx,i6main,i6all);
var i6needfresh = result1.needfresh;
if(i6needfresh){
freshpuArr.push(i6turidx);
}
var changearr = result1.changearr;
var izhijepu = this.checkPuArr(changearr);
zhijepuArr.push(...izhijepu);
}
}
}
}
}
//当前消除不能铺上,之前之后的消除可能铺上
if(oldneedturfarr.length>0){
for(var i3=0;i3<this.recoverArr.length;i3++){
var i3data = this.recoverArr[i3];
var i3turidx = i3data.turidx;
......@@ -6305,6 +6484,9 @@ export default class MainScene extends Scene {
}
//给all能铺的铺上
var olecanturfarr = this.getOneElCanPu(i3main,i3all);
// if(turfidx==3){
// console.log("222铺草检测--------------------------------",JSON.parse(JSON.stringify(olecanturfarr)));
// }
if(olecanturfarr.length){
for(var i4=0;i4<oldneedturfarr.length;i4++){
var i4lidx = oldneedturfarr[i4];
......@@ -6312,23 +6494,33 @@ export default class MainScene extends Scene {
if(olecanturfarr.indexOf(i4lidx)!=-1){
//修改小消除组的数据
var result1 = this.changeOneRecover(i4lidx,i3turidx,i3main,i3all);
// if(turfidx==3){
// console.log("333铺草检测--------------------------------",JSON.parse(JSON.stringify(result1)));
// }
var i3needfresh = result1.needfresh;
if(i3needfresh){
freshpuArr.push(i3turidx);
}
var changearr = result1.changearr;
var izhijepu = this.checkPuArr(changearr);
// if(turfidx==3){
// console.log("444铺草检测--------------------------------",JSON.parse(JSON.stringify(izhijepu)));
// }
zhijepuArr.push(...izhijepu);
}
}
}
}
this.changeGroGrass(zhijepuArr);
}
Tool.removeReapty(zhijepuArr);
Tool.removeReapty(freshpuArr);
this.changeGroGrassCp(zhijepuArr);
//注意检查下,应该有问题
if(freshpuArr.length>0){
console.log("其他小组重新铺草");
// console.log("其他小组重新铺草");
for(var i5=0;i5<freshpuArr.length;i5++){
var i5turidx = freshpuArr[i5];
var i5coverdata = this.recoverArr[i5turidx];
......@@ -6336,13 +6528,12 @@ export default class MainScene extends Scene {
var i5all = i5coverdata.all;
var i5zhijepuArr1 = this.getOneElNorPu(i5main,i5all);
var i5zhijepuArr = this.checkPuArr(i5zhijepuArr1);
this.changeGroGrass(i5zhijepuArr);
this.changeGroGrassCp(i5zhijepuArr);
this.solveTurf(i5turidx,i5main,i5all);
}
}else{
console.log("铺草完毕");
}
// console.log("铺草完毕");
}
}
/**
......@@ -6406,10 +6597,12 @@ export default class MainScene extends Scene {
*/
getOneElNorPu(main:Array<{idx:number,canturff:boolean,canturft:boolean}>,all:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var canturff = false;
// var cantuffarr = [];
for(var i1=0;i1<main.length;i1++){
var i1data = main[i1];
if(i1data.canturff){
canturff = true;
// cantuffarr.push(i1data.idx);
break;
}
}
......@@ -6425,8 +6618,19 @@ export default class MainScene extends Scene {
}
return oldneedturfarr;
}
getOneElNeedFt(main:Array<{idx:number,canturff:boolean,canturft:boolean}>){
var needftarr:Array<number> = new Array();
for(var i=0;i<main.length;i++){
var idata = main[i];
if(!idata.canturff&&idata.canturft){
needftarr.push(idata.idx);
}
}
return needftarr;
}
/**
* 修改小消除组
* 修改小消除组1
* @param lidx
* @param turidx
* @param main
......@@ -6456,6 +6660,63 @@ export default class MainScene extends Scene {
i1data.canturft = false;
i1data.canturff = true;
changemainidxarr.push(i1data.idx);
changeallidxarr.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==lidx&&i2data.canturft){
i2data.canturft = false;
i2data.canturff = true;
changeallidxarr.push(i2data.idx);
}
}
if(changeallidxarr.length>0){
result1.changearr = changeallidxarr;
}
return result1;
}
/**
* 修改小消除组
* @param lidx
* @param turidx
* @param main
* @param all
*/
changeOneRecover1(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);
changeallidxarr.push(i1data.idx);
}
}
//不需要刷新本次小消除的铺草
......@@ -6469,7 +6730,7 @@ export default class MainScene extends Scene {
for(var i2=0;i2<all.length;i2++){
var i2data = all[i2];
if(i2data.idx&&i2data.canturft){
if(i2data.idx==lidx&&i2data.canturft){
i2data.canturft = false;
i2data.canturff = true;
changeallidxarr.push(i2data.idx);
......
......@@ -23,9 +23,12 @@ export default async (thisObj: MainScene) => {
for (const index of indexs) {
const lat: Lattice = thisObj.lattices[index];
let canturgrass = thisObj.judgeTurfing(index);
let grassArr = new Array();
var turfCp = new Array();
// let canturgrass = thisObj.judgeTurfing(index);
// let grassArr = new Array();
// var turfCp = new Array();
var mainidxs:Array<number> = new Array();
var allidxs:Array<number> = new Array();
mainidxs.push(index);
lat.element['fish'].toExplose();
// wait(1000).then(()=>{
const p = Tool.getPositionByIndex(index);
......@@ -33,31 +36,35 @@ export default async (thisObj: MainScene) => {
boomAni.scaleX = boomAni.scaleY = 1;
// });
for (var i = 0; i < thisObj.lattices.length; i++) {
if(canturgrass&&thisObj.lattices[i]&&Math.abs(thisObj.lattices[i].row - lat.row) < 2 && Math.abs(thisObj.lattices[i].column - lat.column) < 2){
if(lat&&lat.element){
if(lat.element.type==ElementType.CANNO&&!lat.grass){
turfCp.push(i);
}else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
turfCp.push(i);
}
}
// if(canturgrass&&thisObj.lattices[i]&&Math.abs(thisObj.lattices[i].row - lat.row) < 2 && Math.abs(thisObj.lattices[i].column - lat.column) < 2){
// if(lat&&lat.element){
// if(lat.element.type==ElementType.CANNO&&!lat.grass){
// turfCp.push(i);
// }else if(lat.element.type==ElementType.Pongo&&!lat.element.hasState(StateType.PongoLockState)&&!lat.grass){
// turfCp.push(i);
// }
// }
// }
if(thisObj.lattices[i]&&Math.abs(thisObj.lattices[i].row - lat.row) < 2 && Math.abs(thisObj.lattices[i].column - lat.column) < 2){
allidxs.push(i);
}
if (Tool.judgeEliminate(thisObj.lattices[i]) &&
(Math.abs(thisObj.lattices[i].row - lat.row) < 2 && Math.abs(thisObj.lattices[i].column - lat.column) < 2)) {
if (thisObj.eliminatedElements.indexOf(thisObj.lattices[i].index) < 0) {
if(canturgrass&&Tool.judgeTurfto(thisObj.lattices[i])){
grassArr.push(i);
}
// if(canturgrass&&Tool.judgeTurfto(thisObj.lattices[i])){
// grassArr.push(i);
// }
thisObj.eliminatedElements.push(thisObj.lattices[i].index);
}
}
}
if(grassArr.length>0){
thisObj.changeGroGrass(grassArr);
}
if(turfCp.length>0){
thisObj.changeGroGrassCp(turfCp);
}
thisObj.addNewTurf(mainidxs,allidxs);
// if(grassArr.length>0){
// thisObj.changeGroGrass(grassArr);
// }
// if(turfCp.length>0){
// thisObj.changeGroGrassCp(turfCp);
// }
}
await wait(500);
......
......@@ -1336,9 +1336,9 @@ export class Tool {
let ele = lat.element;
let canChosen = this.judgeChosen(ele);
if(!canChosen){
if(ele.type==ElementType.CANNO){
if(ele.type==ElementType.CANNO&&lat.grass){
return true;
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)){
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)&&lat.grass){
return true;
}
// console.log("铺出去55555555555555");
......@@ -1367,9 +1367,9 @@ export class Tool {
let ele = lat.element;
let canChosen = this.judgeChosen(ele);
if(!canChosen){
if(ele.type==ElementType.CANNO){
if(ele.type==ElementType.CANNO&&!lat.grass){
return true;
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)){
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)&&!lat.grass){
return true;
}
return false;
......
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