Commit bc3e2017 authored by wjf's avatar wjf

l

parent ca065cb6
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -8,6 +8,7 @@ import { writeCache, getCacheKey } from "../mapScene/GuideCon"; ...@@ -8,6 +8,7 @@ import { writeCache, getCacheKey } from "../mapScene/GuideCon";
import { showToast } from "../../libs/new_wx/ctrls/toastCtrl"; import { showToast } from "../../libs/new_wx/ctrls/toastCtrl";
import { Element } from "../something/class/Element"; import { Element } from "../something/class/Element";
import { StepAni } from "../something/anis/StepAni"; import { StepAni } from "../something/anis/StepAni";
import { StateType } from "../something/enum/StateType";
const msgs = { const msgs = {
...@@ -175,7 +176,7 @@ export class PropGuideInt extends egret.DisplayObjectContainer { ...@@ -175,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.isLock) { if (!lat.element.hasState(StateType.LOCK) && !lat.element.hasState(StateType.HAIRBALL)) {
//算直线+直线LL //算直线+直线LL
this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i)) this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i))
} }
......
...@@ -9,6 +9,7 @@ import { RecoverName } from "./enum/RecoverName"; ...@@ -9,6 +9,7 @@ import { RecoverName } from "./enum/RecoverName";
import { RectMask } from "./class/RectMask"; import { RectMask } from "./class/RectMask";
import { FallType } from "./interface/FallAniData"; import { FallType } from "./interface/FallAniData";
import { GenerateLatData } from "./interface/GenerateLatData"; import { GenerateLatData } from "./interface/GenerateLatData";
import { StateType } from "./enum/StateType";
export class Tool { export class Tool {
/** /**
...@@ -216,7 +217,7 @@ export class Tool { ...@@ -216,7 +217,7 @@ export class Tool {
} }
//上方元素为石头,或元素为锁定,或者是果冻,或者鸡蛋 //上方元素为石头,或元素为锁定,或者是果冻,或者鸡蛋
else if (lat.element.type == ElementType.ROCK || else if (lat.element.type == ElementType.ROCK ||
lat.element.isLock || lat.element.hasState(StateType.LOCK) ||
lat.element.type == ElementType.JELLY || lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG) { lat.element.type == ElementType.CHICKEN_EGG) {
return false return false
...@@ -229,7 +230,7 @@ export class Tool { ...@@ -229,7 +230,7 @@ export class Tool {
/** /**
* 判断格子是否可进行匹配, * 判断格子是否可进行匹配,
* 不包括魔力鸟, * 不包括魔力鸟,不包括头毛球的
* 包括笼子里的 * 包括笼子里的
* @param lat * @param lat
*/ */
...@@ -238,12 +239,13 @@ export class Tool { ...@@ -238,12 +239,13 @@ export class Tool {
if (!lat || !lat.element) { if (!lat || !lat.element) {
return false return false
} }
//上方元素为石头,或为冰淇淋,或为魔力鸟,或为果冻,或为鸡蛋 //上方元素为石头,或为冰淇淋,或为魔力鸟,或为果冻,或为鸡蛋,或有毛球
else if (lat.element.type == ElementType.ROCK || else if (lat.element.type == ElementType.ROCK ||
lat.element.type == ElementType.LOLLIPOP || lat.element.type == ElementType.LOLLIPOP ||
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)) {
return false return false
} }
//剩下情况 //剩下情况
...@@ -272,7 +274,7 @@ export class Tool { ...@@ -272,7 +274,7 @@ export class Tool {
} }
/** /**
* 判断格子上是基础元素 * 判断格子上是基础元素,包括各种状态的
* @param lat * @param lat
*/ */
public static judgeBaseEle(lat: Lattice) { public static judgeBaseEle(lat: Lattice) {
...@@ -299,7 +301,8 @@ export class Tool { ...@@ -299,7 +301,8 @@ export class Tool {
public static judgeChosen(ele: Element) { public static judgeChosen(ele: Element) {
if (!ele || if (!ele ||
ele.type == ElementType.ROCK || ele.type == ElementType.ROCK ||
ele.isLock || ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL) ||
ele.type == ElementType.JELLY || ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG ele.type == ElementType.CHICKEN_EGG
) { ) {
...@@ -307,6 +310,25 @@ export class Tool { ...@@ -307,6 +310,25 @@ export class Tool {
} }
return true return true
} }
/**
* 是否要算分数
* 排除元素 石头,鸡蛋,果冻,
* 排除状态 枷锁,毛球
* @param ele 元素
*/
public static judgeHasScore(ele: Element): boolean {
if (!ele ||
ele.type == ElementType.ROCK ||
ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.LOLLIPOP ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL)
) {
return false;
}
return true
}
/** /**
* 检测死图,需要提示 * 检测死图,需要提示
...@@ -562,13 +584,15 @@ export class Tool { ...@@ -562,13 +584,15 @@ export class Tool {
var effectCount = 0; var effectCount = 0;
//记录是否有两个格子挨着,且未锁定 //记录是否有两个格子挨着,且未锁定
var hasTwo = false; var hasTwo = false;
//记录是否有三个格子挨着,且未锁定,这个逻辑略烦,暂定至少都未锁定,有bug再改 //记录是否有三个格子挨着,且未锁定,没有毛球,这个逻辑略烦,暂定至少都未锁定,有bug再改
var hasThree = false; var hasThree = false;
for (var i = 0; i < lattices.length; i++) { for (var i = 0; i < lattices.length; i++) {
if (lattices[i] && if (lattices[i] &&
lattices[i].element && lattices[i].element &&
lattices[i].element.type <= 4 && lattices[i].element.type <= 4 &&
!lattices[i].element.isLock) { !lattices[i].element.hasState(StateType.LOCK) &&
!lattices[i].element.hasState(StateType.HAIRBALL)
) {
var type = lattices[i].element.type; var type = lattices[i].element.type;
if (!arr[type]) arr[type] = 0; if (!arr[type]) arr[type] = 0;
arr[type]++; arr[type]++;
...@@ -696,7 +720,7 @@ export class Tool { ...@@ -696,7 +720,7 @@ export class Tool {
for (var i = 0; i < generateLats.length; i++) { for (var i = 0; i < generateLats.length; i++) {
var generateLat: GenerateLatData = generateLats[i]; var generateLat: GenerateLatData = generateLats[i];
var index = generateLat.index; var index = generateLat.index;
if(!lattices[index])continue if (!lattices[index]) continue
lattices[index].isGenerate = true; lattices[index].isGenerate = true;
var rc = this.indexToRc(index); var rc = this.indexToRc(index);
//确实属于哪一列 //确实属于哪一列
......
...@@ -4,6 +4,7 @@ import { Pool } from "../Pool"; ...@@ -4,6 +4,7 @@ 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(ele: any, p: number[], con: egret.DisplayObjectContainer) { export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectContainer) {
//弄一个替代的 //弄一个替代的
let eleC; let eleC;
...@@ -24,6 +25,15 @@ export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectCont ...@@ -24,6 +25,15 @@ export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectCont
eleC.reset() 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.x = ele.x;
eleC.y = ele.y; eleC.y = ele.y;
con.addChild(eleC); con.addChild(eleC);
...@@ -42,6 +52,11 @@ export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectCont ...@@ -42,6 +52,11 @@ export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectCont
Pool.recover(RecoverName.ICE, eleC); Pool.recover(RecoverName.ICE, eleC);
con["elementTargets"].targets[ElementType.ICE].count-- con["elementTargets"].targets[ElementType.ICE].count--
} }
//是毛球
else if (ele instanceof HairballState) {
Pool.recover(RecoverName.HAIRBALL_STATE, eleC);
con["elementTargets"].targets[ElementType.HAIRBALL].count--
}
// callback() // callback()
}) })
} }
\ No newline at end of file
import { Ani } from "../class/Ani"; import { Ani } from "../class/Ani";
import { ElementType } from "../enum/ElementType";
export class JellyDisAni extends Ani { export class JellyDisAni extends Ani {
showImage: egret.Bitmap; showImage: egret.Bitmap;
...@@ -8,7 +9,7 @@ export class JellyDisAni extends Ani { ...@@ -8,7 +9,7 @@ export class JellyDisAni extends Ani {
super() super()
this.aniName = "JellyDisAni"; this.aniName = "JellyDisAni";
var arr = ["ele8_png", "greenCircleDown_png", "greenCircleUp_png"]; var arr = ["ele"+ElementType.JELLY+"_png", "greenCircleDown_png", "greenCircleUp_png"];
var objs = ["showImage", "downCircle", "upCircle"]; var objs = ["showImage", "downCircle", "upCircle"];
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
......
...@@ -3,6 +3,7 @@ import { Pool } from "../Pool"; ...@@ -3,6 +3,7 @@ import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName"; import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl"; import { playSound, SoundType } from "../../soundCtrl";
import { Tool } from "../Tool"; import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
/** /**
* 需要回调的 * 需要回调的
...@@ -17,7 +18,7 @@ export class JellySpreadAni extends egret.DisplayObjectContainer { ...@@ -17,7 +18,7 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
shoot: egret.Bitmap; shoot: egret.Bitmap;
constructor() { constructor() {
super() super()
var texture: egret.Texture = RES.getRes("ele8_png") var texture: egret.Texture = RES.getRes("ele"+ElementType.JELLY+"_png")
this.targetImage = new egret.Bitmap(texture); this.targetImage = new egret.Bitmap(texture);
this.targetImage.anchorOffsetX = texture.textureWidth / 2; this.targetImage.anchorOffsetX = texture.textureWidth / 2;
this.targetImage.anchorOffsetY = texture.textureHeight / 2; this.targetImage.anchorOffsetY = texture.textureHeight / 2;
......
This diff is collapsed.
...@@ -2,6 +2,8 @@ import { Pool } from "../Pool"; ...@@ -2,6 +2,8 @@ import { Pool } from "../Pool";
/** /**
* 动效的基类,包含一些固定方法 * 动效的基类,包含一些固定方法
* play无参数,不需要回调
* 有自动回收方法recover
*/ */
export class Ani extends egret.DisplayObjectContainer { export class Ani extends egret.DisplayObjectContainer {
/** /**
......
...@@ -2,12 +2,15 @@ import { ElementType } from "../enum/ElementType"; ...@@ -2,12 +2,15 @@ import { ElementType } from "../enum/ElementType";
import { EffectType } from "../enum/EffectType"; import { EffectType } from "../enum/EffectType";
import { Pool } from "../Pool"; import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName"; import { RecoverName } from "../enum/RecoverName";
import { LockAni } from "../anis/LockAni";
import { MagicLionBgAni } from "../periodAni/MagicLionBgAni"; import { MagicLionBgAni } from "../periodAni/MagicLionBgAni";
import { HorizontalBgAni } from "../periodAni/HorizontalBgAni"; import { HorizontalBgAni } from "../periodAni/HorizontalBgAni";
import { VerticalBgAni } from "../periodAni/VerticalBgAni"; import { VerticalBgAni } from "../periodAni/VerticalBgAni";
import { ExplosiveBgAni } from "../periodAni/ExplosiveBgAni"; import { ExplosiveBgAni } from "../periodAni/ExplosiveBgAni";
import { ChickenEgg } from "./ChickenEgg"; import { ChickenEgg } from "./ChickenEgg";
import { State } from "./State";
import { StateType } from "../enum/StateType";
import { LockState } from "../states/LockState";
import { HairballState } from "../states/HairballState";
/** /**
...@@ -23,7 +26,7 @@ export class Element extends eui.Component { ...@@ -23,7 +26,7 @@ export class Element extends eui.Component {
return this._type return this._type
} }
/** /**
* 显示的图片,直接改source,"ele"+type+effectType * 显示的图片,直接改source,"ele"+type
*/ */
showImage: eui.Image; showImage: eui.Image;
...@@ -39,7 +42,7 @@ export class Element extends eui.Component { ...@@ -39,7 +42,7 @@ export class Element extends eui.Component {
if (this._effectType == value) return if (this._effectType == value) return
if (value != null) { if (value != null) {
//先去掉原先有的 //先去掉原先有的
this.removeHas(); this.removeEffectHas();
//赋值现在的 //赋值现在的
switch (value) { switch (value) {
case EffectType.MAGICLION: case EffectType.MAGICLION:
...@@ -90,7 +93,7 @@ export class Element extends eui.Component { ...@@ -90,7 +93,7 @@ export class Element extends eui.Component {
} else { } else {
// console.log(this._effectType) // console.log(this._effectType)
//回收掉原先有的 //回收掉原先有的
this.removeHas(); this.removeEffectHas();
this.changeSource("ele" + this.type + "_png"); this.changeSource("ele" + this.type + "_png");
this._effectType = null; this._effectType = null;
// console.log(this) // console.log(this)
...@@ -112,34 +115,15 @@ export class Element extends eui.Component { ...@@ -112,34 +115,15 @@ export class Element extends eui.Component {
* 第几列 * 第几列
*/ */
column: number column: number
//鸡蛋
chickenEgg: ChickenEgg;
/** /**
* 带动画的 * 所有的状态,注意,变色气泡特殊,不能和特效共存,所以初始化时,气泡的不能加特效。生成特效,去掉气泡
* 索引必须按枚举
*/ */
lockAni: LockAni private states: State[] = []
private _isLock: boolean = false;
get isLock() {
return this._isLock;
}
set isLock(value: boolean) {
if (this._isLock == value) return;
if (value) {
//如果是加锁,肯定为空
this.lockAni = Pool.takeOut(RecoverName.LOCK_ANI)
if (!this.lockAni) {
//新建,里面是解锁的所有图片组
this.lockAni = new LockAni();
} else {
this.lockAni.reset();
}
this.addChild(this.lockAni)
} else {
//如果去锁
this.lockAni.play()
this.lockAni = null;
}
this._isLock = value
}
chickenEgg: ChickenEgg;
constructor(type: ElementType) { constructor(type: ElementType) {
super(); super();
this._type = type; this._type = type;
...@@ -150,13 +134,14 @@ export class Element extends eui.Component { ...@@ -150,13 +134,14 @@ export class Element extends eui.Component {
if (type == ElementType.CHICKEN_EGG) { if (type == ElementType.CHICKEN_EGG) {
this.chickenEgg = Pool.takeOut(RecoverName.CHICKEN_EGG) this.chickenEgg = Pool.takeOut(RecoverName.CHICKEN_EGG)
if (!this.chickenEgg) { if (!this.chickenEgg) {
//新建,里面是解锁的所有图片组
this.chickenEgg = new ChickenEgg(); this.chickenEgg = new ChickenEgg();
} else { } else {
this.chickenEgg.reset(); this.chickenEgg.reset();
} }
this.addChild(this.chickenEgg) this.addChild(this.chickenEgg)
} }
//
} }
/** /**
...@@ -191,13 +176,28 @@ export class Element extends eui.Component { ...@@ -191,13 +176,28 @@ export class Element extends eui.Component {
//特效重置 //特效重置
this.effectType = null; this.effectType = null;
this.temEffectType = null; this.temEffectType = null;
//lock重置 //所有状态重置
this._isLock = false; for (var i = 0; i < this.states.length; i++) {
//回收lockImage let state = this.states[i];
if (this.lockAni) { if (!state) continue
this.removeChild(this.lockAni); //直接移除
Pool.recover(RecoverName.LOCK_ANI, this.lockAni); this.removeChild(state);
this.lockAni = null; //直接回收
var recoverType: RecoverName
switch (i) {
case StateType.LOCK:
recoverType = RecoverName.LOCK_STATE;
break;
case StateType.BUBBLE:
recoverType = RecoverName.BUBBLE_STATE;
break;
case StateType.HAIRBALL:
recoverType = RecoverName.HAIRBALL_STATE;
break;
}
Pool.recover(recoverType, state);
//置空
this.states[i] = null;
} }
//如果类型是鸡蛋 //如果类型是鸡蛋
if (type == ElementType.CHICKEN_EGG) { if (type == ElementType.CHICKEN_EGG) {
...@@ -217,7 +217,7 @@ export class Element extends eui.Component { ...@@ -217,7 +217,7 @@ export class Element extends eui.Component {
} }
} }
private removeHas() { private removeEffectHas() {
//回收掉原先有的 //回收掉原先有的
switch (this._effectType) { switch (this._effectType) {
case EffectType.MAGICLION: case EffectType.MAGICLION:
...@@ -249,4 +249,87 @@ export class Element extends eui.Component { ...@@ -249,4 +249,87 @@ export class Element extends eui.Component {
// .to({ scaleY: 0.7 }, 200) // .to({ scaleY: 0.7 }, 200)
// .to({ scaleY: 1 }, 100) // .to({ scaleY: 1 }, 100)
} }
/**
* 是否有该状态
* @param state
*/
hasState(state: StateType): boolean {
return !!this.states[state];
}
/**
* 设置状态
* @param state 状态类型
* @param set true为设置
*/
setState(state: StateType, set: boolean, data?: any) {
//set为false的话,
if (!set) {
//如果原先有状态,去掉
if (this.hasState(state)) {
//自己回收,动画,然后从父级移除,最后进入pool
this.states[state].recover();
//置空
this.states[state] = null;
}
//原先每状态不管
else {
}
}
//set为true的话
else {
//如果有状态,执行重置
if (this.hasState(state)) {
this.states[state].reset(data);
}
//没有的话加上
else {
switch (state) {
case StateType.LOCK:
let lockState = Pool.takeOut(RecoverName.LOCK_STATE);
if (!lockState) {
lockState = new LockState();
} else {
lockState.reset()
}
this.states[state] = lockState;
break;
case StateType.BUBBLE:
break;
case StateType.HAIRBALL:
let hairBallState = Pool.takeOut(RecoverName.HAIRBALL_STATE);
if (!hairBallState) {
hairBallState = new HairballState(data);
} else {
hairBallState.reset(data)
}
this.states[state] = hairBallState;
break;
}
//视图添加
this.addChild(this.states[state]);
}
}
}
/**
* 判断是否有任何特效,true表示有,false表示没有
*/
hasAnyState(): boolean {
for (var i = 0; i < this.states.length; i++) {
if (this.states[i]) return true
}
return false
}
/**
* 取得一个状态
* @param state
*/
getState(state: StateType): any {
return this.states[state]
}
} }
\ No newline at end of file
import { ElementType } from "../enum/ElementType";
export class Ice extends eui.Image { export class Ice extends eui.Image {
/** /**
...@@ -18,7 +19,7 @@ export class Ice extends eui.Image { ...@@ -18,7 +19,7 @@ export class Ice extends eui.Image {
constructor(n: number = 2) { constructor(n: number = 2) {
super() super()
this.source = "ele7_png"; this.source = "ele" + ElementType.ICE + "_png";
if (n == 2) { if (n == 2) {
this.alpha = 1; this.alpha = 1;
} else { } else {
...@@ -28,7 +29,7 @@ export class Ice extends eui.Image { ...@@ -28,7 +29,7 @@ export class Ice extends eui.Image {
} }
reset(n: number = 2){ reset(n: number = 2) {
this.scaleX = this.scaleY = 1; this.scaleX = this.scaleY = 1;
if (n == 2) { if (n == 2) {
this.alpha = 1; this.alpha = 1;
......
import { Element } from "./Element";
/**
* 元素的各种状态
*/
export class State extends egret.DisplayObjectContainer {
constructor() {
super()
}
//重置方法,子类重写
reset(data: any) {
}
//回收,子类继承重写
recover() {
}
}
\ No newline at end of file
/** /**
* 元素类型 <=4就是基础元素 * 元素类型 <=4就是基础元素
*
* 修改索引时,需要修改ele的图片,和通关目标类。飞入特效类
*/ */
export enum ElementType { export enum ElementType {
//基础5种元素
RABBIT = 0,//兔子0 RABBIT = 0,//兔子0
CHICKEN,//鸡1 CHICKEN,//鸡1
CATTLE,//牛2 CATTLE,//牛2
LION,//狮子3 LION,//狮子3
PIG,//猪4 PIG,//猪4
//特殊元素
ROCK,//石头5 ROCK,//石头5
LOLLIPOP,//棒棒糖6 LOLLIPOP,//棒棒糖6
JELLY,//果冻7
CHICKEN_EGG,//鸡蛋8
ICE,//冰块7 有时间重构的话,不适合放这里 //下面几种为了通关目标,有时间重构的话,不适合放这里
//地图状态
ICE,//冰块9
//元素身上状态
HAIRBALL,//毛球10
JELLY,//果冻8
CHICKEN_EGG,//鸡蛋9
} }
var a = [ var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0, 0, 40, 30, 0, 44, 0, 20, 40, 0,
......
/** /**
* 掉落元素类型 * 掉落元素类型
* 没用了
*/ */
export enum FallEleType { export enum FallEleType {
RANELE = 0,//随机元素无特效 RANELE = 0,//随机元素无特效
......
...@@ -20,7 +20,6 @@ export enum RecoverName { ...@@ -20,7 +20,6 @@ export enum RecoverName {
//元素身上 //元素身上
LOCK_ANI = "LockAni",
MAGICLIONBG_ANI = "MagicLionBgAni", MAGICLIONBG_ANI = "MagicLionBgAni",
HORIZONTALBG_ANI = "HorizontalBgAni", HORIZONTALBG_ANI = "HorizontalBgAni",
VERTICALBG_ANI = "VerticalBgAni", VERTICALBG_ANI = "VerticalBgAni",
...@@ -44,5 +43,10 @@ export enum RecoverName { ...@@ -44,5 +43,10 @@ export enum RecoverName {
EGGBROKEN_ANI = "EggBrokenAni", EGGBROKEN_ANI = "EggBrokenAni",
//方形遮罩 //方形遮罩
RECT_MASK = "RectMask" RECT_MASK = "RectMask",
//状态的回收
LOCK_STATE ="LockState",
BUBBLE_STATE="BubbleState",
HAIRBALL_STATE="HairballState",
} }
\ No newline at end of file
/**
* 通关类型
*/
export enum StateType {
LOCK = 0,//锁
BUBBLE,//变色气泡
HAIRBALL,//毛球
}
\ No newline at end of file
import { FallEleType } from "../enum/FallELeType";
/** /**
* 格子生成口数据格式 * 格子生成口数据格式
*/ */
...@@ -11,8 +8,9 @@ export interface GenerateLatData{ ...@@ -11,8 +8,9 @@ export interface GenerateLatData{
index: number; index: number;
/** /**
* 掉落元素类型 * 掉落元素类型
* 里面随机类型和下一致
*/ */
type:FallEleType type:number[]
/** /**
* 自定义掉落元素 * 自定义掉落元素
* 十位是基础元素类型,对应数字减1就是基础元素类型 * 十位是基础元素类型,对应数字减1就是基础元素类型
......
...@@ -31,6 +31,9 @@ export interface MapData { ...@@ -31,6 +31,9 @@ export interface MapData {
* 4元素枷锁 * 4元素枷锁
* 5果冻 * 5果冻
* 6鸡蛋 * 6鸡蛋
* 7变色气泡
* 8一级毛球
* 9二级毛球
*/ */
elements?: number[]; elements?: number[];
/** /**
......
...@@ -8,6 +8,7 @@ import { Lattice } from "../class/Lattice"; ...@@ -8,6 +8,7 @@ import { Lattice } from "../class/Lattice";
import { ChickenEgg } from "../class/ChickenEgg"; import { ChickenEgg } from "../class/ChickenEgg";
import { HatchAni } from "../anis/HatchAni"; import { HatchAni } from "../anis/HatchAni";
import { PieceToEggAni } from "../anis/PieceToEggAni"; import { PieceToEggAni } from "../anis/PieceToEggAni";
import { StateType } from "../enum/StateType";
//孵鸡的数量 //孵鸡的数量
const chickenNum: number = 4 const chickenNum: number = 4
...@@ -22,12 +23,31 @@ export class AiControl { ...@@ -22,12 +23,31 @@ export class AiControl {
*/ */
private hasJelly: boolean; private hasJelly: boolean;
/** /**
* 提前记录所有的鸡蛋的索引 * 提前记录所有的鸡蛋的索引,因为鸡蛋数量不会改变
*/ */
private eggs: number[]; private eggs: number[];
/**
* 判断是否还有气泡,暂时不考虑气泡能再生
*/
private hasBubble: boolean;
/**
* 判断是否还有毛球,暂时不考虑毛球能再生
*/
private hasHairball: boolean;
/**
* 用于判断格子中
* 是否有果冻,
* 是否有鸡蛋,
* 是否有毛球,
* 是否有变色气泡,
* 必须在初始化元素后执行
* @param lattices
*/
init(lattices: Lattice[]) { init(lattices: Lattice[]) {
this.hasJelly = judgeJellyExist(lattices); this.hasJelly = judgeJellyExist(lattices);
this.hasBubble = judgeBubbleExist(lattices);
this.hasHairball = judgeHairballExist(lattices);
this.eggs = getEggs(lattices); this.eggs = getEggs(lattices);
} }
...@@ -96,13 +116,13 @@ export class AiControl { ...@@ -96,13 +116,13 @@ export class AiControl {
var chickenIndexs: number[] = []; var chickenIndexs: number[] = [];
for (var a = 0; a < thisObj.lattices.length; a++) { for (var a = 0; a < thisObj.lattices.length; a++) {
var lat = thisObj.lattices[a]; var lat = thisObj.lattices[a];
if (lat && //是基础元素,但是不能有任何状态
lat.element && if (Tool.judgeBaseEle(lat) &&
lat.element.type <= 4) { !lat.element.hasAnyState()) {
chickenIndexs.push(a); chickenIndexs.push(a);
} }
} }
//如果没有能飞的格子 //如果没有能飞的格子,直接回调
if (!chickenIndexs.length) { if (!chickenIndexs.length) {
callback(); callback();
return return
...@@ -120,7 +140,7 @@ export class AiControl { ...@@ -120,7 +140,7 @@ export class AiControl {
for (var b = 0; b < activeEggIndexs.length; b++) { for (var b = 0; b < activeEggIndexs.length; b++) {
let activeEggIndex = activeEggIndexs[b]; let activeEggIndex = activeEggIndexs[b];
//从chickenIndexsCopy取四个,不足就在chickenIndexs随个 //从chickenIndexsCopy取四个,不足就在chickenIndexs随个
let four: number[] = chickenIndexsCopy.splice(0, 4); let four: number[] = chickenIndexsCopy.splice(0, chickenNum);
if (four.length < chickenNum) { if (four.length < chickenNum) {
//补上剩下的,如果还不足,就不管 //补上剩下的,如果还不足,就不管
four = four.concat(Tool.getRandomArrayElementsEx(chickenIndexs, chickenNum - four.length)) four = four.concat(Tool.getRandomArrayElementsEx(chickenIndexs, chickenNum - four.length))
...@@ -145,6 +165,7 @@ export class AiControl { ...@@ -145,6 +165,7 @@ export class AiControl {
if (count == countAll) { if (count == countAll) {
//做个延时,有节奏感 //做个延时,有节奏感
setTimeout(() => { setTimeout(() => {
//检测三消,有就执行消除,没有就回调
if (thisObj.threeMatch()) { if (thisObj.threeMatch()) {
thisObj.eliminate(); thisObj.eliminate();
} else { } else {
...@@ -156,6 +177,36 @@ export class AiControl { ...@@ -156,6 +177,36 @@ export class AiControl {
} }
} }
/**
* 变色气泡
*
* @param thisObj
* @param callback
*/
bubbleMotion(thisObj: MainScene, callback: Function) {
//无气泡,直接回调
if (!this.hasBubble) {
callback();
return
}
//找出所有的气泡
var indexs = [];
for (var i = 0; i < thisObj.lattices.length; i++) {
var lat = thisObj.lattices[i];
//是基础元素,有气泡状态
if (Tool.judgeBaseEle(lat) && !lat.element.hasState(StateType.BUBBLE)) {
indexs.push(i);
}
}
let count = 0;
let contAll = indexs.length;
//对所有气泡进行变色处理
for (var a = 0; a < indexs.length; a++) {
}
}
} }
...@@ -174,6 +225,30 @@ function judgeJellyExist(lattices: Lattice[]) { ...@@ -174,6 +225,30 @@ function judgeJellyExist(lattices: Lattice[]) {
} }
return false; return false;
} }
/**
* 判断毛球是否存在
* @param lattices
*/
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
}
return false;
}
/**
* 判断气泡是否存在
* @param lattices
*/
function judgeBubbleExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//必须是基础元素,然后判断状态气泡,有一个就返回true
if (Tool.judgeBaseEle(lattice) && lattice.element.hasState(StateType.BUBBLE)) return true
}
return false;
}
/** /**
* 获取所有鸡蛋的索引 * 获取所有鸡蛋的索引
* @param lattices * @param lattices
...@@ -190,15 +265,15 @@ function getEggs(lattices: Lattice[]) { ...@@ -190,15 +265,15 @@ function getEggs(lattices: Lattice[]) {
) { ) {
arr.push(i) arr.push(i)
} }
} }
return arr; return arr;
} }
/** /**
* 获取能蔓延的 * 获取能蔓延的果冻
* @param lattices * @param lattices
* @return 返回自身索引和蔓延的索引
*/ */
function getJellySpreadAni(lattices: Lattice[]) { function getJellySpreadAni(lattices: Lattice[]) {
var indexs: number[] = []; var indexs: number[] = [];
...@@ -208,6 +283,7 @@ function getJellySpreadAni(lattices: Lattice[]) { ...@@ -208,6 +283,7 @@ function getJellySpreadAni(lattices: Lattice[]) {
if (!lattice || !lattice.element || lattice.element.type != ElementType.JELLY) continue if (!lattice || !lattice.element || lattice.element.type != ElementType.JELLY) continue
indexs.push(i); indexs.push(i);
} }
//没有果冻,返回0
if (!indexs.length) return 0 if (!indexs.length) return 0
while (indexs.length) { while (indexs.length) {
var rand = Math.floor(Math.random() * indexs.length); var rand = Math.floor(Math.random() * indexs.length);
...@@ -238,10 +314,8 @@ function judgeSpread(index: number, lattices: Lattice[]): number { ...@@ -238,10 +314,8 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
while (arr.length) { while (arr.length) {
var rand = Math.floor(Math.random() * arr.length); var rand = Math.floor(Math.random() * arr.length);
var i = arr.splice(rand, 1)[0]; var i = arr.splice(rand, 1)[0];
if (lattices[i] && if (Tool.judgeBaseEle(lattices[i]) &&
lattices[i].element && !lattices[i].element.hasAnyState()) {
lattices[i].element.type <= 4 &&
!lattices[i].element.isLock) {
return i return i
} }
} }
...@@ -249,3 +323,6 @@ function judgeSpread(index: number, lattices: Lattice[]): number { ...@@ -249,3 +323,6 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
} }
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 枷锁状态
*/
export class HairballState 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) {
super();
this.showImage = new egret.Bitmap();
this.addChild(this.showImage);
this.levelNum = level;
this.isActive = false;
}
reset(level: number = 2) {
this.levelNum = level;
this.isActive = false;
}
recover() {
//动画是添加进这里的
//回收消失动效
setTimeout(() => {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_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
import { Ani } from "../class/Ani";
export class LockAni extends Ani {
export class LockAni extends egret.DisplayObjectContainer {
private showImage: egret.Bitmap; private showImage: egret.Bitmap;
constructor() { constructor() {
super() super()
this.aniName = "LockAni";
var texture: egret.Texture = RES.getRes("lockVine_png") var texture: egret.Texture = RES.getRes("lockVine_png")
this.showImage = new egret.Bitmap(texture); this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage); this.addChild(this.showImage);
...@@ -19,11 +17,12 @@ export class LockAni extends Ani { ...@@ -19,11 +17,12 @@ export class LockAni extends Ani {
reset() { reset() {
this.alpha = 1; this.alpha = 1;
} }
play() { play(callback: Function) {
egret.Tween.get(this) egret.Tween.get(this)
.to({ alpha: 0 }, 750) .to({ alpha: 0 }, 750)
.call(() => { .call(() => {
this.recover(); if (this.parent) this.parent.removeChild(this);
if (callback) callback();
}) })
} }
} }
......
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
/**
* 枷锁状态
*/
export class LockState extends State {
private showImage: egret.Bitmap;
constructor() {
super();
var texture: egret.Texture = RES.getRes("lockVine_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2
}
reset() {
this.alpha = 1;
}
recover() {
egret.Tween.get(this)
.to({ alpha: 0 }, 750)
.call(() => {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.LOCK_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