Commit 3477e420 authored by wjf's avatar wjf

l

parent cf502021
This diff is collapsed.
......@@ -32,7 +32,7 @@ export function MagicRotateAni(ele: Element, p: number[], con: egret.DisplayObje
//算角度,弧度,x正方向为0,0到2pi,逆时针为正
var vec0 = [1, 0]
var vec1 = [deltaX, deltaY]
var rotation = getRot(vec0, vec1);
var rotation = getRotByTwoVectors(vec0, vec1);
if (deltaY > 0) {
rotation = pi2 - rotation;
}
......@@ -81,7 +81,7 @@ function rotationAcodPoint(p: number[], rotation: number, point: number[] = [0,
* @param vec1
* @param vec2
*/
function getRot(vec1: number[], vec2: number[]) {
export function getRotByTwoVectors(vec1: number[], vec2: number[]) {
var a = Math.sqrt(vec1[0] * vec1[0] + vec1[1] * vec1[1])
var b = Math.sqrt(vec2[0] * vec2[0] + vec2[1] * vec2[1])
var ab = vec1[0] * vec2[0] + vec1[1] * vec2[1]
......
import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
import { Element } from "../class/Element";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
export const stepPosition: number[] = [125, 115];
/**
* 需要回调的
* 手动修改this.shoot.rotation=
*/
export class FesRedShootAni extends egret.DisplayObjectContainer {
light: LightingAni;
imageAni: ImageAni;
imageAniCon: egret.DisplayObjectContainer
constructor() {
super()
this.light = new LightingAni();
this.addChild(this.light);
var arr = []
for (var i = 1; i <= 10; i++) {
arr.push("fesEleSmallDis" + i + "_png");
}
this.imageAniCon = new egret.DisplayObjectContainer();
this.imageAni = new ImageAni(arr);
this.imageAniCon.addChild(this.imageAni);
this.addChild(this.imageAniCon);
this.imageAni.visible = false
}
reset() {
this.light.visible = true;
this.imageAni.visible = false;
this.light.scaleX = 0.2;
}
play(startP: number[], ele: Element, callback: Function) {
this.reset()
//算角度
var r = Tool.getForwardRotation(startP, [ele.x, ele.y])
this.light.rotation = r * 180 / Math.PI;
this.light.x = startP[0];
this.light.y = startP[1];
this.imageAniCon.x = ele.x;
this.imageAniCon.y = ele.y;
//247
var dis = Math.sqrt(
(startP[0] - ele.x) * (startP[0] - ele.x) +
(startP[1] - ele.y) * (startP[1] - ele.y)
)
var scaleX = dis / 247;
egret.Tween.get(this.light)
.to({ scaleX: scaleX, }, 400)
.call(() => {
ele.reset(ElementType.FESTIVALELE_SMALL);
ele.scaleX = ele.scaleY = 0.1
egret.Tween.get(ele)
.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut)
//回调
callback();
this.imageAni.visible = true;
this.imageAni.play(() => {
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.FESREDSHOOT_ANI, this)
})
setTimeout(() => {
this.light.visible = false;
}, 200)
})
}
}
class LightingAni extends egret.Bitmap {
sourceAll: string[];
currentFrame: number;
totalFrames: number;
isPlay: boolean;
startTime: number
/**
* 所有时间,帧数按每秒30
*/
allTime: number
/**
* 播放完的回调
*/
constructor() {
super();
var arr = [];
for (var i = 1; i <= 13; i++) {
arr.push("lineLight" + i + "_png")
}
this.anchorOffsetX = 23;
this.anchorOffsetY = 27;
this.sourceAll = arr;
this.texture = RES.getRes(this.sourceAll[0])
this.currentFrame = 0;
this.totalFrames = arr.length;
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this)
this.startTime = Date.now()
this.allTime = this.sourceAll.length / 30 * 1000;
}
onEnterFrame() {
if (!this.stage) return
var dataNow = Date.now();
var deltaTime = dataNow - this.startTime;
var scale = deltaTime / this.allTime;
if (scale >= 1) {
this.startTime = Date.now()
this.currentFrame = 0;
} else {
this.currentFrame = (scale * this.sourceAll.length) >> 0;
}
this.texture = RES.getRes(this.sourceAll[this.currentFrame])
}
}
......@@ -494,15 +494,15 @@ export const Chapters6: ChapterData[] = [
starScores: [5000, 12000, 20000],
map: {
lattices: [
3, 3, 3, 0, 0, 0, 3, 3, 3,
3, 3, 3, 0, 0, 0, 3, 3, 3,
3, 3, 0, 0, 0, 0, 0, 3, 3,
0, 0, 0, 3, 3, 3, 0, 0, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 0, 3, 3, 3, 3,
3, 3, 3, 0, 3, 0, 3, 3, 3,
0, 3, 0, 3, 3, 3, 0, 3, 0,
0, 3, 3, 3, 3, 3, 3, 3, 0
2, 2, 2, 0, 0, 0, 2, 2, 2,
2, 2, 2, 0, 0, 0, 2, 2, 2,
2, 2, 0, 0, 0, 0, 0, 2, 2,
0, 0, 0, 2, 2, 2, 0, 0, 0,
2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 0, 2, 2, 2, 2,
2, 2, 2, 0, 2, 0, 2, 2, 2,
0, 2, 0, 2, 2, 2, 0, 2, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
connectedLats: [[73, 0], [74, 1], [75, 2], [77, 6], [78, 7], [79, 8]],
elements: [
......@@ -550,7 +550,7 @@ export const Chapters6: ChapterData[] = [
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0.1,
stepCount: 30,
stepCount: 40,
passTarget: { type: 1, elements: [{ type: 6, count: 8 }] },
starScores: [5000, 12000, 21000],
map: {
......
......@@ -512,7 +512,7 @@ export const Chapters8: ChapterData[] = [
},
//157
{
baseElementTypes: [0, 1, 2, 3, 4], bubbleProbability: 0, stepCount: 26, passTarget: { type: 1, elements: [{ type: 6, count: 13 }] }, starScores: [5000, 12000, 21000], map: { lattices: [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 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, 0, 1, 1, 1, 1, 1, 0, 0], connectedLats: [[30, 48], [31, 49], [32, 50], [74, 18], [78, 26]], elements: [1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1], baseElements: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], recycles: [75, 76, 77], generateLats: [{ index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 10, type: null }, { index: 16, type: null }, { index: 18, type: null }, { index: 26, type: null }] }
baseElementTypes: [0, 1, 2, 3, 4], bubbleProbability: 0, stepCount: 36, passTarget: { type: 1, elements: [{ type: 6, count: 13 }] }, starScores: [5000, 12000, 21000], map: { lattices: [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 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, 0, 1, 1, 1, 1, 1, 0, 0], connectedLats: [[30, 48], [31, 49], [32, 50], [74, 18], [78, 26]], elements: [1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1], baseElements: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], recycles: [75, 76, 77], generateLats: [{ index: 2, type: null }, { index: 3, type: null }, { index: 4, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 10, type: null }, { index: 16, type: null }, { index: 18, type: null }, { index: 26, type: null }] }
},
//158
{
......
......@@ -24,6 +24,8 @@ export enum RecoverName {
HAIRBALLJUMP_ANI = "HairballJumpAni", //三种毛球是一样的动画
FESREDBOMBSHOW_ANI = "FesRedBombShowAni",
FESREDSHOOT_ANI="FesRedShootAni",
//元素身上,特效常驻动效
......
......@@ -14,9 +14,16 @@ import { Element } from "../class/Element";
import { HairballBrownState } from "../states/HairballBrownState";
import { HairballJumpAni } from "../anis/HairballJumpAni";
import { HairballBrownDivideAni } from "../anis/HairballBrownDivideAni";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import { getRotByTwoVectors } from "../anis/MagicRotateAni";
import { FesRedShootAni } from "../anisCall/FesRedShootAni";
//孵鸡的数量
const chickenNum: number = 4
const chickenNum: number = 4;
//节日大红包的小红包数量
export const fesELeSmallNum: number = 6;
export class AiControl {
private static _ins: AiControl
......@@ -43,6 +50,10 @@ export class AiControl {
*/
private hasHairball: boolean;
/**
* 判断是否还有节日大红包,不可再生
*/
private hasFesEleBig: boolean;
/**
* 用于判断格子中
* 是否有果冻,
......@@ -57,6 +68,115 @@ export class AiControl {
// this.hasBubble = judgeBubbleExist(lattices);
this.hasHairball = judgeHairballExist(lattices);
this.eggs = getEggs(lattices);
this.hasFesEleBig = judgeFesEleBigExist(lattices)
}
fesEleMotion(thisObj: MainScene, callback: Function) {
//无节日大红包,直接回调,气泡能生成,不能直接判断
if (!this.hasFesEleBig) {
callback();
return
}
//找出所有的节日大红包
var indexs: number[] = [];
for (var i = 0; i < thisObj.lattices.length; i++) {
var lat = thisObj.lattices[i];
if (lat &&
lat.element &&
lat.element.type == ElementType.FESTIVALELE_BIG //&&
// lat.element.festivalEle.isActive
) {
indexs.push(i);
}
}
//没有节日大红包,直接回调
if (!indexs.length) {
//标记无节日大红包
this.hasFesEleBig = false;
callback();
return
}
if (!thisObj.lattices[indexs[0]].element.festivalEle.isActive) {
callback();
return
}
//找出6个能飞的小红包
var redIndexs: number[] = [];
for (var a = 0; a < thisObj.lattices.length; a++) {
var lat = thisObj.lattices[a];
//是基础元素,但是不能有任何状态,
if (Tool.judgeBaseEle(lat) &&
!lat.element.hasAnyState() &&
!lat.isGenerate //且格子不是生成口
) {
redIndexs.push(a);
}
}
//打乱索引
redIndexs.sort(function () { return (0.5 - Math.random()); });
let six: any[] = redIndexs.splice(0, fesELeSmallNum);
//如果不足6个,就修改thisObj里的
if (six.length < fesELeSmallNum) {
thisObj.festivalTargetNum = fesELeSmallNum;
thisObj.festivalTarget.count = fesELeSmallNum;
//如果是0;就直接发接口吧
if (!six.length) {
NetManager.ins.hc_redBombAward((success) => {
if (success) thisObj.redBombPanelMark = true;
});
callback();
return
}
}
//变成对象
for (var i = 0; i < six.length; i++) six[i] = { index: six[i] };
//暂时只有一个大红包,
let index = indexs[0];
var p = Tool.getPositionByIndex(index);
var vec0 = [1, 0];
//计算角度
for (var i = 0; i < six.length; i++) {
var po = Tool.getPositionByIndex(six[i].index);
var deltaX = po[0] - p[0];
var deltaY = po[1] - p[1];
// var dis = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
//算角度,弧度,x正方向为0,0到2pi,逆时针为正
var vec1 = [deltaX, deltaY]
var rotation = getRotByTwoVectors(vec0, vec1);
if (deltaY > 0) rotation = Math.PI * 2 - rotation;
six[i].rotation = rotation;
}
//排序
six.sort(function (a, b) { return b.rotation - a.rotation });
//还原为索引
for (var i = 0; i < six.length; i++) six[i] = six[i].index;
//动画
thisObj.redBombLightAni(index, () => {
let count = 0;
let countAll = six.length;
for (let a = 0; a < six.length; a++) {
let endIndex = six[a];
let lat = thisObj.lattices[endIndex];
let ele = lat.element;
let fesRedShootAni: FesRedShootAni = Pool.takeOut(RecoverName.FESREDSHOOT_ANI)
if (!fesRedShootAni) fesRedShootAni = new FesRedShootAni();
setTimeout(() => {
thisObj.addChild(fesRedShootAni);
fesRedShootAni.play(p, ele, () => {
if (++count == countAll) {
thisObj.removeOperation(index);
thisObj.fall(() => {
//掉落停止回调
thisObj.fallCallback();
});
// callback();
}
})
}, 100 * a)
}
})
}
jellyMotion(thisObj: MainScene, callback: Function) {
......@@ -515,6 +635,17 @@ function judgeHairballExist(lattices: Lattice[]) {
}
return false;
}
function judgeFesEleBigExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
if (lattice &&
lattice.element &&
lattice.element.type == ElementType.FESTIVALELE_BIG
) return true
}
return false;
}
/**
* 判断气泡是否存在
* @param lattices
......
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