Commit cc601233 authored by wjf's avatar wjf

l

parent 6f48d065
......@@ -99,8 +99,6 @@ export default class MainScene extends Scene {
choosed: eui.Image;
//消除后生成空格的索引
emptys: number[] = [];
//有特效时要记录,因为结束时要用,记录索引吧,执行消除特效时去掉,生成时加入
effectElements: number[] = [];
//消除队列的索引
eliminatedElements: number[] = [];
//棒棒糖生成标志
......@@ -349,9 +347,9 @@ export default class MainScene extends Scene {
this.soundBtn.source = "mainSoundBtnOff_png"
}
if (getBgOn()) {
this.musicBtn.source = "mainSoundBtnOn_png"
this.musicBtn.source = "mainMusicBtnOn_png"
} else {
this.musicBtn.source = "mainSoundBtnOff_png"
this.musicBtn.source = "mainMusicBtnOff_png"
}
//初始化道具信息
var arrObj = ["boomBtnNum", "hammerBtnNum", "stepBtnNum"];
......@@ -399,7 +397,7 @@ export default class MainScene extends Scene {
case 2:
case 3:
case 6:
var type = this.returnType(i);
var type = Tool.returnType(i, this.lattices, this.chapterData.baseElementTypes);
let ele: Element = Pool.takeOut(RecoverName.ELEMENT);
if (!ele) {
ele = new Element(type)
......@@ -472,7 +470,7 @@ export default class MainScene extends Scene {
this.lattices[connectedLat[1]].up = connectedLat[0];
}
//初始化完先检测死图
this.warningCop = this.dieMapCheck();
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//替换顺序
this.upsetElement();
......@@ -481,31 +479,7 @@ export default class MainScene extends Scene {
// this.enableMouseEvt(true);
// }
}
//返回元素类别
private returnType(index: number) {
var rc = Tool.indexToRc(index);
var arr = this.chapterData.baseElementTypes.slice();
//和左边两个比较
if (rc[1] > 1) {
//
var lat1 = this.lattices[index - 1];
var lat2 = this.lattices[index - 2];
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
}
//和上边两个比较
var lat1 = this.lattices[index - Tool.colNum];
var lat2 = this.lattices[index - Tool.colNum * 2];
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
return Tool.randomT(arr);
}
/**
* 更新三个道具
*/
......@@ -640,7 +614,7 @@ export default class MainScene extends Scene {
NetManager.ins.showLog(getlogItem(7));
if (this.boomBtnNum.count <= 0) {
//购买弹框
PanelCtrl.instance.show("Buy1")
PanelCtrl.instance.show("Buy2")
} else {
this.useProp(PropType.BOOM)
}
......@@ -649,7 +623,7 @@ export default class MainScene extends Scene {
NetManager.ins.showLog(getlogItem(10));
if (this.hammerBtnNum.count <= 0) {
//购买弹框
PanelCtrl.instance.show("Buy2", {})
PanelCtrl.instance.show("Buy1", {})
} else {
this.useProp(PropType.HAMMER)
}
......@@ -1062,251 +1036,6 @@ export default class MainScene extends Scene {
}
/**
* 检测死图,需要提示
* 需要返回一组提示 两个能互相交换元素,数组
* 有返回证明不是死图,
*/
dieMapCheck(): Element[] {
var lattices = this.lattices;
var judgeFall = Tool.judgeFall;
var judgeMatch = Tool.judgeMatch;
//记录有特效的元素,下面特效检测用
var effectElements = []
//检测普通元素,
var lat2, lat3;//额外两个元素声明
for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
var rc = Tool.indexToRc(i);
var row = rc[0];
var col = rc[1];
var lat = lattices[i];
//如果自身格子空或不能交换,跳入下一个
if (!judgeFall(lat)) continue
if (lat.element.effectType != null) {
effectElements.push(lat.element);
}
//与下交换
var latDown = lattices[i + Tool.colNum];
//能交换,并且类型不一致
if (judgeFall(latDown) && lat.element.type != latDown.element.type) {
//判断向下,+2,+3 lat
lat2 = lattices[i + Tool.colNum * 2];
lat3 = lattices[i + Tool.colNum * 3];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
//向上判断 -1 -2 latDown
lat2 = lattices[i - Tool.colNum];
lat3 = lattices[i - Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
//下横向判断左 -1 -2 lat 先确定col>1
if (col > 1) {
lat2 = lattices[i + Tool.colNum - 1];
lat3 = lattices[i + Tool.colNum - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向判断右 +1 +2 lat 先确定col<Tool.colNum -2
if (col < Tool.colNum - 2) {
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i + Tool.colNum + 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向中间 +1 -1 lat 先确定col>0;<Tool.colNum -1
if (col > 0 && col < Tool.colNum - 1) {
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i + Tool.colNum - 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//
//上横向判断左 -1 -2 latDown 先确定col>1
if (col > 1) {
lat2 = lattices[i - 1];
lat3 = lattices[i - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//上横向判断右 +1 +2 latDown 先确定col<Tool.colNum -2
if (col < Tool.colNum - 2) {
lat2 = lattices[i + 1];
lat3 = lattices[i + 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向中间 +1 -1 latDown 先确定col>0;<Tool.colNum -1
if (col > 0 && col < Tool.colNum - 1) {
lat2 = lattices[i + 1];
lat3 = lattices[i - 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
}
//与右交换,先确定col!=Tool.colNum-1,不是最右排元素8
if (col != Tool.colNum - 1) {
var latRight = lattices[i + 1];
//能交换,并且类型不一致
if (judgeFall(latRight) && lat.element.type != latRight.element.type) {
//判断向右,+2,+3 lat 先确定col<Tool.colNum - 3
if (col < Tool.colNum - 3) {
lat2 = lattices[i + 2];
lat3 = lattices[i + 3];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
//向左判断 -1 -2 latRight 先确定col>1
if (col > 1) {
lat2 = lattices[i - 1];
lat3 = lattices[i - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
//右纵向判断下 *1+1 *2+1 lat
lat2 = lattices[i + Tool.colNum * 1 + 1];
lat3 = lattices[i + Tool.colNum * 2 + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//右纵向判断上 -*1+1 -*2+1 lat
lat2 = lattices[i - Tool.colNum * 1 + 1];
lat3 = lattices[i - Tool.colNum * 2 + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//右纵向中间 -*1 *1 lat
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i - Tool.colNum + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//
//左纵向判断下 *1 *2 latRight
lat2 = lattices[i + Tool.colNum * 1];
lat3 = lattices[i + Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//左纵向判断上 -*1 -*2 latRight
lat2 = lattices[i - Tool.colNum * 1];
lat3 = lattices[i - Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//左纵向中间 *1 -*1 latRight
lat2 = lattices[i + Tool.colNum];
lat3 = lattices[i - Tool.colNum];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
}
}
//检测特效的
for (var i = 0; i < effectElements.length; i++) {
var effectElement = effectElements[i];
//是魔力鸟,直接找周围元素,
if (effectElement.effectType == EffectType.MAGICLION) {
//上格子
var up = lattices[effectElement.index - Tool.colNum];
if (judgeFall(up) && up.element.type != ElementType.LOLLIPOP) return [effectElement, up.element];
//下格子
var down = lattices[effectElement.index + Tool.colNum];
if (judgeFall(down) && up.element.type != ElementType.LOLLIPOP) return [effectElement, down.element];
//左格子
var col = Tool.indexToRc(effectElement.index)[1];//列数
if (col != 0) {
var left = lattices[effectElement.index - 1];
if (judgeFall(left) && left.element.type != ElementType.LOLLIPOP) return [effectElement, left.element];
}
if (col != Tool.colNum - 1) {
var right = lattices[effectElement.index + 1];
if (judgeFall(right) && right.element.type != ElementType.LOLLIPOP) return [effectElement, right.element];
}
continue
}
//是普通特效,找周围是特效的
//上格子
var up = lattices[effectElement.index - Tool.colNum];
if (judgeFall(up) && up.element.effectType != null) return [effectElement, up.element];
//下格子
var down = lattices[effectElement.index + Tool.colNum];
if (judgeFall(down) && down.element.effectType != null) return [effectElement, down.element];
//左格子
var col = Tool.indexToRc(effectElement.index)[1];//列数
if (col != 0) {
var left = lattices[effectElement.index - 1];
if (judgeFall(left) && left.element.effectType != null) return [effectElement, left.element];
}
if (col != Tool.colNum) {
var right = lattices[effectElement.index + 1];
if (judgeFall(right) && right.element.effectType != null) return [effectElement, right.element];
}
}
return null
}
/**
* 只关心交换后元素的可消除
* 或者冰淇淋的掉落
......@@ -1347,7 +1076,7 @@ export default class MainScene extends Scene {
for (var g = 0; g < Tool.colNum; g++) {
arr.push(i * Tool.colNum + g)
}
let re = this.fn(arr);
let re = Tool.fn(arr, this.lattices);
for (var j = 0; j < re.length; j++) {
let len = re[j].length;
if (len >= 3) {
......@@ -1382,7 +1111,7 @@ export default class MainScene extends Scene {
for (var g = 0; g < Tool.rowNum; g++) {
arr.push(Tool.colNum * g + m)
}
let re = this.fn(arr);
let re = Tool.fn(arr, this.lattices);
for (var j = 0; j < re.length; j++) {
let len = re[j].length;
if (len >= 3) {
......@@ -1444,30 +1173,7 @@ export default class MainScene extends Scene {
return this.eliminatedElements.length > 0;
}
/**
* 将有相邻相同的组合,不是基础元素的,都会是单独的
* @param arr
*/
public fn(arr: number[]) {
var lattices = this.lattices
var result = [],
i = 0;
result[i] = [arr[0]];
arr.reduce(function (prev, cur) {
var latP = lattices[prev];
var latC = lattices[cur];
if (Tool.judgeMatch(latP) &&
Tool.judgeMatch(latC) &&
latP.element.type == latC.element.type) {
result[i].push(cur)
} else {
result[++i] = [cur];
}
// cur.type == prev.type ? result[i].push(cur) : result[++i] = [cur];
return cur;
});
return result;
}
//执行消除,应该是一个迭代,只要eliminatedElements有东西就一直执行
eliminate() {
......@@ -1552,7 +1258,7 @@ export default class MainScene extends Scene {
PanelCtrl.instance.show("failed");
} else {
//检查死图
this.warningCop = this.dieMapCheck()
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//死图。替换顺序,出toast
showToast("没有可以消除的元素")
......@@ -1794,6 +1500,7 @@ export default class MainScene extends Scene {
*/
effectEliminate(effectIndexs: number[]) {
if (effectIndexs.length && !this.hasPassed) this.effectContinuityTimes++;
var sounds: SoundType[] = [];
for (var j = 0; j < effectIndexs.length; j++) {
var index = effectIndexs[j];
var lat: Lattice = this.lattices[index];
......@@ -1801,7 +1508,7 @@ export default class MainScene extends Scene {
var p = Tool.getPositionByIndex(index);
switch (ele.effectType) {
case EffectType.MAGICLION:
playSound(SoundType.magic)
if (sounds.indexOf(SoundType.magic) == -1) sounds.push(SoundType.magic)
this.playAni(RecoverName.MAGICLION_ANI, p);
this.recoverEle(index);
//为了不重复
......@@ -1837,7 +1544,7 @@ export default class MainScene extends Scene {
}
break;
case EffectType.EXPLOSIVE:
playSound(SoundType.boom)
if (sounds.indexOf(SoundType.boom) == -1) sounds.push(SoundType.boom)
//动画移除自己
var boomAni = this.playAni(RecoverName.BOOM_ANI, p);
boomAni.scaleX = boomAni.scaleY = 1;
......@@ -1857,7 +1564,7 @@ export default class MainScene extends Scene {
}
break;
case EffectType.HORIZONTAL:
playSound(SoundType.line)
if (sounds.indexOf(SoundType.line) == -1) sounds.push(SoundType.line)
var row = lat.row;
//动画移除自己
this.playAni(RecoverName.HORIZONTAL_ANI, p);
......@@ -1876,7 +1583,7 @@ export default class MainScene extends Scene {
}
break;
case EffectType.VERTICAL:
playSound(SoundType.line)
if (sounds.indexOf(SoundType.line) == -1) sounds.push(SoundType.line)
var col = lat.column;
//动画移除自己
this.playAni(RecoverName.VERTICAL_ANI, p);
......@@ -1896,6 +1603,10 @@ export default class MainScene extends Scene {
break;
}
}
//播放音乐
for (var a = 0; a < sounds.length; a++) {
playSound(sounds[a]);
}
}
/**
* 判断是否通关
......@@ -2071,7 +1782,7 @@ export default class MainScene extends Scene {
this.eliminate()
} else {
//检查死图
this.warningCop = this.dieMapCheck()
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//死图。替换顺序
this.upsetElement()
......@@ -2141,8 +1852,8 @@ export default class MainScene extends Scene {
Loading2.instace.show();
NetManager.ins.hc_submit((s, data) => {
if (s) {
const submitData = DataManager.ins.getData('hc_submit').data;
if(submitData.prizeType==1) {
const submitData = DataManager.ins.getData('hc_submit').data;
if (submitData.prizeType == 1) {
//提交成功后捞结果
NetManager.ins.getPlugOrderStatus((s) => {
......@@ -2161,13 +1872,13 @@ export default class MainScene extends Scene {
PanelCtrl.instance.show(ModuleTypes.NO_PRIZE_PANEL, { starCount: this.scoreProgress.starCount });
}
},
submitData.prizeResponse.orderNum,
submitData.prizeResponse.orderNum,
() => { return DataManager.ins.getData('getPlugOrderStatus').result == 0 });
}else {
} else {
PanelCtrl.instance.show(ModuleTypes.NO_PRIZE_PANEL, { starCount: this.scoreProgress.starCount });
}
} else {
Loading2.instace.hide();
if (!data) {
......
......@@ -602,29 +602,242 @@ export const Chapters: ChapterData[] = [
map: {
lattices: [
0, 0, 0, 1, 4, 1, 0, 0, 0,
1, 2, 5, 1, 1, 1, 5, 2, 1,
1, 2, 5, 1, 1, 1, 5, 2, 1,
1, 5, 5, 1, 1, 1, 5, 5, 1,
1, 1, 2, 1, 1, 1, 2, 1, 1,
2, 2, 2, 1, 1, 1, 2, 2, 2,
2, 5, 5, 2, 2, 2, 5, 5, 2,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 1, 1, 1, 0, 2, 5, 2,
5, 5, 5, 5, 5, 5, 5, 5, 5,
1, 1, 1, 1, 1, 1, 1, 1, 1,
],
generateLats: [3, 4, 5],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 46,
stepCount: 18,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.LOLLIPOP,
count: 2
}
]
},
starScores: [2000, 5000, 12000]
},
//第二十二关
{
map: {
lattices: [
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
3, 1, 3, 1, 3, 1, 3, 1, 3,
3, 1, 3, 1, 3, 1, 3, 1, 3,
3, 1, 3, 1, 3, 1, 3, 1, 3,
3, 1, 3, 1, 3, 1, 3, 1, 3,
3, 1, 3, 1, 3, 1, 3, 1, 3,
3, 1, 3, 1, 3, 1, 3, 1, 3,
],
generateLats: [0, 1, 2, 3, 4, 5, 6, 7, 8],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 53,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 22
count: 30
}
]
},
starScores: [11000, 22000, 45000]
starScores: [40000, 80000, 100000]
},
//第二十三关
{
map: {
lattices: [
0, 0, 1, 1, 4, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 0, 1, 0, 1, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
],
generateLats: [2, 3, 4, 5, 6],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 23,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.LOLLIPOP,
count: 2
}
]
},
starScores: [10000, 24000, 35000]
},
//第二十四关
{
map: {
lattices: [
0, 0, 0, 1, 1, 1, 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,
2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2,
],
generateLats: [3, 4, 5],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.1,
stepCount: 42,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 27
}
]
},
starScores: [15000, 35000, 60000]
},
//第二十五关
{
map: {
lattices: [
0, 1, 1, 1, 1, 4, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 5, 5, 5, 5, 5, 5, 5, 0,
0, 5, 5, 5, 5, 5, 5, 5, 0,
0, 5, 5, 5, 5, 5, 5, 5, 0,
],
generateLats: [1, 2, 3, 4, 5, 6, 7],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 35,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.LOLLIPOP,
count: 4
}
]
},
starScores: [20000, 40000, 45000]
},
//第二十六关
{
map: {
lattices: [
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 1, 1, 1, 1, 1, 1, 1, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5,
],
generateLats: [0, 1, 2, 3, 4, 5, 6, 7, 8],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 20,
passTarget: {
type: PassType.SCORE_TARGET,
score: 20000,
},
starScores: [7000, 12000, 20000]
},
//第二十七关
{
map: {
lattices: [
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
5, 5, 5, 5, 5, 5, 5, 5, 5,
3, 5, 3, 5, 3, 5, 3, 5, 3,
5, 5, 5, 5, 5, 5, 5, 5, 5,
3, 5, 3, 5, 3, 5, 3, 5, 3,
],
generateLats: [0, 1, 2, 3, 4, 5, 6, 7, 8],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 22,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 10
}
],
},
starScores: [
15000,
35000,
60000
]
},
//第二十八关
{
map: {
lattices: [
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
1, 1, 1, 1, 5, 1, 1, 1, 1,
0, 1, 1, 1, 5, 1, 1, 1, 1,
0, 1, 1, 1, 5, 1, 1, 1, 1,
0, 5, 5, 5, 5, 5, 5, 5, 5,
3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3,
],
generateLats: [0, 1, 2, 3, 4, 5, 6, 7, 8],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.05,
stepCount: 22,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 10
}
],
},
starScores: [
15000,
35000,
60000
]
},
]
\ No newline at end of file
......@@ -198,6 +198,301 @@ export class Tool {
}
}
/**
* 检测死图,需要提示
* 需要返回一组提示 两个能互相交换元素,数组
* 有返回证明不是死图,
*/
public static dieMapCheck(lattices: Lattice[]): Element[] {
var judgeFall = Tool.judgeFall;
var judgeMatch = Tool.judgeMatch;
//记录有特效的元素,下面特效检测用
var effectElements = []
//检测普通元素,
var lat2, lat3;//额外两个元素声明
for (var i = Tool.colNum * Tool.rowNum - 1; i >= 0; i--) {
var rc = Tool.indexToRc(i);
var row = rc[0];
var col = rc[1];
var lat = lattices[i];
//如果自身格子空或不能交换,跳入下一个
if (!judgeFall(lat)) continue
if (lat.element.effectType != null) {
effectElements.push(lat.element);
}
//与下交换
var latDown = lattices[i + Tool.colNum];
//能交换,并且类型不一致
if (judgeFall(latDown) && lat.element.type != latDown.element.type) {
//判断向下,+2,+3 lat
lat2 = lattices[i + Tool.colNum * 2];
lat3 = lattices[i + Tool.colNum * 3];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
//向上判断 -1 -2 latDown
lat2 = lattices[i - Tool.colNum];
lat3 = lattices[i - Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
//下横向判断左 -1 -2 lat 先确定col>1
if (col > 1) {
lat2 = lattices[i + Tool.colNum - 1];
lat3 = lattices[i + Tool.colNum - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向判断右 +1 +2 lat 先确定col<Tool.colNum -2
if (col < Tool.colNum - 2) {
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i + Tool.colNum + 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向中间 +1 -1 lat 先确定col>0;<Tool.colNum -1
if (col > 0 && col < Tool.colNum - 1) {
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i + Tool.colNum - 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//
//上横向判断左 -1 -2 latDown 先确定col>1
if (col > 1) {
lat2 = lattices[i - 1];
lat3 = lattices[i - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//上横向判断右 +1 +2 latDown 先确定col<Tool.colNum -2
if (col < Tool.colNum - 2) {
lat2 = lattices[i + 1];
lat3 = lattices[i + 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
//下横向中间 +1 -1 latDown 先确定col>0;<Tool.colNum -1
if (col > 0 && col < Tool.colNum - 1) {
lat2 = lattices[i + 1];
lat3 = lattices[i - 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latDown.element.type == lat2.element.type &&
latDown.element.type == lat3.element.type) {
return [lat.element, latDown.element];
}
}
}
//与右交换,先确定col!=Tool.colNum-1,不是最右排元素8
if (col != Tool.colNum - 1) {
var latRight = lattices[i + 1];
//能交换,并且类型不一致
if (judgeFall(latRight) && lat.element.type != latRight.element.type) {
//判断向右,+2,+3 lat 先确定col<Tool.colNum - 3
if (col < Tool.colNum - 3) {
lat2 = lattices[i + 2];
lat3 = lattices[i + 3];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
//向左判断 -1 -2 latRight 先确定col>1
if (col > 1) {
lat2 = lattices[i - 1];
lat3 = lattices[i - 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
//右纵向判断下 *1+1 *2+1 lat
lat2 = lattices[i + Tool.colNum * 1 + 1];
lat3 = lattices[i + Tool.colNum * 2 + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//右纵向判断上 -*1+1 -*2+1 lat
lat2 = lattices[i - Tool.colNum * 1 + 1];
lat3 = lattices[i - Tool.colNum * 2 + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//右纵向中间 -*1 *1 lat
lat2 = lattices[i + Tool.colNum + 1];
lat3 = lattices[i - Tool.colNum + 1];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
lat.element.type == lat2.element.type &&
lat.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//
//左纵向判断下 *1 *2 latRight
lat2 = lattices[i + Tool.colNum * 1];
lat3 = lattices[i + Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//左纵向判断上 -*1 -*2 latRight
lat2 = lattices[i - Tool.colNum * 1];
lat3 = lattices[i - Tool.colNum * 2];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
//左纵向中间 *1 -*1 latRight
lat2 = lattices[i + Tool.colNum];
lat3 = lattices[i - Tool.colNum];
if (judgeMatch(lat2) &&
judgeMatch(lat3) &&
latRight.element.type == lat2.element.type &&
latRight.element.type == lat3.element.type) {
return [lat.element, latRight.element];
}
}
}
}
//检测特效的
for (var i = 0; i < effectElements.length; i++) {
var effectElement = effectElements[i];
//是魔力鸟,直接找周围元素,
if (effectElement.effectType == EffectType.MAGICLION) {
//上格子
var up = lattices[effectElement.index - Tool.colNum];
if (judgeFall(up) && up.element.type != ElementType.LOLLIPOP) return [effectElement, up.element];
//下格子
var down = lattices[effectElement.index + Tool.colNum];
if (judgeFall(down) && up.element.type != ElementType.LOLLIPOP) return [effectElement, down.element];
//左格子
var col = Tool.indexToRc(effectElement.index)[1];//列数
if (col != 0) {
var left = lattices[effectElement.index - 1];
if (judgeFall(left) && left.element.type != ElementType.LOLLIPOP) return [effectElement, left.element];
}
if (col != Tool.colNum - 1) {
var right = lattices[effectElement.index + 1];
if (judgeFall(right) && right.element.type != ElementType.LOLLIPOP) return [effectElement, right.element];
}
continue
}
//是普通特效,找周围是特效的
//上格子
var up = lattices[effectElement.index - Tool.colNum];
if (judgeFall(up) && up.element.effectType != null) return [effectElement, up.element];
//下格子
var down = lattices[effectElement.index + Tool.colNum];
if (judgeFall(down) && down.element.effectType != null) return [effectElement, down.element];
//左格子
var col = Tool.indexToRc(effectElement.index)[1];//列数
if (col != 0) {
var left = lattices[effectElement.index - 1];
if (judgeFall(left) && left.element.effectType != null) return [effectElement, left.element];
}
if (col != Tool.colNum) {
var right = lattices[effectElement.index + 1];
if (judgeFall(right) && right.element.effectType != null) return [effectElement, right.element];
}
}
return null
}
/**
* 将有相邻相同的组合,不是基础元素的,都会是单独的
* @param arr
*/
public static fn(arr: number[], lattices: Lattice[]) {
var result = [],
i = 0;
result[i] = [arr[0]];
arr.reduce(function (prev, cur) {
var latP = lattices[prev];
var latC = lattices[cur];
if (Tool.judgeMatch(latP) &&
Tool.judgeMatch(latC) &&
latP.element.type == latC.element.type) {
result[i].push(cur)
} else {
result[++i] = [cur];
}
// cur.type == prev.type ? result[i].push(cur) : result[++i] = [cur];
return cur;
});
return result;
}
/**
* 返回元素类别
* 元素初始化排列时,不能出现三消的情况
* @param index
*/
public static returnType(index: number, lattices: Lattice[], baseElementTypes: number[]) {
var rc = Tool.indexToRc(index);
var arr = baseElementTypes.slice();
//和左边两个比较
if (rc[1] > 1) {
//
var lat1 = lattices[index - 1];
var lat2 = lattices[index - 2];
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
}
//和上边两个比较
var lat1 = lattices[index - Tool.colNum];
var lat2 = lattices[index - Tool.colNum * 2];
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
return Tool.randomT(arr);
}
/**
* 从数组移除一个元素
......
......@@ -58,6 +58,7 @@ export class GuideMsg extends egret.DisplayObjectContainer {
if (this.moiveClip) this.removeChild(this.moiveClip);
//svga
if (moiveClip["guide" + num]) {
this.moiveClip = moiveClip["guide" + num];
this.addChild(moiveClip["guide" + num]);
callback();
} else {
......
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