Commit c496919e authored by 邱旭's avatar 邱旭

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

parents 1910b8c5 a996c501
......@@ -293,19 +293,19 @@ const chapterFuns = {
]
},
//笼子消除
24: {
25: {
stepCount: 1,
showIndexs: [
[40, 49, 58, 50],
[0, 1, 2, 3],
],
hideIndexs: [
[40, 58],
[0, 1],
],
handIndexs: [
[49, 50]
[3, 2]
],
msg: [
"被困住的元素无法进行移动,当触发元素\n消除时,元素上的藤蔓即可被消除"
"和困住藤蔓里的动物匹配\n消除,就可以打破藤蔓啦!"
]
},
//果冻消除
......
This diff is collapsed.
import { ChapterData } from "./interface/ChapterData";
import { Element } from "./class/Element";
import { Lattice } from "./class/Lattice";
import { ElementType } from "./enum/ElementType";
import { ElementType, FiveBaseElementTypes } from "./enum/ElementType";
import { PassType } from "./enum/PassType";
import { EffectType } from "./enum/EffectType";
import { Pool } from "./Pool";
......@@ -16,7 +16,7 @@ export class Tool {
* 每格掉落时间
* 掉落速度这个定
*/
public static latDeltaTime:number = 90;
public static latDeltaTime: number = 90;
/**
* 总行数
*/
......@@ -304,21 +304,18 @@ export class Tool {
/**
* 判断格子上是基础元素,包括各种状态的
*
* @param lat
*/
public static judgeBaseEle(lat: Lattice) {
//上方格子为null,或格子上元素为null
if (!lat || !lat.element) {
return false
}
//不是基础元素,元素类型枚举01234
else if (lat.element.type > 4) {
return false
}
//剩下情况
else {
if (lat &&
lat.element &&
FiveBaseElementTypes.indexOf(lat.element.type) >= 0 //在5种基本元素中
) {
return true
}
return false
}
/**
......@@ -654,9 +651,7 @@ export class Tool {
//记录是否有三个格子挨着,且未锁定,没有毛球,这个逻辑略烦,暂定至少都未锁定,有bug再改
var hasThree = false;
for (var i = 0; i < lattices.length; i++) {
if (lattices[i] &&
lattices[i].element &&
lattices[i].element.type <= 4 &&
if (this.judgeBaseEle(lattices[i]) &&
!lattices[i].element.hasState(StateType.LOCK) &&
!lattices[i].element.hasState(StateType.HAIRBALLGREY) &&
!lattices[i].element.hasState(StateType.HAIRBALLBLACK) &&
......@@ -938,7 +933,7 @@ export class Tool {
* 十位是基础元素类型,对应数字减1就是基础元素类型
* 个位是特效类型(0表示无特效),对应数字减1就是特效类型
* @param num
* @return [] 0下标是元素类型,1下标是特效类型
* @return [] 0下标是元素类型(返回null说明不合规则),1下标是特效类型
*/
public static praseEleNumber(num) {
//解析num;
......@@ -946,7 +941,7 @@ export class Tool {
//基础类型,没有就是null,有就-1,对ElementType对应
var baseType = arr[1] ? arr[1] - 1 : null;
//不是基础类型
if (baseType > 4) baseType = null;
if (FiveBaseElementTypes.indexOf(baseType) == -1) baseType = null;
//特效类型
var effectType = arr[0] ? arr[0] - 1 : null;
return [baseType, effectType];
......
......@@ -26,7 +26,7 @@ export function HatchAni(startIndex: number, endIndexs: number[], thisObj: MainS
//回收
thisObj.removeChild(eleC);
Pool.recover(RecoverName.ELEMENT, eleC);
//对应的索引的类型变成鸡
//对应的索引的类型变成鸡,抛物线动画时间都一致,其实可以在统一回调里执行数据更新
thisObj.lattices[endIndex].element.reset(ElementType.CHICKEN);
//动画,和bonusTime的效果一样,暂时没加
......
......@@ -4,6 +4,7 @@ import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
import { Element } from "../class/Element";
/**
* 需要回调的
......@@ -18,7 +19,7 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
shoot: egret.Bitmap;
constructor() {
super()
var texture: egret.Texture = RES.getRes("ele"+ElementType.JELLY+"_png")
var texture: egret.Texture = RES.getRes("ele" + ElementType.JELLY + "_png")
this.targetImage = new egret.Bitmap(texture);
this.targetImage.anchorOffsetX = texture.textureWidth / 2;
this.targetImage.anchorOffsetY = texture.textureHeight / 2;
......@@ -35,9 +36,14 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
this.addChild(this.shoot);
}
play(startP: number[], endP: number[], callback: Function) {
play(startP: number[], cloneEle: Element, callback: Function) {
this.x = startP[0];
this.y = startP[1];
//终点位置全局先赋值出来,判断用
var endP = [cloneEle.x, cloneEle.y];
//添加进
this.addChildAt(cloneEle, 0);
this.shoot.visible = true;
this.shoot.x = 0
......@@ -80,7 +86,9 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
obj.x = -Tool.width;
}
}
//cloneEle的位置赋值
cloneEle.x = this.targetImage.x;
cloneEle.y = this.targetImage.y;
egret.Tween.get(this.oriImage)
.to({ scaleX: 1.07, scaleY: 0.89 }, 150)
......@@ -94,6 +102,10 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
.to({ scaleX: 2, scaleY: 1 }, 230)
.to(obj, 50)
.call(() => {
//回收克隆元素
this.removeChild(cloneEle);
Pool.recover(RecoverName.ELEMENT, cloneEle)
//回调
callback();
this.shoot.visible = false;
this.targetImage.visible = true;
......
This diff is collapsed.
......@@ -15,6 +15,7 @@ import { HairballBrownState } from "../states/HairballBrownState";
import { BubbleState } from "../states/BubbleState";
import { HairballGreyState } from "../states/HairballGreyState";
import { HairballBlackState } from "../states/HairballBlackState";
import { Tool } from "../Tool";
/**
......@@ -124,10 +125,14 @@ export class Element extends eui.Component {
/**
* 所有的状态,注意,变色气泡特殊,不能和特效共存,所以初始化时,气泡的不能加特效。生成特效,去掉气泡
* 索引必须按枚举
* 索引必须按StateType的枚举
*/
private states: State[] = []
/**
*
* @param type 只应该是基础元素和特殊元素
*/
constructor(type: ElementType) {
super();
this._type = type;
......@@ -170,7 +175,7 @@ export class Element extends eui.Component {
/**
* 会重置掉所有特效类型,枷锁,鸡蛋等
* @param type
* @param type 只应该是基础元素和特殊元素
*/
reset(type: ElementType) {
this.alpha = this.scaleX = this.scaleY = 1;
......@@ -229,6 +234,7 @@ export class Element extends eui.Component {
/**
* 只修改类型,不改变其他状态
* @param type 只应该是基础元素和特殊元素
*/
resetType(type: ElementType) {
//如果重置成特殊元素,或鸡蛋,或石头,或果冻,或棒棒糖,直接用reset方法
......@@ -408,4 +414,28 @@ export class Element extends eui.Component {
getState(state: StateType): any {
return this.states[state]
}
/**
* 克隆一个
* 类型
* 特效
* 状态
* 位置
*/
clone(): Element {
let ele = Tool.getElement(this.type);
//特效加上
ele.effectType = this.effectType;
//状态加上
for (var i = 0; i < this.states.length; i++) {
let state = this.states[i];
if (!state) continue;
ele.setState(i, true, this.type)
}
//位置信息
ele.x = this.x;
ele.y = this.y;
return ele
}
}
\ No newline at end of file
/**
* 元素类型 <=4就是基础元素
*
* 枚举尽量从后面添加,否则要改很多东西,submitTran重新对应,ele图片重新对应,开始弹框目标实现等等,没改全后果自负
* 修改索引时,需要修改ele的图片,和通关目标类。飞入特效类
*/
export enum ElementType {
......@@ -26,17 +26,18 @@ export enum ElementType {
HAIRBALLBROWN,//褐色毛球11
HAIRBALLBLACK,//黑色毛球12
}
var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0,
0, 20, 20, 0, 40, 0, 50, 50, 0,
0, 30, 50, 0, 3, 0, 20, 30, 0,
0, 10, 0, 0, 0, 0, 0, 20, 0,
0, 50, 40, 0, 0, 0, 10, 30, 0,
30, 10, 30, 50, 0, 40, 50, 50, 20,
0, 50, 40, 30, 50, 20, 10, 40, 0,
0, 0, 10, 10, 3, 30, 50, 0, 0,
0, 0, 0, 30, 50, 40, 0, 0, 0,
/**
* 5种基本元素的数组,每项是ElementType的枚举值
*/
export const FiveBaseElementTypes: ElementType[] = [
ElementType.RABBIT,
ElementType.CHICKEN,
ElementType.CATTLE,
ElementType.LION,
ElementType.PIG,
]
export const codeMsgs = {
"E1002090011": "用户关卡记录异常",
"E1002090012": "暂不能挑战此关卡",
......
......@@ -10,12 +10,16 @@ import { HatchAni } from "../anis/HatchAni";
import { PieceToEggAni } from "../anis/PieceToEggAni";
import { StateType } from "../enum/StateType";
import { BubbleAni } from "../anis/BubbleAni";
import { Element } from "../class/Element";
//孵鸡的数量
const chickenNum: number = 4
export class AiControl {
private static _ins: AiControl
/**
* 只实例一次,所以不能直接把thisObj干进来,每个方法里带吧
*/
static get ins() {
return AiControl._ins || (AiControl._ins = new AiControl())
}
......@@ -32,7 +36,7 @@ export class AiControl {
*/
private hasBubble: boolean;
/**
* 判断是否还有毛球,暂时不考虑毛球能再生
* 判断是否还有毛球,暂时不考虑毛球能再生,以后可能改能掉落毛球,再说
*/
private hasHairball: boolean;
......@@ -102,16 +106,28 @@ export class AiControl {
jellySpreadAni = new JellySpreadAni()
}
thisObj.addChild(jellySpreadAni);
//隐藏原来的元素
thisObj.lattices[spread[0]].element.visible = false;
jellySpreadAni.play(Tool.getPositionByIndex(spread[0]), Tool.getPositionByIndex(spread[1]), () => {
//显示隐藏元素
thisObj.lattices[spread[0]].element.visible = true;
//播放完后,将终点元素变成果冻
thisObj.lattices[spread[1]].element.reset(ElementType.JELLY);
//执行回调
callback()
})
//起始元素
let fromEle: Element = thisObj.lattices[spread[0]].element;
//终点元素
let endEle: Element = thisObj.lattices[spread[1]].element;
//克隆一个终点元素
let cloneEle: Element = endEle.clone();
//对后续有影响的数据必须提交更新,视图不对就隐藏先,动画里加上对应视图,动画播放回调里去掉动画视图,显示数据视图;
//将终点元素变成果冻,,
endEle.reset(ElementType.JELLY);
//隐藏元素
fromEle.visible = false;
endEle.visible = false;
jellySpreadAni.play(
Tool.getPositionByIndex(spread[0]),
cloneEle,
() => {
//显示隐藏元素
fromEle.visible = true;
endEle.visible = true;
//执行回调
callback()
})
}
/**
* 鸡蛋得孵化逻辑
......@@ -171,6 +187,7 @@ export class AiControl {
//补上剩下的,如果还不足,就不管
four = four.concat(Tool.getRandomArrayElementsEx(chickenIndexs, chickenNum - four.length))
}
//四个元素变成鸡的数据更新在动画播放完的函数里执行,暂时对数据无影响,延后更新数据无妨
//播蛋壳动画
let activeEgg = thisObj.lattices[activeEggIndex].element.chickenEgg;
activeEgg.visible = false;
......@@ -215,12 +232,12 @@ export class AiControl {
callback();
return
}
//找出所有的气泡
//找出所有的气泡,必须按顺序,从左到右,从上到下
var indexs: number[] = [];
for (var i = 0; i < thisObj.lattices.length; i++) {
var lat = thisObj.lattices[i];
//是基础元素,有气泡状态
if (Tool.judgeBaseEle(lat) && !lat.element.hasState(StateType.BUBBLE)) {
if (Tool.judgeBaseEle(lat) && lat.element.hasState(StateType.BUBBLE)) {
indexs.push(i);
}
}
......@@ -240,8 +257,8 @@ export class AiControl {
let ele = lat.element;
let fromType = ele.type;
//计算type
let type: ElementType = 1;
//直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示
let type: ElementType = getBubbleType(index, thisObj.lattices, thisObj.chapterData.baseElementTypes);
//直接重置类型,为了后续计算泡泡类型,但是要隐藏,待动画播放完显示
ele.resetType(type);
ele.visible = false;
//变色动画
......@@ -265,6 +282,70 @@ export class AiControl {
})
}
}
/**
* 跳动,以及褐色毛球的分裂
* 黑色毛球眩晕不执行跳动,不过结束后要重置为不眩晕状态,和callback同步执行
* @param thisObj
* @param callback
*/
hairballMotion(thisObj: MainScene, callback: Function) {
//没有毛球。直接回调
if (!this.hasHairball) {
callback();
return
}
//找出所有能跳动的毛球;
var jumpBallIndexs: number[] = [];
//即将唤醒的黑色毛球
var awakeBallIndexs: number[] = [];
//即将分裂的褐色毛球
var divideBallIndexs: number[] = [];
for (var i = 0; i < thisObj.lattices.length; i++) {
var lat = thisObj.lattices[i];
//是基础元素
if (Tool.judgeBaseEle(lat)) {
//灰色直接进跳动
if (lat.element.hasState(StateType.HAIRBALLGREY)) {
jumpBallIndexs.push(i);
}
//黑色
if (lat.element.hasState(StateType.HAIRBALLBLACK)) {
//醒着的跳动
if (lat.element.getState(StateType.HAIRBALLBLACK).isAwake) {
jumpBallIndexs.push(i);
}
//晕着的即将醒
else {
awakeBallIndexs.push(i);
}
}
//褐色
if (lat.element.hasState(StateType.HAIRBALLBROWN)) {
//激活的即将分裂
if (lat.element.getState(StateType.HAIRBALLBROWN).isActive) {
divideBallIndexs.push(i);
}
//未激活的跳动
else {
jumpBallIndexs.push(i);
}
};
}
}
//没有毛球,直接回调,
if (!jumpBallIndexs.length && !awakeBallIndexs.length && !divideBallIndexs.length) {
//标记无毛球
this.hasHairball = false;
callback();
return
}
//分裂的优先
//跳动的
//唤醒的
}
}
/**
......@@ -282,7 +363,7 @@ function judgeJellyExist(lattices: Lattice[]) {
return false;
}
/**
* 判断毛球是否存在
* 判断毛球是否存在,甭管什么毛球
* @param lattices
*/
function judgeHairballExist(lattices: Lattice[]) {
......@@ -355,8 +436,67 @@ function judgeSpread(index: number, lattices: Lattice[]): number {
}
return null
}
/**
* 获得气泡变化类型
* @param index 变化的格子索引
* @param lattices 所有格子
* @param baseElementTypes 可选基础类型
*/
function getBubbleType(index: number, lattices: Lattice[], baseElementTypes: number[]): ElementType {
//变色,只取基础类型
var rc = Tool.indexToRc(index);
var arr = baseElementTypes.slice();
let operation = (lat1: Lattice, lat2: Lattice) => {
//必须是都可匹配的
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
}
//和左边两个比较
if (rc[1] > 1) operation(lattices[index - 1], lattices[index - 2])
//和上边两个比较
if (rc[0] > 1) operation(lattices[index - Tool.colNum], lattices[index - Tool.colNum * 2])
//下面的比较都要忽略因为顺序从小到大,所以忽略带气泡状态的,
//与左右边两个比较,不能是第一列和最后一列
if (rc[1] > 0 && rc[1] < Tool.colNum - 1) {
let lat1 = lattices[index - 1];
let lat2 = lattices[index + 1];
//右边的格子,不能有气泡,有气泡就不用去判断了
if (Tool.judgeMatch(lat2) && !lat2.element.hasState(StateType.BUBBLE)) operation(lat1, lat2)
}
//与上下两个比较,不能是第一行和最后一行
if (rc[0] > 0 && rc[0] < Tool.rowNum - 1) {
let lat1 = lattices[index - Tool.colNum];
let lat2 = lattices[index + Tool.colNum];
//下边的格子,不能有气泡,有气泡就不用去判断了
if (Tool.judgeMatch(lat2) && !lat2.element.hasState(StateType.BUBBLE)) operation(lat1, lat2)
}
// function getBubble
//右二或下二的判断操作
let operationAdd = (lat1: Lattice, lat2: Lattice) => {
if (Tool.judgeMatch(lat1) &&
Tool.judgeMatch(lat2) &&
!lat1.element.hasState(StateType.BUBBLE) &&
!lat2.element.hasState(StateType.BUBBLE) &&
lat1.element.type == lat2.element.type) {
Tool.removeEle(lat1.element.type, arr);
}
}
//与右边两个比较
if (rc[1] < Tool.colNum - 2) operationAdd(lattices[index + 1], lattices[index + 2]);
//与下边两个比较
if (rc[0] < Tool.colNum - 2) operationAdd(lattices[index + Tool.colNum], lattices[index + Tool.colNum * 2]);
//如果没有可选,返回自身的类型,动画还是要放的
if (!arr.length) return lattices[index].element.type;
//随机一个
return Tool.randomT(arr);
}
......
......@@ -7,35 +7,42 @@ import { ElementType } from "../enum/ElementType";
/**
* 黑色毛球状态
* 两次消除,需要修改图片,,,再说,还没写
* 两次消除,需要修改图片,,,再说,还没写,切换眩晕状态,是否有动画,都再说
*/
export class HairballBlackState extends State {
private showImage: egret.Bitmap;
/**
* 是否激活
*/
isActive: boolean;
_isAwake: boolean;
get isAwake(): boolean {
return this._isAwake;
}
set isAwake(value: boolean) {
this._isAwake = value;
//换图
}
constructor() {
super();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLBLACK + "_png")
this.showImage = new egret.Bitmap(texture);
this.showImage = new egret.Bitmap();
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false;
this.changeSource("ele" + ElementType.HAIRBALLBLACK + "_png")
this._isAwake = true;
}
reset() {
this.isActive = false;
this._isAwake = true;
//换图
this.changeSource("ele" + ElementType.HAIRBALLBLACK + "_png")
}
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
// }
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
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