Commit 5a5875f1 authored by wjf's avatar wjf

l

parent b25ed195
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main"
data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-orientation="auto" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750"
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false" data-content-height="1624" data-multi-fingered="2" data-show-fps="true" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
......
...@@ -309,19 +309,19 @@ const chapterFuns = { ...@@ -309,19 +309,19 @@ const chapterFuns = {
] ]
}, },
//果冻消除 //果冻消除
81: { 41: {
stepCount: 1, stepCount: 1,
showIndexs: [ showIndexs: [
[32, 41, 50, 49], [40, 49, 58, 48, 50],
], ],
hideIndexs: [ hideIndexs: [
[32, 41], [58, 48, 50],
], ],
handIndexs: [ handIndexs: [
[49, 50] [40, 49]
], ],
msg: [ msg: [
"当果冻附近的元素产生消除时,即可消除果冻\n不消除果冻时,果冻会逐渐蔓延" "小心!会蔓延的果冻!\n消除果冻旁边的动物\n就能消除果冻~"
] ]
}, },
} }
......
...@@ -171,14 +171,6 @@ export default class MainScene extends Scene { ...@@ -171,14 +171,6 @@ export default class MainScene extends Scene {
* 4表示都有,遍历两边,down比up小,从左先 * 4表示都有,遍历两边,down比up小,从左先
*/ */
connectState: number = 2; connectState: number = 2;
/**
* 应用棋盘大遮罩,还是单独对生成元素,连通元素用小方形遮罩
* 出于性能问题,用大遮罩,只遮一次,
* 但是如果出现连通口上格子的下排正下方格子不为空的情况,必须用小方形遮罩,否则元素穿帮
* 或者生成口上排正上方格子不为空时也
* 默认用大遮罩
*/
useSmallMask: boolean = false;
//皮肤上的 //皮肤上的
public starProgress: eui.Image; public starProgress: eui.Image;
public scoreTxt: eui.Label; public scoreTxt: eui.Label;
...@@ -262,7 +254,15 @@ export default class MainScene extends Scene { ...@@ -262,7 +254,15 @@ export default class MainScene extends Scene {
this.initElement(); this.initElement();
//重置基础元素类型及特效 //重置基础元素类型及特效
this.initBaseElement(); this.initBaseElement();
//初始化完先检测死图 //设置栏置顶
this.addChild(this["settingAll"])
//AiControl初始化,
AiControl.ins.init(this.lattices);
//检查一次三消
if (this.threeMatch()) {
this.eliminate();
} else {
//先检测死图
this.warningCop = Tool.dieMapCheck(this.lattices); this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) { if (!this.warningCop) {
//替换顺序 //替换顺序
...@@ -270,14 +270,11 @@ export default class MainScene extends Scene { ...@@ -270,14 +270,11 @@ export default class MainScene extends Scene {
} }
else { else {
this.enableMouseEvt(true); this.enableMouseEvt(true);
}
//设置栏置顶
this.addChild(this["settingAll"])
//AiControl初始化,
AiControl.ins.init(this.lattices);
//引导 //引导
this.initGuide(); this.initGuide();
} }
}
}
/** /**
* 加载所有用到的svga * 加载所有用到的svga
*/ */
...@@ -330,12 +327,10 @@ export default class MainScene extends Scene { ...@@ -330,12 +327,10 @@ export default class MainScene extends Scene {
//容器 //容器
this.elementContainer = new egret.DisplayObjectContainer(); this.elementContainer = new egret.DisplayObjectContainer();
this.addChild(this.elementContainer); this.addChild(this.elementContainer);
//加遮罩 //加遮罩,大遮罩一直都加,小遮罩时时判断
if (!this.useSmallMask) {
var mask = drawShape(path); var mask = drawShape(path);
this.elementContainer.mask = mask; this.elementContainer.mask = mask;
this.addChild(mask) this.addChild(mask)
}
//容器事件 //容器事件
this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this); this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDownE, this);
this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this); this.elementContainer.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMoveE, this);
...@@ -486,12 +481,7 @@ export default class MainScene extends Scene { ...@@ -486,12 +481,7 @@ export default class MainScene extends Scene {
var genLatDatas = this.chapterData.map.generateLats || []; var genLatDatas = this.chapterData.map.generateLats || [];
//设置生成口, //设置生成口,
this.generateIndexs = Tool.setGenerateLats(this.lattices, genLatDatas) this.generateIndexs = Tool.setGenerateLats(this.lattices, genLatDatas)
//判断生成口上排正上方格子是否存在
for (var i = 0; i < genLatDatas.length; i++) {
var genLatData: GenerateLatData = genLatDatas[i]
var index = genLatData.index;
if (this.lattices[index - Tool.colNum]) this.useSmallMask = true;
}
var downMax: number = 0; var downMax: number = 0;
var upMax: number = 0; var upMax: number = 0;
...@@ -511,8 +501,6 @@ export default class MainScene extends Scene { ...@@ -511,8 +501,6 @@ export default class MainScene extends Scene {
upMax = Math.max(upMax, colUp); upMax = Math.max(upMax, colUp);
if (colUp > colDown) hasBigToSmall = true; if (colUp > colDown) hasBigToSmall = true;
else if (colUp < colDown) hasSmallToBig = true; else if (colUp < colDown) hasSmallToBig = true;
//连通口上格子的下排正下方格子是否存在
if (this.lattices[connectedLat[0] + Tool.colNum]) this.useSmallMask = true;
} }
//1表示存在小列连通到大列,从右往左遍历 //1表示存在小列连通到大列,从右往左遍历
//2表示存在大列连通到小烈,从左往右遍历 //2表示存在大列连通到小烈,从左往右遍历
...@@ -653,7 +641,7 @@ export default class MainScene extends Scene { ...@@ -653,7 +641,7 @@ export default class MainScene extends Scene {
//初始化引导,游戏和道具 //初始化引导,游戏和道具
initGuide() { initGuide() {
//游戏引导 //游戏引导
const gameGuideChapterNum = [1, 2, 3, 5, 8, 9, 10, 12, 17, 25] const gameGuideChapterNum = [1, 2, 3, 5, 8, 9, 10, 12, 17, 25, 41]
if (gameGuideChapterNum.indexOf(this.chapter >> 0) > -1) { if (gameGuideChapterNum.indexOf(this.chapter >> 0) > -1) {
if (!readCache(getCacheKey() + this.chapter)) { if (!readCache(getCacheKey() + this.chapter)) {
this.gameGuide = new GameGuide(this); this.gameGuide = new GameGuide(this);
...@@ -1092,12 +1080,12 @@ export default class MainScene extends Scene { ...@@ -1092,12 +1080,12 @@ export default class MainScene extends Scene {
} }
/** /**
* 竖直掉落,一格判断 * 竖直掉落,一格判断,,没有按竖直生成口从上到下,所以有点问题
* 逻辑要重写 * 逻辑要重写
*/ */
private fallVertical() { private fallVertical() {
var anis: FallAniData[] = [] var anis: FallAniData[] = []
//先把竖直的掉落完,掉满后 //先把竖直掉落一格
for (var m = 0; m < Tool.colNum; m++) { for (var m = 0; m < Tool.colNum; m++) {
//同一列 //同一列
for (var n = Tool.rowNum - 1; n >= 0; n--) { for (var n = Tool.rowNum - 1; n >= 0; n--) {
...@@ -1240,16 +1228,7 @@ export default class MainScene extends Scene { ...@@ -1240,16 +1228,7 @@ export default class MainScene extends Scene {
for (var i = 0; i < emptys.length; i++) { for (var i = 0; i < emptys.length; i++) {
let indexMy = emptys[i]; let indexMy = emptys[i];
var lat = this.lattices[indexMy]; var lat = this.lattices[indexMy];
//判断是否是生成口
if (lat.isGenerate) {
//是生成口,就不用管落下乐
anis.push({ ele: null, indexs: [{ index: indexMy, type: FallType.STRIGHT }] })
//去掉
emptys.splice(i, 1);
//优先判断生成的,不用管掉落了,跳下一个
i--
continue
}
let latFall; let latFall;
let indexFall; let indexFall;
let type: FallType = FallType.STRIGHT let type: FallType = FallType.STRIGHT
...@@ -1316,6 +1295,17 @@ export default class MainScene extends Scene { ...@@ -1316,6 +1295,17 @@ export default class MainScene extends Scene {
latFall.element = null; latFall.element = null;
//长度加了,多加+ //长度加了,多加+
i--; i--;
} else {
//判断是否是生成口
if (lat.isGenerate) {
//是生成口,就不用管落下乐
anis.push({ ele: null, indexs: [{ index: indexMy, type: FallType.STRIGHT }] })
//去掉
emptys.splice(i, 1);
//优先判断生成的,不用管掉落了,跳下一个
i--
continue
}
} }
} }
return anis return anis
...@@ -1343,7 +1333,7 @@ export default class MainScene extends Scene { ...@@ -1343,7 +1333,7 @@ export default class MainScene extends Scene {
let tween: egret.Tween; let tween: egret.Tween;
if (!ele) { if (!ele) {
//取出第一个索引 //取出第一个索引
let firstIndex = indexs.shift() let firstIndex: { index: number, type: FallType } = indexs.shift()
ele = this.createELement(firstIndex.index); ele = this.createELement(firstIndex.index);
this.elementContainer.addChild(ele); this.elementContainer.addChild(ele);
oriRow = Tool.indexToRc(firstIndex.index)[0]; oriRow = Tool.indexToRc(firstIndex.index)[0];
...@@ -1353,8 +1343,8 @@ export default class MainScene extends Scene { ...@@ -1353,8 +1343,8 @@ export default class MainScene extends Scene {
tween = egret.Tween.get(ele); tween = egret.Tween.get(ele);
//有等待的话,只有多格子掉落的时候才有 //有等待的话,只有多格子掉落的时候才有
if (wait) tween.wait(wait); if (wait) tween.wait(wait);
//加遮罩,需要遮罩写法, //加遮罩,需要遮罩写法,如果该口上方有格子
if (this.useSmallMask) { if (this.lattices[firstIndex.index - Tool.colNum]) {
let mask = Tool.getRectMask(); let mask = Tool.getRectMask();
mask.x = fp[0]; mask.x = fp[0];
mask.y = fp[1]; mask.y = fp[1];
...@@ -1387,19 +1377,24 @@ export default class MainScene extends Scene { ...@@ -1387,19 +1377,24 @@ export default class MainScene extends Scene {
let indexUp = this.lattices[index].up; let indexUp = this.lattices[index].up;
let downPos = Tool.getPositionByIndex(index); let downPos = Tool.getPositionByIndex(index);
let upPos = Tool.getPositionByIndex(indexUp); let upPos = Tool.getPositionByIndex(indexUp);
//用遮罩的写法
if (this.useSmallMask) {
//up处的动画 //up处的动画
//如果上格子下面有格子, 用遮罩的写法,
if (this.lattices[indexUp + Tool.colNum]) {
EleMaskAni(ele, upPos, wait, this.elementContainer, true, deltaTime); EleMaskAni(ele, upPos, wait, this.elementContainer, true, deltaTime);
tween.set({ alpha: 0 }) tween.set({ alpha: 0 })
.wait(deltaTime) .wait(deltaTime)
.set({ alpha: 1 }) .set({ alpha: 1 })
//down位置处的动画
EleMaskAni(ele, downPos, wait, this.elementContainer, false, deltaTime);
} else { } else {
tween.to({ x: upPos[0], y: upPos[1] + Tool.height }, deltaTime); tween.to({ x: upPos[0], y: upPos[1] + Tool.height }, deltaTime);
}
//down处的动画
//如果下格子上方有格子,用遮罩的写法
if (this.lattices[index - Tool.colNum]) {
EleMaskAni(ele, downPos, wait, this.elementContainer, false, deltaTime);
} else {
EleDownAni(ele, downPos, wait, this.elementContainer, false, deltaTime) EleDownAni(ele, downPos, wait, this.elementContainer, false, deltaTime)
} }
//修改oriRow //修改oriRow
oriRow = Tool.indexToRc(index)[0]; oriRow = Tool.indexToRc(index)[0];
lastX = downPos[0]; lastX = downPos[0];
...@@ -1508,7 +1503,8 @@ export default class MainScene extends Scene { ...@@ -1508,7 +1503,8 @@ export default class MainScene extends Scene {
} }
} }
let ele = Tool.getElement(type); let ele = Tool.getElement(type);
ele.effectType = effectType; //如果未通关,有特效的话可以加
if (!this.hasPassed) ele.effectType = effectType;
//没有特效的时候,考虑加气泡 //没有特效的时候,考虑加气泡
if (effectType == null && if (effectType == null &&
this.chapterData.bubbleProbability && this.chapterData.bubbleProbability &&
......
...@@ -794,10 +794,15 @@ export class Tool { ...@@ -794,10 +794,15 @@ export class Tool {
if (!arr[col]) arr[col] = []; if (!arr[col]) arr[col] = [];
arr[col].push({ arr[col].push({
index: generateLat.index, index: generateLat.index,
type: generateLat.type, type: generateLat.type || [],
cus: generateLat.cus.slice(),//防止数据被修改 cus: generateLat.cus.slice(),//防止数据被修改
}); });
} }
//每一列的数据排个序,因为生成口掉落,index小的在前面
for (var j = 0; j < arr.length; j++) {
//排序从小到大
if (arr[j]) arr[j].sort(function (a, b) { return a.index > b.index ? 1 : -1 });
}
return arr return arr
// var indexs = []; // var indexs = [];
// for (var m = 0; m < Tool.colNum; m++) { // for (var m = 0; m < Tool.colNum; m++) {
...@@ -830,7 +835,7 @@ export class Tool { ...@@ -830,7 +835,7 @@ export class Tool {
return arr return arr
} }
/** /**
* 找一个格子,最终掉落点,所有的index吧 * 找一个格子,最终掉落点,所有的index吧,不改变数据
* @param lattice 能掉落的格子,格子上肯定有元素,并且能掉落 * @param lattice 能掉落的格子,格子上肯定有元素,并且能掉落
* @param empty * @param empty
* @param lattices * @param lattices
...@@ -886,6 +891,11 @@ export class Tool { ...@@ -886,6 +891,11 @@ export class Tool {
} }
} }
/**
* 不改变数据
* @param emptys
* @param lattices
*/
public static judgeOutOne(emptys: number[], lattices: Lattice[]) { public static judgeOutOne(emptys: number[], lattices: Lattice[]) {
for (var m = 0; m < Tool.colNum; m++) { for (var m = 0; m < Tool.colNum; m++) {
//同一列 //同一列
......
...@@ -26,7 +26,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS ...@@ -26,7 +26,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
//回收 //回收
thisObj.removeChild(eleC); thisObj.removeChild(eleC);
Pool.recover(RecoverName.ELEMENT, eleC); Pool.recover(RecoverName.ELEMENT, eleC);
//对应的索引的类型变成鸡,抛物线动画时间都一致,其实可以在统一回调里执行数据更新 //对应的索引的类型变成鸡,抛物线动画时间都一致,其实可以在统一回调里执行数据更新,这里的数据更新迟早改掉
thisObj.lattices[endIndex].element.reset(ElementType.CHICKEN); thisObj.lattices[endIndex].element.reset(ElementType.CHICKEN);
//动画,和bonusTime的效果一样,暂时没加 //动画,和bonusTime的效果一样,暂时没加
......
...@@ -1001,7 +1001,7 @@ export const Chapters1: ChapterData[] = [ ...@@ -1001,7 +1001,7 @@ export const Chapters1: ChapterData[] = [
], ],
}, },
}, },
//17 引导棒棒糖 //17 引导棒棒糖,定制掉落待加
{ {
baseElementTypes: [0, 1, 2, 3], baseElementTypes: [0, 1, 2, 3],
bubbleProbability: 0, bubbleProbability: 0,
......
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 181到200关数据
*/
export const Chapters10: ChapterData[] = [
//181
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 61到80关数据
*/
export const Chapters4: ChapterData[] = [
//61 测试鸡蛋
{ baseElementTypes: [0, 2, 3, 4], bubbleProbability: 0, stepCount: 37, passTarget: { type: 1, elements: [{ type: 1, count: 30 }] }, starScores: [8000, 15000, 22000], map: { lattices: [0, 0, 0, 0, 0, 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, 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, 0, 0, 0, 1, 1, 1, 0, 0, 0], connectedLats: [], elements: [0, 0, 0, 0, 0, 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 }] } }
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 81到100关数据
*/
export const Chapters5: ChapterData[] = [
//81
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 101到120关数据
*/
export const Chapters6: ChapterData[] = [
//101
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 121到140关数据
*/
export const Chapters7: ChapterData[] = [
//121
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 141到160关数据
*/
export const Chapters8: ChapterData[] = [
//141
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType";
/**
* 161到180关数据
*/
export const Chapters9: ChapterData[] = [
//161
{
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 20,
passTarget: { type: 1, elements: [{ type: 9, count: 27 }] },
starScores: [5000, 12000, 25000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 2, 2, 2, 2, 2, 1, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 0, 2, 2, 2, 2, 2, 0, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0
],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 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,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 2, 2, 5, 2, 2, 0, 0,
0, 0, 5, 1, 1, 1, 5, 0, 0,
0, 2, 2, 2, 5, 2, 2, 2, 0
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 10, 0, 0, 0, 0,
0, 0, 0, 40, 20, 40, 0, 0, 0,
0, 0, 20, 20, 30, 40, 20, 0, 0,
0, 20, 40, 30, 20, 30, 30, 10, 0,
0, 0, 10, 20, 10, 20, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 40, 40, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
],
recycles: [],
generateLats: [
{ index: 13, type: 0 },
{ index: 21, type: 0 },
{ index: 23, type: 0 },
{ index: 29, type: 0 },
{ index: 33, type: 0 },
{ index: 37, type: 0 },
{ index: 43, type: 0 }
]
}
}
]
\ No newline at end of file
import { ChapterData } from "../interface/ChapterData";
import { Chapters1 } from "./Chapter1"; import { Chapters1 } from "./Chapter1";
import { Chapters2 } from "./Chapter2"; import { Chapters2 } from "./Chapter2";
import { ChapterData } from "../interface/ChapterData"; import { Chapters3 } from "./Chapter3";
import { Chapters4 } from "./Chapter4";
//所有的关卡 //所有的关卡
const chapters: ChapterData[] = [].concat( const chapters: ChapterData[] = [].concat(
Chapters1, Chapters1,
Chapters2, Chapters2,
Chapters3,
Chapters4
) )
/** /**
* 获取关卡数据,返回关卡数据 * 获取关卡数据,返回关卡数据
* 以后每添加20关,添加一个文件,上面concat一个文件 * 以后每添加20关,添加一个文件,上面concat一个文件
* @param index 关数 从1开始 * @param index 关数 从1开始
*/ */
export function getChapterData(index: number) { export function getChapterData(index: number): ChapterData {
//没有数据就返回第一关数据 //没有数据就返回第一关数据
return chapters[index] || chapters[1]; return chapters[index] || chapters[1];
} }
\ No newline at end of file
...@@ -22,6 +22,6 @@ export interface FallAniData { ...@@ -22,6 +22,6 @@ export interface FallAniData {
} }
export enum FallType { export enum FallType {
STRIGHT = 0, STRIGHT = 0, //垂直
THROUGH, THROUGH, //连通穿过
} }
\ No newline at end of file
...@@ -9,8 +9,9 @@ export interface GenerateLatData { ...@@ -9,8 +9,9 @@ export interface GenerateLatData {
/** /**
* 掉落元素类型 * 掉落元素类型
* 里面随机类型和下一致 * 里面随机类型和下一致
* 或者null
*/ */
type?: number[] type?: number[] | 0
/** /**
* 自定义掉落元素 * 自定义掉落元素
* 十位是基础元素类型,对应数字减1就是基础元素类型 * 十位是基础元素类型,对应数字减1就是基础元素类型
......
...@@ -88,7 +88,7 @@ export class AiControl { ...@@ -88,7 +88,7 @@ export class AiControl {
//随机取 //随机取
var rand = Math.floor(Math.random() * indexs.length); var rand = Math.floor(Math.random() * indexs.length);
var randIndex = indexs.splice(rand, 1)[0]; var randIndex = indexs.splice(rand, 1)[0];
var index = judgeSpread(randIndex, thisObj.lattices); var index = judgeActionIndex(randIndex, thisObj.lattices);
//考虑0,判断null,有就break //考虑0,判断null,有就break
if (index != null) { if (index != null) {
//能蔓延,返回自身索引和蔓延的索引 //能蔓延,返回自身索引和蔓延的索引
...@@ -295,8 +295,8 @@ export class AiControl { ...@@ -295,8 +295,8 @@ export class AiControl {
callback(); callback();
return return
} }
//找出所有能跳动的毛球; //找出所有能跳动的毛球;需要记录类型
var jumpBallIndexs: number[] = []; var jumpBallIndexs: { type: StateType, index: number }[] = [];
//即将唤醒的黑色毛球 //即将唤醒的黑色毛球
var awakeBallIndexs: number[] = []; var awakeBallIndexs: number[] = [];
//即将分裂的褐色毛球 //即将分裂的褐色毛球
...@@ -307,13 +307,13 @@ export class AiControl { ...@@ -307,13 +307,13 @@ export class AiControl {
if (Tool.judgeBaseEle(lat)) { if (Tool.judgeBaseEle(lat)) {
//灰色直接进跳动 //灰色直接进跳动
if (lat.element.hasState(StateType.HAIRBALLGREY)) { if (lat.element.hasState(StateType.HAIRBALLGREY)) {
jumpBallIndexs.push(i); jumpBallIndexs.push({ type: StateType.HAIRBALLGREY, index: i });
} }
//黑色 //黑色
if (lat.element.hasState(StateType.HAIRBALLBLACK)) { if (lat.element.hasState(StateType.HAIRBALLBLACK)) {
//醒着的跳动 //醒着的跳动
if (lat.element.getState(StateType.HAIRBALLBLACK).isAwake) { if (lat.element.getState(StateType.HAIRBALLBLACK).isAwake) {
jumpBallIndexs.push(i); jumpBallIndexs.push({ type: StateType.HAIRBALLBLACK, index: i });
} }
//晕着的即将醒 //晕着的即将醒
else { else {
...@@ -328,7 +328,7 @@ export class AiControl { ...@@ -328,7 +328,7 @@ export class AiControl {
} }
//未激活的跳动 //未激活的跳动
else { else {
jumpBallIndexs.push(i); jumpBallIndexs.push({ type: StateType.HAIRBALLBROWN, index: i });
} }
}; };
} }
...@@ -343,7 +343,7 @@ export class AiControl { ...@@ -343,7 +343,7 @@ export class AiControl {
let count = 0; let count = 0;
let countAll = (jumpBallIndexs.length ? 1 : 0) + (awakeBallIndexs.length ? 1 : 0) + (divideBallIndexs.length ? 1 : 0) let countAll = (jumpBallIndexs.length ? 1 : 0) + (awakeBallIndexs.length ? 1 : 0) + (divideBallIndexs.length ? 1 : 0)
//回调操作
let callbackOperation = () => { let callbackOperation = () => {
if (++count == countAll) { if (++count == countAll) {
setTimeout(() => { setTimeout(() => {
...@@ -360,11 +360,11 @@ export class AiControl { ...@@ -360,11 +360,11 @@ export class AiControl {
//分裂的优先,因为存在多出状态,不需要多次,按顺序就行 //分裂的优先,因为存在多出状态,不需要多次,按顺序就行
let countDivide = 0; let countDivide = 0;
let countDivideAll = divideBallIndexs.length; let countDivideAll = divideBallIndexs.length;
for (var a = 0; a < divideBallIndexs.length; a++) { for (var a = 0; a < countDivideAll; a++) {
let indexFrom = divideBallIndexs[a]; let indexFrom = divideBallIndexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element; let elementFrom: Element = thisObj.lattices[indexFrom].element;
//判断是否能分裂 //判断是否能分裂
let indexEnd = judgeDivide(indexFrom, thisObj.lattices); let indexEnd = judgeActionIndex(indexFrom, thisObj.lattices);
//有执行分裂动画 //有执行分裂动画
if (indexEnd != null) { if (indexEnd != null) {
//去掉原先的褐色 //去掉原先的褐色
...@@ -394,47 +394,47 @@ export class AiControl { ...@@ -394,47 +394,47 @@ export class AiControl {
}, 200); }, 200);
} }
} }
//跳动的,需要考虑尽量都能跳, //跳动的,
let countJump = 0; let countJump = 0;
let countJumpAll = jumpBallIndexs.length; let countJumpAll = jumpBallIndexs.length;
for (var a = 0; a < jumpBallIndexs.length; a++) { for (var a = 0; a < jumpBallIndexs.length; a++) {
let indexFrom = jumpBallIndexs[a]; let data: { type: StateType, index: number } = jumpBallIndexs[a];
let indexFrom = data.index;
let elementFrom: Element = thisObj.lattices[indexFrom].element; let elementFrom: Element = thisObj.lattices[indexFrom].element;
//判断是否能分裂 let stateType: StateType = data.type;
let indexEnd = judgeDivide(indexFrom, thisObj.lattices); //判断是否能跳动
//有执行分裂动画 let indexEnd = judgeActionIndex(indexFrom, thisObj.lattices);
//有执行跳动动画
if (indexEnd != null) { if (indexEnd != null) {
//去掉原先的褐色 //去掉原先的状态
elementFrom.setState(StateType.HAIRBALLBROWN, false); elementFrom.setState(stateType, false);
//变成灰色毛球
elementFrom.setState(StateType.HAIRBALLGREY, true);
let elementEnd = thisObj.lattices[indexEnd].element; let elementEnd = thisObj.lattices[indexEnd].element;
//变成灰色毛球 //变成毛球
elementEnd.setState(StateType.HAIRBALLGREY, true); elementEnd.setState(stateType, true);
//动画 //动画
setTimeout(() => { setTimeout(() => {
//都执行了 //都执行了
if (++countDivide == countDivideAll) callbackOperation(); if (++countJump == countJumpAll) callbackOperation();
}, 200); }, 200);
} }
//没有则执行直接变灰动画 //没有则计数
else { else {
//去掉原先的褐色 if (++countJump == countJumpAll) callbackOperation();
elementFrom.setState(StateType.HAIRBALLBROWN, false); }
//变成灰色毛球 }
elementFrom.setState(StateType.HAIRBALLGREY, true); //唤醒的
let countAwake = 0;
//动画 let countAwakeAll = awakeBallIndexs.length;
for (var a = 0; a < awakeBallIndexs.length; a++) {
let indexFrom = awakeBallIndexs[a];
let elementFrom: Element = thisObj.lattices[indexFrom].element;
//唤醒的动画直接写在自己的blackState里吧,然后换图
setTimeout(() => { setTimeout(() => {
//都执行了 //都执行了
if (++countDivide == countDivideAll) callbackOperation(); if (++countAwake == countAwakeAll) callbackOperation();
}, 200); }, 200);
} }
} }
//唤醒的
}
} }
/** /**
...@@ -502,11 +502,16 @@ function getEggs(lattices: Lattice[]) { ...@@ -502,11 +502,16 @@ function getEggs(lattices: Lattice[]) {
} }
/** /**
* 判断可蔓延的方向,并返回蔓延的格子索引 * 判断可蔓延的方向,并返回蔓延终点的格子索引
* 判断可分裂的方向,并返回分裂终点的格子索引
* 判断可跳动的方向,并返回跳动终点的格子索引
*
* 4个方向随机,
* 得是基础元素,且无任何状态,可以有特效
* @param index * @param index
* @return 没有返回null,注意判断时可能有0 * @return 没有返回null,注意判断时可能有0
*/ */
function judgeSpread(index: number, lattices: Lattice[]): number { function judgeActionIndex(index: number, lattices: Lattice[]): number {
//四个方向尽量随机 //四个方向尽量随机
var arr = [index - Tool.colNum, index + Tool.colNum]; var arr = [index - Tool.colNum, index + Tool.colNum];
var rc = Tool.indexToRc(index); var rc = Tool.indexToRc(index);
...@@ -587,40 +592,7 @@ function getBubbleType(index: number, lattices: Lattice[], baseElementTypes: num ...@@ -587,40 +592,7 @@ function getBubbleType(index: number, lattices: Lattice[], baseElementTypes: num
return Tool.randomT(arr); 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