Commit dde2d83c authored by wjf's avatar wjf

l

parent ad23ece5
This diff is collapsed.
...@@ -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 {
......
...@@ -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();
......
...@@ -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