Commit 1b766b54 authored by wjf's avatar wjf

l

parent e56185c5
......@@ -273,6 +273,17 @@ export default class MainScene extends Scene {
this.initLattices();
//初始化元素
this.initElement();
//重置基础元素类型及特效
this.initBaseElement();
//初始化完先检测死图
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//替换顺序
this.upsetElement();
}
else {
this.enableMouseEvt(true);
}
//设置栏置顶
this.addChild(this["settingAll"])
//如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞
......@@ -505,6 +516,7 @@ export default class MainScene extends Scene {
}
}
initElement() {
//没有就根据地图格子随机元素
var elements = this.chapterData.map.elements || Tool.setNumber01(this.chapterData.map.lattices.slice());
for (var i = 0; i < elements.length; i++) {
//如果对应格子为空,直接跳过,
......@@ -603,15 +615,31 @@ export default class MainScene extends Scene {
}
}
console.log(bbb);
//初始化完先检测死图
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//替换顺序
this.upsetElement();
}
else {
this.enableMouseEvt(true);
}
//重置基础元素及特效类型
initBaseElement() {
var elements = this.chapterData.map.baseElements;
if (!elements || !elements.length) return;
for (var i = 0; i < elements.length; i++) {
//不是基础元素,跳过,
if (!Tool.judgeBaseEle(this.lattices[i])) continue;
//是0,跳过
if (!elements[i]) continue
//解析elements[i];
var arr: number[] = Tool.returnTO(elements[i]);
//基础类型,没有就是null,有就-1,对ElementType对应
var baseType = arr[1] ? arr[1] - 1 : null;
//不是基础类型,跳出
if (baseType > 4) continue;
let ele: Element = this.lattices[i].element;
if (baseType != null) {
//重置类型
var isLock = ele.isLock;
ele.reset(baseType);
ele.isLock = isLock;
}
//特效类型
ele.effectType = arr[0] ? arr[0] - 1 : null;
}
}
......
......@@ -264,6 +264,25 @@ export class Tool {
}
}
/**
* 判断格子上是基础元素
* @param lat
*/
public static judgeBaseEle(lat: Lattice) {
//上方格子为null,或格子上元素为null
if (!lat || !lat.element) {
return false
}
//不是基础元素,元素类型枚举01234
else if (lat.element.type > 4) {
return false
}
//剩下情况
else {
return true
}
}
/**
* 判断元素是否可被手势选中和交换
* 主要点击元素判断使用
......@@ -490,7 +509,7 @@ export class Tool {
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];
if (judgeFall(down) && down.element.type != ElementType.LOLLIPOP) return [effectElement, down.element];
//左格子
var col = Tool.indexToRc(effectElement.index)[1];//列数
if (col != 0) {
......@@ -863,7 +882,7 @@ export class Tool {
}
return shuffled.slice(min);
}
public static getRandomArrayElementsEx(arr: any[], count: number):any[] {
public static getRandomArrayElementsEx(arr: any[], count: number): any[] {
//如果count大于等于数组长度,返回所有数组
if (arr.length <= count) return arr.slice();
if (count <= 0) return [];
......
......@@ -171,7 +171,7 @@ export class Element extends eui.Component {
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
//特殊逻辑,因为魔力鸟动效要旋转,所以隐藏原图showImage
//特殊逻辑,因为魔力鸟动效要旋转,所以隐藏原图showImage,还有鸡蛋
if (source == "magicLion_png" || source == "ele9_png") {
this.showImage.alpha = 0;
} else {
......@@ -179,6 +179,10 @@ export class Element extends eui.Component {
}
}
/**
* 会重置掉所有特效类型,枷锁,鸡蛋等
* @param type
*/
reset(type: ElementType) {
this.alpha = this.scaleX = this.scaleY = 1;
//类型重置,showImage修改
......@@ -199,7 +203,7 @@ export class Element extends eui.Component {
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();
......
......@@ -16,6 +16,17 @@ export enum ElementType {
JELLY,//果冻8
CHICKEN_EGG,//鸡蛋9
}
var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0,
0, 20, 20, 0, 40, 0, 50, 50, 0,
0, 30, 50, 0, 3, 0, 20, 30, 0,
0, 10, 0, 0, 0, 0, 0, 20, 0,
0, 50, 40, 0, 0, 0, 10, 30, 0,
30, 10, 30, 50, 0, 40, 50, 50, 20,
0, 50, 40, 30, 50, 20, 10, 40, 0,
0, 0, 10, 10, 3, 30, 50, 0, 0,
0, 0, 0, 30, 50, 40, 0, 0, 0,
]
export const codeMsgs = {
"E1002090011": "用户关卡记录异常",
"E1002090012": "暂不能挑战此关卡",
......
......@@ -34,7 +34,18 @@ export interface MapData {
* 5果冻
* 6鸡蛋
*/
elements?:number[]
elements?:number[];
/**
* 9*9的格子
* 十位是基础元素类型,对应数字减1就是基础元素类型
* 个位是特效类型(0表示无特效),对应数字减1就是特效类型
* 10
* 11
* 12
* 13
* 14
*/
baseElements?:number[];
/**
* 路径的索引
* 暂时不需要了
......
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