Commit fcbff6ce authored by wildfirecode's avatar wildfirecode

1

parent c47ff5ff
......@@ -32,7 +32,8 @@ import { ThreeCrossAni } from '../something/anis/ThreeCrossAni';
import { VerticalAni } from '../something/anis/VerticalAni';
import { FesRedBombShowAni } from '../something/anisCall/FesRedBombShowAni';
import { RectsWaveAni } from '../something/anisCall/RectsWaveAni';
import BlockBase, { genBlockDisplay } from '../something/block/BlockBase';
import BaseBlock from '../something/block/BaseBlock';
import genBlockDisplay from '../something/block/genBlockDisplay';
import { getChapterData } from '../something/chapters/getChapter';
import { Element } from '../something/class/Element';
import { Ice } from '../something/class/Ice';
......@@ -506,7 +507,7 @@ export default class MainScene extends Scene {
this.lattices[i].ice = ice;
} else {
latticeDisplay = genBlockDisplay(latticesD[i]);
this.lattices[i].block = latticeDisplay;
this.lattices[i].block = latticeDisplay as BaseBlock;
}
this.map.addChild(latticeDisplay);
latticeDisplay.x = p[0];
......@@ -570,7 +571,7 @@ export default class MainScene extends Scene {
case ElementConfigType.EMPTY:
this.emptys.push(i);
break;
//基础元素,枷锁,气泡,灰色毛球,褐色毛球,黑色毛球
//基础元素,枷锁,气泡,灰色毛球,褐色毛球,黑色毛球 && 石门锁,有条件的锁
case ElementConfigType.BASE:
case ElementConfigType.LOCK:
case ElementConfigType.BUBBLE:
......@@ -1804,6 +1805,8 @@ export default class MainScene extends Scene {
this.eliminate()
return
}
//消除结束之后检查石门
this.checkAllBlock();
//鸡蛋的ai操作,存在判断三消,毛球的ai,也一样,所以放前面,存在三消时都直接执行eliminate了。不执行后续的回调
AiControl.ins.eggMotion(this, () => {
//后执行毛球跳动
......@@ -1881,6 +1884,12 @@ export default class MainScene extends Scene {
})
})
}
checkAllBlock() {
this.lattices.filter(item => item.block).forEach((item) => {
item.block.nextState();
});
}
/**
* 果冻蔓延和气泡变色需要重新检查死图
*/
......@@ -2687,20 +2696,19 @@ export default class MainScene extends Scene {
const p = Tool.getPositionByIndex(lat.index);
//动画
this.playAni(RecoverName.ICE_ANI, p);
} else if (lat.block) {//石门(可能带冰)
} else if (lat.block && lat.block.ice && lat.block.canIceBroken) {//石门(可能带冰) && 石门反转了可以消除了
const block = lat.block;
block.iceCountNum--;
if (block.iceCountNum == 0) {
block.ice && this.map.removeChild(block.ice);
block.ice && block.ice.parent && block.ice.parent.removeChild(block.ice);
this.goElementTarget(ElementType.ICE, [block.x, block.y]);
block.ice = null;
this.goElementTarget(ElementType.ICE, [block.ice.x, block.ice.y]);
} else {
block.ice.alpha = 0.6;
}
const p = Tool.getPositionByIndex(lat.index);
//动画
this.playAni(RecoverName.ICE_ANI, p);
}
}
......
......@@ -400,6 +400,7 @@ export class Tool {
if (!ele ||
ele.type == ElementType.ROCK ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.BLOCK_LOCK) || //石门盖住
ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN) ||
......
import centerAnchor from "./centerAnchor";
import { Element } from "../class/Element";
import { StateType } from "../enum/StateType";
export default class BaseBlock extends egret.DisplayObjectContainer {
constructor() {
super();
this.initUI();
}
initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png'));
this._blockBgFront = new egret.Bitmap(RES.getRes('common_block_front_png'));
this._blockBgBlue = new egret.Bitmap(RES.getRes('common_block_bg_blue_png'));
this._blockBgRed = new egret.Bitmap(RES.getRes('common_block_bg_red_png'));
this._blockBgYellow = new egret.Bitmap(RES.getRes('common_block_bg_yellow_png'));
this.addChild(this._blockBgBlue);
this.addChild(this._blockBgRed);
this.addChild(this._blockBgYellow);
this.addChild(this._block);
this.addChild(this._blockBgFront);
centerAnchor(this._block);
centerAnchor(this._blockBgFront);
centerAnchor(this._blockBgBlue);
centerAnchor(this._blockBgRed);
centerAnchor(this._blockBgYellow);
this._blockBgRed.scaleX = this._blockBgRed.scaleY = 1.1;
this._blockBgBlue.scaleX = this._blockBgBlue.scaleY = 1.1;
this._blockBgYellow.scaleX = this._blockBgYellow.scaleY = 1.1;
this.nextState(true);
}
private _element: Element;
set element(val: Element) {
if (val) {
this._element = val;
this.updateElementState(); //刚刚设置元素的时候
} else {
}
};
iceCountNum?: number;
ice: egret.Bitmap;
/**
* 石门反转了可以消除了
*/
get canIceBroken() {
return this._state >= 3;
}
//状态0红门 1蓝门 2黄门 3红 4黄 5蓝
private _state = -1;
private _changing = false;
nextState(first = false) {
//先改数据再改视图
this._state++;
if (this._state > 5)
this._state = 0;
this.changeState(first);
}
private updateElementState() {
if (this._state <= 2) {
this._element.scaleX = 0;
this._element.setState(StateType.BLOCK_LOCK,true);
}else {
this._element.scaleX = 1;
this._element.setState(StateType.BLOCK_LOCK,false);
}
}
playToFrontAni() {
return new Promise((r) => {
const dur = 300;
this._block.visible = true;
this._block.scaleX = 1;
egret.Tween.get(this._block).to({ scaleX: 0 }, dur).call(() => {
this._blockBgFront.visible = true;
this._blockBgFront.scaleX = 0;
if (this.ice) {
this.ice.visible = true;
this.ice.scaleX = 0;
egret.Tween.get(this.ice).to({ scaleX: 1 }, dur);
}
if (this._element) {
this._element.scaleX = 0;
egret.Tween.get(this._element).to({ scaleX: 1 }, dur);
}
egret.Tween.get(this._blockBgFront).to({ scaleX: 1 }, dur).call(() => {
r();
})
})
})
}
playToBackAni() {
return new Promise((r) => {
const dur = 300;
this._blockBgFront.visible = true;
this._blockBgFront.scaleX = 1;
egret.Tween.get(this._blockBgFront).to({ scaleX: 0 }, dur).call(() => {
this._block.visible = true;
this._block.scaleX = 0;
egret.Tween.get(this._block).to({ scaleX: 1 }, dur).call(() => {
r();
})
});
if (this.ice) {
this.ice.visible = true;
this.ice.scaleX = 1;
egret.Tween.get(this.ice).to({ scaleX: 0 }, dur);
}
if (this._element) {
this._element.scaleX = 1;
egret.Tween.get(this._element).to({ scaleX: 0 }, dur);
}
})
}
async changeState(first) {
if (this._changing) {
throw new Error('正在更改状态中')
}
this._changing = true;
this._block.visible = false;
this._blockBgFront.visible = false;
this._blockBgBlue.visible = false;
this._blockBgRed.visible = false;
this._blockBgYellow.visible = false;
switch (this._state) {
case 0:
if (!first) {
await this.playToBackAni();
this.updateElementState();
this._blockBgFront.visible = false;
this._blockBgFront.scaleX = 1;
} else {
this._block.visible = true;
}
this._blockBgRed.visible = true;
this.addAni(this._blockBgRed);
break;
case 1:
this._block.visible = true;
this._blockBgYellow.visible = true;
this.addAni(this._blockBgYellow);
break;
case 2:
this._block.visible = true;
this._blockBgBlue.visible = true;
this.addAni(this._blockBgBlue);
break;
case 3://翻转了
await this.playToFrontAni();
this.updateElementState();
this._block.visible = false;
this._block.scaleX = 1;
this._blockBgRed.visible = true;
this.addAni(this._blockBgRed);
break;
case 4://翻转了
this._blockBgFront.visible = true;
this._blockBgYellow.visible = true;
this.addAni(this._blockBgYellow);
break;
case 5://翻转了
this._blockBgFront.visible = true;
this._blockBgBlue.visible = true;
this.addAni(this._blockBgBlue);
break;
default:
break;
}
this._changing = false;
}
_blockBgYellow: egret.Bitmap;
_blockBgRed: egret.Bitmap;
_blockBgBlue: egret.Bitmap;
/**
* 未反转过来的背面
*/
_block: egret.Bitmap;
/**
* 反转过来的正面
*/
_blockBgFront: egret.Bitmap;
addAni(obj) {
egret.Tween.removeTweens(obj);
const dur = 600;
egret.Tween.get(obj, { loop: true }).set({ alpha: 0 })
.to({ alpha: 1 }, dur).to({ alpha: 0 }, dur)
.to({ alpha: 1 }, dur).to({ alpha: 0 }, dur)
// .wait(dur * 3);
}
}
\ No newline at end of file
import BlockBase from "./BlockBase";
import BaseBlock from "./BaseBlock";
import centerAnchor from "./centerAnchor";
export default class Block extends egret.DisplayObjectContainer implements BlockBase {
constructor() {
super();
this.initUI();
}
export default class Block extends BaseBlock {
initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png'));
this._blockBgFront = new egret.Bitmap(RES.getRes('common_block_front_png'));
this._blockBgBlue = new egret.Bitmap(RES.getRes('common_block_bg_blue_png'));
this._blockBgRed = new egret.Bitmap(RES.getRes('common_block_bg_red_png'));
this._blockBgYellow = new egret.Bitmap(RES.getRes('common_block_bg_yellow_png'));
this.addChild(this._block);
this.addChild(this._blockBgFront);
this.addChild(this._blockBgBlue);
this.addChild(this._blockBgRed);
this.addChild(this._blockBgYellow);
centerAnchor(this._block);
centerAnchor(this._blockBgFront);
centerAnchor(this._blockBgBlue);
centerAnchor(this._blockBgRed);
centerAnchor(this._blockBgYellow);
this._block.visible = false;
this._blockBgFront.visible = false;
this._blockBgBlue.visible = false;
this._blockBgRed.visible = false;
this._blockBgYellow.visible = false;
this.addAni(this._blockBgBlue);
this.addAni(this._blockBgYellow);
this.addAni(this._blockBgRed);
this._block.visible = true;
super.initUI();
}
private _blockBgYellow: egret.Bitmap;
private _blockBgRed: egret.Bitmap;
private _blockBgBlue: egret.Bitmap;
/**
* 未反转过来的背面
*/
private _block: egret.Bitmap;
/**
* 反转过来的正面
*/
private _blockBgFront: egret.Bitmap;
addAni(obj) {
const dur = 1000;
egret.Tween.get(obj, { loop: true }).to({ alpha: 0 }, dur).to({ alpha: 1 }, dur);
}
}
\ No newline at end of file
import BlockBase from "./BlockBase";
import { ElementType } from "../enum/ElementType";
import BaseBlock from "./BaseBlock";
import centerAnchor from "./centerAnchor";
export default class BlockDarkIce extends egret.DisplayObjectContainer implements BlockBase {
constructor() {
super();
this.initUI();
}
export default class BlockDarkIce extends BaseBlock {
initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png'));
this._blockBgFront = new egret.Bitmap(RES.getRes('common_block_front_png'));
this._blockBgBlue = new egret.Bitmap(RES.getRes('common_block_bg_blue_png'));
this._blockBgRed = new egret.Bitmap(RES.getRes('common_block_bg_red_png'));
this._blockBgYellow = new egret.Bitmap(RES.getRes('common_block_bg_yellow_png'));
super.initUI();
this.ice = new egret.Bitmap(RES.getRes("ele" + ElementType.ICE + "_png"));
this.ice.alpha = 1;
this.addChild(this.ice);
this.addChild(this._block);
this.addChild(this._blockBgFront);
this.addChild(this._blockBgBlue);
this.addChild(this._blockBgRed);
this.addChild(this._blockBgYellow);
centerAnchor(this._block);
centerAnchor(this._blockBgFront);
centerAnchor(this._blockBgBlue);
centerAnchor(this._blockBgRed);
centerAnchor(this._blockBgYellow);
centerAnchor(this.ice);
this.ice.visible = false;
this._block.visible = false;
this._blockBgFront.visible = false;
this._blockBgBlue.visible = false;
this._blockBgRed.visible = false;
this._blockBgYellow.visible = false;
this.addAni(this._blockBgBlue);
this.addAni(this._blockBgYellow);
this.addAni(this._blockBgRed);
this._block.visible = true;
}
iceCountNum=2;
checkRemoveIce() {
}
resetToBack() {
}
resetToFront() {
}
ice: egret.Bitmap;
private _blockBgYellow: egret.Bitmap;
private _blockBgRed: egret.Bitmap;
private _blockBgBlue: egret.Bitmap;
/**
* 未反转过来的背面
*/
private _block: egret.Bitmap;
/**
* 反转过来的正面
*/
private _blockBgFront: egret.Bitmap;
addAni(obj) {
const dur = 1000;
egret.Tween.get(obj, { loop: true }).to({ alpha: 0 }, dur).to({ alpha: 1 }, dur);
}
iceCountNum = 2;
}
\ No newline at end of file
import BlockBase from "./BlockBase";
import { ElementType } from "../enum/ElementType";
import BaseBlock from "./BaseBlock";
import centerAnchor from "./centerAnchor";
export default class BlockIce extends egret.DisplayObjectContainer implements BlockBase {
constructor() {
super();
this.initUI();
}
export default class BlockIce extends BaseBlock {
initUI() {
this._block = new egret.Bitmap(RES.getRes('common_block_png'));
this._blockBgFront = new egret.Bitmap(RES.getRes('common_block_front_png'));
this._blockBgBlue = new egret.Bitmap(RES.getRes('common_block_bg_blue_png'));
this._blockBgRed = new egret.Bitmap(RES.getRes('common_block_bg_red_png'));
this._blockBgYellow = new egret.Bitmap(RES.getRes('common_block_bg_yellow_png'));
super.initUI();
this.ice = new egret.Bitmap(RES.getRes("ele" + ElementType.ICE + "_png"));
this.ice.alpha = 0.6;
this.addChild(this.ice);
this.addChild(this._block);
this.addChild(this._blockBgFront);
this.addChild(this._blockBgBlue);
this.addChild(this._blockBgRed);
this.addChild(this._blockBgYellow);
centerAnchor(this._block);
centerAnchor(this._blockBgFront);
centerAnchor(this._blockBgBlue);
centerAnchor(this._blockBgRed);
centerAnchor(this._blockBgYellow);
centerAnchor(this.ice);
this.ice.visible = false;
this._block.visible = false;
this._blockBgFront.visible = false;
this._blockBgBlue.visible = false;
this._blockBgRed.visible = false;
this._blockBgYellow.visible = false;
this.addAni(this._blockBgBlue);
this.addAni(this._blockBgYellow);
this.addAni(this._blockBgRed);
this._block.visible = true;
}
iceCountNum=1;
ice: egret.Bitmap;
private _blockBgYellow: egret.Bitmap;
private _blockBgRed: egret.Bitmap;
private _blockBgBlue: egret.Bitmap;
/**
* 未反转过来的背面
*/
private _block: egret.Bitmap;
/**
* 反转过来的正面
*/
private _blockBgFront: egret.Bitmap;
addAni(obj) {
const dur = 1000;
egret.Tween.get(obj, { loop: true }).to({ alpha: 0 }, dur).to({ alpha: 1 }, dur);
}
iceCountNum = 1;
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ import Block from "./Block";
import BlockDarkIce from "./BlockDarkIce";
import BlockIce from "./BlockIce";
export const genBlockDisplay = (type: LatticeType) => {
export default (type: LatticeType) => {
switch (type) {
case LatticeType.BlOCK:
return new Block();
......@@ -17,8 +17,3 @@ export const genBlockDisplay = (type: LatticeType) => {
}
return null
}
export default interface BlockBase {
iceCountNum:number;
ice:egret.Bitmap;
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ export const Chapters2: ChapterData[] = [
starScores: [4000, 8000, 12000],
map: {
lattices: [
0, 4, 3, 3, 3, 3, 3, 3, 0,
0, 3, 3, 3, 3, 3, 3, 3, 0,
0, 3, 3, 3, 3, 3, 3, 3, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0,
......@@ -34,7 +34,7 @@ export const Chapters2: ChapterData[] = [
1, 1, 1, 0, 0, 0, 1, 1, 1,
],
elements: [
0, 4, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 2, 1, 1, 1, 1, 1, 2, 0,
0, 2, 1, 1, 1, 1, 1, 2, 0,
0, 2, 2, 2, 2, 2, 2, 2, 0,
......
import BaseBlock from "../block/BaseBlock";
import { Tool } from "../Tool";
import { Element } from "./Element";
import { Ice } from "./Ice";
import { Tool } from "../Tool";
import BlockBase from "../block/BlockBase";
/**
* 位置信息直接用一个二维数组记录,然后用row,col取
......@@ -17,7 +17,7 @@ export class Lattice {
/**
* 石门,冰石门,深冰石门
*/
block: BlockBase;
block: BaseBlock;
/**
* 上面的元素(null,消除元素,石头,冰激凌等),
*/
......@@ -35,6 +35,9 @@ export class Lattice {
value.column = this.column;
}
this._element = value
if(this.block) {
this.block.element = this._element;
}
}
/**
* 索引
......
......@@ -47,4 +47,9 @@ export enum ElementConfigType {
* 黑色毛球
*/
HAIRBALLBLACK=10,
// /**
// * 石门。石门正面的时候,无法消除。不是锁,锁可以被打破。
// */
// BLOCK_LOCK=11,
}
\ No newline at end of file
......@@ -65,5 +65,7 @@ export enum RecoverName {
HAIRBALLGREY_STATE = "HairballGreyState",
HAIRBALLBLACK_STATE = "HairballBlackState",
HAIRBALLBROWN_STATE = "HairballBrownState",
BLOCK_STATE = "BLOCK_STATE",
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { LockState } from "../states/LockState";
import { HairballGreyState } from "../states/HairballGreyState";
import { HairballBrownState } from "../states/HairballBrownState";
import { HairballBlackState } from "../states/HairballBlackState";
import { BlockLockState } from "../states/BlockLockState";
/**
* 状态类型
......@@ -14,6 +15,7 @@ export enum StateType {
HAIRBALLGREY,//灰色毛球 ,一次就消除
HAIRBALLBROWN,//褐色毛球 ,只能特效消除
HAIRBALLBLACK,//黑色毛球 ,两次消除,一次闭眼
BLOCK_LOCK,//石门盖住状态
}
......@@ -24,4 +26,5 @@ export const stateDatas: { recoverName: RecoverName, className: any }[] = [
{ recoverName: RecoverName.HAIRBALLGREY_STATE, className: HairballGreyState },
{ recoverName: RecoverName.HAIRBALLBROWN_STATE, className: HairballBrownState },
{ recoverName: RecoverName.HAIRBALLBLACK_STATE, className: HairballBlackState },
{ recoverName: RecoverName.BLOCK_STATE, className: BlockLockState },
]
\ No newline at end of file
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
/**
* 石门锁住的状态比较特殊,他没有视图,是无形的
* 和lock有区别的,lock可以用消除来解除,石门锁不行
*/
export class BlockLockState 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);
// })
}
}
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