Commit a8e5c753 authored by wjf's avatar wjf

l

parent e73267bb
......@@ -1049,8 +1049,7 @@ export default class MainScene extends Scene {
}
fallVerMark: boolean
/**
* 修改方法,遍历所有格子,上面的元素进行掉落,
* @param emptys 消除后生成的空格
* 掉落方法还有问题,遇到那种少量垂直元素,只能等垂直元素到底后,才考虑斜落,以后再考虑一边掉落逻辑
* @param callback 所有fall完成后的回调,检查三消,
*/
fall(callback: Function) {
......
......@@ -29,9 +29,8 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
//对应的索引的类型变成鸡,抛物线动画时间都一致,其实可以在统一回调里执行数据更新
thisObj.lattices[endIndex].element.reset(ElementType.CHICKEN);
//动画,和bonusTime的效果一样,暂时没加
count++;
if (count == countAll) callback();
if (++count == countAll) callback();
})
}
}
......
......@@ -11,6 +11,7 @@ import { PieceToEggAni } from "../anis/PieceToEggAni";
import { StateType } from "../enum/StateType";
import { BubbleAni } from "../anis/BubbleAni";
import { Element } from "../class/Element";
import { HairballBrownState } from "../states/HairballBrownState";
//孵鸡的数量
const chickenNum: number = 4
......@@ -204,8 +205,7 @@ export class AiControl {
activeEgg.visible = true;
})
count++;
if (count == countAll) {
if (++count == countAll) {
//做个延时,有节奏感
setTimeout(() => {
//检测三消,有就执行消除,没有就回调
......@@ -340,11 +340,100 @@ export class AiControl {
callback();
return
}
//分裂的优先
//跳动的
//唤醒的
let count = 0;
let countAll = (jumpBallIndexs.length ? 1 : 0) + (awakeBallIndexs.length ? 1 : 0) + (divideBallIndexs.length ? 1 : 0)
let callbackOperation = () => {
if (++count == countAll) {
setTimeout(() => {
//检测三消,有就执行消除,没有就回调
if (thisObj.threeMatch()) {
thisObj.eliminate();
} else {
callback()
}
}, 200)
}
}
//分裂的优先,因为存在多出状态,不需要多次,按顺序就行
let countDivide = 0;
let countDivideAll = divideBallIndexs.length;
for (var a = 0; a < divideBallIndexs.length; a++) {
let indexFrom = divideBallIndexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element;
//判断是否能分裂
let indexEnd = judgeDivide(indexFrom, thisObj.lattices);
//有执行分裂动画
if (indexEnd != null) {
//去掉原先的褐色
elementFrom.setState(StateType.HAIRBALLBROWN, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
let elementEnd = thisObj.lattices[indexEnd].element;
//变成灰色毛球
elementEnd.setState(StateType.HAIRBALLGREY, true);
//动画
setTimeout(() => {
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
}
//没有则执行直接变灰动画
else {
//去掉原先的褐色
elementFrom.setState(StateType.HAIRBALLBROWN, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
//动画
setTimeout(() => {
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
}
}
//跳动的,需要考虑尽量都能跳,
let countJump = 0;
let countJumpAll = jumpBallIndexs.length;
for (var a = 0; a < jumpBallIndexs.length; a++) {
let indexFrom = jumpBallIndexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element;
//判断是否能分裂
let indexEnd = judgeDivide(indexFrom, thisObj.lattices);
//有执行分裂动画
if (indexEnd != null) {
//去掉原先的褐色
elementFrom.setState(StateType.HAIRBALLBROWN, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
let elementEnd = thisObj.lattices[indexEnd].element;
//变成灰色毛球
elementEnd.setState(StateType.HAIRBALLGREY, true);
//动画
setTimeout(() => {
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
}
//没有则执行直接变灰动画
else {
//去掉原先的褐色
elementFrom.setState(StateType.HAIRBALLBROWN, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
//动画
setTimeout(() => {
//都执行了
if (++countDivide == countDivideAll) callbackOperation();
}, 200);
}
}
//唤醒的
}
}
......@@ -498,6 +587,40 @@ function getBubbleType(index: number, lattices: Lattice[], baseElementTypes: num
return Tool.randomT(arr);
}
/**
* 判断可分裂的方向,并返回分裂终点的格子索引
* 判断和judgeSpread一样,但以防万一,单独写
* @param index
* @return 没有返回null,注意判断时可能有0
*/
function judgeDivide(index: number, lattices: Lattice[]) {
//四个方向尽量随机
var arr = [index - Tool.colNum, index + Tool.colNum];
var rc = Tool.indexToRc(index);
var col = rc[1];
//列数大于0才可能有左边格子
if (col > 0) arr.push(index - 1);
//列数不为最右边
if (col < Tool.colNum - 1) arr.push(index + 1);
while (arr.length) {
var rand = Math.floor(Math.random() * arr.length);
var i = arr.splice(rand, 1)[0];
if (Tool.judgeBaseEle(lattices[i]) &&
!lattices[i].element.hasAnyState()) {
return i
}
}
return null
}
/**
* 根据可跳的索引和所有的格子数据,返回
* @param jumpBallIndexs
* @param lattices
*/
function returnAllJumps(jumpBallIndexs:number,lattices:Lattice[]){
}
......
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