Commit 570f1d68 authored by zjz1994's avatar zjz1994

解放猩猩

parent 16c4acbb
...@@ -2337,28 +2337,6 @@ export default class MainScene extends Scene { ...@@ -2337,28 +2337,6 @@ export default class MainScene extends Scene {
this.pushScoreAni(baseScore * this.commonContinuityTimes, Tool.getPositionByIndex(index)) this.pushScoreAni(baseScore * this.commonContinuityTimes, Tool.getPositionByIndex(index))
} }
} }
// if(this.eliminatedElements.length>0){
// for(var i=0;i<this.eliminatedElements.length;i++){
// var ielimidx = this.eliminatedElements[i];
// for(var p=0;p<this.cannoArr.length;p++){
// var pcannoidx = this.cannoArr[p].idx;
// var isnext = Tool.checkNebByidx(pcannoidx,ielimidx);
// if(isnext){
// var pcannoele = this.cannoArr[p].ele;
// pcannoele.addOneCannoStat();
// var pcannostat = pcannoele.checkCannoStat();
// if(pcannostat){
// if(this.readyCannoArr.indexOf(p)==-1){
// this.readyCannoArr.push(p);
// }
// }
// }
// }
// }
// }
return this.eliminatedElements.length > 0; return this.eliminatedElements.length > 0;
} }
...@@ -3921,12 +3899,100 @@ export default class MainScene extends Scene { ...@@ -3921,12 +3899,100 @@ export default class MainScene extends Scene {
} }
} }
checkPongoNebEle(lat0: Lattice, ele?: Element) {
if(!lat0 || !ele) return;
var indexs = this.getNextIndexs(lat0);
var lockPongoArr:Array<{idx:number,part:string}> = new Array();
for(let i = 0; i < indexs.length; i++) {
let index = indexs[i];
let lat = this.lattices[index];
if(lat && lat.element && lat.element.type == ElementType.Pongo) {
const type = ele.type;
if(this.passElements && this.passElements[type] != 0) {
if(lat.element.hasState(StateType.PongoLockState)){
var ilockpongo = {
idx:lat.element.index,
part:lat.element.inPongoPart
}
lockPongoArr.push(ilockpongo);
//解锁猩猩被锁状态
lat.element.removePongoLockStat();
}
}
}
}
//对本次解锁的猩猩部分,分成对应的几个猩猩
var alockPongo:Array<number> = [];//只存左上
for(var j=0;j<lockPongoArr.length;j++){
var jpongodata = lockPongoArr[j];
var jpongoidx = jpongodata.idx;
var jpongopart = jpongodata.part;
var tlidx:number;
if(jpongopart=="tl"){
tlidx = jpongoidx;
}
else if(jpongopart=="tr"){
tlidx = jpongoidx - 1;
}
else if(jpongopart=="bl"){
tlidx = jpongoidx -Tool.colNum;
}
else if(jpongopart=="br"){
tlidx = jpongoidx - Tool.colNum-1;
}
if(alockPongo.indexOf(tlidx)==-1){
alockPongo.push(tlidx);
}
}
var pglockstat = StateType.PongoLockState;
//本次参与的消除的猩猩
for(var p=0;p<alockPongo.length;p++){
var tlpongoidx = alockPongo[p];
var trpongoidx = tlpongoidx+1;
var blpongoidx = tlpongoidx+Tool.colNum;
var brpongoidx = blpongoidx+1;
var tlpartstat = this.lattices[tlpongoidx].element.hasState(pglockstat);
var trpartstat = this.lattices[trpongoidx].element.hasState(pglockstat);
var blpartstat = this.lattices[blpongoidx].element.hasState(pglockstat);
var brpartstat = this.lattices[brpongoidx].element.hasState(pglockstat);
//猩猩自由了
if(!tlpartstat&&!trpartstat&&!blpartstat&&!brpartstat){
console.log(tlpongoidx,"猩猩自由了");
}
}
}
getNextIndexs(lat0:Lattice){
var indexMy = lat0.index;
var indexs = [
indexMy - Tool.colNum,
indexMy + Tool.colNum,
];
if(lat0.column > 0) {
indexs.push(indexMy - 1)
}
if(lat0.column < Tool.colNum - 1) {
indexs.push(indexMy + 1)
}
return indexs;
}
//检查附近所有元素 //检查附近所有元素
checkNebAll(latttice: Lattice, ele?: Element) { checkNebAll(latttice: Lattice, ele?: Element) {
//如果格子有冰 //如果格子有冰
this.checkLatticeBroken(latttice); this.checkLatticeBroken(latttice);
this.checkFireworksNebEle(latttice, ele); this.checkFireworksNebEle(latttice, ele);
this.checkFishNebEle(latttice); this.checkFishNebEle(latttice);
this.checkPongoNebEle(latttice,ele);
//如果附近有石头 //如果附近有石头
this.checkNebEle(latttice, (lat) => { this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.ROCK return lat && lat.element && lat.element.type == ElementType.ROCK
...@@ -4097,6 +4163,10 @@ export default class MainScene extends Scene { ...@@ -4097,6 +4163,10 @@ export default class MainScene extends Scene {
// } // }
// } // }
// } // }
//消除
return ele return ele
} }
......
...@@ -236,7 +236,7 @@ export class Element extends eui.Component { ...@@ -236,7 +236,7 @@ export class Element extends eui.Component {
var state = StateType.PongoLockState; var state = StateType.PongoLockState;
if(this.hasState(state)){ if(this.hasState(state)){
this.states[state].reset(part);
} }
else{ else{
var stateData = stateDatas[state]; var stateData = stateDatas[state];
...@@ -247,11 +247,15 @@ export class Element extends eui.Component { ...@@ -247,11 +247,15 @@ export class Element extends eui.Component {
stateEx = new className(); stateEx = new className();
} }
this.states[state] = stateEx; this.states[state] = stateEx;
stateEx.reset(part);
//视图添加
this.addChild(this.states[state]);
} }
this.states[state].reset(part);
//视图添加
this.addChild(this.states[state]);
}
removePongoLockStat(){
var state = StateType.PongoLockState;
this.states[state].recover();
this.states[state] = null;
} }
changeShowCannoStat(){ changeShowCannoStat(){
this.cannolab.text = this._cannoStat+""; this.cannolab.text = this._cannoStat+"";
......
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