Commit a1c0fc85 authored by zjz1994's avatar zjz1994

樱花暂存

parent 87904b64
...@@ -445,6 +445,13 @@ export default class MainScene extends Scene { ...@@ -445,6 +445,13 @@ export default class MainScene extends Scene {
//樱花 //樱花
//当前关卡的所有樱花 //当前关卡的所有樱花
cherryData:Array<Array<number>> = []; cherryData:Array<Array<number>> = [];
//本次激活需要消除的樱花
freeCherryData:Array<number> = [];
//已消除樱花
amoveCherryData:Array<number> = [];
//等待樱花
waitCherry = false;
constructor(){ constructor(){
super(); super();
window['gm'] = this.gm; window['gm'] = this.gm;
...@@ -3168,8 +3175,15 @@ export default class MainScene extends Scene { ...@@ -3168,8 +3175,15 @@ export default class MainScene extends Scene {
} }
} }
} }
//樱花绽放,放在fallAllPormise里 //樱花绽放
var amove = this.checkFaCherry();
if(!amove){
console.log("樱花未消除,等待消除");
this.waitCherry = true;
return;
}else{
console.log("樱花消除完毕,自动掉落");
}
//没有可消除元素,执行掉落, //没有可消除元素,执行掉落,
// setTimeout(() => { // setTimeout(() => {
await wait(200); await wait(200);
...@@ -7457,8 +7471,9 @@ export default class MainScene extends Scene { ...@@ -7457,8 +7471,9 @@ export default class MainScene extends Scene {
console.log("1消除樱花----------------------",idx); console.log("1消除樱花----------------------",idx);
var lat = this.lattices[idx]; var lat = this.lattices[idx];
var ele = this.lattices[idx].element; var ele = this.lattices[idx].element;
let pro1 = ele.activeCherry(); ele.activeCherry();
this.fallAllPormise.push(pro1); this.playCherryAni(idx);
this.addFreeCherryData(idx);
var nearidxs:Array<{ var nearidxs:Array<{
forback:string, forback:string,
...@@ -7474,15 +7489,57 @@ export default class MainScene extends Scene { ...@@ -7474,15 +7489,57 @@ export default class MainScene extends Scene {
// }, 200); // }, 200);
// }) // })
// this.fallAllPormise.push(pro2); // this.fallAllPormise.push(pro2);
setTimeout(() => {
for(let i=0;i<nearidxs.length;i++){ for(let i=0;i<nearidxs.length;i++){
let nidx = nearidxs[i].idx; let nidx = nearidxs[i].idx;
let nlat = this.lattices[nidx]; let nlat = this.lattices[nidx];
let nele = nlat.element; let nele = nlat.element;
if(nele&&nele.type==ElementType.cherry&&nele.activeStatus==0){ if(nele&&nele.type==ElementType.cherry&&nele.activeStatus==0){
this.activeCherry(nidx); this.activeCherry(nidx);
} }
} }
}, 300);
}
//樱花动画
playCherryAni(idx:number){
var oneani = new eui.Image();
var texture = RES.getRes("ele46_png");
oneani.texture = texture;
var p = Tool.getPositionByIndex(idx);
oneani.anchorOffsetX = texture.textureWidth/2;
oneani.anchorOffsetY = texture.textureHeight/2;
oneani.x = p[0];
oneani.y = p[1];
this.effectContainer.addChild(oneani);
console.log("樱花动画");
egret.Tween.get(oneani)
.to({
alpha:0,
scaleX:2,
scaleY:2
},800)
.call(()=>{
var lat = this.lattices[idx];
var ele = lat.element;
ele.dieCherry();
this.elementContainer.removeChild(ele);
if(this.amoveCherryData.indexOf(idx)==-1){
this.amoveCherryData.push(idx);
if(this.eliminatedElements.indexOf(idx)==-1){
this.eliminatedElements.push(idx);
}
if(this.emptys.indexOf(idx)==-1){
this.emptys.push(idx);
}
var amove = this.checkFaCherry();
if(amove&&this.waitCherry){
this.waitCherry = false;
console.log("樱花移除完毕,手动消除掉落")
this.eliminate();
}
}
})
} }
//获取相邻樱花 //获取相邻樱花
getNearCherry(idx:number){ getNearCherry(idx:number){
...@@ -7528,4 +7585,36 @@ export default class MainScene extends Scene { ...@@ -7528,4 +7585,36 @@ export default class MainScene extends Scene {
isz&&this.mapupContainer.removeChild(isz); isz&&this.mapupContainer.removeChild(isz);
} }
} }
addFreeCherryData(idx:number){
var icheryidx:number;
for(var i=0;i<this.cherryData.length;i++){
var icherrydata = this.cherryData[i];
if(icherrydata.indexOf(idx)!=-1){
icheryidx = i;
break;
}
}
var pcherrydata = this.cherryData[icheryidx];
for(var j=0;j<pcherrydata.length;j++){
var pcheryidx = pcherrydata[j];
if(this.freeCherryData.indexOf(pcheryidx)==-1){
this.freeCherryData.push(pcheryidx);
}
}
}
checkFaCherry(){
var amove:boolean = true;
for(var i=0;i<this.freeCherryData.length;i++){
var iidx = this.freeCherryData[i];
if(this.amoveCherryData.indexOf(iidx)==-1){
amove = false;
break;
}
}
return amove;
}
} }
\ No newline at end of file
export class elementEffect{
}
\ No newline at end of file
...@@ -1006,6 +1006,7 @@ export class Element extends eui.Component { ...@@ -1006,6 +1006,7 @@ export class Element extends eui.Component {
* @param type 只应该是基础元素和特殊元素 * @param type 只应该是基础元素和特殊元素
*/ */
reset(type: ElementType) { reset(type: ElementType) {
this.activeStatus = 0;
this.effectType = null; this.effectType = null;
this._isMonsterJelly=false; this._isMonsterJelly=false;
this._isNeb = false; this._isNeb = false;
...@@ -1318,16 +1319,12 @@ export class Element extends eui.Component { ...@@ -1318,16 +1319,12 @@ export class Element extends eui.Component {
activeStatus:number = 0;//0未激活,1绽放中,2,结束 activeStatus:number = 0;//0未激活,1绽放中,2,结束
activeCherry(){ activeCherry(){
this.activeStatus = 1; this.activeStatus = 1;
return new Promise(res=>{ this.showImage.alpha = 0;
egret.Tween.get(this.showImage) }
.to({ //樱花消失
alpha:0 dieCherry(){
},300) this.activeStatus = 2;
.call(function(){
this.activeStatus = 2;
res();
},null);
})
} }
} }
\ 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