Commit 90c4dfc2 authored by wjf's avatar wjf

l

parent 40d1e5c8
......@@ -144,9 +144,6 @@ export default class MainBase extends eui.UILayer {
for (var i = 1; i <= 6; i++) {
RES.getResAsync("ice" + i + "_png")
}
for (var i = 1; i <= 6; i++) {
RES.getResAsync("ice" + i + "_png")
}
for (var i = 1; i <= 6; i++) {
RES.getResAsync("rock" + i + "_png")
}
......@@ -160,6 +157,7 @@ export default class MainBase extends eui.UILayer {
RES.getResAsync("targetNumber" + i + "_png")
}
var arr = [
"bonusShoot",
"ele5",
"ele6",
"ele7",
......
......@@ -39,6 +39,7 @@ import { ElementTarget } from '../something/uis/ElementTarget';
import { ElementTargets } from '../something/uis/ElementTargets';
import { Chapters } from '../something/Chapters';
import { FlyTargetAni } from '../something/anis/FlyTargetAni';
import { BonusShootAni, stepPosition } from '../something/anis/BonusShootAni';
// import BridgeFactory from "../../libs/JSBridge/bridge/BridgeFactory";
const aniClass = {
......@@ -189,6 +190,9 @@ export default class MainScene extends Scene {
this.enableMouseEvt(false);
this.initBuired()
var b=new BonusShootAni();
console.log(b)
this.addChild(b)
//步数初始化
this.steps = this.chapterData.stepCount;
//分数置0
......@@ -1227,7 +1231,6 @@ export default class MainScene extends Scene {
this.rotateEliminate()
//消除同时找出带特效的
var effectIndexs = this.commonEliminate();
var scoreAll = 0;
//得分动效执行,在上面消除动效后出现,分数动效层级要高
for (var i = 0; i < this.scoreAnis.length; i++) {
......@@ -1269,6 +1272,7 @@ export default class MainScene extends Scene {
//连消倍数为1
this.commonContinuityTimes = 1;
this.effectContinuityTimes = 1;
//先出toast bonusTime,播完后
//bonustime,toast,把所有有特效的消除先
this.terminateSteps()
} else {
......@@ -1654,28 +1658,58 @@ export default class MainScene extends Scene {
* 消耗完所有步数,
*/
terminateSteps() {
//先出toast bonusTime
//遍历有特效的,和,基础元素
// var effectElements = [], elements = [];
// for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
// var rc = Tool.indexToRc(i);
// var row = rc[0];
// var col = rc[1];
// var lat = this.lattices[i];
// if (!Tool.judgeMatch(lat)) continue
// if (lat.element.effectType != null) {
// effectElements.push(lat.element);
// } else {
// elements.push(lat.element)
// }
// }
// //如果特效有,消除特效
// if (effectElements.length) {
// Array.prototype.push.apply(this.eliminatedElements, effectElements);
// }
//遍历有特效的索引,和,基础元素
var effectElements = [], elements = [];
for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
var lat = this.lattices[i];
if (!Tool.judgeMatch(lat)) continue
if (lat.element.effectType != null) {
effectElements.push(i);
} else {
elements.push(lat.element)
}
}
//如果特效有,消除特效
if (effectElements.length) {
Array.prototype.push.apply(this.eliminatedElements, effectElements);
this.eliminate();
}
else {
//分数
this.score += this.steps * 500;
let countAll = Math.min(this.steps, elements.length);
let count = 0;
let deltaCount = 0;
//将步数变成横竖特效
while (deltaCount < countAll) {
var rand = Math.floor(Math.random() * elements.length);
let ele: Element = elements.splice(rand, 1)[0];
if (!ele) break;
deltaCount++;
let bonusShootAni: BonusShootAni = Pool.takeOut(RecoverName.BONUSSHOOT_ANI)
if (!bonusShootAni) {
bonusShootAni = new BonusShootAni()
}
setTimeout(() => {
this.steps--;
this.addChild(bonusShootAni);
//算角度
var r = Tool.getForwardRotation(stepPosition, [ele.x, ele.y])
bonusShootAni.play(r * 180 / Math.PI, [ele.x, ele.y], () => {
ele.effectType = Math.random() > 0.5 ? EffectType.HORIZONTAL : EffectType.VERTICAL;
count++;
this.eliminatedElements.push(ele.index)
if (count == countAll) {
this.eliminate();
//如果还有步数就置0
if (this.steps) this.steps = 0;
}
})
}, 150 * deltaCount)
}
//动画一步一步
//将指定步数的的元素变成横竖的特效,同时加500分,并加入消除队列,执行消除,
}
}
/**
* 创建分数得动画
......
......@@ -37,7 +37,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.15,
stepCount: 50,
stepCount: 30,
// passTarget: {
// type: PassType.SCORE_TARGET,
// score: 10000000,
......@@ -55,7 +55,7 @@ export const Chapters: ChapterData[] = [
},
{
type: ElementType.LOLLIPOP,
count: 4,
count: 2,
}
],
},
......
......@@ -213,7 +213,7 @@ export class Tool {
}
//算角度,弧度,x正方向为0,0到2pi,顺时针为正
public static getForwardRotation(fromPoint: number[], toPoint: number[]) {
public static getForwardRotation(fromPoint: number[], toPoint: number[]): number {
var deltaX = toPoint[0] - fromPoint[0];
var deltaY = toPoint[1] - fromPoint[1];
var vec1 = [1, 0];
......@@ -226,5 +226,6 @@ export class Tool {
if (deltaY < 0) {
r = Math.PI * 2 - r;
}
return r
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
export const stepPosition: number[] = [125, 115];
/**
* 需要回调的
* 手动修改this.shoot.rotation=
......@@ -11,7 +13,8 @@ export class BonusShootAni extends egret.DisplayObjectContainer {
imageAni: ImageAni
constructor() {
super()
this.shoot = new egret.Bitmap();
var texture = RES.getRes("bonusShoot_png")
this.shoot = new egret.Bitmap(texture);
this.shoot.anchorOffsetX = 78;
this.shoot.anchorOffsetY = 37 / 2;
this.addChild(this.shoot);
......@@ -25,21 +28,26 @@ export class BonusShootAni extends egret.DisplayObjectContainer {
}
reset() {
this.shoot.visible = true;
this.imageAni.visible = false
this.imageAni.visible = false;
this.x = stepPosition[0];
this.y = stepPosition[1];
}
play(rotation: number, p: number[], callback: Function) {
this.reset()
this.shoot.rotation = rotation;
egret.Tween.get(this)
.to({ x: p[0], y: p[1] }, 1000 + Math.random() * 200 >> 0)
.to({ x: p[0], y: p[1] }, 400)
.call(() => {
callback();
this.shoot.visible = false;
this.imageAni.visible = true;
this.imageAni.play(() => {
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.BONUSSHOOT_ANI, this)
callback();
// callback();
})
})
}
......
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