Commit 7add61de authored by zjz1994's avatar zjz1994

草地暂存

parent 5de9a8d7
......@@ -250,7 +250,6 @@ export default class MainScene extends Scene {
elementContainer: egret.DisplayObjectContainer;
//虫洞层
wormholeContainer:egret.DisplayObjectContainer;
mapbotContainer:egret.DisplayObjectContainer;
//流沙提出来,解决流沙抖动问题
mapupContainer:egret.DisplayObjectContainer;
//选中框
......@@ -430,9 +429,6 @@ export default class MainScene extends Scene {
this.wormholeContainer = new egret.DisplayObjectContainer();
this.addChild(this.wormholeContainer);
//底部草坪
this.mapbotContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapbotContainer);
//修改流沙的问题
this.mapupContainer = new egret.DisplayObjectContainer();
this.addChild(this.mapupContainer);
......@@ -491,7 +487,6 @@ export default class MainScene extends Scene {
this.mapContainer.removeChildren();
this.mapbotContainer.removeChildren();
this.mapupContainer.removeChildren();
this.elementContainer.removeChildren();
this.effectContainer.removeChildren();
......@@ -799,7 +794,7 @@ export default class MainScene extends Scene {
}
}
}
//该遍历之后尽量简化下todo
//该遍历之后尽量简化下
getCannoByBianhao(cannoidx:number):Element{
var canno:Element;
// console.log("获取大炮",cannoidx,this.cannoidxArr);
......@@ -1938,7 +1933,7 @@ export default class MainScene extends Scene {
// }
// }
var grassArr = new Array();
var canturgrass = Tool.judgeTurfing(this.lattices[index]);
var canturgrass = this.judgeTurfing(index);
//新增石头阻挡
var elimitarr = this.getEliPassCannoStone(rc[0],rc[1]);
for(var j=0;j<elimitarr.length;j++){
......@@ -1958,6 +1953,13 @@ export default class MainScene extends Scene {
}
}
}
//特效铺草把炮台和猩猩加进去
var turfCp = new Array();
if(canturgrass){
this.turfEliPassCp(rc[0],rc[1],turfCp);
}
//新大炮充能
var pcannostatArr = new Array();
for(var np=0;np<this.cannonums;np++){
......@@ -1982,12 +1984,16 @@ export default class MainScene extends Scene {
//特效消除猩猩
this.checkPongoHVEle(rc[0],rc[1],"hor");
this.checkPongoHVEle(rc[0],rc[1],"vir");
setTimeout(() => {
this.initOneElmtTag();
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
this.initOneElmtTag();
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
this.eliminate(pcannostatArr);
}, 200)
break;
......@@ -2111,6 +2117,7 @@ export default class MainScene extends Scene {
elimitarr.push(...elimitarrver);
return elimitarr;
}
mouseDownE(e: egret.TextEvent) {
this.wormHolePromise = new Array();
......@@ -3443,6 +3450,7 @@ 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;
}
......@@ -3464,6 +3472,13 @@ 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{
......@@ -3486,6 +3501,9 @@ export default class MainScene extends Scene {
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];
......@@ -3645,7 +3663,9 @@ export default class MainScene extends Scene {
//特效铺草坪
var grassArr = new Array();
var canturgrass = Tool.judgeTurfing(lat1)||Tool.judgeTurfing(lat2);
var turfCp = new Array();
var canturgrass = this.judgeTurfing(one)||this.judgeTurfing(two);
if(canturgrass){
if(Tool.judgeTurfto(lat1)){
grassArr.push(one);
......@@ -3685,6 +3705,13 @@ export default class MainScene extends Scene {
//把所有元素加入
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(Tool.judgeEliminate(lat)) {
if(canturgrass&&Tool.judgeTurfto(lat)){
grassArr.push(i);
......@@ -3824,6 +3851,9 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliPassCp(lat1.row,lat1.column,turfCp);
}
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
var npdata = pcannostatArr[np];
......@@ -3895,6 +3925,9 @@ 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.turfEliHorPassCp(prcrow,prccol,turfCp);
}
this.checkPongoHVEle(prcrow,prccol,"hor");
for(var np=0;np<pcannostatArr.length;np++){
......@@ -3911,6 +3944,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);
}
this.checkPongoHVEle(prcrow,prccol,"vir");
for(var np=0;np<pcannostatArr.length;np++){
......@@ -3973,6 +4010,15 @@ 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&&(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)) {
......@@ -3992,9 +4038,10 @@ export default class MainScene extends Scene {
}
if(grassArr.length>0){
setTimeout(() => {
this.changeGroGrass(grassArr);
}, 200);
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
}
......@@ -4227,8 +4274,9 @@ export default class MainScene extends Scene {
let ele = lat.element;
if(!ele)continue;
var p = Tool.getPositionByIndex(index);
var canturgrass = Tool.judgeTurfing(lat);
var canturgrass = this.judgeTurfing(index);
var grassArr = new Array();
var turfCp = new Array();
switch(ele.effectType) {
case EffectType.MAGICLION:
if(sounds.indexOf(SoundType.magic) == -1) sounds.push(SoundType.magic)
......@@ -4296,6 +4344,15 @@ export default class MainScene extends Scene {
this.recoverEle(index);
//3*3,需要优化
for(var i = 0; i < this.lattices.length; i++) {
if(canturgrass&&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(this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
......@@ -4361,6 +4418,10 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliHorPassCp(row,lat.column,turfCp);
}
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
var npdata = pcannostatArr[np];
......@@ -4420,6 +4481,10 @@ export default class MainScene extends Scene {
}
}
}
if(canturgrass){
this.turfEliVerPassCp(lat.row,col,turfCp);
}
//新大炮充能
for(var np=0;np<pcannostatArr.length;np++){
var npdata = pcannostatArr[np];
......@@ -4434,8 +4499,12 @@ export default class MainScene extends Scene {
break;
}
this.changeGroGrass(grassArr);
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
}
//播放音乐
for(var a = 0; a < sounds.length; a++) {
......@@ -5289,12 +5358,42 @@ export default class MainScene extends Scene {
}
/**
* 多猩猩清场
* 多猩猩清场,猩猩下有草坪,清场铺草坪
*/
pongoClearScene(){
//判断清场猩猩中是否包含草坪
var canturgrass = false;
var grassArr = new Array();
var turfCp = new Array();
for(var p=0;p<this.freepongoArr.length;p++){
var itlpongoidx = this.freepongoArr[p];
var itrpongoidx = itlpongoidx+1;
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;
}
}
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(Tool.judgeEliminate(lat)) {
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) {
......@@ -5306,6 +5405,12 @@ export default class MainScene extends Scene {
}
}
}
if(grassArr.length>0){
this.changeGroGrass(grassArr);
}
if(turfCp.length>0){
this.changeGroGrassCp(turfCp);
}
}
getNextIndexs(lat0:Lattice){
......@@ -5491,7 +5596,9 @@ 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){
this.turfing(index);
}
......@@ -5870,17 +5977,27 @@ export default class MainScene extends Scene {
this.steps += 5;
}, 333)
}
}
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(Tool.judgeTurfing(jlat)){
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)){
......@@ -5892,19 +6009,36 @@ export default class MainScene extends Scene {
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>){
for(let p=0;p<arr.length;p++){
let pidx = arr[p];
this.turfing(pidx);
}
}
//新增铺草地
turfing(index:number){
var lat = this.lattices[index];
if(lat&&lat.element){//消除元素铺草坪
if(lat&&lat.element&&!lat.grass){//消除元素铺草坪
//存在冰块和流沙时,草坪铺不上去
// if(lat.ice&&lat.ice.alpha!=0){
// return;
......@@ -5921,7 +6055,7 @@ export default class MainScene extends Scene {
grassDisplay = new Grass();
}
lat.grass = grassDisplay;
this.mapbotContainer.addChild(grassDisplay);
this.mapupContainer.addChild(grassDisplay);
var grasspos = Tool.getPositionByIndex(index);
grassDisplay.x = grasspos[0];
grassDisplay.y = grasspos[1];
......@@ -5936,4 +6070,78 @@ export default class MainScene extends Scene {
}
return Tool.judgeTurfing(this.lattices[idx]);
}
//特效铺炮台和猩猩
turfEliHorPassCp(row:number,col:number,turfCp: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(iscannoblock){
break;
}
}
//向右
for(var i=col;i<Tool.colNum;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(iscannoblock){
break;
}
}
}
turfEliVerPassCp(row:number,col:number,turfCp: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(iscannoblock){
break;
}
}
//向下
for(var i=row;i<Tool.rowNum;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(iscannoblock){
break;
}
}
}
turfEliPassCp(row:number,col:number,turfCp:Array<number>){
this.turfEliHorPassCp(row,col,turfCp);
this.turfEliVerPassCp(row,col,turfCp);
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import wait from "../../libs/new_tc/wait";
import { Tool } from "../something/Tool";
import { Lattice } from "../something/class/Lattice";
import { RecoverName } from "../something/enum/RecoverName";
import { StateType } from "../something/enum/StateType";
/**
* fish爆炸
*/
......@@ -22,8 +23,9 @@ export default async (thisObj: MainScene) => {
for (const index of indexs) {
const lat: Lattice = thisObj.lattices[index];
let canturgrass = Tool.judgeTurfing(lat);
let canturgrass = thisObj.judgeTurfing(index);
let grassArr = new Array();
var turfCp = new Array();
lat.element['fish'].toExplose();
// wait(1000).then(()=>{
const p = Tool.getPositionByIndex(index);
......@@ -31,6 +33,15 @@ export default async (thisObj: MainScene) => {
boomAni.scaleX = boomAni.scaleY = 1;
// });
for (var i = 0; i < thisObj.lattices.length; i++) {
if(canturgrass&&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 (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) {
......@@ -41,8 +52,12 @@ export default async (thisObj: MainScene) => {
}
}
}
thisObj.changeGroGrass(grassArr);
if(grassArr.length>0){
thisObj.changeGroGrass(grassArr);
}
if(turfCp.length>0){
thisObj.changeGroGrassCp(turfCp);
}
}
await wait(500);
......
......@@ -1332,6 +1332,11 @@ export class Tool {
let ele = lat.element;
let canChosen = this.judgeChosen(ele);
if(!canChosen){
if(ele.type==ElementType.CANNO){
return true;
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)){
return true;
}
return false;
}
if(!lat.grass){
......@@ -1356,6 +1361,12 @@ export class Tool {
let ele = lat.element;
let canChosen = this.judgeChosen(ele);
if(!canChosen){
if(ele.type==ElementType.CANNO){
console.log("炮台可以上草坪");
return true;
}else if(ele.type==ElementType.Pongo&&!ele.hasState(StateType.PongoLockState)){
return true;
}
return false;
}
if(lat.grass){
......
......@@ -22,7 +22,7 @@ export const Chapters27: ChapterData[] = [
2, 1, 2, 1, 1, 2, 1, 2, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 19, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
16, 2, 16, 2, 1, 6, 6, 6, 6,
1, 1, 1, 1, 1, 1, 1, 1, 1,
......
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