Commit 357b195f authored by wjf's avatar wjf

l

parent 56df4c40
...@@ -63,6 +63,7 @@ import { HairballBrownState } from '../something/states/HairballBrownState'; ...@@ -63,6 +63,7 @@ import { HairballBrownState } from '../something/states/HairballBrownState';
import { EleDownAni } from '../something/anis/EleDownAni'; import { EleDownAni } from '../something/anis/EleDownAni';
import { GameGuide } from '../something/uis/GameGuide'; import { GameGuide } from '../something/uis/GameGuide';
import { PropBtnCon } from '../something/uis/PropBtnCon'; import { PropBtnCon } from '../something/uis/PropBtnCon';
import { ChapterNum } from '../something/uis/ChapterNum';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -304,6 +305,12 @@ export default class MainScene extends Scene { ...@@ -304,6 +305,12 @@ export default class MainScene extends Scene {
} }
//初始化界面ui,,道具弄在这里s //初始化界面ui,,道具弄在这里s
initUi() { initUi() {
//第几关
var chapterTxt = new ChapterNum();
chapterTxt.num = this.chapter >> 0;
chapterTxt.x = 122;
chapterTxt.y = 148
this.addChild(chapterTxt)
//步数 //步数
this.stepNumber = new StepNumber(); this.stepNumber = new StepNumber();
this.stepNumber.x = 123; this.stepNumber.x = 123;
...@@ -1888,8 +1895,10 @@ export default class MainScene extends Scene { ...@@ -1888,8 +1895,10 @@ export default class MainScene extends Scene {
this.magicRotateData = [rotateData]; this.magicRotateData = [rotateData];
for (var i = 0; i < this.lattices.length; i++) { for (var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i]; var lat = this.lattices[i];
if (Tool.judgeMatch(lat) && if (Tool.judgeBaseEle(lat) && //是基础元素
lat.element.type == other.type) { lat.element.effectType != EffectType.MAGICLION && //不能是魔力鸟特效
lat.element.type == other.type //类型相等
) {
//一个魔力鸟时其实不用加,因为石头或果冻的不会进入判断 //一个魔力鸟时其实不用加,因为石头或果冻的不会进入判断
if (this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i); if (this.eliminatedElements.indexOf(i) == -1) this.eliminatedElements.push(i);
//如果other带特效,符合的元素都加上特效,没动效,直接加吧先, //如果other带特效,符合的元素都加上特效,没动效,直接加吧先,
...@@ -2146,8 +2155,10 @@ export default class MainScene extends Scene { ...@@ -2146,8 +2155,10 @@ export default class MainScene extends Scene {
this.magicRotateData.push(rotateData); this.magicRotateData.push(rotateData);
//对于魔力鸟的效果有不一样的,旋转,该组元素要旋转消除 //对于魔力鸟的效果有不一样的,旋转,该组元素要旋转消除
for (var i = 0; i < this.lattices.length; i++) { for (var i = 0; i < this.lattices.length; i++) {
if (Tool.judgeMatch(this.lattices[i]) && if (Tool.judgeBaseEle(this.lattices[i]) && //是基础元素
this.lattices[i].element.type == type) { this.lattices[i].element.effectType != EffectType.MAGICLION && //不是魔力鸟
this.lattices[i].element.type == type //类型相等
) {
if (this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) { if (this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
this.eliminatedElements.push(i); this.eliminatedElements.push(i);
//无特效未枷锁,无毛球的参与旋转 //无特效未枷锁,无毛球的参与旋转
......
...@@ -269,11 +269,14 @@ export class Tool { ...@@ -269,11 +269,14 @@ export class Tool {
if (!lat || !lat.element) { if (!lat || !lat.element) {
return false return false
} }
//上方元素为石头,或元素为锁定,或者是果冻,或者鸡蛋 //上方元素为石头,或元素为锁定,或者是果冻,或者鸡蛋,或者大小节日元素
else if (lat.element.type == ElementType.ROCK || else if (lat.element.type == ElementType.ROCK ||
lat.element.hasState(StateType.LOCK) || lat.element.hasState(StateType.LOCK) ||
lat.element.type == ElementType.JELLY || lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG) { lat.element.type == ElementType.CHICKEN_EGG ||
lat.element.type == ElementType.FESTIVALELE_BIG ||
lat.element.type == ElementType.FESTIVALELE_SMALL
) {
return false return false
} }
//剩下情况 //剩下情况
...@@ -299,35 +302,25 @@ export class Tool { ...@@ -299,35 +302,25 @@ export class Tool {
} }
/** /**
* 判断格子是否可进行匹配, * 判断格子是否可进行匹配,只有基础5种元素才能参与匹配
* 不包括魔力鸟,不包括毛球的 * 不包括魔力鸟,不包括毛球的
* 包括笼子里的 * 包括笼子里的
* @param lat * @param lat
*/ */
public static judgeMatch(lat: Lattice) { public static judgeMatch(lat: Lattice) {
//上方格子为null,或格子上元素为null if (Tool.judgeBaseEle(lat) && //是基础元素
if (!lat || !lat.element) { lat.element.effectType != EffectType.MAGICLION && //特效不为魔力鸟
return false !lat.element.hasState(StateType.HAIRBALLGREY) && //不带毛球, 下同
} !lat.element.hasState(StateType.HAIRBALLBLACK) &&
//上方元素为石头,或为冰淇淋,或为魔力鸟,或为果冻,或为鸡蛋,或有毛球 !lat.element.hasState(StateType.HAIRBALLBROWN)
else if (lat.element.type == ElementType.ROCK || ) {
lat.element.type == ElementType.LOLLIPOP ||
lat.element.effectType == EffectType.MAGICLION ||
lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG ||
lat.element.hasState(StateType.HAIRBALLGREY) ||
lat.element.hasState(StateType.HAIRBALLBLACK) ||
lat.element.hasState(StateType.HAIRBALLBROWN)) {
return false
}
//剩下情况
else {
return true return true
} }
return false
} }
/** /**
* 判断能执行消除的元素, * 判断能执行消除的元素,
* 包括所有特效和基本元素,石头,果冻,鸡蛋,各种状态的 * 包括所有特效和基本元素,石头,果冻,鸡蛋,节日元素,各种状态的
* @param lat * @param lat
*/ */
public static judgeEliminate(lat: Lattice) { public static judgeEliminate(lat: Lattice) {
...@@ -358,7 +351,6 @@ export class Tool { ...@@ -358,7 +351,6 @@ export class Tool {
return true return true
} }
return false return false
} }
/** /**
...@@ -366,9 +358,9 @@ export class Tool { ...@@ -366,9 +358,9 @@ export class Tool {
* @param lat 格子 * @param lat 格子
*/ */
public static judgeUpsetMove(lat: Lattice) { public static judgeUpsetMove(lat: Lattice) {
if (Tool.judgeBaseEle(lat) && if (Tool.judgeBaseEle(lat) && //基础元素
!lat.element.hasState(StateType.LOCK) && !lat.element.hasState(StateType.LOCK) && //不带锁
!lat.element.hasState(StateType.HAIRBALLGREY) && !lat.element.hasState(StateType.HAIRBALLGREY) && //不带毛球,下同
!lat.element.hasState(StateType.HAIRBALLBLACK) && !lat.element.hasState(StateType.HAIRBALLBLACK) &&
!lat.element.hasState(StateType.HAIRBALLBROWN) !lat.element.hasState(StateType.HAIRBALLBROWN)
) { ) {
...@@ -392,7 +384,9 @@ export class Tool { ...@@ -392,7 +384,9 @@ export class Tool {
ele.hasState(StateType.HAIRBALLBLACK) || ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN) || ele.hasState(StateType.HAIRBALLBROWN) ||
ele.type == ElementType.JELLY || ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.FESTIVALELE_BIG ||
ele.type == ElementType.FESTIVALELE_SMALL
) { ) {
return false; return false;
} }
...@@ -400,7 +394,7 @@ export class Tool { ...@@ -400,7 +394,7 @@ export class Tool {
} }
/** /**
* 是否要算分数 * 是否要算分数
* 排除元素 石头,鸡蛋,果冻, * 排除元素 石头,鸡蛋,果冻,节日元素
* 排除状态 枷锁,毛球,因为存在时,元素不会消除 * 排除状态 枷锁,毛球,因为存在时,元素不会消除
* @param ele 元素 * @param ele 元素
*/ */
...@@ -410,6 +404,8 @@ export class Tool { ...@@ -410,6 +404,8 @@ export class Tool {
ele.type == ElementType.JELLY || ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG || ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.LOLLIPOP || ele.type == ElementType.LOLLIPOP ||
ele.type == ElementType.FESTIVALELE_BIG ||
ele.type == ElementType.FESTIVALELE_SMALL ||
ele.hasState(StateType.LOCK) || ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALLGREY) || ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) || ele.hasState(StateType.HAIRBALLBLACK) ||
...@@ -420,7 +416,7 @@ export class Tool { ...@@ -420,7 +416,7 @@ export class Tool {
return true return true
} }
/** /**
* 判断能否参与魔力鸟旋转的元素 * 判断能否参与魔力鸟旋转的元素,不判断基础元素,因为这方法前必加判断
* 无特效,无锁,无毛球, * 无特效,无锁,无毛球,
* @param ele 元素 * @param ele 元素
*/ */
......
import { BitmapNumber } from "../class/BitmapNumber";
import { Tool } from "../Tool";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
/**
* 位图数字 目标元素数量
* 不管多少位,都按中间数字居中
* 暂不做通用,以后再说,否则回收问题
*/
export class ChapterNum extends egret.DisplayObjectContainer {
/**
* 数字
*/
private _num: number;
get num(): number {
return this._num
}
set num(value: number) {
if (value == this._num) return;
this._num = value;
var arr = Tool.returnTO(value);
//位数从小到大add,
for (var i = 0; i < arr.length; i++) {
if (this.$children[i]) {
//先用完原先$children里的,不通用就没必要修改resName
this.$children[i]["num"] = arr[i];
} else {
//如果没有就
let o: BitmapNumber = Pool.takeOut(RecoverName.BITMAP_NUMBER);
if (!o) {
o = new BitmapNumber("propNum");
} else {
o.reset("propNum")
}
o.num = arr[i];
this.addChild(o)
}
}
//如果多了,去掉后面的,回收
if (this.$children.length > arr.length) {
//移除后序
for (var i = this.$children.length - 1; i >= arr.length; i--) {
let c = this.$children[i];
this.removeChild(c);
Pool.recover(RecoverName.BITMAP_NUMBER, c);
}
}
//居中适配
this.center()
}
constructor() {
super();
this.num = 0;
}
/**
* 居中位置
*/
center() {
//按顺序排,从右到左,
var len = this.$children.length;
var w = this.$children[0]["texture"].textureWidth-2;
var right = len / 2 * w - w;
for (var i = 0; i < this.$children.length; i++) {
this.$children[i].x = right - w * i;
}
}
}
\ No newline at end of file
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