Commit 8a23fe95 authored by wildfirecode's avatar wildfirecode

1

parent c7feef76
import { Element } from "../something/class/Element";
import { Lattice } from "../something/class/Lattice";
import { ElementType } from "../something/enum/ElementType";
import { AiControl } from "../something/logic/AiControl";
import { Tool } from "../something/Tool";
import MainScene from "./MainScene";
import wait from "../../libs/new_tc/wait";
import { AiControl } from "../something/logic/AiControl";
export default async (thisObj: MainScene) => {
//找到所有的怪物
......@@ -13,9 +12,11 @@ export default async (thisObj: MainScene) => {
var indexs: number[] = [];
for (var i = 0; i < thisObj.lattices.length; i++) {
var lattice = thisObj.lattices[i]
if (lattice && lattice.element && lattice.element.type == ElementType.JELLY_MONSTER)
if (lattice && lattice.element && lattice.element.type == ElementType.JELLY_MONSTER) {
indexs.push(i);
}
}
//获取果冻动画,0是自身索引,1是终点索引
let spreads: number[][] = [];
for (const fromIndex of indexs) {
......@@ -29,22 +30,22 @@ export default async (thisObj: MainScene) => {
if (spreads.length > 0)
AiControl.ins.setHasJelly(true);
await wait(1000);
for (const spread of spreads) {
var i = Math.floor(Math.random() * spreads.length);
let spread;
if (spreads.length > 0) {
spread = spreads.splice(i, 1)[0];
const [fromIndex, toIndex] = spread;
//起始元素
const fromEle: Element = thisObj.lattices[fromIndex].element;
//终点元素
const endEle: Element = thisObj.lattices[toIndex].element;
const fromEle: Element = thisObj.lattices[fromIndex].element;//起始元素
await fromEle.toAction();
const endEle: Element = thisObj.lattices[toIndex].element; //终点元素
endEle.reset(ElementType.JELLY);
endEle.isMonsterJelly = true;
}
return spreads.length;
if (spread)
return 1;
return 0;
}
/**
* 判断可蔓延的方向,并返回蔓延终点的格子索引
* 判断可分裂的方向,并返回分裂终点的格子索引
......
......@@ -36,10 +36,14 @@ export class JellySpreadAni extends egret.DisplayObjectContainer {
this.addChild(this.shoot);
}
play(startP: number[], cloneEle: Element, callback: Function,isMonsterJelly) {
if(isMonsterJelly)
this.targetImage.texture = RES.getRes('ele20_png');
this.oriImage.texture = RES.getRes('ele20_png');
play(startP: number[], cloneEle: Element, callback: Function, isMonsterJelly) {
if (isMonsterJelly) {
this.targetImage.texture = RES.getRes('ele20_png');
this.oriImage.texture = RES.getRes('ele20_png');
} else {
this.targetImage.texture = RES.getRes("ele" + ElementType.JELLY + "_png");
this.oriImage.texture = RES.getRes("ele" + ElementType.JELLY + "_png");
}
this.x = startP[0];
this.y = startP[1];
//终点位置全局先赋值出来,判断用
......
This diff is collapsed.
......@@ -36,6 +36,7 @@ export class Element extends eui.Component {
_mv;
async resetMonster() {
this.changeSource('empty_png');
this.showImage.alpha = 0;
const mv: any = await loadSvga(getResPath() + 'resource/assets/svgas/monster.svga');
this._mv = mv;
this.addChild(mv);
......@@ -43,9 +44,6 @@ export class Element extends eui.Component {
mv.anchorOffsetY = 150;
mv.x = - 3;
mv.y = - 6;
// setInterval(() => {
// this.toAction();
// }, 5000);
this.toStandByAction();
}
......@@ -71,29 +69,35 @@ export class Element extends eui.Component {
}
toAction() {
if (!this._mv) return;
var p = Tool.getPositionByIndex(this.index);
const mv = this._mv;
const cb = () => {
if (mv.currentFrame == 508) { //向上吹
this.toStandByAction();
}
if (mv.currentFrame == 391) {
this.dispatchEvent(new egret.Event('onBlow'));
// const tex: egret.Texture = RES.getRes("ele20_png");
// const pic = new egret.Bitmap(tex);
// pic.anchorOffsetX = tex.textureWidth / 2;
// pic.anchorOffsetY = tex.textureHeight;
// pic.x = p[0];
// pic.y = p[1];
// this.stage.addChild(pic);
// egret.Tween.get(pic).set({ scaleX: 0, scaleY: 0 }).to({ scaleX: 1.1, scaleY: 1.1 }, 300).wait(1000).call(()=>{
// pic.parent.removeChild(pic);
// });
return new Promise((r) => {
if (!this._mv) {
r();
return;
}
};
this._mv.addEventListener(egret.Event.ENTER_FRAME, cb, this);
mv.gotoAndPlay(361, true);
var p = Tool.getPositionByIndex(this.index);
const mv = this._mv;
const cb = () => {
if (mv.currentFrame == 508) { //向上吹
this.toStandByAction();
}
if (mv.currentFrame == 391) {
// this.dispatchEvent(new egret.Event('onBlow'));
r();
// const tex: egret.Texture = RES.getRes("ele20_png");
// const pic = new egret.Bitmap(tex);
// pic.anchorOffsetX = tex.textureWidth / 2;
// pic.anchorOffsetY = tex.textureHeight;
// pic.x = p[0];
// pic.y = p[1];
// this.stage.addChild(pic);
// egret.Tween.get(pic).set({ scaleX: 0, scaleY: 0 }).to({ scaleX: 1.1, scaleY: 1.1 }, 300).wait(1000).call(()=>{
// pic.parent.removeChild(pic);
// });
}
};
this._mv.addEventListener(egret.Event.ENTER_FRAME, cb, this);
mv.gotoAndPlay(361, true);
});
}
private _candy: Candy;
......@@ -318,7 +322,7 @@ export class Element extends eui.Component {
changeSource(source: string) {
// this.showImage.source = source;
var texture: egret.Texture = RES.getRes(source);
if (!texture) {return;}
if (!texture) { return; }
this.showImage.texture = texture
this.showImage.x = -texture.textureWidth / 2;
......
......@@ -40,7 +40,7 @@ export class AiControl {
* 判断是否还有果冻,暂时不考虑果冻无中生有,否则逻辑修改
*/
private hasJelly: boolean;
setHasJelly(val) {this.hasJelly=val}
setHasJelly(val) { this.hasJelly = val }
/**
* 提前记录所有的鸡蛋的索引,因为鸡蛋数量不会改变
*/
......@@ -218,13 +218,13 @@ export class AiControl {
for (var i = 0; i < thisObj.lattices.length; i++) {
var lattice = thisObj.lattices[i]
//没有格子或没有元素或不是果冻 跳过
if (lattice && lattice.element && lattice.block && lattice.block.isLock() && lattice.element.type == ElementType.JELLY ) {
if (lattice && lattice.element && lattice.block && lattice.block.isLock() && lattice.element.type == ElementType.JELLY) {
blocked.push(i);
}
if (!lattice || !lattice.element || lattice.element.type != ElementType.JELLY || (lattice.block && lattice.block.isLock())) continue
indexs.push(i);
}
console.log('没有被锁的果冻数量',indexs.length,'被锁果冻数量',blocked.length,)
console.log('没有被锁的果冻数量', indexs.length, '被锁果冻数量', blocked.length)
//如果没有果冻,直接回调
if (!indexs.length && blocked.length == 0) {
//标记为无果冻
......@@ -254,7 +254,7 @@ export class AiControl {
//果冻蔓延动画
let jellySpreadAni: JellySpreadAni = Pool.takeOut(RecoverName.JELLYSPREAD_ANI)
if (!jellySpreadAni) {
jellySpreadAni = new JellySpreadAni()
jellySpreadAni = new JellySpreadAni();
}
thisObj.addChild(jellySpreadAni);
//起始元素
......@@ -266,8 +266,8 @@ export class AiControl {
//对后续有影响的数据必须提交更新,视图不对就隐藏先,动画里加上对应视图,动画播放回调里去掉动画视图,显示数据视图;
//将终点元素变成果冻,,
endEle.reset(ElementType.JELLY);
if(fromEle.isMonsterJelly)
endEle.isMonsterJelly=true;
if (fromEle.isMonsterJelly)
endEle.isMonsterJelly = true;
//隐藏元素
fromEle.visible = false;
endEle.visible = false;
......@@ -280,7 +280,7 @@ export class AiControl {
endEle.visible = true;
//执行回调
callback()
},fromEle.isMonsterJelly)
}, fromEle.isMonsterJelly)
}
/**
* 鸡蛋得孵化逻辑
......
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