Commit 6c914c8b authored by wjf's avatar wjf

l

parent e41cc2b9
import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
import { Element } from "../class/Element";
import { StateType } from "../enum/StateType";
const offsetX = 71 / 2;
const offsetY = 62 / 2;
/**
* 分裂的动画,待写
* 71*62
*/
export class HairballBrownDivideAni extends egret.DisplayObjectContainer {
startHairball: Hairball;
endHairball: Hairball;
constructor() {
super()
//起点处的
this.startHairball = new Hairball();
this.startHairball.brownFace.visible = false;
this.startHairball.x = -offsetX;
this.startHairball.y = -offsetY;
this.addChild(this.startHairball);
//移动的
this.endHairball = new Hairball();
this.endHairball.x = -offsetX;
this.endHairball.y = -offsetY;
this.addChild(this.endHairball);
}
play(type: StateType, startP: number[], endP: number[], callback: Function) {
var source: string;
switch (type) {
case StateType.HAIRBALLBLACK:
source = "ele" + ElementType.HAIRBALLBLACK + "_png";
break;
case StateType.HAIRBALLGREY:
source = "ele" + ElementType.HAIRBALLGREY + "_png";
break;
case StateType.HAIRBALLBROWN:
source = "ele" + ElementType.HAIRBALLBROWN + "_png";
break;
default:
source = "ele" + ElementType.HAIRBALLGREY + "_png";
break
reset() {
this.startHairball.eyesDown.scaleY = 1.5;
this.startHairball.visible = false;
this.endHairball.x = -offsetX;
this.endHairball.y = -offsetY;
this.endHairball.brownFace.visible = true;
this.endHairball.greyFace.alpha = 0;
}
play(startP: number[], endP: number[], callback: Function) {
this.reset();
var oriEyeX = 10.99;
var oriEyeY = 24.66;
//判断上下左右,
var obj = { x: -offsetX, y: -offsetY };//整体的位置跳动
var eyeObj = { x: oriEyeX, y: oriEyeY };//眼睛的移动
//一个位置不能移动,都相等
if (Math.abs(endP[0] - startP[0]) <= 0.001 && Math.abs(endP[1] - startP[1]) <= 0.001) {
}
//x相等 上下
else if (Math.abs(endP[0] - startP[0]) <= 0.001) {
//下
if (endP[1] - startP[1] > 0) {
obj.y += Tool.height;
eyeObj.y += 4;
}
//上
else {
obj.y -= Tool.height;
eyeObj.y -= 4;
}
}
//y相等 左右
else {
//左
if (endP[0] - startP[0] > 0) {
obj.x += Tool.width;
eyeObj.x += 4;
}
//右
else {
obj.x -= Tool.width;
eyeObj.x -= 4;
}
}
var texture: egret.Texture = RES.getRes(source)
this.anchorOffsetX = texture.textureWidth / 2;
this.anchorOffsetY = texture.textureHeight;
//自己的
this.x = startP[0];
this.y = startP[1] + texture.textureHeight / 2;
egret.Tween.get(this)
.to({ scaleX: 1.2, scaleY: 0.8 }, 50)
.to({ scaleX: 0.8, scaleY: 1.2 }, 50)
.to({ scaleX: 1, scaleY: 1 }, 50)
.to({ scaleX: 1.2, scaleY: 0.8 }, 50)
.to({ scaleX: 0.8, scaleY: 1.2 }, 50)
.to({ scaleX: 1, scaleY: 1 }, 50)
this.y = startP[1];
//整体的移动
let tweenPosAll = egret.Tween.get(this.endHairball);
for (var i = 0; i < 5; i++) {
tweenPosAll.to({ x: -offsetX - 1 }, 20)
.to({ x: -offsetX + 2 }, 20)
.to({ x: -offsetX }, 20)
}
tweenPosAll.call(() => {
this.startHairball.visible = true;
})
tweenPosAll.to(obj, 200)
//褐色变灰色,灰色透明度到1
egret.Tween.get(this.endHairball.greyFace)
.wait(100)
.to({ alpha: 1 }, 100)
.call(() => {
this.endHairball.brownFace.visible = false;
})
//endHairball的眼白
egret.Tween.get(this.endHairball.eyesDown)
.wait(50)
.to({ scaleY: 1.5 }, 50)
.wait(420)
.to({ scaleY: 1 }, 30)
//startHairball的眼白
egret.Tween.get(this.startHairball.eyesDown)
.wait(520)
.to({ scaleY: 1 }, 30)
//endHairball的眼珠的移动
egret.Tween.get(this.endHairball.eyes)
.wait(200)
.to(eyeObj, 30)
.wait(290)
.to({ x: oriEyeX, y: oriEyeY }, 30)
.call(() => {
//回收元素
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALLJUMP_ANI, this)
Pool.recover(RecoverName.HAIRBALLBROWNDIVIDE_ANI, this)
//回调
callback();
})
egret.Tween.get(this)
.to({ x: endP[0], y: endP[1]+texture.textureHeight / 2 }, 300, egret.Ease.sineInOut)
}
}
/**
* 整个球
*/
class Hairball extends egret.DisplayObjectContainer {
brownFace: egret.Bitmap;
greyFace: egret.Bitmap;
eyesDown: EyesDown;
eyes: Eyes;
constructor() {
super();
this.brownFace = new egret.Bitmap(RES.getRes("brownBallFace_png"));
this.addChild(this.brownFace);
this.greyFace = new egret.Bitmap(RES.getRes("greyBallFace_png"));
this.addChild(this.greyFace);
this.eyesDown = new EyesDown();
this.eyesDown.x = 10;
this.eyesDown.y = 32.66;
this.addChild(this.eyesDown);
this.eyes = new Eyes();
this.eyes.x = 10.99;
this.eyes.y = 24.66;
this.addChild(this.eyes);
}
}
/**
* 眼睛的,整体位置10.99,24.66
*/
class Eyes extends egret.DisplayObjectContainer {
left: egret.Bitmap;
right: egret.Bitmap;
constructor() {
super();
var texture: egret.Texture = RES.getRes("eyeSingle_png")
this.left = new egret.Bitmap(texture);
this.addChild(this.left);
this.right = new egret.Bitmap(texture);
this.right.x = 27.85;
this.addChild(this.right)
}
}
/**
* 整体位置是10,32.66
*/
class EyesDown extends egret.DisplayObjectContainer {
left: egret.Bitmap;
right: egret.Bitmap;
constructor() {
super();
this.left = new egret.Bitmap(RES.getRes("eyeDownLeft_png"));
this.left.y = -10;
this.addChild(this.left);
this.right = new egret.Bitmap(RES.getRes("eyeDownRight_png"));
this.right.x = 27.51;
this.right.y = -10;
this.addChild(this.right)
}
}
......@@ -6,7 +6,7 @@ import { ElementType } from "../enum/ElementType";
* 61到80关数据
*/
export const Chapters4: ChapterData[] = [
//61 测试鸡蛋
//61 鸡蛋引导,待调整
{
baseElementTypes: [0, 4, 2, 3],
bubbleProbability: 0,
......@@ -14,17 +14,50 @@ export const Chapters4: ChapterData[] = [
passTarget: { type: 1, elements: [{ type: 1, count: 30 }] },
starScores: [8000, 15000, 22000],
map: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0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
1, 1, 6, 1, 1, 1, 6, 1, 1,
1, 1, 6, 1, 1, 1, 6, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0
],
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: [],
generateLats: [
{ index: 12, type: null },
{ index: 13, type: null },
{ index: 14, type: null },
{ index: 20, type: null },
{ index: 24, type: null },
{ index: 28, type: null },
{ index: 34, type: null },
{ index: 36, type: null },
{ index: 44, type: null }
......
This diff is collapsed.
......@@ -57,7 +57,7 @@ export enum RecoverName {
LOCK_STATE = "LockState",
BUBBLE_STATE = "BubbleState",
HAIRBALLGREY_STATE = "HairballGreyState",
HAIRBALLBLACK_STATE = "HairballGreyState",
HAIRBALLBROWN_STATE = "HairballGreyState",
HAIRBALLBLACK_STATE = "HairballBlackState",
HAIRBALLBROWN_STATE = "HairballBrownState",
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import { BubbleAni } from "../anis/BubbleAni";
import { Element } from "../class/Element";
import { HairballBrownState } from "../states/HairballBrownState";
import { HairballJumpAni } from "../anis/HairballJumpAni";
import { HairballBrownDivideAni } from "../anis/HairballBrownDivideAni";
//孵鸡的数量
const chickenNum: number = 4
......@@ -361,10 +362,18 @@ export class AiControl {
}
//分裂的优先,因为存在多出状态,不需要多次,按顺序就行
let countDivide = 0;
let countDivideAll = divideBallIndexs.length;
for (var a = 0; a < countDivideAll; a++) {
let indexFrom = divideBallIndexs[a];
this.divideAni(thisObj,divideBallIndexs,callbackOperation)
//跳动的,
this.jumpAni(thisObj, jumpBallIndexs, callbackOperation)
//唤醒的
this.awakeAni(thisObj, awakeBallIndexs, callbackOperation)
}
private divideAni(thisObj: MainScene, indexs: number[], callback: Function) {
let count = 0;
let countAll = indexs.length;
for (var a = 0; a < countAll; a++) {
let indexFrom = indexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element;
//判断是否能分裂
let indexEnd = judgeActionIndex(indexFrom, thisObj.lattices);
......@@ -377,31 +386,54 @@ export class AiControl {
let elementEnd = thisObj.lattices[indexEnd].element;
//变成灰色毛球
elementEnd.setState(StateType.HAIRBALLGREY, true);
//动画
setTimeout(() => {
//两个都隐藏
elementFrom.getState(StateType.HAIRBALLGREY).visible = false;
elementEnd.getState(StateType.HAIRBALLGREY).visible = false;
//分裂动画
let divideAni: HairballBrownDivideAni = Pool.takeOut(RecoverName.HAIRBALLBROWNDIVIDE_ANI)
if (!divideAni) divideAni = new HairballBrownDivideAni()
thisObj.addChild(divideAni);
divideAni.play(Tool.getPositionByIndex(indexFrom), Tool.getPositionByIndex(indexEnd), () => {
//显示
elementFrom.getState(StateType.HAIRBALLGREY).visible = true;
elementEnd.getState(StateType.HAIRBALLGREY).visible = true;
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
if (++count == countAll) callback();
})
// setTimeout(()=>{
// if (++count == countAll) callback();
// },200)
}
//没有则执行直接变灰动画
//没有则执行传自身位置
else {
//去掉原先的褐色
elementFrom.setState(StateType.HAIRBALLBROWN, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
//隐藏
elementFrom.getState(StateType.HAIRBALLGREY).visible = false;
//动画
setTimeout(() => {
let divideAni: HairballBrownDivideAni = Pool.takeOut(RecoverName.HAIRBALLBROWNDIVIDE_ANI)
if (!divideAni) divideAni = new HairballBrownDivideAni()
thisObj.addChild(divideAni);
divideAni.play(Tool.getPositionByIndex(indexFrom), Tool.getPositionByIndex(indexFrom), () => {
//显示
elementFrom.getState(StateType.HAIRBALLGREY).visible = true;
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
if (++count == countAll) callback();
})
// setTimeout(()=>{
// if (++count == countAll) callback();
// },200)
}
}
//跳动的,
let countJump = 0;
let countJumpAll = jumpBallIndexs.length;
for (var a = 0; a < jumpBallIndexs.length; a++) {
let data: { type: StateType, index: number } = jumpBallIndexs[a];
}
private jumpAni(thisObj: MainScene, indexs: { type: StateType, index: number }[], callback: Function) {
let count = 0;
let countAll = indexs.length;
for (var a = 0; a < indexs.length; a++) {
let data: { type: StateType, index: number } = indexs[a];
let indexFrom = data.index;
let elementFrom: Element = thisObj.lattices[indexFrom].element;
let stateType: StateType = data.type;
......@@ -421,33 +453,29 @@ export class AiControl {
let jumpAni: HairballJumpAni = Pool.takeOut(RecoverName.HAIRBALLJUMP_ANI)
if (!jumpAni) jumpAni = new HairballJumpAni()
thisObj.addChild(jumpAni);
jumpAni.play(stateType, Tool.getPositionByIndex(indexFrom), Tool.getPositionByIndex(indexEnd), () => {
//显示
elementEnd.getState(stateType).visible = true;
//都执行了
if (++countJump == countJumpAll) callbackOperation();
if (++count == countAll) callback();
})
// setTimeout(()=>{
// //都执行了
// if (++countJump == countJumpAll) callbackOperation();
// },200)
}
//没有则计数
else {
if (++countJump == countJumpAll) callbackOperation();
if (++count == countAll) callback();
}
}
//唤醒的
let countAwake = 0;
let countAwakeAll = awakeBallIndexs.length;
for (var a = 0; a < awakeBallIndexs.length; a++) {
let indexFrom = awakeBallIndexs[a];
}
private awakeAni(thisObj: MainScene, indexs: number[], callback: Function) {
let count = 0;
let countAll = indexs.length;
for (var a = 0; a < indexs.length; a++) {
let indexFrom = indexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element;
//唤醒的动画直接写在自己的blackState里吧,然后换图
setTimeout(() => {
//都执行了
if (++countAwake == countAwakeAll) callbackOperation();
if (++count == countAll) callback();
}, 200);
}
}
......
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