Commit ea080f98 authored by zjz1994's avatar zjz1994

调整炮台动画

parent 8cfdbb00
...@@ -270,6 +270,8 @@ export default class MainScene extends Scene { ...@@ -270,6 +270,8 @@ export default class MainScene extends Scene {
//新增炮台,地图上所有的炮台 //新增炮台,地图上所有的炮台
cannoArr:Array<{idx:number,ele:Element}> = []; cannoArr:Array<{idx:number,ele:Element}> = [];
//每个炮台对应的特效
cannoEffect:Array<any> = [];
//准备发射的炮台 //准备发射的炮台
readyCannoArr:number[] = []; readyCannoArr:number[] = [];
get steps(): number { get steps(): number {
...@@ -411,7 +413,6 @@ export default class MainScene extends Scene { ...@@ -411,7 +413,6 @@ export default class MainScene extends Scene {
var svgas = ["amazing", "great", "wonderful", "bonusTime"]; var svgas = ["amazing", "great", "wonderful", "bonusTime"];
//如果有节日的加 //如果有节日的加
if (this.festivalTarget) svgas.push("redBombLight"); if (this.festivalTarget) svgas.push("redBombLight");
svgas.push(...["canno","cannofire","cannolight","cannoparticle"]);//新增大炮的动画
for (let i = 0; i < svgas.length; i++) { for (let i = 0; i < svgas.length; i++) {
if (movieClips[svgas[i]]) continue; if (movieClips[svgas[i]]) continue;
...@@ -428,7 +429,7 @@ export default class MainScene extends Scene { ...@@ -428,7 +429,7 @@ export default class MainScene extends Scene {
let fun; let fun;
mv.addEventListener(egret.Event.COMPLETE, fun = function (e) { mv.addEventListener(egret.Event.COMPLETE, fun = function (e) {
e.target.stop() e.target.stop()
if (e.target.parent&&mvname!="canno") { if (e.target.parent) {
e.target.parent.removeChild(e.target) e.target.parent.removeChild(e.target)
} }
}, this) }, this)
...@@ -438,6 +439,101 @@ export default class MainScene extends Scene { ...@@ -438,6 +439,101 @@ export default class MainScene extends Scene {
}) })
} }
} }
/**
* 一个炮台有三个附属动画
*/
initCannoSvgas(arr:Array<{idx:number,ele:Element}>){
var resPath = getResPath();
this.cannoEffect = new Array();
if (!svgaParser) svgaParser = new window["SVGA"].Parser();
var svgas = ["cannofire","cannolight","cannoparticle"];//新增大炮的动画
for(let i=0;i<arr.length;i++){
let icanno:Element = arr[i].ele;
var icannodir:forwardDirection = icanno._cannoDir;
var icannolpos = Tool.getPositionByIndex(arr[i].idx);
var icannowpos = this.elementContainer.localToGlobal(icannolpos[0],icannolpos[1]);
let icannobox:eui.Group = new eui.Group;
let icannoboxwid:number=116;
let icannoboxhei:number=116;
icannobox.width = icannoboxwid;
icannobox.height = icannoboxhei;
icannobox.anchorOffsetX = icannoboxwid/2;
icannobox.anchorOffsetY = icannoboxhei/2;
let effectobj = {};
this.cannoEffect[i] = effectobj;
this.cannoEffect[i]["box"] = icannobox;
this.addChild(icannobox);
icannobox.x = icannowpos.x;
icannobox.y = icannowpos.y;
var roanum = Tool.getCannoRoaByDir(icannodir);
// console.log("icannobox旋转朝向",roanum);
icannobox.touchEnabled = false;
icannobox.touchThrough = true;
icannobox.rotation = roanum;
for(let j=0;j<svgas.length;j++){
let jsvgname = svgas[j];
svgaParser.load(resPath + 'resource/assets/svgas/' + jsvgname + ".svga", (videoItem) => {
var mv = new window["SVGA"].EgretMovieClip(videoItem);
mv.lockStep = true;
if(jsvgname=="cannofire"){
// console.log("cannofire",mv);
mv.x = icannoboxwid-6;
mv.y = -icannoboxhei*3/2;
mv.rotation = 90;
}else if(jsvgname=="cannolight"){
var mvwidth = 400;
var mvheight = 400;
mv.x = (icannoboxwid-mvwidth)/2;
mv.y = (icannoboxhei-mvheight)/2;
}else if(jsvgname=="cannoparticle"){
mv.x = icannoboxwid;
mv.y = -icannoboxhei/2;
mv.rotation = 90;
}
mv.stop();
// mv.gotoAndPlay(1,true);
let fun;
mv.addEventListener(egret.Event.COMPLETE,fun=function(e){
e.target.stop();
e.target.visible = false;
if(jsvgname=="cannofire"){//炮弹光波完毕,执行消除
// console.log("光波发射完毕,执行消除");
this.callBackFireCanno(icanno);
}else if(jsvgname=="cannoparticle"){
console.log("发射充能光波");
this.selectPlayCannoEffect(i,"cannofire");
}
},this);
// mv.gotoAndStop(100);
this.cannoEffect[i][jsvgname] = mv;
// if(jsvgname=="cannofire"){
icannobox.addChild(this.cannoEffect[i][jsvgname]);
// }
this.cannoEffect[i][jsvgname].visible = false;
// console.log("初始"+i+"炮台"+jsvgname+"特效");
},function(error){
console.log("炮台svg加载失败",jsvgname);
})
}
}
}
/**
* 播放炮台动画
*/
selectPlayCannoEffect(idx:number,name:string){
if(!this.cannoEffect[idx][name].visible){
this.cannoEffect[idx][name].visible = true;
}
this.cannoEffect[idx][name].stop();
// this.cannoEffect[idx][name].gotoAndStop(1);
console.error("炮台特效播放",idx,name)
this.cannoEffect[idx][name].gotoAndPlay(1);
}
//初始化界面ui,,道具弄在这里s //初始化界面ui,,道具弄在这里s
initUi() { initUi() {
...@@ -887,6 +983,8 @@ export default class MainScene extends Scene { ...@@ -887,6 +983,8 @@ export default class MainScene extends Scene {
idx:i, idx:i,
ele:canno ele:canno
}); });
var dirType = Tool.getCannoDir(elements[i]);
canno.resetToCannoView(dirType);
break; break;
case ElementConfigType.CANNO_BLOCK: case ElementConfigType.CANNO_BLOCK:
let canno_block:Element = Tool.getElement(ElementType.CANNO_BLOCK); let canno_block:Element = Tool.getElement(ElementType.CANNO_BLOCK);
...@@ -901,8 +999,8 @@ export default class MainScene extends Scene { ...@@ -901,8 +999,8 @@ export default class MainScene extends Scene {
break break
} }
} }
this.initCannoSvgas(this.cannoArr);
console.log("关卡大炮配置",this.cannoArr); // console.log("关卡大炮配置",this.cannoArr);
} }
//重置基础元素及特效类型 //重置基础元素及特效类型
...@@ -915,11 +1013,10 @@ export default class MainScene extends Scene { ...@@ -915,11 +1013,10 @@ export default class MainScene extends Scene {
const baseElement = elements[i]; const baseElement = elements[i];
const isCandyEle = elementConfig == ElementConfigType.CANDY; const isCandyEle = elementConfig == ElementConfigType.CANDY;
const isMonsterEle = elementConfig == ElementConfigType.MONSTER; const isMonsterEle = elementConfig == ElementConfigType.MONSTER;
const isCanno = Tool.IsCanno(elementConfig);
//不是基础元素,跳过, //不是基础元素,跳过,
if (!Tool.judgeBaseEle(this.lattices[i]) && !isCandyEle && !isMonsterEle && !isCanno) continue; if (!Tool.judgeBaseEle(this.lattices[i]) && !isCandyEle && !isMonsterEle) continue;
//是0,跳过 //是0,跳过
if (!baseElement && !isCandyEle && !isMonsterEle && !isCanno) continue if (!baseElement && !isCandyEle && !isMonsterEle) continue
const ele: Element = this.lattices[i].element; const ele: Element = this.lattices[i].element;
if (isCandyEle) { //糖果元素 if (isCandyEle) { //糖果元素
...@@ -937,10 +1034,6 @@ export default class MainScene extends Scene { ...@@ -937,10 +1034,6 @@ export default class MainScene extends Scene {
} }
ele.resetToMonsterView(elementMonsterResMap[ele.type]); ele.resetToMonsterView(elementMonsterResMap[ele.type]);
} }
else if(isCanno){//是炮台
var dirType = Tool.getCannoDir(elementConfig);
ele.resetToCannoView(dirType);
}
else { else {
//解析elements[i]; //解析elements[i];
var arr: number[] = Tool.returnTO(elements[i]); var arr: number[] = Tool.returnTO(elements[i]);
...@@ -2424,8 +2517,10 @@ export default class MainScene extends Scene { ...@@ -2424,8 +2517,10 @@ export default class MainScene extends Scene {
} }
} }
} }
canno.fireCanno(); canno.fireCanno();
var cannoarridx = this.getCannoArrByIdx(canno);
this.selectPlayCannoEffect(cannoarridx,"cannoparticle");
// setTimeout(()=>{ // setTimeout(()=>{
// this.eliminate(); // this.eliminate();
...@@ -2433,6 +2528,18 @@ export default class MainScene extends Scene { ...@@ -2433,6 +2528,18 @@ export default class MainScene extends Scene {
// canno.resetCannoStat(); // canno.resetCannoStat();
// },200); // },200);
} }
getCannoArrByIdx(canno:Element){
var cannoidx = canno.index;
var arridx:number = 0;
for(var i=0;i<this.cannoArr.length;i++){
var icannoidx = this.cannoArr[i].idx;
if(icannoidx==cannoidx){
arridx = i;
break;
}
}
return arridx;
}
/** /**
* 炮台发射完毕,开始炮台消除 * 炮台发射完毕,开始炮台消除
*/ */
...@@ -3660,12 +3767,18 @@ export default class MainScene extends Scene { ...@@ -3660,12 +3767,18 @@ export default class MainScene extends Scene {
//返回下,有地方要用 //返回下,有地方要用
//炮台充能 //炮台充能
for(var p=0;p<this.cannoArr.length;p++){ for(let p=0;p<this.cannoArr.length;p++){
var pcannoidx = this.cannoArr[p].idx; let pcannoidx = this.cannoArr[p].idx;
var isnext = Tool.checkNebByidx(pcannoidx,index); var isnext = Tool.checkNebByidx(pcannoidx,index);
if(isnext){ if(isnext){
var pcannoele = this.cannoArr[p].ele; var pcannoele = this.cannoArr[p].ele;
var lastpcannostatnum:number = pcannoele._cannoStat
pcannoele.addOneCannoStat(); pcannoele.addOneCannoStat();
var newpcannostatnum:number = pcannoele._cannoStat
if(newpcannostatnum>lastpcannostatnum){
console.log('发射充能光波',lastpcannostatnum,newpcannostatnum);
this.selectPlayCannoEffect(p,"cannolight");
}
var pcannostat = pcannoele.checkCannoStat(); var pcannostat = pcannoele.checkCannoStat();
if(pcannostat){ if(pcannostat){
if(this.readyCannoArr.indexOf(p)==-1){ if(this.readyCannoArr.indexOf(p)==-1){
......
...@@ -1249,4 +1249,19 @@ export class Tool { ...@@ -1249,4 +1249,19 @@ export class Tool {
console.error("未定义跑跳"); console.error("未定义跑跳");
} }
} }
//炮台的旋转朝向
public static getCannoRoaByDir(cannodir:forwardDirection){
var roaidx:number;
if(cannodir==forwardDirection.left){
roaidx = 0;
}else if(cannodir==forwardDirection.up){
roaidx = 1;
}else if(cannodir==forwardDirection.right){
roaidx = 2;
}else if(cannodir==forwardDirection.down){
roaidx = 3;
}
var roanum = [-90,0,90,180][roaidx];
return roanum;
}
} }
\ No newline at end of file
...@@ -40,7 +40,7 @@ export const Chapters22: ChapterData[] = [ ...@@ -40,7 +40,7 @@ export const Chapters22: ChapterData[] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 19, 1, 1, 1, 1, 1, 1, 1, 1, 21, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
...@@ -53,7 +53,7 @@ export const Chapters22: ChapterData[] = [ ...@@ -53,7 +53,7 @@ export const Chapters22: ChapterData[] = [
0, 20, 10, 20, 0, 20, 10, 20, 0, 0, 20, 10, 20, 0, 20, 10, 20, 0,
20, 10, 20, 10, 20, 10, 20, 10, 20, 20, 10, 20, 10, 20, 10, 20, 10, 20,
20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20,
0, 20, 10, 20, 10, 20, 10, 20, 0, 0, 20, 10, 14, 11, 20, 10, 20, 0,
0, 0, 20, 10, 20, 10, 20, 0, 0, 0, 0, 20, 10, 20, 10, 20, 0, 0,
0, 0, 0, 20, 10, 20, 0, 0, 0, 0, 0, 0, 20, 10, 20, 0, 0, 0,
0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0,
......
...@@ -45,7 +45,7 @@ export class Element extends eui.Component { ...@@ -45,7 +45,7 @@ export class Element extends eui.Component {
fishCanEliFlag: boolean; fishCanEliFlag: boolean;
cannoMoveClip:any; cannoMoveClip:any;
cannoCnClip:any; // cannoCnClip:any;
cannoStat:number[] = [1,61,121,181,241,361]; cannoStat:number[] = [1,61,121,181,241,361];
//尝试设置碰撞状态,如果之前被特效集中,那么可以设置碰撞状态。碰撞状态之后可以准备消除。 //尝试设置碰撞状态,如果之前被特效集中,那么可以设置碰撞状态。碰撞状态之后可以准备消除。
...@@ -197,7 +197,7 @@ export class Element extends eui.Component { ...@@ -197,7 +197,7 @@ export class Element extends eui.Component {
} }
_cannoDir:forwardDirection; _cannoDir:forwardDirection;
private _cannoStat:number = 0; _cannoStat:number = 0;
resetToCannoView(cannodir:forwardDirection){ resetToCannoView(cannodir:forwardDirection){
this._cannoDir = cannodir; this._cannoDir = cannodir;
this.resetCannoStat(); this.resetCannoStat();
...@@ -206,17 +206,22 @@ export class Element extends eui.Component { ...@@ -206,17 +206,22 @@ export class Element extends eui.Component {
// this.showImage.y = 0; // this.showImage.y = 0;
// this.showImage.anchorOffsetX = this.showImage.width / 2; // this.showImage.anchorOffsetX = this.showImage.width / 2;
// this.showImage.anchorOffsetY = this.showImage.height / 2; // this.showImage.anchorOffsetY = this.showImage.height / 2;
var roaidx:number;
if(cannodir==forwardDirection.left){
roaidx = 0; // var roaidx:number;
}else if(cannodir==forwardDirection.up){ // if(cannodir==forwardDirection.left){
roaidx = 1; // roaidx = 0;
}else if(cannodir==forwardDirection.right){ // }else if(cannodir==forwardDirection.up){
roaidx = 2; // roaidx = 1;
}else if(cannodir==forwardDirection.down){ // }else if(cannodir==forwardDirection.right){
roaidx = 3; // roaidx = 2;
} // }else if(cannodir==forwardDirection.down){
this.cannobox.rotation = [-90,0,90,180][roaidx]; // roaidx = 3;
// }
// this.cannobox.rotation = [-90,0,90,180][roaidx];
var roanum = Tool.getCannoRoaByDir(cannodir);
this.cannobox.rotation = roanum;
} }
changeShowCannoStat(){ changeShowCannoStat(){
this.cannolab.text = this._cannoStat+""; this.cannolab.text = this._cannoStat+"";
...@@ -226,19 +231,25 @@ export class Element extends eui.Component { ...@@ -226,19 +231,25 @@ export class Element extends eui.Component {
if(this.cannoMoveClip){ if(this.cannoMoveClip){
var endframe:number; var endframe:number;
var curframe:number = this.cannoMoveClip.currentFrame; var curframe:number = this.cannoMoveClip.currentFrame;
this.cannoMoveClip.gotoAndPlay(curframe,true);
if(_stat==0){ if(_stat==0){
curframe = 0;
endframe = 1; endframe = 1;
}else if(_stat==1){ }else if(_stat==1){
curframe = 61;
endframe = 121; endframe = 121;
}else if(_stat==2){ }else if(_stat==2){
curframe = 121
endframe = 181; endframe = 181;
}else if(_stat==3){ }else if(_stat==3){
curframe = 181;
endframe = 241; endframe = 241;
}else if(_stat==4){ }else if(_stat==4){
curframe = 241;
endframe = 361; endframe = 361;
} }
// this.changeShowCanno(curframe,endframe); // this.cannoMoveClip.gotoAndPlay(curframe,true);
this.cannoMoveClip.gotoAndPlay(curframe,1);
this.stopFrame = endframe; this.stopFrame = endframe;
} }
} }
...@@ -267,7 +278,7 @@ export class Element extends eui.Component { ...@@ -267,7 +278,7 @@ export class Element extends eui.Component {
if(this._cannoStat>3){ if(this._cannoStat>3){
this._cannoStat = 3; this._cannoStat = 3;
}else{//充能动画 }else{//充能动画
this.cannoCnClip.gotoAndPlay(1,true); // this.cannoCnClip.gotoAndPlay(1,true);
} }
this.changeShowCannoStat(); this.changeShowCannoStat();
} }
...@@ -511,13 +522,13 @@ export class Element extends eui.Component { ...@@ -511,13 +522,13 @@ export class Element extends eui.Component {
return; return;
} }
if (!svgaParser) svgaParser = new window["SVGA"].Parser(); if (!svgaParser) svgaParser = new window["SVGA"].Parser();
var svgas = ["canno","cannofire","cannoparticle","cannolight"]; var svgas = ["canno"]//,"cannofire","cannoparticle","cannolight"];
for(let i=0;i<svgas.length;i++){ for(let i=0;i<svgas.length;i++){
let mvname = svgas[i]; let mvname = svgas[i];
svgaParser.load(resPath + 'resource/assets/svgas/'+mvname+'.svga',(videoItem)=>{ svgaParser.load(resPath + 'resource/assets/svgas/'+mvname+'.svga',(videoItem)=>{
if(mvname=="canno"){ if(mvname=="canno"){
this.cannoMoveClip = new window["SVGA"].EgretMovieClip(videoItem); this.cannoMoveClip = new window["SVGA"].EgretMovieClip(videoItem);
this.cannoMoveClip.lockStep = true; // this.cannoMoveClip.lockStep = true;
var mvwidth = 102; var mvwidth = 102;
var mvheight = 116; var mvheight = 116;
this.cannoMoveClip.x = (this.cannoboxwid-mvwidth)/2; this.cannoMoveClip.x = (this.cannoboxwid-mvwidth)/2;
...@@ -525,20 +536,21 @@ export class Element extends eui.Component { ...@@ -525,20 +536,21 @@ export class Element extends eui.Component {
this.cannobox.addChild(this.cannoMoveClip); this.cannobox.addChild(this.cannoMoveClip);
this.cannoMoveClip.gotoAndStop(1); this.cannoMoveClip.gotoAndStop(1);
this.cannoMoveClip.addEventListener(egret.Event.ENTER_FRAME,this.toFrameAni,this); this.cannoMoveClip.addEventListener(egret.Event.ENTER_FRAME,this.toFrameAni,this);
}else if(mvname=="cannolight"){
this.cannoCnClip = new window["SVGA"].EgretMovieClip(videoItem);
this.cannoCnClip.lockStep = true;
var mvwidth = 400;
var mvheight = 400;
this.cannoCnClip.x = (this.cannoboxwid-mvwidth)/2;
this.cannoCnClip.y = (this.cannoboxhei-mvheight)/2;
this.cannobox.addChild(this.cannoCnClip);
this.cannoCnClip.gotoAndStop(1);
this.cannoCnClip.addEventListener(egret.Event.COMPLETE,this.addOnePower,this);
console.log("光圈cannocnClip",this.cannoCnClip);
}else if(mvname=="cannoparticle"){
} }
// else if(mvname=="cannolight"){
// this.cannoCnClip = new window["SVGA"].EgretMovieClip(videoItem);
// this.cannoCnClip.lockStep = true;
// var mvwidth = 400;
// var mvheight = 400;
// this.cannoCnClip.x = (this.cannoboxwid-mvwidth)/2;
// this.cannoCnClip.y = (this.cannoboxhei-mvheight)/2;
// this.cannobox.addChild(this.cannoCnClip);
// this.cannoCnClip.gotoAndStop(1);
// this.cannoCnClip.addEventListener(egret.Event.COMPLETE,this.addOnePower,this);
// console.log("光圈cannocnClip",this.cannoCnClip);
// }else if(mvname=="cannoparticle"){
// }
}); });
} }
} }
...@@ -552,17 +564,17 @@ export class Element extends eui.Component { ...@@ -552,17 +564,17 @@ export class Element extends eui.Component {
if(curframe>=this.stopFrame){ if(curframe>=this.stopFrame){
this.cannoMoveClip.gotoAndStop(this.stopFrame); this.cannoMoveClip.gotoAndStop(this.stopFrame);
if(this.stopFrame==361){ if(this.stopFrame==361){
console.log("炮台发射完毕"); // console.log("炮台发射完毕");
} }
} }
} }
/** // /**
* 光圈充能动画 // * 光圈充能动画,现放在mainscene
*/ // */
addOnePower(){ // addOnePower(){
console.log("一次光圈充能"); // console.log("一次光圈充能");
this.cannoCnClip.gotoAndStop(1); // this.cannoCnClip.gotoAndStop(1);
} // }
/** /**
* 替换资源时,同时修改 * 替换资源时,同时修改
* @param source * @param source
......
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