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

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

parents 937553a1 043dfd8f
This diff is collapsed.
......@@ -176,7 +176,7 @@ export class PropGuideInt extends egret.DisplayObjectContainer {
if (Tool.judgeEliminate(lat) && (lat.row == rc[0] || lat.column == rc[1])) {
if (this.thisObj.eliminatedElements.indexOf(i) == -1) {
this.thisObj.eliminatedElements.push(i);
if (!lat.element.hasState(StateType.LOCK) && !lat.element.hasState(StateType.HAIRBALL)) {
if (Tool.judgeHasScore(lat.element)) {
//算直线+直线LL
this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i))
}
......
......@@ -26,8 +26,8 @@ export class Tool {
* 格子高度
*/
public static height = 80// 81.5;
//整体偏移X
public static offsetX = 15// 8.25;
//整体偏移X,为了下面初始化,这里不定义数值
public static offsetX //= 15// 8.25;
//整体偏移Y
public static offsetY = 275 //260;
/**
......@@ -56,11 +56,18 @@ export class Tool {
* 索引位置
*/
private static indexPositions: number[][] = [];
//给出10*10
private static indexToRcMap10: number[][] = [];
private static indexPositions10: number[][] = [];
/**
* 初始化数据
*/
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
//位置信息
var spaceX = this.width,
......@@ -77,11 +84,17 @@ export class Tool {
}
//10*10的格子位置信息
// for (var i = 0; i < this.rowNum + 1; i++) {
// for (var j = 0; j < this.colNum + 1; j++) {
// }
// }
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;
this.indexToRcMap10[i * colNum + j] = [i, j];
this.indexPositions10[i * colNum + j] = [offsetX + j * Tool.width, offsetY + i * Tool.height];
}
}
}
/**
* row和col获得index值
......@@ -118,6 +131,13 @@ export class Tool {
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格子得到中间列数的奇偶性
* 其实只是要知道左右两边空的列数
......@@ -245,7 +265,9 @@ export class Tool {
lat.element.effectType == EffectType.MAGICLION ||
lat.element.type == ElementType.JELLY ||
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
}
//剩下情况
......@@ -255,7 +277,7 @@ export class Tool {
}
/**
* 判断能执行消除的元素,
* 包括所有特效和基本元素,石头,果冻,鸡蛋
* 包括所有特效和基本元素,石头,果冻,鸡蛋,各种状态的
* @param lat
*/
public static judgeEliminate(lat: Lattice) {
......@@ -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 {
if (!ele ||
ele.type == ElementType.ROCK ||
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.CHICKEN_EGG
) {
......@@ -313,7 +354,7 @@ export class Tool {
/**
* 是否要算分数
* 排除元素 石头,鸡蛋,果冻,
* 排除状态 枷锁,毛球
* 排除状态 枷锁,毛球,因为存在时,元素不会消除
* @param ele 元素
*/
public static judgeHasScore(ele: Element): boolean {
......@@ -323,7 +364,26 @@ export class Tool {
ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.LOLLIPOP ||
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;
}
......@@ -591,7 +651,9 @@ export class Tool {
lattices[i].element &&
lattices[i].element.type <= 4 &&
!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;
if (!arr[type]) arr[type] = 0;
......
......@@ -4,59 +4,33 @@ import { Pool } from "../Pool";
import { Element } from "../class/Element";
import { Ice } from "../class/Ice";
import { ElementType } from "../enum/ElementType";
import { HairballState } from "../states/HairballState";
export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectContainer) {
export function FlyTargetAni(
type: ElementType,
fromP: number[],
targetP: number[],
con: egret.DisplayObjectContainer
) {
//弄一个替代的
let eleC;
if (ele instanceof Element) {
eleC = Pool.takeOut(RecoverName.ELEMENT);
if (!eleC) {
eleC = new Element(ele.type)
} else {
eleC.reset(ele.type)
}
}
//是冰块
else if (ele instanceof Ice) {
eleC = Pool.takeOut(RecoverName.ICE);
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;
let eleC: egret.Bitmap = Pool.takeOut(RecoverName.FLYIMAGE);
if (!eleC) eleC = new egret.Bitmap();
var texture: egret.Texture = RES.getRes("ele" + type + "_png");
eleC.texture = texture;
//都按格子的中心点
eleC.anchorOffsetX = texture.textureWidth / 2;
eleC.anchorOffsetY = texture.textureHeight / 2;
//重置缩放
eleC.scaleX = 1;
eleC.scaleY = 1;
eleC.x = fromP[0];
eleC.y = fromP[1];
con.addChild(eleC);
var a = { t: 0 };
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(() => {
//回收
con.removeChild(eleC);
if (ele instanceof Element) {
Pool.recover(RecoverName.ELEMENT, eleC);
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()
Pool.recover(RecoverName.FLYIMAGE, eleC);
con["elementTargets"].targets[type].count--;
})
}
\ No newline at end of file
......@@ -5,14 +5,14 @@ import { ImageAni } from "../class/ImageAni";
* 待写
* 毛球消失动效
*/
export class HairballDisAni extends Ani {
export class HairballGreyDisAni extends Ani {
/**
* 图片
*/
showImage: ImageAni;
constructor() {
super();
this.aniName = "HairballDisAni";
this.aniName = "HairballGreyDisAni";
var arr = []
for (var i = 1; i <= 19; i++) {
arr.push("eleDis" + i + "_png");
......
......@@ -76,7 +76,7 @@ export const Chapters2: ChapterData[] = [
elements: [
{
type: ElementType.ROCK,
count: 34
count: 40
},
{
type: ElementType.CHICKEN,
......
......@@ -10,8 +10,11 @@ import { ChickenEgg } from "./ChickenEgg";
import { State } from "./State";
import { StateType } from "../enum/StateType";
import { LockState } from "../states/LockState";
import { HairballState } from "../states/HairballState";
import { HairballBrownState } from "../states/HairballBrownState";
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 {
case StateType.BUBBLE:
recoverType = RecoverName.BUBBLE_STATE;
break;
case StateType.HAIRBALL:
recoverType = RecoverName.HAIRBALL_STATE;
case StateType.HAIRBALLGREY:
recoverType = RecoverName.HAIRBALLGREY_STATE;
break;
case StateType.HAIRBALLBLACK:
recoverType = RecoverName.HAIRBALLBLACK_STATE;
break;
case StateType.HAIRBALLBROWN:
recoverType = RecoverName.HAIRBALLBROWN_STATE;
break;
}
Pool.recover(recoverType, state);
......@@ -347,14 +356,32 @@ export class Element extends eui.Component {
this.states[state] = bubbleState;
this.showImage.alpha = 0;
break;
case StateType.HAIRBALL:
let hairBallState = Pool.takeOut(RecoverName.HAIRBALL_STATE);
if (!hairBallState) {
hairBallState = new HairballState(data);
case StateType.HAIRBALLGREY:
let hairballGreyState = Pool.takeOut(RecoverName.HAIRBALLGREY_STATE);
if (!hairballGreyState) {
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 {
hairBallState.reset(data)
hairballBrowState.reset()
}
this.states[state] = hairBallState;
this.states[state] = hairballBrowState;
break;
}
//视图添加
......
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 {
constructor(n: number = 2) {
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) {
this.alpha = 1;
} else {
......
......@@ -22,8 +22,9 @@ export enum ElementType {
ICE,//冰块9
//元素身上状态
HAIRBALL,//毛球10
HAIRBALLGREY,//灰色毛球10
HAIRBALLBROWN,//褐色毛球11
HAIRBALLBLACK,//黑色毛球12
}
var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0,
......
......@@ -12,11 +12,15 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni",
//目标飞入的图片,没有相应的类,直接用egret.Bitmap
FLYIMAGE = "flyImage",
//带回调的动画,和不带的合并不了,因为可能还有其他参数
BONUSSHOOT_ANI = "BonusShootAni",
JELLYSPREAD_ANI = "JellySpreadAni",
PIECETOEGG_ANI = "PieceToEggAni",
BUBBLE_ANI = "BubbleAni",
HAIRBALLBROWNDIVIDE = "HairballBrownDivide",
......@@ -42,7 +46,8 @@ export enum RecoverName {
STEP_ANI = "StepAni",
JELLYDIS_ANI = "JellyDisAni",
EGGBROKEN_ANI = "EggBrokenAni",
HAIRBALLDIS_ANI = "HairballDisAni",
HAIRBALLGREYDIS_ANI = "HairballGreyDisAni",
HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni",
//方形遮罩
RECT_MASK = "RectMask",
......@@ -50,5 +55,8 @@ export enum RecoverName {
//状态的回收
LOCK_STATE = "LockState",
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 @@
export enum StateType {
LOCK = 0,//锁
BUBBLE,//变色气泡
HAIRBALL,//毛球
HAIRBALLGREY,//灰色毛球 ,一次就消除
HAIRBALLBROWN,//褐色毛球 ,只能特效消除
HAIRBALLBLACK,//黑色毛球 ,两次消除,一次闭眼
}
\ No newline at end of file
/**
* 格子生成口数据格式
*/
export interface GenerateLatData{
export interface GenerateLatData {
/**
* 生成口的索引
*/
......@@ -10,7 +10,7 @@ export interface GenerateLatData{
* 掉落元素类型
* 里面随机类型和下一致
*/
type:number[]
type?: number[]
/**
* 自定义掉落元素
* 十位是基础元素类型,对应数字减1就是基础元素类型
......@@ -21,5 +21,5 @@ export interface GenerateLatData{
* 13
* 14
*/
cus: number[];
cus?: number[];
}
\ No newline at end of file
......@@ -32,8 +32,9 @@ export interface MapData {
* 5果冻
* 6鸡蛋
* 7变色气泡
* 8一级毛球
* 9二级毛球
* 8灰色毛球 一次消除
* 9褐色毛球 特效消除,分裂
* 10黑色毛球 两次消除,一次眩晕,
*/
elements?: number[];
/**
......
......@@ -238,7 +238,7 @@ export class AiControl {
let index = indexs[a];
let lat = thisObj.lattices[index];
let ele = lat.element;
let fromType= ele.type;
let fromType = ele.type;
//计算type
let type: ElementType = 1;
//直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示
......@@ -255,7 +255,7 @@ export class AiControl {
bubbleAni.y = p[1];
thisObj.addChild(bubbleAni);
//播放动画
bubbleAni.play(fromType,type, () => {
bubbleAni.play(fromType, type, () => {
//显示
ele.visible = true;
count++;
......@@ -265,9 +265,6 @@ export class AiControl {
})
}
}
}
/**
......@@ -292,7 +289,13 @@ function judgeHairballExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//必须是基础元素,然后判断状态毛球,有一个就返回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;
}
......
......@@ -150,35 +150,6 @@ function calVet(index: string): number[] {
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
......@@ -203,7 +174,7 @@ export function generateMapBg(lattices: number[]): PathData[] {
//周围至少右一个
// console.log(vertexs)
if (vertexs[i].indexOf(1) > -1) {
var p = getPositionByIndex10(i)
var p = Tool.getPositionByIndex10(i)
//判断是否在groups内
var group = judgeInGroups(i, paths, vertexs[i])
if (group) {
......@@ -256,7 +227,7 @@ function isPointIn(point: number[], points: number[]): boolean {
}
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++) {
var group = groups[i];
if (isPointIn(p, group.points)) {
......@@ -377,7 +348,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
while (curIndex != index) {
lastIndex = curIndex || index;
//求得行列
var rc = indexToRc10(lastIndex);
var rc = Tool.indexToRc10(lastIndex);
var directionAll = {
"r": rc[1] < Tool.colNum ? lastIndex + 1 : null,
"l": rc[1] > 0 ? lastIndex - 1 : null,
......@@ -408,7 +379,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (curIndex == index) {
group.indexs10.push(lastIndex);
if (lastDirection != direction) {
var point = getPositionByIndex10(lastIndex);
var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]);
lastDirection = direction
}
......@@ -419,7 +390,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (lastDirection == direction) {
} else {
var point = getPositionByIndex10(lastIndex);
var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]);
lastDirection = direction
}
......@@ -432,7 +403,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
//取顶点格子左上角格子索引
function getLeftUp(index: number): number {
var rc = indexToRc10(index);
var rc = Tool.indexToRc10(index);
if (rc[0] > 0 && rc[1] > 0) {
return Tool.rcToIndex(rc[0] - 1, rc[1] - 1)
} else {
......@@ -441,7 +412,7 @@ function getLeftUp(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) {
return Tool.rcToIndex(rc[0] - 1, rc[1])
} else {
......@@ -450,7 +421,7 @@ function getRightUp(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) {
return Tool.rcToIndex(rc[0], rc[1])
} else {
......@@ -459,7 +430,7 @@ function getRightDown(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) {
return Tool.rcToIndex(rc[0], rc[1] - 1)
} else {
......@@ -469,8 +440,8 @@ function getLeftDown(index: number): number {
//根据两个顶点索引,有顺序,取下是否有
function getDown(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l);
var rcR = indexToRc10(r);
var rcL = Tool.indexToRc10(l);
var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) {
//正下方
return vertexs[l][2]
......@@ -490,8 +461,8 @@ function getDown(l: number, r: number, vertexs: number[][]) {
}
////根据两个顶点索引,有顺序,取上是否有
function getUp(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l);
var rcR = indexToRc10(r);
var rcL = Tool.indexToRc10(l);
var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) {
//上方
return vertexs[l][1]
......@@ -534,9 +505,9 @@ function clearGroup(group: PathData) {
var one = group.indexs10[0];
var two = group.indexs10[1];
var Last = group.indexs10[group.indexs10.length - 1];
var rc1 = indexToRc10(one);
var rc2 = indexToRc10(two);
var rcL = indexToRc10(Last);
var rc1 = Tool.indexToRc10(one);
var rc2 = Tool.indexToRc10(two);
var rcL = Tool.indexToRc10(Last);
if ((rc1[0] == rc2[0] && rc1[0] == rcL[0]) || (rc1[1] == rc2[1] && rc1[1] == rcL[1])) {
// group.indexs10.shift();
group.points.shift();
......
......@@ -29,7 +29,7 @@ export class BubbleState extends State {
//直接回收
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this);
Pool.recover(RecoverName.BUBBLE_STATE, this);
}
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";
import { ElementType } from "../enum/ElementType";
/**
* 毛球状态
* 消失动画。和分裂动画都在外面单独掉
* 褐色帽绣毛球状态
* 分裂动画都在外面单独掉
*/
export class HairballState extends State {
export class HairballBrownState extends State {
private showImage: egret.Bitmap;
/**
* 是否激活
*/
isActive: boolean;
/**
* 毛球等级,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) {
constructor() {
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.levelNum = level;
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false;
}
reset(level: number = 2) {
this.levelNum = level;
reset() {
this.isActive = false;
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this);
Pool.recover(RecoverName.HAIRBALLBROWN_STATE, this);
}
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