Commit 85cc4884 authored by zjz1994's avatar zjz1994

修改烟花和黑洞的bug,加入黑洞动画

parent d8cb8ff9
......@@ -175,6 +175,8 @@ let pongorfootdata:any = null;
let pongojiodata:any = null;
let pongojioArr:Array<any> = [];
let wormlightdata:any = null;
let wormlightArr:Array<any> = [];
//红包炸弹弹框名字
const redBombPanelName = "RedBombAlert";
......@@ -193,7 +195,7 @@ export default class MainScene extends Scene {
// private _converyorTag;
// private _wormholeTag;
//一次操作仅影响一次
private _checkMtag:{
_checkMtag:{
coveryor:boolean,//传送带
sand:boolean,//流沙
block:boolean,//石门
......@@ -377,7 +379,7 @@ export default class MainScene extends Scene {
//黑洞转移需在所有动画播放完毕后进行
wormHolePromise: Promise<any>[];
//处理烟花的
wormFireworks:any;
wormFireworks:Array<number> = [];
//todo
targetContainer:egret.DisplayObjectContainer;
chapterTxt:ChapterNum;
......@@ -709,6 +711,23 @@ export default class MainScene extends Scene {
}
}
}
/**
* 黑洞上的光
*/
initWormSvgas(){
var resPath = getResPath();
if (!svgaParser) svgaParser = new window["SVGA"].Parser();
if(wormlightdata){
}else{
svgaParser.load(resPath + 'resource/assets/svgas/wormholelight.svga', (videoItem) => {
if(!wormlightdata){
wormlightdata = videoItem;
}
})
}
}
/**
* 加载猩猩脚印
*/
......@@ -1060,6 +1079,7 @@ export default class MainScene extends Scene {
this.wormholeContainer.addChild(onehole);
onehole.x = jholepos[0];
onehole.y = jholepos[1];
onehole.name = "wormhole_"+i+"_"+j;
// console.log("添加了一个黑洞",onehole);
}
......@@ -1067,6 +1087,7 @@ export default class MainScene extends Scene {
console.error(i+"号线仅存在一个黑洞????");
}
}
this.initWormSvgas();
}
}
......@@ -1871,7 +1892,7 @@ export default class MainScene extends Scene {
}
if(s) {
this.wormHolePromise = new Array();
this.wormFireworks = {};
this.wormFireworks = new Array();
//成功的
switch(prop) {
case PropType.BOOM:
......@@ -2061,7 +2082,7 @@ export default class MainScene extends Scene {
mouseDownE(e: egret.TextEvent) {
this.wormHolePromise = new Array();
this.wormFireworks = {};
this.wormFireworks = new Array();
// if (!this.enableTouch) return
this.initOneElmtTag();
var self = this;
......@@ -2089,7 +2110,7 @@ export default class MainScene extends Scene {
mouseMoveE(e) {
this.wormHolePromise = new Array();
this.wormFireworks = {};
this.wormFireworks = new Array();
this.initOneElmtTag();
if(this.SELECTED && e.target.parent instanceof Element) {
......@@ -3442,6 +3463,16 @@ export default class MainScene extends Scene {
})
}
checkFireWorks(idx:number){
let inidx = this.wormFireworks.indexOf(idx);
if(inidx!=-1){
this.wormFireworks.splice(inidx,1);
if(this.wormFireworks.length==0){
console.log("黑洞上的烟花播放完毕");
this.aiMotionCheckDieMap();
}
}
}
/**
* 果冻蔓延和气泡变色需要重新检查死图
*/
......@@ -3449,27 +3480,19 @@ export default class MainScene extends Scene {
console.log("重置点击");
//黑洞转移
if(this._checkMtag.wormhole){
this._checkMtag.wormhole = false;
let wormholes = this.chapterData.map.WORMHOLE;
if(wormholes&&wormholes.length>0){
console.log("虫洞位移",this.wormHolePromise.length);
console.log("虫洞位移检测",this.wormHolePromise.length);
await Promise.all(this.wormHolePromise).then(()=>{
console.log("动画完毕");
});
let fireworkspro = new Array();
for(let firekey in this.wormFireworks){
let ifirepro = this.wormFireworks[firekey];
fireworkspro.push(ifirepro);
}
if(fireworkspro.length>0){
await Promise.all(fireworkspro).then(()=>{
console.log("烟花完毕,虫洞可以开始移动");
})
}
if(this.wormFireworks.length>0){
return console.error("等待烟花放完");
}
console.log("开始黑洞转移");
await doWormHoleAI(this);
this._checkMtag.wormhole = false;
// console.log("黑洞转移完毕");
//黑洞转移,使黑洞占位变空,需要添加到emptys中,
......@@ -3504,6 +3527,8 @@ export default class MainScene extends Scene {
this.fallCallback();
})
return;
}else{
this._checkMtag.wormhole = false;
}
}
//检查死图
......@@ -4652,7 +4677,7 @@ export default class MainScene extends Scene {
const p = Tool.getPositionByIndex(lat.index);
//动画
let pro = this.playAni(RecoverName.ICE_ANI, p);
if(Tool.judgeInWormHole(lat.index,this.chapterData.map.WORMHOLE)){
if(this._checkMtag.wormhole&&Tool.judgeInWormHole(lat.index,this.chapterData.map.WORMHOLE)){
console.log("冰块pro",lat.index);
this.wormHolePromise.push(pro);
}
......@@ -4670,7 +4695,7 @@ export default class MainScene extends Scene {
const p = Tool.getPositionByIndex(lat.index);
//动画
let pro = this.playAni(RecoverName.ICE_ANI, p);
if(Tool.judgeInWormHole(lat.index,this.chapterData.map.WORMHOLE)){
if(this._checkMtag.wormhole&&Tool.judgeInWormHole(lat.index,this.chapterData.map.WORMHOLE)){
console.log("石门冰块pro",lat.index);
this.wormHolePromise.push(pro);
}
......@@ -4746,11 +4771,12 @@ export default class MainScene extends Scene {
let pro = lat.element.fire(type);
let isInworm = Tool.judgeInWormHole(index,this.chapterData.map.WORMHOLE);
if(isInworm){
if(isInworm&&this._checkMtag.wormhole){
console.error("添加烟花pro",lat.index);
// this.wormHolePromise.push(pro);
this.wormFireworks[index] = pro;
if(this.wormFireworks.indexOf(index)==-1){
this.wormFireworks.push(index);
}
}
}
this.goElementTarget(type, [ele.x, ele.y]);
......@@ -5209,7 +5235,7 @@ export default class MainScene extends Scene {
this.removeOperation(index);
//播放动效
let pro = this.playAni(RecoverName.ROCK_ANI, Tool.getPositionByIndex(index))
if(Tool.judgeInWormHole(index,this.chapterData.map.WORMHOLE)){
if(this._checkMtag.wormhole&&Tool.judgeInWormHole(index,this.chapterData.map.WORMHOLE)){
console.log("石头裂开pro",index);
this.wormHolePromise.push(pro);
}
......@@ -5661,4 +5687,39 @@ export default class MainScene extends Scene {
this.eliminate();
}
}
//黑洞星星动画
wormlightAnm(posx,posy){
let onewormlight;
if(wormlightArr.length>0){
onewormlight = wormlightArr.shift();
}else{
onewormlight = new window["SVGA"].EgretMovieClip(wormlightdata);
}
this.effectContainer.addChild(onewormlight);
console.log(onewormlight);
onewormlight.x = posx-41;
onewormlight.y = posy-41;
// onewormlight.addEventListener(egret.Event.ENTER_FRAME,this.playWormLightFrame,this);
onewormlight.addEventListener(egret.Event.COMPLETE,this.playWormLightComplete,this);
onewormlight.gotoAndPlay(1,1);
}
playWormLightFrame(e){
let onewormlight = e.target;
var curframe = onewormlight.currentFrame;
if(curframe==60){
}
}
playWormLightComplete(e){
let onewormlight = e.target;
onewormlight.removeEventListener(egret.Event.COMPLETE,this.playWormLightComplete,this);
onewormlight.gotoAndStop(1);
if(onewormlight.parent){
onewormlight.parent.removeChild(onewormlight);
wormlightArr.push(onewormlight);
}
}
}
\ No newline at end of file
......@@ -3,6 +3,8 @@ import { Lattice } from "../something/class/Lattice";
import { LatticeType } from "../something/enum/LatticeType";
import { Tool } from "../something/Tool";
import { ElementType } from "../something/enum/ElementType";
import WormHole from "../something/class/WormHole";
import wait from "../../libs/new_tc/wait";
const getMapsp = function(lattice:Lattice){
var mapcf:{
......@@ -67,28 +69,37 @@ const tweenAnisp = function(sp:egret.DisplayObject,posx:number,posy:number,latti
//统一处理
var norscaleX = sp.scaleX;
var norscaleY = sp.scaleY;
var startalpha = sp.alpha;
// console.log("翻转检查",norscaleX,norscaleY);
var pro = new Promise(function(resolve,reject){
egret.Tween.get(sp)
.wait(1300)
.to({
scaleX:0,
scaleY:0,
},500)
alpha:0
},700,egret.Ease.quadOut)
.wait(200)
.to({
alpha:startalpha
},700,egret.Ease.quadOut);
egret.Tween.get(sp)
.wait(1300)
.to({
scaleX:0.2,
scaleY:0.2,
rotation:180
},800,egret.Ease.quadOut)
.call(()=>{
sp.x = posx;
sp.y = posy;
// console.log("黑洞转移位置",posx,posy);
})
.to({
scaleX:norscaleX,
scaleY:norscaleY
},500)
scaleY:norscaleY,
rotation:360
},800,egret.Ease.quadOut)
.call(()=>{
// if(lattice&&mapcf&&elecf){
// // console.log("需要替换数据11111111",lattice.index);
// lattice.changeData(mapcf,elecf);
// // console.log("替换数据",JSON.stringify(lattice));
// }
sp.rotation = 0;
resolve();
})
})
......@@ -176,6 +187,15 @@ export default async (thisObj:MainScene)=>{
let jlidxpos = Tool.getPositionByIndex(jlholeidx);
// console.log("转移前1----------",JSON.stringify(jidxlattice),"\n2--------------",JSON.stringify(jlidxlattice))
// console.log("11111111黑洞转移位置",jlholeidx,jlidxpos[0],jlidxpos[1]);
//黑洞动画
let holesp:WormHole = thisObj.wormholeContainer.getChildByName("wormhole_"+i+"_"+j) as WormHole;
let holeposx = holesp.x;
let holeposy = holesp.y;
thisObj.wormlightAnm(holeposx,holeposy);
// console.log("下一个洞");
// let waitpro = wait(1300).then(()=>{
// console.log("开始缓动");
if(mapsp){
let mapro = tweenAnisp(mapsp,jlidxpos[0],jlidxpos[1]);
promiseList.push(mapro);
......@@ -190,11 +210,40 @@ export default async (thisObj:MainScene)=>{
// console.log("烟花特殊处理");
let firework = elesp["_fireworks"];
let fireposx = jlidxpos[0];
let fireposy = jlidxpos[1]+12;
let fireposy = jlidxpos[1]+3;
let firepro = tweenAnisp(firework,fireposx,fireposy);
promiseList.push(firepro);
}
}
wait(1000).then(()=>{
holesp.playAnm();
})
// })
// promiseList.push(waitpro);
// setTimeout(() => {
// console.log("开始缓动");
// if(mapsp){
// let mapro = tweenAnisp(mapsp,jlidxpos[0],jlidxpos[1]);
// promiseList.push(mapro);
// }
// if(elesp){
// // console.log("000000发起时准备替换元素",jlidxlattice.index,mapcf.mapdata["maptype"],elecf.eledata["type"]);
// let elepro = tweenAnisp(elesp,jlidxpos[0],jlidxpos[1]);
// promiseList.push(elepro);
// //烟花特殊处理
// if(elecf.eledata["type"]==ElementType.FIREWORKS_SHOOTER){
// // console.log("烟花特殊处理");
// let firework = elesp["_fireworks"];
// let fireposx = jlidxpos[0];
// let fireposy = jlidxpos[1]+3;
// let firepro = tweenAnisp(firework,fireposx,fireposy);
// promiseList.push(firepro);
// }
// }
// holesp.playAnm();
// }, 1300);
}
}
}
......
......@@ -273,7 +273,7 @@ export default class MapScene extends Scene {
RES.getResAsync(`${key}_png`)]);
} catch (error) {
}
console.log("开始加载一系列资源");
// console.log("开始加载一系列资源");
RES.getResAsync('candydis0_json');
RES.getResAsync('candydis1_json');
RES.getResAsync('candydis2_json');
......
......@@ -106,6 +106,7 @@ export class Element extends eui.Component {
_fireworks;
resetFireworks(thisobj) {
this.mainScene = thisobj;
this.changeSource('empty_png');
this.showImage.alpha = 0;
if(this._fireworks){
......@@ -118,7 +119,7 @@ export class Element extends eui.Component {
}
this._fireworks.x = this.x;
this._fireworks.y = this.y + 12;
this._fireworks.y = this.y+3;
thisobj.addChild(this._fireworks);
this._fireworks.gotoAndStop(1);
}
......@@ -129,6 +130,7 @@ export class Element extends eui.Component {
this._fireworks.gotoAndStop(start);
this._fireworks.removeEventListener(egret.Event.ENTER_FRAME, cb, this);
console.error("释放烟花pro",this.index);
this.mainScene.checkFireWorks(this.index);
resolve();
}
};
......
let wormvideo:any;
let svgaParser
export default class WormHole extends egret.Sprite{
showImage:eui.Image;
wormHoleClip:any;
constructor(){
super();
this.showImage = new eui.Image();
this.addChild(this.showImage);
var texture: egret.Texture = RES.getRes("wormhole_png");
if(texture){
this.showImage.texture = texture;
// this.showImage = new eui.Image();
// this.addChild(this.showImage);
// var texture: egret.Texture = RES.getRes("wormhole_png");
// if(texture){
// this.showImage.texture = texture;
this.showImage.x = 0;
this.showImage.y = 0;
this.showImage.anchorOffsetX = this.showImage.width/2;
this.showImage.anchorOffsetY = this.showImage.height/2;
this.showImage.scaleX = 1.5;
this.showImage.scaleY = 1.5;
}
// this.showImage.x = 0;
// this.showImage.y = 0;
// this.showImage.anchorOffsetX = this.showImage.width/2;
// this.showImage.anchorOffsetY = this.showImage.height/2;
// this.showImage.scaleX = 1.5;
// this.showImage.scaleY = 1.5;
// }
this.initSvga();
}
index:number
init(index:number){
this.index = index;
}
initSvga(){
if(wormvideo){
console.log("复用黑洞数据");
this.createWormHole();
}else{
if (!svgaParser) svgaParser = new window["SVGA"].Parser();
svgaParser.load(resPath + 'resource/assets/svgas/wormhole.svga',(videoItem)=>{
if(!wormvideo){
wormvideo = videoItem;
}
this.createWormHole();
})
}
}
createWormHole(){
this.wormHoleClip = new window["SVGA"].EgretMovieClip(wormvideo);
var mvwidth = 82;
var mvheight = 82;
this.wormHoleClip.x = -mvwidth/2;
this.wormHoleClip.y = -mvwidth/2;
this.addChild(this.wormHoleClip);
this.wormHoleClip.gotoAndStop(1);
this.wormHoleClip.addEventListener(egret.Event.ENTER_FRAME,this.toFrameAni,this);
console.log("添加黑洞",this.wormHoleClip);
}
toFrameAni(){
var curframe = this.wormHoleClip.currentFrame;
if(curframe==123){
var endtime = new Date().getTime();
console.log("passtime",endtime-this.playtime);
this.wormHoleClip.gotoAndStop(1);
}
}
playtime:number;
playAnm(){
this.playtime = new Date().getTime();
this.wormHoleClip&&this.wormHoleClip.gotoAndPlay(1,1);
}
recover(){
if(this.parent){
this.parent.removeChild(this);
......
......@@ -378,8 +378,11 @@ export class AiControl {
resolve();
})
})
if(thisObj._checkMtag.wormhole){
console.log("蛋壳pro",activeEggIndex);
thisObj.wormHolePromise.push(pro);
}
if (++count == countAll) {
//做个延时,有节奏感
......
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