Commit 7cb8086f authored by 邱旭's avatar 邱旭

Merge branch 'dev' of http://gitlab2.dui88.com/wanghongyuan/xiaoxiaole into dev

parents 937553a1 043dfd8f
...@@ -59,8 +59,9 @@ import { EleMaskAni } from '../something/anis/EleMaskAni'; ...@@ -59,8 +59,9 @@ import { EleMaskAni } from '../something/anis/EleMaskAni';
import { getChapterData } from '../something/chapters/getChapter'; import { getChapterData } from '../something/chapters/getChapter';
import { GenerateLatData } from '../something/interface/GenerateLatData'; import { GenerateLatData } from '../something/interface/GenerateLatData';
import { StateType } from '../something/enum/StateType'; import { StateType } from '../something/enum/StateType';
import { HairballState } from '../something/states/HairballState'; import { HairballBlackState } from '../something/states/HairballBlackState';
import { HairballDisAni } from '../something/anis/HairballDisAni'; import { HairballGreyDisAni } from '../something/anis/HairballGreyDisAni';
import { HairballBrownState } from '../something/states/HairballBrownState';
const aniClass = { const aniClass = {
"BoomAni": BoomAni, "BoomAni": BoomAni,
...@@ -75,7 +76,7 @@ const aniClass = { ...@@ -75,7 +76,7 @@ const aniClass = {
"StepAni": StepAni, "StepAni": StepAni,
"JellyDisAni": JellyDisAni, "JellyDisAni": JellyDisAni,
"EggBrokenAni": EggBrokenAni, "EggBrokenAni": EggBrokenAni,
"HairballDisAni": HairballDisAni, "HairballGreyDisAni": HairballGreyDisAni,
} }
export const baseScore = 20; export const baseScore = 20;
/** /**
...@@ -150,7 +151,7 @@ export default class MainScene extends Scene { ...@@ -150,7 +151,7 @@ export default class MainScene extends Scene {
hasPassed: boolean = false; hasPassed: boolean = false;
//是否结算时间 //是否结算时间
isCountingTime: boolean = false; isCountingTime: boolean = false;
//通关的目标元素的计数,下标和元素类型索引一致 //通关的目标元素的计数,下标和元素类型ElementType枚举一致
passElements: number[]; passElements: number[];
elementTargets: ElementTargets; elementTargets: ElementTargets;
//所有元素的消耗数量,需要传给后端 //所有元素的消耗数量,需要传给后端
...@@ -224,8 +225,8 @@ export default class MainScene extends Scene { ...@@ -224,8 +225,8 @@ export default class MainScene extends Scene {
this.chapterTxt.text = "第" + this.chapter + "关"; this.chapterTxt.text = "第" + this.chapter + "关";
//关卡数据 //关卡数据
this.chapterData = getChapterData(this.chapter) this.chapterData = getChapterData(this.chapter)
//初始化索引信息,暂时不做判断列数的奇偶,如需,要修改的地方再考虑,还有道具使用的蒙层是否要改 //初始化索引信息,包括10*10的,
Tool.init(/*Tool.getColOddEven(this.chapterData.map.lattices)*/); Tool.init(Tool.getColOddEven(this.chapterData.map.lattices));
this.initUi(); this.initUi();
this.initSvgas(); this.initSvgas();
//先禁掉事件 //先禁掉事件
...@@ -464,8 +465,8 @@ export default class MainScene extends Scene { ...@@ -464,8 +465,8 @@ export default class MainScene extends Scene {
} }
this.map.addChild(ice); this.map.addChild(ice);
this.lattices[i].ice = ice; this.lattices[i].ice = ice;
ice.x = p[0] - 80 / 2; ice.x = p[0];
ice.y = p[1] - 81 / 2; ice.y = p[1];
} }
} }
//设置生成口, //设置生成口,
...@@ -1456,6 +1457,8 @@ export default class MainScene extends Scene { ...@@ -1456,6 +1457,8 @@ export default class MainScene extends Scene {
/** /**
* 只关心交换后元素的可消除 * 只关心交换后元素的可消除
* 或者冰淇淋的掉落 * 或者冰淇淋的掉落
* 逻辑以后待加,
* 该方法只针对手动触发的消除,包括特效组合,手动三消的,可以另写方法,并重新修改鸡蛋,石头,果冻,毛球逻辑
*/ */
simpleMatch(s: Element, o: Element) { simpleMatch(s: Element, o: Element) {
//先判断两个都是特效 //先判断两个都是特效
...@@ -1810,10 +1813,8 @@ export default class MainScene extends Scene { ...@@ -1810,10 +1813,8 @@ export default class MainScene extends Scene {
lat.element.effectType = Math.random() > 0.5 ? EffectType.HORIZONTAL : EffectType.VERTICAL; lat.element.effectType = Math.random() > 0.5 ? EffectType.HORIZONTAL : EffectType.VERTICAL;
} }
} else { } else {
//普通元素的旋转消除,无特效,无锁 //普通元素的旋转消除,无特效,无锁,无毛球
if (!lat.element.hasState(StateType.LOCK) && if (Tool.judgeMagicRotate(lat.element)) {
!lat.element.hasState(StateType.HAIRBALL) &&
lat.element.effectType == null) {
rotateData.elementsIndex.push(i); rotateData.elementsIndex.push(i);
} }
} }
...@@ -1919,7 +1920,7 @@ export default class MainScene extends Scene { ...@@ -1919,7 +1920,7 @@ export default class MainScene extends Scene {
} }
/** /**
* 普通元素消除,先消除无特效的,有特效的存下,然后触发,找下一步消除的元素 * 普通元素消除,先消除无特效的,有特效的存下,然后触发,找下一步消除的元素
* 加入石头,果冻,鸡蛋 * 加入石头,果冻,鸡蛋,各种状态
*/ */
commonEliminate(): number[] { commonEliminate(): number[] {
playSound(SoundType.eliminate) playSound(SoundType.eliminate)
...@@ -1934,28 +1935,32 @@ export default class MainScene extends Scene { ...@@ -1934,28 +1935,32 @@ export default class MainScene extends Scene {
if (!ele) { if (!ele) {
//以防万一还是判断一次 //以防万一还是判断一次
} }
//下面带状态的要优先判断
//有枷锁的 //有枷锁的
else if (ele.hasState(StateType.LOCK)) { else if (ele.hasState(StateType.LOCK)) {
//被禁锢的解开 //被禁锢的解开
ele.setState(StateType.LOCK, false); ele.setState(StateType.LOCK, false);
} //暂时笼子不算个数,算的话,改图片名称,列入ElementType的状态下
//有毛球的 }
else if (ele.hasState(StateType.HAIRBALL)) { //有褐色毛球的,记录分裂激活
else if (ele.hasState(StateType.HAIRBALLBROWN)) {
var hairballState: HairballState = ele.getState(StateType.HAIRBALL); var hairballBrownState: HairballBrownState = ele.getState(StateType.HAIRBALLBROWN);
//二级毛球的记录需要分裂isActive hairballBrownState.isActive = true;
if (hairballState.levelNum == 2) { //算个数,不能在这里算,得在分裂时算
hairballState.isActive = true; // this.goElementTarget(ElementType.HAIRBALLBROWN, [ele.x, ele.y]);
} }
//一级的直接消失 //有灰色毛球的,消失
else { else if (ele.hasState(StateType.HAIRBALLGREY)) {
//播放毛球消失动画 //播放毛球消失动画
this.playAni(RecoverName.HAIRBALLDIS_ANI, p) this.playAni(RecoverName.HAIRBALLGREYDIS_ANI, p)
//设为无毛球 //设为无毛球
ele.setState(StateType.HAIRBALL, false) ele.setState(StateType.HAIRBALLGREY, false)
//算个数 //算个数
this.goElementTarget(ele.getState(StateType.HAIRBALL)); this.goElementTarget(ElementType.HAIRBALLGREY, [ele.x, ele.y]);
} }
//有黑色毛球的,一次眩晕,两次消失
else if (ele.hasState(StateType.HAIRBALLGREY)) {
//逻辑待写,参照上面
} }
//如果有特效,存下 //如果有特效,存下
else if (ele.effectType != null) { else if (ele.effectType != null) {
...@@ -1970,26 +1975,27 @@ export default class MainScene extends Scene { ...@@ -1970,26 +1975,27 @@ export default class MainScene extends Scene {
ele.setState(StateType.BUBBLE, false) ele.setState(StateType.BUBBLE, false)
} }
//但是算个数, //但是算个数,
this.goElementTarget(ele); this.goElementTarget(ele.type, [ele.x, ele.y]);
//附近依旧有影响 //附近依旧有影响
this.checkNebAll(this.lattices[index]) this.checkNebAll(this.lattices[index])
} else { } else {
//单纯元素消失特效 //单纯元素消失特效
if (ele.type <= 4) { if (ele.type <= 4) {
this.playAni(RecoverName.ELEDIS_ANI, p) this.playAni(RecoverName.ELEDIS_ANI, p)
//这里面会去算个数
this.recoverEle(index) this.recoverEle(index)
} }
//石头 //石头
else if (ele.type == ElementType.ROCK) { else if (ele.type == ElementType.ROCK) {
this.removeRock(index); this.removeRock(index);
//算个数 //算个数
this.goElementTarget(ele); this.goElementTarget(ele.type, [ele.x, ele.y]);
} }
//果冻 //果冻
else if (ele.type == ElementType.JELLY) { else if (ele.type == ElementType.JELLY) {
this.removeJelly(index); this.removeJelly(index);
//算个数 //算个数
this.goElementTarget(ele); this.goElementTarget(ele.type, [ele.x, ele.y]);
} }
//鸡蛋 //鸡蛋
else if (ele.type == ElementType.CHICKEN_EGG) { else if (ele.type == ElementType.CHICKEN_EGG) {
...@@ -2044,13 +2050,11 @@ export default class MainScene extends Scene { ...@@ -2044,13 +2050,11 @@ export default class MainScene extends Scene {
this.lattices[i].element.type == type) { 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);
//无特效未枷锁 //无特效未枷锁,无毛球的参与旋转
if (!this.lattices[i].element.hasState(StateType.LOCK) && if (Tool.judgeMagicRotate(this.lattices[i].element)) {
!this.lattices[i].element.hasState(StateType.HAIRBALL) &&
this.lattices[i].element.effectType == null) {
rotateData.elementsIndex.push(i); rotateData.elementsIndex.push(i);
} }
// //加分
if (Tool.judgeHasScore(this.lattices[i].element)) { if (Tool.judgeHasScore(this.lattices[i].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["3"], Tool.getPositionByIndex(i)) this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["3"], Tool.getPositionByIndex(i))
} }
...@@ -2070,7 +2074,7 @@ export default class MainScene extends Scene { ...@@ -2070,7 +2074,7 @@ export default class MainScene extends Scene {
(Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2)) { (Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2)) {
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);
// //加分
if (Tool.judgeHasScore(this.lattices[i].element)) { if (Tool.judgeHasScore(this.lattices[i].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["2"], Tool.getPositionByIndex(i)) this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["2"], Tool.getPositionByIndex(i))
} }
...@@ -2089,7 +2093,7 @@ export default class MainScene extends Scene { ...@@ -2089,7 +2093,7 @@ export default class MainScene extends Scene {
if (Tool.judgeEliminate(this.lattices[ein])) { if (Tool.judgeEliminate(this.lattices[ein])) {
if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) { if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) {
this.eliminatedElements.push(ein); this.eliminatedElements.push(ein);
// //加分
if (Tool.judgeHasScore(this.lattices[ein].element)) { if (Tool.judgeHasScore(this.lattices[ein].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["0"], Tool.getPositionByIndex(ein)) this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["0"], Tool.getPositionByIndex(ein))
} }
...@@ -2108,7 +2112,7 @@ export default class MainScene extends Scene { ...@@ -2108,7 +2112,7 @@ export default class MainScene extends Scene {
if (Tool.judgeEliminate(this.lattices[ein])) { if (Tool.judgeEliminate(this.lattices[ein])) {
if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) { if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) {
this.eliminatedElements.push(ein); this.eliminatedElements.push(ein);
// //加分
if (Tool.judgeHasScore(this.lattices[ein].element)) { if (Tool.judgeHasScore(this.lattices[ein].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["1"], Tool.getPositionByIndex(ein)) this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["1"], Tool.getPositionByIndex(ein))
} }
...@@ -2270,11 +2274,7 @@ export default class MainScene extends Scene { ...@@ -2270,11 +2274,7 @@ export default class MainScene extends Scene {
var anis = [];//两个,0下标是元素,1下标是索引 var anis = [];//两个,0下标是元素,1下标是索引
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.judgeBaseEle(lat) && if (Tool.judgeUpsetMove(lat)) lats.push(lat);
!lat.element.hasState(StateType.LOCK) &&
!lat.element.hasState(StateType.HAIRBALL)) {
lats.push(lat)
}
} }
//不改变的 //不改变的
var latsCopy = lats.slice(); var latsCopy = lats.slice();
...@@ -2340,7 +2340,7 @@ export default class MainScene extends Scene { ...@@ -2340,7 +2340,7 @@ export default class MainScene extends Scene {
//棒棒糖消除不产生任何其他效果 //棒棒糖消除不产生任何其他效果
if (ele.type != ElementType.LOLLIPOP) this.checkNebAll(this.lattices[index]); if (ele.type != ElementType.LOLLIPOP) this.checkNebAll(this.lattices[index]);
//计算元素消除个数 //计算元素消除个数
this.goElementTarget(ele); this.goElementTarget(ele.type, [ele.x, ele.y]);
} }
/** /**
...@@ -2460,13 +2460,12 @@ export default class MainScene extends Scene { ...@@ -2460,13 +2460,12 @@ export default class MainScene extends Scene {
if (lat && lat.ice) { if (lat && lat.ice) {
var ice = lat.ice; var ice = lat.ice;
ice.countNum--; ice.countNum--;
let fun;
if (ice.countNum == 0) { if (ice.countNum == 0) {
this.map.removeChild(ice); this.map.removeChild(ice);
//回收 //回收
Pool.recover(RecoverName.ICE, ice); Pool.recover(RecoverName.ICE, ice);
lat.ice = null; lat.ice = null;
this.goElementTarget(ice); this.goElementTarget(ElementType.ICE, [ice.x, ice.y]);
} else { } else {
ice.alpha = 0.6; ice.alpha = 0.6;
} }
...@@ -2477,22 +2476,13 @@ export default class MainScene extends Scene { ...@@ -2477,22 +2476,13 @@ export default class MainScene extends Scene {
} }
goElementTarget(ele: Element | Ice | HairballState) { goElementTarget(type: ElementType, fromP: number[]) {
if (!this.passElements) return if (!this.passElements) return
var type: number;
if (ele instanceof Ice) {
type = ElementType.ICE;
}
else if (ele instanceof HairballState) {
type = ElementType.HAIRBALL;
} else {
type = ele.type;
}
if (this.passElements[type] != undefined) { if (this.passElements[type] != undefined) {
if (this.passElements[type] != 0) { if (this.passElements[type] != 0) {
this.passElements[type]--; this.passElements[type]--;
var p = this.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8) var p = this.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8)
FlyTargetAni(ele, [p.x, p.y], this) FlyTargetAni(type, fromP, [p.x, p.y], this);
} }
//数量增加 //数量增加
this.hasEliminatedElements[type]++; this.hasEliminatedElements[type]++;
...@@ -2537,9 +2527,13 @@ export default class MainScene extends Scene { ...@@ -2537,9 +2527,13 @@ export default class MainScene extends Scene {
this.checkNebEle(latttice, (lat) => { this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.CHICKEN_EGG return lat && lat.element && lat.element.type == ElementType.CHICKEN_EGG
}); });
//如果附近有毛球 //如果附近有灰色毛球
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.hasState(StateType.HAIRBALLGREY)
});
//如果附近有黑色毛球
this.checkNebEle(latttice, (lat) => { this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.hasState(StateType.HAIRBALL) return lat && lat.element && lat.element.hasState(StateType.HAIRBALLBLACK)
}); });
} }
/** /**
......
...@@ -176,7 +176,7 @@ export class PropGuideInt extends egret.DisplayObjectContainer { ...@@ -176,7 +176,7 @@ export class PropGuideInt extends egret.DisplayObjectContainer {
if (Tool.judgeEliminate(lat) && (lat.row == rc[0] || lat.column == rc[1])) { if (Tool.judgeEliminate(lat) && (lat.row == rc[0] || lat.column == rc[1])) {
if (this.thisObj.eliminatedElements.indexOf(i) == -1) { if (this.thisObj.eliminatedElements.indexOf(i) == -1) {
this.thisObj.eliminatedElements.push(i); this.thisObj.eliminatedElements.push(i);
if (!lat.element.hasState(StateType.LOCK) && !lat.element.hasState(StateType.HAIRBALL)) { if (Tool.judgeHasScore(lat.element)) {
//算直线+直线LL //算直线+直线LL
this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i)) this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i))
} }
......
...@@ -26,8 +26,8 @@ export class Tool { ...@@ -26,8 +26,8 @@ export class Tool {
* 格子高度 * 格子高度
*/ */
public static height = 80// 81.5; public static height = 80// 81.5;
//整体偏移X //整体偏移X,为了下面初始化,这里不定义数值
public static offsetX = 15// 8.25; public static offsetX //= 15// 8.25;
//整体偏移Y //整体偏移Y
public static offsetY = 275 //260; public static offsetY = 275 //260;
/** /**
...@@ -56,11 +56,18 @@ export class Tool { ...@@ -56,11 +56,18 @@ export class Tool {
* 索引位置 * 索引位置
*/ */
private static indexPositions: number[][] = []; private static indexPositions: number[][] = [];
//给出10*10
private static indexToRcMap10: number[][] = [];
private static indexPositions10: number[][] = [];
/** /**
* 初始化数据 * 初始化数据
*/ */
public static init(isTwo: boolean = false) { public static init(isTwo: boolean = false) {
this.offsetX = isTwo ? 55 : 15// 49 : 8.25 var ooox = isTwo ? 55 : 15;// 49 : 8.25
//相等的就return,没必要每关都算一次,暂时只有x轴偏移有可能改变
if (this.offsetX == ooox) return;
this.offsetX = ooox;
//都是9*9 //都是9*9
//位置信息 //位置信息
var spaceX = this.width, var spaceX = this.width,
...@@ -77,11 +84,17 @@ export class Tool { ...@@ -77,11 +84,17 @@ export class Tool {
} }
//10*10的格子位置信息 //10*10的格子位置信息
// for (var i = 0; i < this.rowNum + 1; i++) { var rowNum = Tool.rowNum + 1;
// for (var j = 0; j < this.colNum + 1; j++) { var colNum = Tool.colNum + 1;
var offsetX = Tool.offsetX
// } var offsetY = Tool.offsetY
// } for (var i = 0; i < rowNum; i++) {
for (var j = 0; j < colNum; j++) {
// rcToIndexMap["" + i + j] = i * colNum + j;
this.indexToRcMap10[i * colNum + j] = [i, j];
this.indexPositions10[i * colNum + j] = [offsetX + j * Tool.width, offsetY + i * Tool.height];
}
}
} }
/** /**
* row和col获得index值 * row和col获得index值
...@@ -118,6 +131,13 @@ export class Tool { ...@@ -118,6 +131,13 @@ export class Tool {
return this.indexPositions[index] return this.indexPositions[index]
} }
public static indexToRc10(index: number): number[] {
return this.indexToRcMap10[index]
}
public static getPositionByIndex10(index: number): number[] {
return this.indexPositions10[index]
}
/** /**
* 根据9*9格子得到中间列数的奇偶性 * 根据9*9格子得到中间列数的奇偶性
* 其实只是要知道左右两边空的列数 * 其实只是要知道左右两边空的列数
...@@ -245,7 +265,9 @@ export class Tool { ...@@ -245,7 +265,9 @@ export class Tool {
lat.element.effectType == EffectType.MAGICLION || lat.element.effectType == EffectType.MAGICLION ||
lat.element.type == ElementType.JELLY || lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG || lat.element.type == ElementType.CHICKEN_EGG ||
lat.element.hasState(StateType.HAIRBALL)) { lat.element.hasState(StateType.HAIRBALLGREY) ||
lat.element.hasState(StateType.HAIRBALLBLACK) ||
lat.element.hasState(StateType.HAIRBALLBROWN)) {
return false return false
} }
//剩下情况 //剩下情况
...@@ -255,7 +277,7 @@ export class Tool { ...@@ -255,7 +277,7 @@ export class Tool {
} }
/** /**
* 判断能执行消除的元素, * 判断能执行消除的元素,
* 包括所有特效和基本元素,石头,果冻,鸡蛋 * 包括所有特效和基本元素,石头,果冻,鸡蛋,各种状态的
* @param lat * @param lat
*/ */
public static judgeEliminate(lat: Lattice) { public static judgeEliminate(lat: Lattice) {
...@@ -292,6 +314,23 @@ export class Tool { ...@@ -292,6 +314,23 @@ export class Tool {
} }
} }
/**
* 判断在打乱时,格子上元素是否能移动交换
* @param lat 格子
*/
public static judgeUpsetMove(lat: Lattice) {
if (Tool.judgeBaseEle(lat) &&
!lat.element.hasState(StateType.LOCK) &&
!lat.element.hasState(StateType.HAIRBALLGREY) &&
!lat.element.hasState(StateType.HAIRBALLBLACK) &&
!lat.element.hasState(StateType.HAIRBALLBROWN)
) {
return true;
}
return false;
}
/** /**
* 判断元素是否可被手势选中和交换 * 判断元素是否可被手势选中和交换
* 主要点击元素判断使用 * 主要点击元素判断使用
...@@ -302,7 +341,9 @@ export class Tool { ...@@ -302,7 +341,9 @@ export class Tool {
if (!ele || if (!ele ||
ele.type == ElementType.ROCK || ele.type == ElementType.ROCK ||
ele.hasState(StateType.LOCK) || ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL) || ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN) ||
ele.type == ElementType.JELLY || ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG ele.type == ElementType.CHICKEN_EGG
) { ) {
...@@ -313,7 +354,7 @@ export class Tool { ...@@ -313,7 +354,7 @@ export class Tool {
/** /**
* 是否要算分数 * 是否要算分数
* 排除元素 石头,鸡蛋,果冻, * 排除元素 石头,鸡蛋,果冻,
* 排除状态 枷锁,毛球 * 排除状态 枷锁,毛球,因为存在时,元素不会消除
* @param ele 元素 * @param ele 元素
*/ */
public static judgeHasScore(ele: Element): boolean { public static judgeHasScore(ele: Element): boolean {
...@@ -323,7 +364,26 @@ export class Tool { ...@@ -323,7 +364,26 @@ export class Tool {
ele.type == ElementType.CHICKEN_EGG || ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.LOLLIPOP || ele.type == ElementType.LOLLIPOP ||
ele.hasState(StateType.LOCK) || ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL) ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN)
) {
return false;
}
return true
}
/**
* 判断能否参与魔力鸟旋转的元素
* 无特效,无锁,无毛球,
* @param ele 元素
*/
public static judgeMagicRotate(ele: Element): boolean {
if (!ele ||
ele.effectType != null ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN)
) { ) {
return false; return false;
} }
...@@ -591,7 +651,9 @@ export class Tool { ...@@ -591,7 +651,9 @@ export class Tool {
lattices[i].element && lattices[i].element &&
lattices[i].element.type <= 4 && lattices[i].element.type <= 4 &&
!lattices[i].element.hasState(StateType.LOCK) && !lattices[i].element.hasState(StateType.LOCK) &&
!lattices[i].element.hasState(StateType.HAIRBALL) !lattices[i].element.hasState(StateType.HAIRBALLGREY) &&
!lattices[i].element.hasState(StateType.HAIRBALLBLACK) &&
!lattices[i].element.hasState(StateType.HAIRBALLGREY)
) { ) {
var type = lattices[i].element.type; var type = lattices[i].element.type;
if (!arr[type]) arr[type] = 0; if (!arr[type]) arr[type] = 0;
......
...@@ -4,59 +4,33 @@ import { Pool } from "../Pool"; ...@@ -4,59 +4,33 @@ import { Pool } from "../Pool";
import { Element } from "../class/Element"; import { Element } from "../class/Element";
import { Ice } from "../class/Ice"; import { Ice } from "../class/Ice";
import { ElementType } from "../enum/ElementType"; import { ElementType } from "../enum/ElementType";
import { HairballState } from "../states/HairballState"; export function FlyTargetAni(
export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectContainer) { type: ElementType,
fromP: number[],
targetP: number[],
con: egret.DisplayObjectContainer
) {
//弄一个替代的 //弄一个替代的
let eleC; let eleC: egret.Bitmap = Pool.takeOut(RecoverName.FLYIMAGE);
if (ele instanceof Element) { if (!eleC) eleC = new egret.Bitmap();
eleC = Pool.takeOut(RecoverName.ELEMENT); var texture: egret.Texture = RES.getRes("ele" + type + "_png");
if (!eleC) { eleC.texture = texture;
eleC = new Element(ele.type) //都按格子的中心点
} else { eleC.anchorOffsetX = texture.textureWidth / 2;
eleC.reset(ele.type) eleC.anchorOffsetY = texture.textureHeight / 2;
} //重置缩放
} eleC.scaleX = 1;
//是冰块 eleC.scaleY = 1;
else if (ele instanceof Ice) { eleC.x = fromP[0];
eleC = Pool.takeOut(RecoverName.ICE); eleC.y = fromP[1];
if (!eleC) {
eleC = new Ice()
} else {
eleC.reset()
}
}
//是毛球
else if(ele instanceof HairballState){
eleC = Pool.takeOut(RecoverName.HAIRBALL_STATE);
if (!eleC) {
eleC = new HairballState()
} else {
eleC.reset(1)
}
}
eleC.x = ele.x;
eleC.y = ele.y;
con.addChild(eleC); con.addChild(eleC);
var a = { t: 0 }; var a = { t: 0 };
egret.Tween.get(eleC) egret.Tween.get(eleC)
.to({ x: p[0], y: p[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0) .to({ x: targetP[0], y: targetP[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0)
.call(() => { .call(() => {
//回收 //回收
con.removeChild(eleC); con.removeChild(eleC);
if (ele instanceof Element) { Pool.recover(RecoverName.FLYIMAGE, eleC);
Pool.recover(RecoverName.ELEMENT, eleC); con["elementTargets"].targets[type].count--;
con["elementTargets"].targets[eleC.type].count--
}
//是冰块
else if (ele instanceof Ice) {
Pool.recover(RecoverName.ICE, eleC);
con["elementTargets"].targets[ElementType.ICE].count--
}
//是毛球
else if (ele instanceof HairballState) {
Pool.recover(RecoverName.HAIRBALL_STATE, eleC);
con["elementTargets"].targets[ElementType.HAIRBALL].count--
}
// callback()
}) })
} }
\ No newline at end of file
...@@ -5,14 +5,14 @@ import { ImageAni } from "../class/ImageAni"; ...@@ -5,14 +5,14 @@ import { ImageAni } from "../class/ImageAni";
* 待写 * 待写
* 毛球消失动效 * 毛球消失动效
*/ */
export class HairballDisAni extends Ani { export class HairballGreyDisAni extends Ani {
/** /**
* 图片 * 图片
*/ */
showImage: ImageAni; showImage: ImageAni;
constructor() { constructor() {
super(); super();
this.aniName = "HairballDisAni"; this.aniName = "HairballGreyDisAni";
var arr = [] var arr = []
for (var i = 1; i <= 19; i++) { for (var i = 1; i <= 19; i++) {
arr.push("eleDis" + i + "_png"); arr.push("eleDis" + i + "_png");
......
...@@ -76,7 +76,7 @@ export const Chapters2: ChapterData[] = [ ...@@ -76,7 +76,7 @@ export const Chapters2: ChapterData[] = [
elements: [ elements: [
{ {
type: ElementType.ROCK, type: ElementType.ROCK,
count: 34 count: 40
}, },
{ {
type: ElementType.CHICKEN, type: ElementType.CHICKEN,
......
...@@ -10,8 +10,11 @@ import { ChickenEgg } from "./ChickenEgg"; ...@@ -10,8 +10,11 @@ import { ChickenEgg } from "./ChickenEgg";
import { State } from "./State"; import { State } from "./State";
import { StateType } from "../enum/StateType"; import { StateType } from "../enum/StateType";
import { LockState } from "../states/LockState"; import { LockState } from "../states/LockState";
import { HairballState } from "../states/HairballState"; import { HairballBrownState } from "../states/HairballBrownState";
import { BubbleState } from "../states/BubbleState"; import { BubbleState } from "../states/BubbleState";
import { HairballGreyState } from "../states/HairballGreyState";
import { HairballBlackState } from "../states/HairballBlackState";
/** /**
...@@ -192,8 +195,14 @@ export class Element extends eui.Component { ...@@ -192,8 +195,14 @@ export class Element extends eui.Component {
case StateType.BUBBLE: case StateType.BUBBLE:
recoverType = RecoverName.BUBBLE_STATE; recoverType = RecoverName.BUBBLE_STATE;
break; break;
case StateType.HAIRBALL: case StateType.HAIRBALLGREY:
recoverType = RecoverName.HAIRBALL_STATE; recoverType = RecoverName.HAIRBALLGREY_STATE;
break;
case StateType.HAIRBALLBLACK:
recoverType = RecoverName.HAIRBALLBLACK_STATE;
break;
case StateType.HAIRBALLBROWN:
recoverType = RecoverName.HAIRBALLBROWN_STATE;
break; break;
} }
Pool.recover(recoverType, state); Pool.recover(recoverType, state);
...@@ -347,14 +356,32 @@ export class Element extends eui.Component { ...@@ -347,14 +356,32 @@ export class Element extends eui.Component {
this.states[state] = bubbleState; this.states[state] = bubbleState;
this.showImage.alpha = 0; this.showImage.alpha = 0;
break; break;
case StateType.HAIRBALL: case StateType.HAIRBALLGREY:
let hairBallState = Pool.takeOut(RecoverName.HAIRBALL_STATE); let hairballGreyState = Pool.takeOut(RecoverName.HAIRBALLGREY_STATE);
if (!hairBallState) { if (!hairballGreyState) {
hairBallState = new HairballState(data); hairballGreyState = new HairballGreyState();
} else {
hairballGreyState.reset()
}
this.states[state] = hairballGreyState;
break;
case StateType.HAIRBALLBLACK:
let hairballBlackState = Pool.takeOut(RecoverName.HAIRBALLBLACK_STATE);
if (!hairballBlackState) {
hairballBlackState = new HairballBlackState();
} else {
hairballBlackState.reset()
}
this.states[state] = hairballBlackState;
break;
case StateType.HAIRBALLBROWN:
let hairballBrowState = Pool.takeOut(RecoverName.HAIRBALLBROWN_STATE);
if (!hairballBrowState) {
hairballBrowState = new HairballBrownState();
} else { } else {
hairBallState.reset(data) hairballBrowState.reset()
} }
this.states[state] = hairBallState; this.states[state] = hairballBrowState;
break; break;
} }
//视图添加 //视图添加
......
import { ElementType } from "../enum/ElementType"; import { ElementType } from "../enum/ElementType";
export class Ice extends eui.Image { export class Ice extends egret.Bitmap {
/** /**
* 消除次数 * 消除次数
*/ */
...@@ -19,7 +19,10 @@ export class Ice extends eui.Image { ...@@ -19,7 +19,10 @@ export class Ice extends eui.Image {
constructor(n: number = 2) { constructor(n: number = 2) {
super() super()
this.source = "ele" + ElementType.ICE + "_png"; var texture: egret.Texture = RES.getRes("ele" + ElementType.ICE + "_png");
this.texture = texture;
this.anchorOffsetX = texture.textureWidth / 2;
this.anchorOffsetY = texture.textureHeight / 2;
if (n == 2) { if (n == 2) {
this.alpha = 1; this.alpha = 1;
} else { } else {
......
...@@ -10,7 +10,7 @@ export enum ElementType { ...@@ -10,7 +10,7 @@ export enum ElementType {
CATTLE,//牛2 CATTLE,//牛2
LION,//狮子3 LION,//狮子3
PIG,//猪4 PIG,//猪4
//特殊元素 //特殊元素
ROCK,//石头5 ROCK,//石头5
LOLLIPOP,//棒棒糖6 LOLLIPOP,//棒棒糖6
...@@ -22,8 +22,9 @@ export enum ElementType { ...@@ -22,8 +22,9 @@ export enum ElementType {
ICE,//冰块9 ICE,//冰块9
//元素身上状态 //元素身上状态
HAIRBALL,//毛球10 HAIRBALLGREY,//灰色毛球10
HAIRBALLBROWN,//褐色毛球11
HAIRBALLBLACK,//黑色毛球12
} }
var a = [ var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0, 0, 40, 30, 0, 44, 0, 20, 40, 0,
......
...@@ -12,11 +12,15 @@ export enum RecoverName { ...@@ -12,11 +12,15 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni", SCORE_ANI = "ScoreAni",
//目标飞入的图片,没有相应的类,直接用egret.Bitmap
FLYIMAGE = "flyImage",
//带回调的动画,和不带的合并不了,因为可能还有其他参数 //带回调的动画,和不带的合并不了,因为可能还有其他参数
BONUSSHOOT_ANI = "BonusShootAni", BONUSSHOOT_ANI = "BonusShootAni",
JELLYSPREAD_ANI = "JellySpreadAni", JELLYSPREAD_ANI = "JellySpreadAni",
PIECETOEGG_ANI = "PieceToEggAni", PIECETOEGG_ANI = "PieceToEggAni",
BUBBLE_ANI = "BubbleAni", BUBBLE_ANI = "BubbleAni",
HAIRBALLBROWNDIVIDE = "HairballBrownDivide",
...@@ -42,7 +46,8 @@ export enum RecoverName { ...@@ -42,7 +46,8 @@ export enum RecoverName {
STEP_ANI = "StepAni", STEP_ANI = "StepAni",
JELLYDIS_ANI = "JellyDisAni", JELLYDIS_ANI = "JellyDisAni",
EGGBROKEN_ANI = "EggBrokenAni", EGGBROKEN_ANI = "EggBrokenAni",
HAIRBALLDIS_ANI = "HairballDisAni", HAIRBALLGREYDIS_ANI = "HairballGreyDisAni",
HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni",
//方形遮罩 //方形遮罩
RECT_MASK = "RectMask", RECT_MASK = "RectMask",
...@@ -50,5 +55,8 @@ export enum RecoverName { ...@@ -50,5 +55,8 @@ export enum RecoverName {
//状态的回收 //状态的回收
LOCK_STATE = "LockState", LOCK_STATE = "LockState",
BUBBLE_STATE = "BubbleState", BUBBLE_STATE = "BubbleState",
HAIRBALL_STATE = "HairballState", HAIRBALLGREY_STATE = "HairballGreyState",
HAIRBALLBLACK_STATE = "HairballGreyState",
HAIRBALLBROWN_STATE = "HairballGreyState",
} }
\ No newline at end of file
...@@ -4,5 +4,7 @@ ...@@ -4,5 +4,7 @@
export enum StateType { export enum StateType {
LOCK = 0,//锁 LOCK = 0,//锁
BUBBLE,//变色气泡 BUBBLE,//变色气泡
HAIRBALL,//毛球 HAIRBALLGREY,//灰色毛球 ,一次就消除
HAIRBALLBROWN,//褐色毛球 ,只能特效消除
HAIRBALLBLACK,//黑色毛球 ,两次消除,一次闭眼
} }
\ No newline at end of file
/** /**
* 格子生成口数据格式 * 格子生成口数据格式
*/ */
export interface GenerateLatData{ export interface GenerateLatData {
/** /**
* 生成口的索引 * 生成口的索引
*/ */
...@@ -10,7 +10,7 @@ export interface GenerateLatData{ ...@@ -10,7 +10,7 @@ export interface GenerateLatData{
* 掉落元素类型 * 掉落元素类型
* 里面随机类型和下一致 * 里面随机类型和下一致
*/ */
type:number[] type?: number[]
/** /**
* 自定义掉落元素 * 自定义掉落元素
* 十位是基础元素类型,对应数字减1就是基础元素类型 * 十位是基础元素类型,对应数字减1就是基础元素类型
...@@ -21,5 +21,5 @@ export interface GenerateLatData{ ...@@ -21,5 +21,5 @@ export interface GenerateLatData{
* 13 * 13
* 14 * 14
*/ */
cus: number[]; cus?: number[];
} }
\ No newline at end of file
...@@ -32,8 +32,9 @@ export interface MapData { ...@@ -32,8 +32,9 @@ export interface MapData {
* 5果冻 * 5果冻
* 6鸡蛋 * 6鸡蛋
* 7变色气泡 * 7变色气泡
* 8一级毛球 * 8灰色毛球 一次消除
* 9二级毛球 * 9褐色毛球 特效消除,分裂
* 10黑色毛球 两次消除,一次眩晕,
*/ */
elements?: number[]; elements?: number[];
/** /**
......
...@@ -238,7 +238,7 @@ export class AiControl { ...@@ -238,7 +238,7 @@ export class AiControl {
let index = indexs[a]; let index = indexs[a];
let lat = thisObj.lattices[index]; let lat = thisObj.lattices[index];
let ele = lat.element; let ele = lat.element;
let fromType= ele.type; let fromType = ele.type;
//计算type //计算type
let type: ElementType = 1; let type: ElementType = 1;
//直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示 //直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示
...@@ -255,7 +255,7 @@ export class AiControl { ...@@ -255,7 +255,7 @@ export class AiControl {
bubbleAni.y = p[1]; bubbleAni.y = p[1];
thisObj.addChild(bubbleAni); thisObj.addChild(bubbleAni);
//播放动画 //播放动画
bubbleAni.play(fromType,type, () => { bubbleAni.play(fromType, type, () => {
//显示 //显示
ele.visible = true; ele.visible = true;
count++; count++;
...@@ -265,9 +265,6 @@ export class AiControl { ...@@ -265,9 +265,6 @@ export class AiControl {
}) })
} }
} }
} }
/** /**
...@@ -292,7 +289,13 @@ function judgeHairballExist(lattices: Lattice[]) { ...@@ -292,7 +289,13 @@ function judgeHairballExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) { for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i] var lattice = lattices[i]
//必须是基础元素,然后判断状态毛球,有一个就返回true //必须是基础元素,然后判断状态毛球,有一个就返回true
if (Tool.judgeBaseEle(lattice) && lattice.element.hasState(StateType.HAIRBALL)) return true if (Tool.judgeBaseEle(lattice) &&
(
lattice.element.hasState(StateType.HAIRBALLGREY) ||
lattice.element.hasState(StateType.HAIRBALLBLACK) ||
lattice.element.hasState(StateType.HAIRBALLBROWN)
)
) return true
} }
return false; return false;
} }
......
...@@ -150,35 +150,6 @@ function calVet(index: string): number[] { ...@@ -150,35 +150,6 @@ function calVet(index: string): number[] {
return [center[0] + dis[arr[1]], center[1] + dis[arr[2]]] return [center[0] + dis[arr[1]], center[1] + dis[arr[2]]]
} }
//给出10*10
let indexToRcMap10: number[][];
let indexPositions10: number[][];
function get10DataUp() {
indexToRcMap10 = [];
indexPositions10 = [];
var rowNum = Tool.rowNum + 1;
var colNum = Tool.colNum + 1;
var offsetX = Tool.offsetX
var offsetY = Tool.offsetY
for (var i = 0; i < rowNum; i++) {
for (var j = 0; j < colNum; j++) {
// rcToIndexMap["" + i + j] = i * colNum + j;
indexToRcMap10[i * colNum + j] = [i, j];
indexPositions10[i * colNum + j] = [offsetX + j * Tool.width, offsetY + i * Tool.height];
}
}
}
//返回10的索引
function indexToRc10(index: number): number[] {
if (!indexToRcMap10) get10DataUp();
return indexToRcMap10[index]
}
//
function getPositionByIndex10(index: number): number[] {
if (!indexPositions10) get10DataUp();
return indexPositions10[index]
}
/** /**
* 生成格子背景的路径 * 生成格子背景的路径
* @param lattices * @param lattices
...@@ -203,7 +174,7 @@ export function generateMapBg(lattices: number[]): PathData[] { ...@@ -203,7 +174,7 @@ export function generateMapBg(lattices: number[]): PathData[] {
//周围至少右一个 //周围至少右一个
// console.log(vertexs) // console.log(vertexs)
if (vertexs[i].indexOf(1) > -1) { if (vertexs[i].indexOf(1) > -1) {
var p = getPositionByIndex10(i) var p = Tool.getPositionByIndex10(i)
//判断是否在groups内 //判断是否在groups内
var group = judgeInGroups(i, paths, vertexs[i]) var group = judgeInGroups(i, paths, vertexs[i])
if (group) { if (group) {
...@@ -256,7 +227,7 @@ function isPointIn(point: number[], points: number[]): boolean { ...@@ -256,7 +227,7 @@ function isPointIn(point: number[], points: number[]): boolean {
} }
function judgeInGroups(index: number, groups: PathData[], vertex: number[]): PathData { function judgeInGroups(index: number, groups: PathData[], vertex: number[]): PathData {
var p = getPositionByIndex10(index) var p = Tool.getPositionByIndex10(index)
for (var i = 0; i < groups.length; i++) { for (var i = 0; i < groups.length; i++) {
var group = groups[i]; var group = groups[i];
if (isPointIn(p, group.points)) { if (isPointIn(p, group.points)) {
...@@ -377,7 +348,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData { ...@@ -377,7 +348,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
while (curIndex != index) { while (curIndex != index) {
lastIndex = curIndex || index; lastIndex = curIndex || index;
//求得行列 //求得行列
var rc = indexToRc10(lastIndex); var rc = Tool.indexToRc10(lastIndex);
var directionAll = { var directionAll = {
"r": rc[1] < Tool.colNum ? lastIndex + 1 : null, "r": rc[1] < Tool.colNum ? lastIndex + 1 : null,
"l": rc[1] > 0 ? lastIndex - 1 : null, "l": rc[1] > 0 ? lastIndex - 1 : null,
...@@ -408,7 +379,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData { ...@@ -408,7 +379,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (curIndex == index) { if (curIndex == index) {
group.indexs10.push(lastIndex); group.indexs10.push(lastIndex);
if (lastDirection != direction) { if (lastDirection != direction) {
var point = getPositionByIndex10(lastIndex); var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]); group.points.push(point[0], point[1]);
lastDirection = direction lastDirection = direction
} }
...@@ -419,7 +390,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData { ...@@ -419,7 +390,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (lastDirection == direction) { if (lastDirection == direction) {
} else { } else {
var point = getPositionByIndex10(lastIndex); var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]); group.points.push(point[0], point[1]);
lastDirection = direction lastDirection = direction
} }
...@@ -432,7 +403,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData { ...@@ -432,7 +403,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
//取顶点格子左上角格子索引 //取顶点格子左上角格子索引
function getLeftUp(index: number): number { function getLeftUp(index: number): number {
var rc = indexToRc10(index); var rc = Tool.indexToRc10(index);
if (rc[0] > 0 && rc[1] > 0) { if (rc[0] > 0 && rc[1] > 0) {
return Tool.rcToIndex(rc[0] - 1, rc[1] - 1) return Tool.rcToIndex(rc[0] - 1, rc[1] - 1)
} else { } else {
...@@ -441,7 +412,7 @@ function getLeftUp(index: number): number { ...@@ -441,7 +412,7 @@ function getLeftUp(index: number): number {
} }
//取顶点格子右上角格子索引 //取顶点格子右上角格子索引
function getRightUp(index: number): number { function getRightUp(index: number): number {
var rc = indexToRc10(index); var rc = Tool.indexToRc10(index);
if (rc[0] > 0 && rc[1] < Tool.colNum) { if (rc[0] > 0 && rc[1] < Tool.colNum) {
return Tool.rcToIndex(rc[0] - 1, rc[1]) return Tool.rcToIndex(rc[0] - 1, rc[1])
} else { } else {
...@@ -450,7 +421,7 @@ function getRightUp(index: number): number { ...@@ -450,7 +421,7 @@ function getRightUp(index: number): number {
} }
//取顶点格子右下角格子 //取顶点格子右下角格子
function getRightDown(index: number): number { function getRightDown(index: number): number {
var rc = indexToRc10(index); var rc = Tool.indexToRc10(index);
if (rc[0] < Tool.rowNum && rc[1] < Tool.colNum) { if (rc[0] < Tool.rowNum && rc[1] < Tool.colNum) {
return Tool.rcToIndex(rc[0], rc[1]) return Tool.rcToIndex(rc[0], rc[1])
} else { } else {
...@@ -459,7 +430,7 @@ function getRightDown(index: number): number { ...@@ -459,7 +430,7 @@ function getRightDown(index: number): number {
} }
//取顶点格子左下角格子 //取顶点格子左下角格子
function getLeftDown(index: number): number { function getLeftDown(index: number): number {
var rc = indexToRc10(index); var rc = Tool.indexToRc10(index);
if (rc[0] < Tool.rowNum && rc[1] > 0) { if (rc[0] < Tool.rowNum && rc[1] > 0) {
return Tool.rcToIndex(rc[0], rc[1] - 1) return Tool.rcToIndex(rc[0], rc[1] - 1)
} else { } else {
...@@ -469,8 +440,8 @@ function getLeftDown(index: number): number { ...@@ -469,8 +440,8 @@ function getLeftDown(index: number): number {
//根据两个顶点索引,有顺序,取下是否有 //根据两个顶点索引,有顺序,取下是否有
function getDown(l: number, r: number, vertexs: number[][]) { function getDown(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l); var rcL = Tool.indexToRc10(l);
var rcR = indexToRc10(r); var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) { if (rcR[1] - rcL[1] == 1) {
//正下方 //正下方
return vertexs[l][2] return vertexs[l][2]
...@@ -490,8 +461,8 @@ function getDown(l: number, r: number, vertexs: number[][]) { ...@@ -490,8 +461,8 @@ function getDown(l: number, r: number, vertexs: number[][]) {
} }
////根据两个顶点索引,有顺序,取上是否有 ////根据两个顶点索引,有顺序,取上是否有
function getUp(l: number, r: number, vertexs: number[][]) { function getUp(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l); var rcL = Tool.indexToRc10(l);
var rcR = indexToRc10(r); var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) { if (rcR[1] - rcL[1] == 1) {
//上方 //上方
return vertexs[l][1] return vertexs[l][1]
...@@ -534,9 +505,9 @@ function clearGroup(group: PathData) { ...@@ -534,9 +505,9 @@ function clearGroup(group: PathData) {
var one = group.indexs10[0]; var one = group.indexs10[0];
var two = group.indexs10[1]; var two = group.indexs10[1];
var Last = group.indexs10[group.indexs10.length - 1]; var Last = group.indexs10[group.indexs10.length - 1];
var rc1 = indexToRc10(one); var rc1 = Tool.indexToRc10(one);
var rc2 = indexToRc10(two); var rc2 = Tool.indexToRc10(two);
var rcL = indexToRc10(Last); var rcL = Tool.indexToRc10(Last);
if ((rc1[0] == rc2[0] && rc1[0] == rcL[0]) || (rc1[1] == rc2[1] && rc1[1] == rcL[1])) { if ((rc1[0] == rc2[0] && rc1[0] == rcL[0]) || (rc1[1] == rc2[1] && rc1[1] == rcL[1])) {
// group.indexs10.shift(); // group.indexs10.shift();
group.points.shift(); group.points.shift();
......
...@@ -14,7 +14,7 @@ export class BubbleState extends State { ...@@ -14,7 +14,7 @@ export class BubbleState extends State {
* 显示图片 * 显示图片
*/ */
private showImage: egret.Bitmap; private showImage: egret.Bitmap;
constructor(type: ElementType) { constructor(type: ElementType) {
super(); super();
this.showImage = new egret.Bitmap(); this.showImage = new egret.Bitmap();
...@@ -29,7 +29,7 @@ export class BubbleState extends State { ...@@ -29,7 +29,7 @@ export class BubbleState extends State {
//直接回收 //直接回收
recover() { recover() {
if (this.parent) this.parent.removeChild(this); if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this); Pool.recover(RecoverName.BUBBLE_STATE, this);
} }
private changeSource(source: string) { private changeSource(source: string) {
......
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 黑色毛球状态
* 两次消除,需要修改图片,,,再说,还没写
*/
export class HairballBlackState extends State {
private showImage: egret.Bitmap;
/**
* 是否激活
*/
isActive: boolean;
constructor() {
super();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLBLACK + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false;
}
reset() {
this.isActive = false;
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALLBLACK_STATE, this);
}
// private changeSource(source: string) {
// var texture: egret.Texture = RES.getRes(source);
// this.showImage.texture = texture;
// this.showImage.x = -texture.textureWidth / 2;
// this.showImage.y = -texture.textureHeight / 2
// }
}
\ No newline at end of file
...@@ -6,48 +6,30 @@ import { RecoverName } from "../enum/RecoverName"; ...@@ -6,48 +6,30 @@ import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType"; import { ElementType } from "../enum/ElementType";
/** /**
* 毛球状态 * 褐色帽绣毛球状态
* 消失动画。和分裂动画都在外面单独掉 * 分裂动画都在外面单独掉
*/ */
export class HairballState extends State { export class HairballBrownState extends State {
private showImage: egret.Bitmap; private showImage: egret.Bitmap;
/** /**
* 是否激活 * 是否激活
*/ */
isActive: boolean; isActive: boolean;
/** constructor() {
* 毛球等级,1或2
*/
private _levelNum: number;
get levelNum() {
return this._levelNum
}
set levelNum(value: number) {
if (this._levelNum == value) return
this._levelNum = value;
var source: string;
if (value == 2) {
source = "hairballDark_png";
} else {
source = "ele" + ElementType.HAIRBALL + "_png"
}
this.changeSource(source)
}
constructor(level: number = 2) {
super(); super();
this.showImage = new egret.Bitmap(); var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLBROWN + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage); this.addChild(this.showImage);
this.levelNum = level; this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false; this.isActive = false;
} }
reset(level: number = 2) { reset() {
this.levelNum = level;
this.isActive = false; this.isActive = false;
} }
recover() { recover() {
if (this.parent) this.parent.removeChild(this); if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this); Pool.recover(RecoverName.HAIRBALLBROWN_STATE, this);
} }
private changeSource(source: string) { private changeSource(source: string) {
......
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 褐色帽绣毛球状态
* 分裂动画都在外面单独掉
*/
export class HairballGreyState extends State {
private showImage: egret.Bitmap;
constructor() {
super();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLGREY + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
}
reset() {
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALLGREY_STATE, this);
}
}
\ 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