Commit 60796e3e authored by wjf's avatar wjf

l

parent 649bd363
......@@ -184,9 +184,9 @@ export default class MainBase extends eui.UILayer {
for (var i = 0; i <= 9; i++) {
RES.getResAsync("propNum" + i + "_png")
}
for (var i = 1; i <= 5; i++) {
RES.getResAsync("guideTxt" + i + "_png")
}
// for (var i = 1; i <= 5; i++) {
// RES.getResAsync("guideTxt" + i + "_png")
// }
for (var i = 1; i <= 11; i++) {
RES.getResAsync("stepAni" + i + "_png")
}
......@@ -196,7 +196,18 @@ export default class MainBase extends eui.UILayer {
RES.getResAsync("exLighting" + i + "_png")
}
}
for (var i = 0; i <= 2; i++) {
RES.getResAsync("eggStatus" + i + "_png")
}
for (var i = 1; i <= 5; i++) {
RES.getResAsync("eggPiece" + i + "_png")
}
var arr = [
"yellowCircleDown",
"yellowCircleUp",
"greenCircleDown",
"greenCircleUp",
"jellyArrow",
"lockVine",
"guidePropHand",
"guidePropCow",
......@@ -218,13 +229,14 @@ export default class MainBase extends eui.UILayer {
"hammerBtn",
"stepBtn",
"propNumBg",
"guideBg",
"guideKnowBtn",
// "guideBg",
// "guideKnowBtn",
"bonusShoot",
"ele5",
"ele6",
"ele7",
"ele8",
"ele9",
"leftArrow",
"chooseRect",
"lightedStar",
......
......@@ -45,7 +45,7 @@
"name": "shop"
},
{
"keys": "yezi1_png,unlightedStar_png,targetBoard_png,stepsBoard_png,stepNumber9_png,stepNumber8_png,stepNumber7_png,stepNumber6_png,stepNumber5_png,stepNumber4_png,stepNumber3_png,stepNumber2_png,stepNumber1_png,stepNumber0_png,stepBtn_png,starProgress_png,setting_png,scoreNumber9_png,scoreNumber8_png,scoreNumber7_png,scoreNumber6_png,scoreNumber5_png,scoreNumber4_png,scoreNumber3_png,scoreNumber2_png,scoreNumber1_png,scoreNumber0_png,rock6_png,rock5_png,rock4_png,rock3_png,rock2_png,rightMark_png,rightArrow_png,rectLat_png,progressDown_png,magicLionBg_png,magicLion_png,lockUp_png,lockDown_png,lineLight_png,lightedStar_png,leftArrow_png,ice6_png,ice5_png,ice4_png,ice3_png,ice2_png,hammerBtn_png,eleDis9_png,eleDis8_png,eleDis7_png,eleDis6_png,eleDis5_png,eleDis4_png,eleDis3_png,eleDis2_png,eleDis12_png,eleDis11_png,eleDis10_png,eleDis1_png,ele5_png,ele4_png,ele3_png,ele2_png,ele1_png,ele0_png,dangqianfenshu_png,chooseRect_png,boomBtn_png,boom9_png,boom8_png,boom7_png,boom6_png,boom5_png,boom4_png,boom3_png,boom2_png,boom18_png,boom17_png,boom16_png,boom15_png,boom14_png,boom13_png,boom12_png,boom11_png,boom10_png,boom1_png,mainSoundBtnOn_png,mainSettingBg_png,mainQuestionBtn_png,mainMusicBtnOn_png,mainQuitBtn_png,mainSoundBtnOff_png,mainMusicBtnOff_png,targetNumber9_png,targetNumber8_png,targetNumber7_png,targetNumber6_png,targetNumber5_png,targetNumber4_png,targetNumber3_png,targetNumber2_png,targetNumber1_png,targetNumber0_png,ele7_png,ele6_png,bonusFra9_png,bonusFra8_png,bonusFra7_png,bonusFra6_png,bonusFra5_png,bonusFra4_png,bonusFra3_png,bonusFra27_png,bonusFra26_png,bonusFra25_png,bonusFra24_png,bonusFra23_png,bonusFra22_png,bonusFra21_png,bonusFra20_png,bonusFra2_png,bonusFra19_png,bonusFra18_png,bonusFra17_png,bonusFra16_png,bonusFra15_png,bonusFra14_png,bonusFra13_png,bonusFra12_png,bonusFra11_png,bonusFra10_png,bonusFra1_png,bonusShoot_png,guideTxt5_png,guideTxt4_png,guideTxt3_png,guideTxt2_png,guideTxt1_png,guideKnowBtn_png,guideBg_png,propNum9_png,propNum8_png,propNum7_png,propNum6_png,propNum5_png,propNum4_png,propNum3_png,propNum2_png,propNum1_png,propNum0_png,propNumBg_png,bonusTime_png,eleDis19_png,eleDis18_png,eleDis17_png,eleDis16_png,eleDis15_png,eleDis14_png,eleDis13_png,main_mapbottom_png,guidePropShoe_png,guidePropMsgPanel_png,guidePropHand_png,guidePropHammer_png,guidePropCow_png,guidePropBoom_png,stepAni9_png,stepAni8_png,stepAni7_png,stepAni6_png,stepAni5_png,stepAni4_png,stepAni3_png,stepAni2_png,stepAni11_png,stepAni10_png,stepAni1_png,lockVine_png,exLighting1_png,exLighting11_png,exLighting14_png,exLighting16_png,exLighting18_png,exLighting19_png,exLighting21_png,exLighting23_png,exLighting25_png,exLighting27_png,exLighting29_png,exLighting3_png,exLighting32_png,exLighting34_png,exLighting5_png,exLighting7_png,exLighting9_png,playSceneBg_jpg,ele8_png,ele0Line_png,ele0Exp_png,ele1Line_png,ele1Exp_png,ele2Line_png,ele2Exp_png,ele3Line_png,ele3Exp_png,ele4Line_png,ele4Exp_png",
"keys": "yezi1_png,unlightedStar_png,targetBoard_png,stepsBoard_png,stepNumber9_png,stepNumber8_png,stepNumber7_png,stepNumber6_png,stepNumber5_png,stepNumber4_png,stepNumber3_png,stepNumber2_png,stepNumber1_png,stepNumber0_png,stepBtn_png,starProgress_png,setting_png,scoreNumber9_png,scoreNumber8_png,scoreNumber7_png,scoreNumber6_png,scoreNumber5_png,scoreNumber4_png,scoreNumber3_png,scoreNumber2_png,scoreNumber1_png,scoreNumber0_png,rock6_png,rock5_png,rock4_png,rock3_png,rock2_png,rightMark_png,rightArrow_png,rectLat_png,progressDown_png,magicLionBg_png,magicLion_png,lockUp_png,lockDown_png,lineLight_png,lightedStar_png,leftArrow_png,ice6_png,ice5_png,ice4_png,ice3_png,ice2_png,hammerBtn_png,eleDis9_png,eleDis8_png,eleDis7_png,eleDis6_png,eleDis5_png,eleDis4_png,eleDis3_png,eleDis2_png,eleDis12_png,eleDis11_png,eleDis10_png,eleDis1_png,ele5_png,ele4_png,ele3_png,ele2_png,ele1_png,ele0_png,dangqianfenshu_png,chooseRect_png,boomBtn_png,boom9_png,boom8_png,boom7_png,boom6_png,boom5_png,boom4_png,boom3_png,boom2_png,boom18_png,boom17_png,boom16_png,boom15_png,boom14_png,boom13_png,boom12_png,boom11_png,boom10_png,boom1_png,mainSoundBtnOn_png,mainSettingBg_png,mainQuestionBtn_png,mainMusicBtnOn_png,mainQuitBtn_png,mainSoundBtnOff_png,mainMusicBtnOff_png,targetNumber9_png,targetNumber8_png,targetNumber7_png,targetNumber6_png,targetNumber5_png,targetNumber4_png,targetNumber3_png,targetNumber2_png,targetNumber1_png,targetNumber0_png,ele7_png,ele6_png,bonusFra9_png,bonusFra8_png,bonusFra7_png,bonusFra6_png,bonusFra5_png,bonusFra4_png,bonusFra3_png,bonusFra27_png,bonusFra26_png,bonusFra25_png,bonusFra24_png,bonusFra23_png,bonusFra22_png,bonusFra21_png,bonusFra20_png,bonusFra2_png,bonusFra19_png,bonusFra18_png,bonusFra17_png,bonusFra16_png,bonusFra15_png,bonusFra14_png,bonusFra13_png,bonusFra12_png,bonusFra11_png,bonusFra10_png,bonusFra1_png,bonusShoot_png,propNum9_png,propNum8_png,propNum7_png,propNum6_png,propNum5_png,propNum4_png,propNum3_png,propNum2_png,propNum1_png,propNum0_png,propNumBg_png,bonusTime_png,eleDis19_png,eleDis18_png,eleDis17_png,eleDis16_png,eleDis15_png,eleDis14_png,eleDis13_png,main_mapbottom_png,guidePropShoe_png,guidePropMsgPanel_png,guidePropHand_png,guidePropHammer_png,guidePropCow_png,guidePropBoom_png,stepAni9_png,stepAni8_png,stepAni7_png,stepAni6_png,stepAni5_png,stepAni4_png,stepAni3_png,stepAni2_png,stepAni11_png,stepAni10_png,stepAni1_png,lockVine_png,exLighting1_png,exLighting11_png,exLighting14_png,exLighting16_png,exLighting18_png,exLighting19_png,exLighting21_png,exLighting23_png,exLighting25_png,exLighting27_png,exLighting29_png,exLighting3_png,exLighting32_png,exLighting34_png,exLighting5_png,exLighting7_png,exLighting9_png,playSceneBg_jpg,ele8_png,ele0Line_png,ele0Exp_png,ele1Line_png,ele1Exp_png,ele2Line_png,ele2Exp_png,ele3Line_png,ele3Exp_png,ele4Line_png,ele4Exp_png,jellyArrow_png,greenCircleUp_png,greenCircleDown_png,ele9_png,eggStatus1_png,eggStatus0_png,eggStatus2_png,yellowCircleUp_png,yellowCircleDown_png,eggPiece5_png,eggPiece4_png,eggPiece3_png,eggPiece2_png,eggPiece1_png",
"name": "main2"
},
{
......@@ -1210,41 +1210,6 @@
"type": "image",
"name": "showoff_jpg"
},
{
"url": "assets/mainScene/guideTxt5.png",
"type": "image",
"name": "guideTxt5_png"
},
{
"url": "assets/mainScene/guideBg.png",
"type": "image",
"name": "guideBg_png"
},
{
"url": "assets/mainScene/guideKnowBtn.png",
"type": "image",
"name": "guideKnowBtn_png"
},
{
"url": "assets/mainScene/guideTxt1.png",
"type": "image",
"name": "guideTxt1_png"
},
{
"url": "assets/mainScene/guideTxt2.png",
"type": "image",
"name": "guideTxt2_png"
},
{
"url": "assets/mainScene/guideTxt3.png",
"type": "image",
"name": "guideTxt3_png"
},
{
"url": "assets/mainScene/guideTxt4.png",
"type": "image",
"name": "guideTxt4_png"
},
{
"url": "assets/mainScene/propNum9.png",
"type": "image",
......@@ -1934,6 +1899,76 @@
"url": "assets/mainScene/ele4Exp.png",
"type": "image",
"name": "ele4Exp_png"
},
{
"url": "assets/mainScene/jellyArrow.png",
"type": "image",
"name": "jellyArrow_png"
},
{
"url": "assets/mainScene/greenCircleDown.png",
"type": "image",
"name": "greenCircleDown_png"
},
{
"url": "assets/mainScene/greenCircleUp.png",
"type": "image",
"name": "greenCircleUp_png"
},
{
"url": "assets/mainScene/eggStatus0.png",
"type": "image",
"name": "eggStatus0_png"
},
{
"url": "assets/mainScene/eggStatus1.png",
"type": "image",
"name": "eggStatus1_png"
},
{
"url": "assets/mainScene/eggStatus2.png",
"type": "image",
"name": "eggStatus2_png"
},
{
"url": "assets/mainScene/ele9.png",
"type": "image",
"name": "ele9_png"
},
{
"url": "assets/mainScene/yellowCircleUp.png",
"type": "image",
"name": "yellowCircleUp_png"
},
{
"url": "assets/mainScene/yellowCircleDown.png",
"type": "image",
"name": "yellowCircleDown_png"
},
{
"url": "assets/mainScene/eggPiece1.png",
"type": "image",
"name": "eggPiece1_png"
},
{
"url": "assets/mainScene/eggPiece2.png",
"type": "image",
"name": "eggPiece2_png"
},
{
"url": "assets/mainScene/eggPiece3.png",
"type": "image",
"name": "eggPiece3_png"
},
{
"url": "assets/mainScene/eggPiece4.png",
"type": "image",
"name": "eggPiece4_png"
},
{
"url": "assets/mainScene/eggPiece5.png",
"type": "image",
"name": "eggPiece5_png"
}
]
}
\ No newline at end of file
......@@ -55,6 +55,8 @@ import { updateMainTimerAfterGetData } from '../../libs/new_wx/MainBase';
import wait from '../../libs/new_tc/wait';
import { GameGuide } from './GameGuide';
import { AiControl } from '../something/logic/AiControl';
import { JellyDisAni } from '../something/anis/JellyDisAni';
import { EggBrokenAni } from '../something/anis/EggBrokenAni';
// tslint:disable: no-var-keyword
// tslint:disable: prefer-const
// tslint:disable: cyclomatic-complexity
......@@ -72,6 +74,8 @@ const aniClass = {
"EleDisAni": EleDisAni,
"MagicLionAni": MagicLionAni,
"StepAni": StepAni,
"JellyDisAni": JellyDisAni,
"EggBrokenAni": EggBrokenAni,
}
export const baseScore = 20;
/**
......@@ -155,7 +159,7 @@ export default class MainScene extends Scene {
//每一步生成的总分数
oneStepScore: number;
//果冻有消除的标记;
jellyBrokeMark: boolean
jellyBrokenMark: boolean
//皮肤上的
public starProgress: eui.Image;
public scoreTxt: eui.Label;
......@@ -215,7 +219,7 @@ export default class MainScene extends Scene {
super.start();
//第几关
this.chapter = (data && data.chapter) ? data.chapter : 1;
// this.chapter = 81;
this.chapter = 81;
this.chapterTxt.text = "第" + this.chapter + "关";
//关卡数据,1期定制,70,后面35关地图一致,步数减少
var mapDataIndex = this.chapter;
......@@ -572,6 +576,14 @@ export default class MainScene extends Scene {
this.elementContainer.addChild(jelly);
this.lattices[i].element = jelly;
break;
//鸡蛋
case 6:
let egg: Element = Tool.getElement(ElementType.CHICKEN_EGG)
egg.x = p[0];
egg.y = p[1];
this.elementContainer.addChild(egg);
this.lattices[i].element = egg;
break;
default:
//其他标识按空元素记
this.emptys.push(i);
......@@ -781,7 +793,7 @@ export default class MainScene extends Scene {
this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_BEGIN, fun = function (e) {
var ele = e.target.parent
if (ele instanceof Element &&
ele.type != ElementType.ROCK &&
// ele.type != ElementType.ROCK &&
ele.type != ElementType.LOLLIPOP) {
this.elementContainer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, fun, this);
var index = ele.index;
......@@ -1434,7 +1446,10 @@ export default class MainScene extends Scene {
//执行消除,应该是一个迭代,只要eliminatedElements有东西就一直执行
/**
* 执行消除,应该是一个迭代,只要eliminatedElements有东西就一直执行
* 掉落后的逻辑很复杂
*/
eliminate() {
//如果是是带组合特效的,组合时的特效本身的算分在effectCombination内,暂不计
if (this.isManual) {
......@@ -1471,9 +1486,14 @@ export default class MainScene extends Scene {
//执行掉落
setTimeout(() => {
this.fall(() => {
//掉落后有消除
if (this.threeMatch()) {
this.eliminate()
} else {
return
}
//鸡蛋的操作,无鸡蛋,或鸡蛋无小鸡 直接执行回调,
//有小鸡飞出要走threeMatch,有eliminate,没有直接走回调
AiControl.ins.eggMotion(this, () => {
//如果早已通关,正在结算
if (this.hasPassed) {
//如果原先特效还有,
......@@ -1492,6 +1512,7 @@ export default class MainScene extends Scene {
//判断是否已达目标
this.hasPassed = this.judgePass();
console.log(this.hasPassed)
//如果已达目标
if (this.hasPassed) {
//通关就不允许退出按钮
this.quitBtn.touchEnabled = false;
......@@ -1522,16 +1543,15 @@ export default class MainScene extends Scene {
//连消置0
this.commonContinuityTimes = 0;
this.effectContinuityTimes = 0;
//先判断步数是否为0;
//判断步数是否为0;
if (this.steps == 0) {
//判断是否有加步数的道具,有则提示是否加(加完判断死图),没有则直接结束
//失败弹框
playSound(SoundType.fail);
PanelCtrl.instance.show("failed", { level: this.chapter });
} else {
//额外加一步ai的操作,然后再执行检查死图
AiControl.ins.aiMotion(this, () => {
return
}
//额外加一步ai果冻的操作,然后再执行检查死图
AiControl.ins.jellyMotion(this, () => {
//检查死图
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
......@@ -1560,8 +1580,7 @@ export default class MainScene extends Scene {
this.enableMouseEvt(true)
}
})
}
}
})
});
}, 200)
}
......@@ -1778,13 +1797,13 @@ export default class MainScene extends Scene {
//但是算个数,
this.goElementTarget(ele);
//如果格子有冰
this.iceBroke(this.lattices[index]);
this.iceBroken(this.lattices[index]);
//如果格子附近有石头
this.rokeBroke(this.lattices[index]);
this.rokeBroken(this.lattices[index]);
//如果格子附近有果冻
this.jellyBroke(this.lattices[index]);
this.jellyBroken(this.lattices[index]);
//如果附近有鸡蛋
this.eggBroke(this.lattices[index])
this.eggBroken(this.lattices[index])
} else {
//单纯元素消失特效
if (ele.type <= 4) {
......@@ -1793,7 +1812,7 @@ export default class MainScene extends Scene {
}
//石头
else if (ele.type == ElementType.ROCK) {
this.removeRoke(index);
this.removeRock(index);
}
//果冻
else if (ele.type == ElementType.JELLY) {
......@@ -1801,8 +1820,12 @@ export default class MainScene extends Scene {
}
//鸡蛋
else if (ele.type == ElementType.CHICKEN_EGG) {
//额外逻辑,鸡蛋动效,或者累计小鸡数量
//额外逻辑,
ele.chickenEgg.statusNum--;
//鸡蛋的摆动
ele.chickenEgg.shakeAni();
//鸡蛋动效,待改
this.playAni(RecoverName.EGGBROKEN_ANI, p)
}
}
}
......@@ -1955,13 +1978,16 @@ export default class MainScene extends Scene {
var effectElements = [], elements = [];
for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
var lat = this.lattices[i];
if (!Tool.judgeEliminate(lat)) continue
if (lat &&
lat.element &&
lat.element.type <= 4) {
if (lat.element.effectType != null) {
effectElements.push(i);
} else {
elements.push(lat.element)
}
}
}
//如果特效有,消除特效
if (effectElements.length) {
Array.prototype.push.apply(this.eliminatedElements, effectElements);
......@@ -2139,13 +2165,13 @@ export default class MainScene extends Scene {
this.lattices[index].element = null;
if (ele.type != ElementType.LOLLIPOP) {
//如果格子有冰
this.iceBroke(this.lattices[index]);
this.iceBroken(this.lattices[index]);
//如果附近有石头
this.rokeBroke(this.lattices[index]);
this.rokeBroken(this.lattices[index]);
//如果附近有果冻
this.jellyBroke(this.lattices[index]);
this.jellyBroken(this.lattices[index]);
//如果附近有鸡蛋
this.eggBroke(this.lattices[index])
this.eggBroken(this.lattices[index])
}
//计算元素消除个数
this.goElementTarget(ele);
......@@ -2264,7 +2290,7 @@ export default class MainScene extends Scene {
* 格子上的冰块破碎
* @param lat
*/
iceBroke(lat: Lattice) {
iceBroken(lat: Lattice) {
if (lat && lat.ice) {
var ice = lat.ice;
ice.countNum--;
......@@ -2310,7 +2336,7 @@ export default class MainScene extends Scene {
* 附近是否有石头
* @param lat 格子
*/
rokeBroke(lat: Lattice) {
rokeBroken(lat: Lattice) {
var indexMy = lat.index;
//判断上下左右是否有石头
var indexs = [
......@@ -2329,7 +2355,7 @@ export default class MainScene extends Scene {
if (lat &&
lat.element &&
lat.element.type == ElementType.ROCK) {
// this.removeRoke(index)
// this.removeRock(index)
//添加进消除队列,注意重复
if (this.eliminatedElements.indexOf(index) == -1) this.eliminatedElements.push(index)
}
......@@ -2339,7 +2365,7 @@ export default class MainScene extends Scene {
* 附近是否有果冻
* @param lat 格子
*/
jellyBroke(lat: Lattice) {
jellyBroken(lat: Lattice) {
var indexMy = lat.index;
//判断上下左右是否有果冻
var indexs = [
......@@ -2368,7 +2394,7 @@ export default class MainScene extends Scene {
* 附近是否有鸡蛋
* @param lat
*/
eggBroke(lat: Lattice) {
eggBroken(lat: Lattice) {
var indexMy = lat.index;
//判断上下左右是否有果冻
var indexs = [
......@@ -2396,7 +2422,7 @@ export default class MainScene extends Scene {
* 石头的移除,包括动效
* @param index
*/
removeRoke(index: number) {
removeRock(index: number) {
//回收
let ele = this.lattices[index].element;
//添加进emptys
......@@ -2415,7 +2441,7 @@ export default class MainScene extends Scene {
* @param index
*/
removeJelly(index: number) {
this.jellyBrokeMark = true;
this.jellyBrokenMark = true;
//回收
let ele = this.lattices[index].element;
//添加进emptys
......@@ -2427,7 +2453,7 @@ export default class MainScene extends Scene {
//置空格子的element,
this.lattices[index].element = null;
//播放动效,果冻的特效,待写
this.playAni(RecoverName.ROCK_ANI, Tool.getPositionByIndex(index))
this.playAni(RecoverName.JELLYDIS_ANI, Tool.getPositionByIndex(index))
}
/**
* 禁用与开启事件
......
......@@ -2941,7 +2941,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.3,
stepCount: 14 + 6 + 5,
stepCount: 25,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -2986,7 +2986,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.03,
stepCount: 20 + 6,
stepCount: 26,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3031,7 +3031,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 15 + 5,
stepCount: 20,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3076,7 +3076,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0,
stepCount: 20 + 4,
stepCount: 24,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3121,7 +3121,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20 + 5,
stepCount: 25,
passTarget: {
type: PassType.SCORE_TARGET,
score: 15000
......@@ -3161,7 +3161,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20 + 4,
stepCount: 24,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3206,7 +3206,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 15 + 5,
stepCount: 20,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3251,7 +3251,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20 + 4,
stepCount: 24,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3296,7 +3296,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 25 + 3,
stepCount: 28,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3312,6 +3312,7 @@ export const Chapters: ChapterData[] = [
15000
]
},
////////////////////////////////
//第八十一关
{
map: {
......@@ -3331,9 +3332,9 @@ export const Chapters: ChapterData[] = [
0, 1, 0, 1, 0, 1, 0, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 1, 1, 1, 1, 1, 1, 1, 0,
2, 1, 1, 1, 1, 1, 1, 1, 2,
0, 1, 1, 1, 1, 1, 1, 1, 0,
2, 1, 1, 1, 1, 1, 1, 1, 2,
2, 1, 1, 1, 6, 1, 1, 1, 2,
0, 1, 1, 1, 6, 1, 1, 1, 0,
2, 1, 1, 1, 6, 1, 1, 1, 2,
0, 1, 1, 1, 1, 1, 1, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 5, 0, 5, 0, 5, 0, 5, 0,
......@@ -3346,8 +3347,8 @@ export const Chapters: ChapterData[] = [
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 65
type: ElementType.CHICKEN,
count: 1000
}
],
},
......@@ -3358,4 +3359,49 @@ export const Chapters: ChapterData[] = [
]
},
//第一百关
{
map: {
lattices: [
0, 3, 0, 3, 0, 3, 0, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 0, 3, 0, 3, 0, 3, 0,
],
generateLats: [0, 1, 0, 1, 0, 1, 0, 1, 0],
elements: [
0, 1, 0, 1, 0, 1, 0, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 1, 1, 1, 1, 1, 1, 1, 0,
2, 1, 1, 1, 6, 1, 1, 1, 2,
0, 1, 1, 1, 6, 1, 1, 1, 0,
2, 1, 1, 1, 6, 1, 1, 1, 2,
0, 1, 1, 1, 1, 1, 1, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 5, 0, 5, 0, 5, 0, 5, 0,
],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 250 + 3,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.CHICKEN,
count: 1000
}
],
},
starScores: [
6000,
10000,
22000
]
},
]
\ No newline at end of file
......@@ -802,8 +802,8 @@ export class Tool {
* 获得元素
* @param type
*/
public static getElement(type: ElementType):Element {
let obj:Element = Pool.takeOut(RecoverName.ELEMENT);
public static getElement(type: ElementType): Element {
let obj: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!obj) {
obj = new Element(type)
} else {
......@@ -845,4 +845,35 @@ export class Tool {
}
return r
}
/**
* 随机取数组arr中count个元素
* @param arr
* @param count
*/
public static getRandomArrayElements(arr: any[], count: number) {
var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
//如果count大于等于数组长度,返回所有数组
if (min <= 0) return shuffled;
//随机排序,然后取出后面的元素
while (i-- > min) {
index = Math.floor((i + 1) * Math.random());
temp = shuffled[index];
shuffled[index] = shuffled[i];
shuffled[i] = temp;
}
return shuffled.slice(min);
}
public static getRandomArrayElementsEx(arr: any[], count: number):any[] {
//如果count大于等于数组长度,返回所有数组
if (arr.length <= count) return arr.slice();
if (count <= 0) return [];
var arrCopy = arr.slice();
var outArr = [];
while (count--) {
var rand = Math.floor(Math.random() * arrCopy.length);
var ele = arrCopy.splice(rand, 1)[0];
outArr.push(ele);
}
return outArr
}
}
\ No newline at end of file
import { Ani } from "../class/Ani";
const offsetX = 91 / 2;
const offsetY = 62 / 2;
export class EggBrokenAni extends Ani {
downCircle: egret.Bitmap;
upCircle: egret.Bitmap;
eggPiece1: egret.Bitmap;
eggPiece2: egret.Bitmap;
eggPiece3: egret.Bitmap;
eggPiece4: egret.Bitmap;
eggPiece5: egret.Bitmap;
constructor() {
super()
this.aniName = "EggBrokenAni";
var arr = ["yellowCircleDown_png", "yellowCircleUp_png", "eggPiece1_png", "eggPiece2_png", "eggPiece3_png", "eggPiece4_png", "eggPiece5_png"];
var objs = ["downCircle", "upCircle", "eggPiece1", "eggPiece2", "eggPiece3", "eggPiece4", "eggPiece5"];
for (var i = 0; i < arr.length; i++) {
var texture: egret.Texture = RES.getRes(arr[i])
var obj = new egret.Bitmap(texture);
this.addChild(obj);
obj.anchorOffsetX = texture.textureWidth / 2;
obj.anchorOffsetY = texture.textureHeight / 2;
this[objs[i]] = obj;
}
}
play() {
this.alpha = 1;
//黄色圈下
egret.Tween.get(this.downCircle)
.set({ scaleX: 0.01, scaleY: 0.01 })
.to({ scaleX: 0.6, scaleY: 0.6 }, 300, egret.Ease.cubicOut)
egret.Tween.get(this.downCircle)
.set({ alpha: 1 })
.wait(140)
.to({ alpha: 0 }, 160);
//黄色圈上
egret.Tween.get(this.upCircle)
.set({ scaleX: 0.01, scaleY: 0.01 })
.wait(70)
.to({ scaleX: 1, scaleY: 1 }, 160, egret.Ease.cubicOut);
egret.Tween.get(this.upCircle)
.set({ alpha: 1 })
.wait(170)
.to({ alpha: 0 }, 100);
//下面所有的蛋壳碎片
egret.Tween.get(this.eggPiece1)
.set({ rotation: 0, x: 37 - offsetX, y: 22 - offsetY })
.to({ rotation: 60, x: 37 - offsetX - 30, y: 22 - offsetY - 34 }, 400);
egret.Tween.get(this.eggPiece2)
.set({ rotation: 0, x: 48 - offsetX, y: 20 - offsetY })
.to({ rotation: 60, x: 48 - offsetX + 36, y: 20 - offsetY - 28 }, 400);
egret.Tween.get(this.eggPiece3)
.set({ rotation: 0, x: 52 - offsetX, y: 32 - offsetY })
.to({ rotation: 60, x: 52 - offsetX + 30, y: 32 - offsetY + 10 }, 400);
egret.Tween.get(this.eggPiece4)
.set({ rotation: 0, x: 45 - offsetX, y: 44 - offsetY })
.to({ rotation: 60, x: 45 - offsetX + 32, y: 44 - offsetY + 38 }, 400);
egret.Tween.get(this.eggPiece5)
.set({ rotation: 0, x: 34 - offsetX, y: 34 - offsetY })
.to({ rotation: 60, x: 34 - offsetX - 20, y: 34 - offsetY + 14 }, 400);
//整体透明度
egret.Tween.get(this)
.wait(250)
.to({ alpha: 0 }, 150)
.call(() => {
this.recover();
})
}
}
\ No newline at end of file
import { RecoverName } from "../enum/RecoverName";
import { Pool } from "../Pool";
import { Element } from "../class/Element";
import { Ice } from "../class/Ice";
import { ElementType } from "../enum/ElementType";
import { Tool } from "../Tool";
import MainScene from "../../mainScene/MainScene";
/**
* 孵蛋的动效
*/
export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainScene, callback: Function) {
let countAll = endIndexs.length;
let count = 0;
var startP = Tool.getPositionByIndex(startIndex);
for (let i = 0; i < endIndexs.length; i++) {
let endIndex = endIndexs[i];
let endP = Tool.getPositionByIndex(endIndex);
let eleC: Element = Tool.getElement(ElementType.CHICKEN);
eleC.x = startP[0];
eleC.y = startP[1];
eleC.scaleX = eleC.scaleY = 0.7;
thisObj.addChild(eleC);
paraCurveAni(eleC, startP, endP, () => {
//回收
thisObj.removeChild(eleC);
Pool.recover(RecoverName.ELEMENT, eleC);
//对应的索引的类型变成鸡
thisObj.lattices[endIndex].element.reset(ElementType.CHICKEN);
//动画,和bonusTime的效果一样,暂时没加
count++;
if (count == countAll) callback();
})
}
}
const deltaTime = 500;
const gravity = 0.003
/**
* 抛物线路径
* @param startP
* @param endP
* @param callback
*/
function paraCurveAni(ele: Element, startP: number[], endP: number[], callback: Function) {
//x方向匀速,线性
var deltaX = endP[0] - startP[0]
//y方向,自由落体,y向下为正,加速度向下为正,初速度根据情况而定
var deltaY = endP[1] - startP[1];
var vy0 = deltaY / deltaTime - gravity * deltaTime / 2;
var a = { t: 0 };
egret.Tween.get(a, {
onChange: function () {
ele.x = deltaX * a.t / deltaTime + startP[0];
ele.y = vy0 * a.t + gravity * a.t * a.t / 2 + startP[1];
}
})
.to({ t: deltaTime }, deltaTime)
.call(() => {
callback();
})
var rotation;
if (deltaX > 0) {
rotation = 360;
}
else if (deltaX < 0) {
rotation = -360;
} else {
rotation = 0
}
//旋转
egret.Tween.get(ele)
.set({ scaleX: 0.3, scaleY: 0.3, rotation: 0 })
.to({ scaleX: 1, scaleY: 1, rotation: rotation }, deltaTime)
}
\ No newline at end of file
import { Ani } from "../class/Ani";
export class JellyDisAni extends Ani {
showImage: egret.Bitmap;
downCircle: egret.Bitmap;
upCircle: egret.Bitmap;
constructor() {
super()
this.aniName = "JellyDisAni";
var arr = ["ele8_png", "greenCircleDown_png", "greenCircleUp_png"];
var objs = ["showImage", "downCircle", "upCircle"];
for (var i = 0; i < arr.length; i++) {
var texture: egret.Texture = RES.getRes(arr[i])
var obj = new egret.Bitmap(texture);
this.addChild(obj);
obj.anchorOffsetX = texture.textureWidth / 2;
obj.anchorOffsetY = texture.textureHeight / 2;
this[objs[i]] = obj;
}
}
play() {
egret.Tween.get(this.showImage)
.set({ alpha: 1 })
.to({ alpha: 0 }, 250*1.5)
egret.Tween.get(this.downCircle)
.set({ scaleX: 0.01, scaleY: 0.01 })
.to({ scaleX: 0.6, scaleY: 0.6 }, 300*1.5, egret.Ease.cubicOut)
.call(() => {
this.recover();
})
egret.Tween.get(this.downCircle)
.set({ alpha: 1 })
.wait(140*1.5)
.to({ alpha: 0 }, 160*1.5);
egret.Tween.get(this.upCircle)
.set({ scaleX: 0.01, scaleY: 0.01 })
.wait(70*1.5)
.to({ scaleX: 1, scaleY: 1 }, 160*1.5, egret.Ease.cubicOut);
egret.Tween.get(this.upCircle)
.set({ alpha: 1 })
.wait(170*1.5)
.to({ alpha: 0 }, 100*1.5);
}
}
\ No newline at end of file
......@@ -2,45 +2,113 @@ import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
import { Tool } from "../Tool";
/**
* 需要回调的
*
*/
export class JellySpreadAni extends egret.DisplayObjectContainer {
//原位置的图片
oriImage: egret.Bitmap;
//目标位置的图片,到时根据方向定
targetImage: egret.Bitmap;
imageAni: ImageAni
shoot: egret.Bitmap;
constructor() {
super()
var texture = RES.getRes("bonusShoot_png")
var texture: egret.Texture = RES.getRes("ele8_png")
this.targetImage = new egret.Bitmap(texture);
this.targetImage.anchorOffsetX = 78;
this.targetImage.anchorOffsetY = 37 / 2;
this.targetImage.anchorOffsetX = texture.textureWidth / 2;
this.targetImage.anchorOffsetY = texture.textureHeight / 2;
this.addChild(this.targetImage);
var arr = []
for (var i = 1; i <= 27; i++) {
arr.push("bonusFra" + i + "_png");
}
this.imageAni = new ImageAni(arr);
this.addChild(this.imageAni);
}
this.oriImage = new egret.Bitmap(texture);
this.oriImage.anchorOffsetX = texture.textureWidth / 2;
this.oriImage.anchorOffsetY = texture.textureHeight / 2;
this.addChild(this.oriImage);
this.shoot = new egret.Bitmap(RES.getRes("jellyArrow_png"));
this.shoot.anchorOffsetX = 0;
this.shoot.anchorOffsetY = 23 / 2;
this.addChild(this.shoot);
}
play(startP: number[], endP: number[], callback: Function) {
this.x = startP[0];
this.y = startP[1];
//判断方向
this.shoot.visible = true;
this.shoot.x = 0
this.shoot.y = 0;
this.shoot.scaleX = this.shoot.scaleY = 0.01;
this.targetImage.visible = false;
//判断上下左右,
var obj = { scaleX: 0.01, scaleY: 0.01, x: 0, y: 0 };
//x相等 上下
if (Math.abs(endP[0] - startP[0]) <= 0.001) {
//下
if (endP[1] - startP[1] > 0) {
this.shoot.rotation = 90;
this.targetImage.x = 0;
this.targetImage.y = Tool.height;
obj.y = Tool.height;
}
//上
else {
this.shoot.rotation = 270;
this.targetImage.x = 0;
this.targetImage.y = -Tool.height;
obj.y = -Tool.height;
}
}
//y相等 左右
else {
//左
if (endP[0] - startP[0] > 0) {
this.shoot.rotation = 0;
this.targetImage.x = Tool.width;
this.targetImage.y = 0;
obj.x = Tool.width;
}
//右
else {
this.shoot.rotation = 180;
this.targetImage.x = -Tool.width;
this.targetImage.y = 0;
obj.x = -Tool.width;
}
}
egret.Tween.get(this.oriImage)
.to({ scaleX: 1.07, scaleY: 0.89 }, 150)
.to({ scaleX: 0.91, scaleY: 1.07 }, 150)
.to({ scaleX: 1.07, scaleY: 0.89 }, 100)
.to({ scaleX: 0.93, scaleY: 1.06 }, 100)
.to({ scaleX: 1.07, scaleY: 0.93 }, 100)
.to({ scaleX: 1, scaleY: 1 }, 100)
this.imageAni.play(() => {
egret.Tween.get(this.shoot)
.to({ scaleX: 2, scaleY: 1 }, 230)
.to(obj, 50)
.call(() => {
callback();
this.shoot.visible = false;
this.targetImage.visible = true;
egret.Tween.get(this.targetImage)
.to({ scaleX: 1.07, scaleY: 0.89 }, 150)
.to({ scaleX: 0.91, scaleY: 1.07 }, 150)
.to({ scaleX: 1.07, scaleY: 0.89 }, 100)
.to({ scaleX: 0.93, scaleY: 1.06 }, 100)
.to({ scaleX: 1.07, scaleY: 0.93 }, 100)
.to({ scaleX: 1, scaleY: 1 }, 100)
.call(() => {
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.JELLYSPREAD_ANI, this)
})
})
}
}
\ No newline at end of file
import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
import { Tool } from "../Tool";
const offsetX = 91 / 2;
const offsetY = 62 / 2;
/**
* 需要回调的
*
*/
export class PieceToEggAni extends egret.DisplayObjectContainer {
showImage: egret.Bitmap;
eggPiece1: egret.Bitmap;
eggPiece2: egret.Bitmap;
eggPiece3: egret.Bitmap;
eggPiece4: egret.Bitmap;
eggPiece5: egret.Bitmap;
constructor() {
super()
var arr = ["ele9_png", "eggPiece1_png", "eggPiece2_png", "eggPiece3_png", "eggPiece4_png", "eggPiece5_png"];
var objs = ["showImage", "eggPiece1", "eggPiece2", "eggPiece3", "eggPiece4", "eggPiece5"];
for (var i = 0; i < arr.length; i++) {
var texture: egret.Texture = RES.getRes(arr[i])
var obj = new egret.Bitmap(texture);
this.addChild(obj);
obj.anchorOffsetX = texture.textureWidth / 2;
obj.anchorOffsetY = texture.textureHeight / 2;
this[objs[i]] = obj;
}
}
play(p: number[], callback: Function) {
this.x = p[0];
this.y = p[1];
this.showImage.alpha = 0;
egret.Tween.get(this.showImage)
.wait(250)
.to({ alpha: 1 }, 150)
this.alpha = 0;
//整体透明度
egret.Tween.get(this)
.to({ alpha: 1 }, 150)
//下面所有的蛋壳碎片
egret.Tween.get(this.eggPiece1)
.set({ rotation: 60, x: 37 - offsetX - 30, y: 22 - offsetY - 34 })
.to({ rotation: 0, x: 37 - offsetX, y: 22 - offsetY }, 400);
egret.Tween.get(this.eggPiece2)
.set({ rotation: 60, x: 48 - offsetX + 36, y: 20 - offsetY - 28 })
.to({ rotation: 0, x: 48 - offsetX, y: 20 - offsetY }, 400);
egret.Tween.get(this.eggPiece3)
.set({ rotation: 60, x: 52 - offsetX + 30, y: 32 - offsetY + 10 })
.to({ rotation: 0, x: 52 - offsetX, y: 32 - offsetY }, 400);
egret.Tween.get(this.eggPiece4)
.set({ rotation: 60, x: 45 - offsetX + 32, y: 44 - offsetY + 38 })
.to({ rotation: 0, x: 45 - offsetX, y: 44 - offsetY }, 400);
egret.Tween.get(this.eggPiece5)
.set({ rotation: 60, x: 34 - offsetX - 20, y: 34 - offsetY + 14 })
.to({ rotation: 0, x: 34 - offsetX, y: 34 - offsetY }, 400)
.call(() => {
callback();
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.PIECETOEGG_ANI, this)
})
}
}
\ No newline at end of file
//四种状态的图片
const images = {
3: "ele9_png",
2: "eggStatus2_png",
1: "eggStatus1_png",
0: "eggStatus0_png"
}
/**
* 鸡蛋的状态
*
*/
export class ChickenEgg extends eui.Image {
export class ChickenEgg extends eui.Component {
private showImage: eui.Image;
/**
* 小鸡数量
* 是否孵小鸡
*/
private chickenNum: number = 0;
isActive: boolean;
/**
* 鸡蛋状态变化 3 2 1 0 再往后,直接加孵鸡次数
* 鸡蛋状态变化 3 2 1 0 再往后,可孵鸡
*/
private _statusNum: number;
get statusNum() {
......@@ -17,41 +25,48 @@ export class ChickenEgg extends eui.Image {
set statusNum(value: number) {
if (value >= 0) {
this._statusNum = value;
//修改图片
if (this.showImage.source != images[this._statusNum]) {
this.changeSource(images[this._statusNum]);
}
} else {
this._statusNum = 0;
this.chickenNum++;
this.isActive = true;
}
}
constructor(n: number = 3) {
super()
this.source = "ele7_png";
//图片需要居中
this.showImage = new eui.Image();
this.addChild(this.showImage)
this.changeSource(images[n]);
this.chickenNum = 0;
this.isActive = false;
this._statusNum = n;
}
changeSource(source: string) {
var texture: egret.Texture = RES.getRes(source);
this.showImage.texture = texture
reset(n: number = 3) {
//图片修改
this.chickenNum = 0;
this._statusNum = n;
this.showImage.anchorOffsetX = texture.textureWidth / 2;
this.showImage.anchorOffsetY = texture.textureHeight / 2 + 20;
this.showImage.y = 20
}
/**
* 孵蛋动作
*/
hatch(callback: Function) {
if (!this.chickenNum) {
callback();
return
shakeAni() {
this.showImage.rotation = 0;
egret.Tween.get(this.showImage)
.to({ rotation: 10 }, 80)
.to({ rotation: -8 }, 160)
.to({ rotation: 5 }, 160)
.to({ rotation: 0 }, 50)
}
}
reset(n: number = 3) {
this.changeSource(images[n]);
this.isActive = false;
this._statusNum = n;
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import { MagicLionBgAni } from "../periodAni/MagicLionBgAni";
import { HorizontalBgAni } from "../periodAni/HorizontalBgAni";
import { VerticalBgAni } from "../periodAni/VerticalBgAni";
import { ExplosiveBgAni } from "../periodAni/ExplosiveBgAni";
import { ChickenEgg } from "./ChickenEgg";
/**
......@@ -17,7 +18,10 @@ export class Element extends eui.Component {
/**
* 初始类型
*/
type: ElementType;
private _type: ElementType;
get type() {
return this._type
}
/**
* 显示的图片,直接改source,"ele"+type+effectType
*/
......@@ -135,13 +139,24 @@ export class Element extends eui.Component {
}
this._isLock = value
}
chickenEgg: ChickenEgg;
constructor(type: ElementType) {
super();
this.type = type;
this._type = type;
this.showImage = new eui.Image();
this.changeSource("ele" + this.type + "_png");
this.addChild(this.showImage);
// this.showImage.touchEnabled=false
if (type == ElementType.CHICKEN_EGG) {
this.chickenEgg = Pool.takeOut(RecoverName.CHICKEN_EGG)
if (!this.chickenEgg) {
//新建,里面是解锁的所有图片组
this.chickenEgg = new ChickenEgg();
} else {
this.chickenEgg.reset();
}
this.addChild(this.chickenEgg)
}
}
/**
......@@ -157,7 +172,7 @@ export class Element extends eui.Component {
this.showImage.y = -texture.textureHeight / 2;
//特殊逻辑,因为魔力鸟动效要旋转,所以隐藏原图showImage
if (source == "magicLion_png") {
if (source == "magicLion_png" || source == "ele9_png") {
this.showImage.alpha = 0;
} else {
this.showImage.alpha = 1;
......@@ -167,7 +182,7 @@ export class Element extends eui.Component {
reset(type: ElementType) {
this.alpha = this.scaleX = this.scaleY = 1;
//类型重置,showImage修改
this.type = type;
this._type = type;
this.changeSource("ele" + type + "_png");
//特效重置
this.effectType = null;
......@@ -180,6 +195,22 @@ export class Element extends eui.Component {
Pool.recover(RecoverName.LOCK_ANI, this.lockAni);
this.lockAni = null;
}
//如果类型是鸡蛋
if (type == ElementType.CHICKEN_EGG) {
this.chickenEgg = this.chickenEgg || Pool.takeOut(RecoverName.CHICKEN_EGG)
if (!this.chickenEgg) {
//新建,里面是解锁的所有图片组
this.chickenEgg = new ChickenEgg();
} else {
this.chickenEgg.reset();
}
this.addChild(this.chickenEgg)
}
else if (this.chickenEgg) {
this.removeChild(this.chickenEgg);
Pool.recover(RecoverName.CHICKEN_EGG, this.chickenEgg);
this.chickenEgg = null;
}
}
private removeHas() {
......
/**
* 特效类型
* 回收类型
*/
export enum RecoverName {
ELEMENT = "Element",
......@@ -12,9 +12,12 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni",
//带回调的动画
BONUSSHOOT_ANI = "BonusShootAni",
JELLYSPREAD_ANI = "JellySpreadAni",
PIECETOEGG_ANI = "PieceToEggAni",
//元素身上
LOCK_ANI = "LockAni",
......@@ -23,6 +26,9 @@ export enum RecoverName {
VERTICALBG_ANI = "VerticalBgAni",
EXPLOSIVEBG_ANI = "ExplosiveBgAni",
//元素身上的鸡蛋
CHICKEN_EGG = "ChickenEgg",
//所有继承ani的,能单独播放的
ROCK_ANI = "RockAni",
ICE_ANI = "IceAni",
......@@ -34,4 +40,6 @@ export enum RecoverName {
THREECROSS_ANI = "ThreeCrossAni",
MAGICLION_ANI = "MagicLionAni",
STEP_ANI = "StepAni",
JELLYDIS_ANI = "JellyDisAni",
EGGBROKEN_ANI = "EggBrokenAni",
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ export interface MapData {
* 3棒棒糖
* 4元素枷锁
* 5果冻
* 6鸡蛋
*/
elements?:number[]
/**
......
......@@ -5,6 +5,12 @@ import { RecoverName } from "../enum/RecoverName";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
import { Lattice } from "../class/Lattice";
import { ChickenEgg } from "../class/ChickenEgg";
import { HatchAni } from "../anis/HatchAni";
import { PieceToEggAni } from "../anis/PieceToEggAni";
//孵鸡的数量
const chickenNum: number = 4
export class AiControl {
private static _ins: AiControl
......@@ -15,40 +21,27 @@ export class AiControl {
* 判断是否还有果冻,暂时不考虑果冻无中生有,否则逻辑修改
*/
private hasJelly: boolean;
private hasEgg: boolean;
/**
* 提前记录所有的鸡蛋的索引
*/
private eggs: number[];
init(lattices: Lattice[]) {
this.hasJelly = judgeJellyExist(lattices);
this.hasEgg = judgeEggExist(lattices);
this.eggs = getEggs(lattices);
}
aiMotion(thisObj: MainScene, callback: Function) {
//果冻的
this.jellyMotion(thisObj, () => {
//鸡蛋的
this.eggMotion(thisObj, callback)
})
// if (noAction) {
// callback()
// }
}
private jellyMotion(thisObj: MainScene, callback: Function) {
if (!this.hasJelly || thisObj.jellyBrokeMark) {
thisObj.jellyBrokeMark = false;
jellyMotion(thisObj: MainScene, callback: Function) {
if (!this.hasJelly || thisObj.jellyBrokenMark) {
//没有果冻,或上一步有果冻被消除,直接回调
callback();
thisObj.jellyBrokenMark = false;
return
}
//标识记为false
thisObj.jellyBrokeMark = false;
thisObj.jellyBrokenMark = false;
//果冻蔓延
var spread = getJellySpreadAni(thisObj.lattices);
let spread = getJellySpreadAni(thisObj.lattices);
if (spread) {
//执行动画
let jellySpreadAni: JellySpreadAni = Pool.takeOut(RecoverName.JELLYSPREAD_ANI)
......@@ -56,7 +49,11 @@ export class AiControl {
jellySpreadAni = new JellySpreadAni()
}
thisObj.addChild(jellySpreadAni);
//隐藏原来的元素
thisObj.lattices[spread[0]].element.visible = false;
jellySpreadAni.play(Tool.getPositionByIndex(spread[0]), Tool.getPositionByIndex(spread[1]), () => {
//显示隐藏元素
thisObj.lattices[spread[0]].element.visible = true;
//播放完后,将终点元素变成果冻
thisObj.lattices[spread[1]].element.reset(ElementType.JELLY);
//执行回调
......@@ -76,13 +73,86 @@ export class AiControl {
* @param thisObj
* @param callback
*/
private eggMotion(thisObj: MainScene, callback: Function) {
if (!this.hasEgg) {
eggMotion(thisObj: MainScene, callback: Function) {
//无蛋,直接回调
if (!this.eggs.length) {
callback();
return
}
var activeEggIndexs: number[] = []
//找出所有有鸡的蛋的索引
for (var i = 0; i < this.eggs.length; i++) {
var index = this.eggs[i];
var egg: ChickenEgg = thisObj.lattices[index].element.chickenEgg
if (egg.isActive) activeEggIndexs.push(index);
}
//无有鸡的蛋,直接回调
if (!activeEggIndexs.length) {
callback();
return
}
//逻辑再写,暂时没有
//找出所有能飞小鸡的格子索引
var chickenIndexs: number[] = [];
for (var a = 0; a < thisObj.lattices.length; a++) {
var lat = thisObj.lattices[a];
if (lat &&
lat.element &&
lat.element.type <= 4) {
chickenIndexs.push(a);
}
}
//如果没有能飞的格子
if (!chickenIndexs.length) {
callback();
return
}
//打乱索引
chickenIndexs.sort(function () {
return (0.5 - Math.random());
});
//拷贝
var chickenIndexsCopy = chickenIndexs.slice();
let countAll = activeEggIndexs.length;
let count = 0;
//开始给每个有鸡的蛋做匹配
for (var b = 0; b < activeEggIndexs.length; b++) {
let activeEggIndex = activeEggIndexs[b];
//从chickenIndexsCopy取四个,不足就在chickenIndexs随个
let four: number[] = chickenIndexsCopy.splice(0, 4);
if (four.length < chickenNum) {
//补上剩下的,如果还不足,就不管
four = four.concat(Tool.getRandomArrayElementsEx(chickenIndexs, chickenNum - four.length))
}
//播蛋壳动画
let activeEgg = thisObj.lattices[activeEggIndex].element.chickenEgg;
activeEgg.visible = false;
HatchAni(activeEggIndex, four, thisObj, () => {
//飞完后恢复蛋的状态
//蛋壳变为蛋的动画,回调里执行吧
let pieceToEggAni: PieceToEggAni = Pool.takeOut(RecoverName.PIECETOEGG_ANI)
if (!pieceToEggAni) {
pieceToEggAni = new PieceToEggAni()
}
thisObj.addChild(pieceToEggAni);
pieceToEggAni.play(Tool.getPositionByIndex(activeEggIndex), () => {
activeEgg.reset();
activeEgg.visible = true;
})
count++;
if (count == countAll) {
setTimeout(() => {
if (thisObj.threeMatch()) {
thisObj.eliminate();
} else {
callback()
}
})
}
})
}
}
......@@ -104,18 +174,24 @@ function judgeJellyExist(lattices: Lattice[]) {
return false;
}
/**
* 判断鸡蛋是否存在
* 获取所有鸡蛋的索引
* @param lattices
* @return false表示不存在,true表示存在
*/
function judgeEggExist(lattices: Lattice[]) {
function getEggs(lattices: Lattice[]) {
var arr = [];
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//没有格子或没有元素或不是果冻 跳过
if (!lattice || !lattice.element || lattice.element.type != ElementType.CHICKEN_EGG) continue
return true
if (lattice &&
lattice.element &&
lattice.element.type == ElementType.CHICKEN_EGG
) {
arr.push(i)
}
return false;
}
return arr;
}
......@@ -170,4 +246,4 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
return null
}
//
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