Commit 670ab98a authored by wjf's avatar wjf

l

parent 476d415d
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"common","version":5,"files":["../assets/common/toast.png","../assets/common/closeCommonBtn.png","../assets/common/btn.png","../assets/common/alertbg.png","../assets/common/按钮 副本 4.png","../assets/common/按钮 副本 3.png","../assets/common/share_btn2.png","../assets/common/share_btn1.png","../assets/common/commmon_okbtn1.png","../assets/common/lightani.png"]}
{"options":{"layoutMath":"2","sizeMode":"2n","useExtension":1,"layoutGap":1,"extend":0},"projectName":"common","version":5,"files":["..\\assets\\common\\toast.png","..\\assets\\common\\closeCommonBtn.png","..\\assets\\common\\btn.png","..\\assets\\common\\alertbg.png","..\\assets\\common\\按钮 副本 4.png","..\\assets\\common\\按钮 副本 3.png","..\\assets\\common\\share_btn2.png","..\\assets\\common\\share_btn1.png","..\\assets\\common\\commmon_okbtn1.png","..\\assets\\common\\lightani.png"]}
\ No newline at end of file
This diff is collapsed.
......@@ -1018,13 +1018,10 @@ export default class MainScene extends Scene {
* @param callback 所有fall完成后的回调,检查三消,
*/
fall(callback: Function) {
//记录一个对象和位置信息[obj,index]的数组,如果obj是null则生成,index位置上方
// var anis = [];
//排序从小到大
// emptys.sort(function (a, b) { return a > b ? 1 : -1 })
//先找完竖直的,
//去重一次
Tool.removeReapty(this.emptys);
//注释里的备用
var anis = this.fallVertical();
//然后找斜落得
anis = anis.concat(this.fallSkew());
if (!anis.length) {
//如果没有能掉落的就直接回调
......@@ -1079,55 +1076,6 @@ export default class MainScene extends Scene {
}
return anis;
}
private fallVertical1() {
var verticalAnis = []
//先把竖直的掉落完,掉满后
for (var m = 0; m < Tool.colNum; m++) {
//同一列
for (var n = Tool.rowNum - 1; n >= 0; n--) {
var index = Tool.rcToIndex(n, m);
let lat = this.lattices[index];
if (Tool.judgeFall(lat)) {
var emptyIndex = Tool.findBottom(lat, this.emptys, this.lattices)
if (emptyIndex != null) {
verticalAnis.push([lat.element, this.emptys[emptyIndex]]);
//去掉一个
this.emptys.splice(emptyIndex, 1);
//加上一个
this.emptys.push(index);
lat.element = null
}
//找最下面的那个空格
var latDown, indexDown;
if (lat.down != null) {
latDown = this.lattices[lat.down];
indexDown = lat.down;
} else {
latDown = this.lattices[index + Tool.colNum]
indexDown = index + Tool.colNum;
}
//下方有格子,并且再this.empty中
var emptyIndex = this.emptys.indexOf(indexDown)
if (emptyIndex > -1) {
verticalAnis.push([lat.element, indexDown]);
//去掉一个
this.emptys.splice(emptyIndex, 1);
//加上一个
this.emptys.push(index);
lat.element = null
}
} else {
//如果有格子。无元素,是生成口
if (lat && !lat.element && lat.isGenerate) {
verticalAnis.push([null, index]);
Tool.removeEle(index, this.emptys)
}
}
}
}
return verticalAnis;
}
private fallSkew() {
//记录一个对象和位置信息[obj,index]的数组,如果obj是null则生成,index位置上方
......@@ -1240,7 +1188,7 @@ export default class MainScene extends Scene {
obj.fallAni()
//执行Tween
egret.Tween.get(obj)
.to({ x: position[0], y: position[1] }, 180/*, egret.Ease.cubicOut*/)
.to({ x: position[0], y: position[1] }, 100/*, egret.Ease.cubicOut*/)
.call(() => {
obj.x = position[0];
obj.y = position[1];
......@@ -1263,7 +1211,6 @@ export default class MainScene extends Scene {
}
}
/**
* 只关心交换后元素的可消除
* 或者冰淇淋的掉落
......
......@@ -4,6 +4,8 @@ import { Lattice } from "./class/Lattice";
import { ElementType } from "./enum/ElementType";
import { PassType } from "./enum/PassType";
import { EffectType } from "./enum/EffectType";
import { Pool } from "./Pool";
import { RecoverName } from "./enum/RecoverName";
export class Tool {
public static rowNum = 9;
......@@ -585,6 +587,34 @@ export class Tool {
return e && "number" == typeof e.length && e.length ? e[Math.floor(Math.random() * e.length)] : ("number" != typeof n && (n = e || 1, e = 0), e + Math.random() * (n - e))
}
/**
* 数字数组去重
*/
public static removeReapty(arr: number[]) {
var obj = {};
for (var i = arr.length - 1; i >= 0; i--) {
if (obj[arr[i]]) {
//有出现的的,去掉
arr.splice(i, 1)
} else {
obj[arr[i]] = true
}
}
}
/**
* 获得元素
* @param type
*/
public static getElement(type: ElementType) {
let obj = Pool.takeOut(RecoverName.ELEMENT);
if (!obj) {
obj = new Element(type)
} else {
obj.reset(type)
}
return obj
}
/**
* 返回个十百等,0是个位
* 78[ 8, 7]
......
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