Commit 83405de5 authored by wildfirecode's avatar wildfirecode

1

parent 908db4b2
...@@ -102,7 +102,7 @@ import Sand, { getSandDisplayBlock } from '../something/Sand'; ...@@ -102,7 +102,7 @@ import Sand, { getSandDisplayBlock } from '../something/Sand';
import { SandAni } from '../something/anis/SandAni'; import { SandAni } from '../something/anis/SandAni';
import doSandAI from './doSandAI'; import doSandAI from './doSandAI';
import { createSandDisAni } from '../effect/createSandDisAni'; import { createSandDisAni } from '../effect/createSandDisAni';
import { getArrowDir, getArrowRotation, fillConveyor } from '../something/conveyor/conveyorTool'; import { getArrowDir, getArrowRotation, fillConveyor, getOneConveyorMask } from '../something/conveyor/conveyorTool';
import createArrowBg from '../something/conveyor/createArrowBg'; import createArrowBg from '../something/conveyor/createArrowBg';
import doConveyorAI from './doConveyorAI'; import doConveyorAI from './doConveyorAI';
...@@ -201,7 +201,7 @@ export default class MainScene extends Scene { ...@@ -201,7 +201,7 @@ export default class MainScene extends Scene {
eliminatedElements: number[] = []; eliminatedElements: number[] = [];
//棒棒糖生成标志 //棒棒糖生成标志
lollipopMark: boolean; lollipopMark: boolean;
conveyor: egret.DisplayObjectContainer; private conveyorLayer: egret.DisplayObjectContainer;
conveyorMap: any; conveyorMap: any;
//地图背景容器 //地图背景容器
map: egret.DisplayObjectContainer; map: egret.DisplayObjectContainer;
...@@ -460,7 +460,7 @@ export default class MainScene extends Scene { ...@@ -460,7 +460,7 @@ export default class MainScene extends Scene {
var bg = drawBg(path, this.chapterData.map.lattices) var bg = drawBg(path, this.chapterData.map.lattices)
this.addChild(bg); this.addChild(bg);
const conveyor = new egret.Sprite(); const conveyor = new egret.Sprite();
this.conveyor = conveyor; this.conveyorLayer = conveyor;
this.conveyorMap = {}; this.conveyorMap = {};
this.map = bg; this.map = bg;
this.map.addChild(conveyor); this.map.addChild(conveyor);
...@@ -611,20 +611,35 @@ export default class MainScene extends Scene { ...@@ -611,20 +611,35 @@ export default class MainScene extends Scene {
initConveyor() { initConveyor() {
const conveyorList = this.chapterData.map.conveyor; const conveyorList = this.chapterData.map.conveyor;
if (!conveyorList) return; if (!conveyorList) return;
const tex = RES.getRes('arrowbg_png'); const tex = RES.getRes('arrowbg_png');
for (const conveyor of conveyorList) { for (const conveyor of conveyorList) {
const dir = getArrowDir(conveyor); const dir = getArrowDir(conveyor);
const list = fillConveyor(conveyor); const list = fillConveyor(conveyor);
const conveyorContainer = new egret.Sprite();
this.conveyorLayer.addChild(conveyorContainer);
const mask = new egret.Sprite();
conveyorContainer.mask = mask;
conveyorContainer.addChild(mask);
const oneMask = getOneConveyorMask(list, dir);
const maskP = Tool.getPositionByIndex(list[0]);
oneMask.x = maskP[0];
oneMask.y = maskP[1];
mask.addChild(oneMask);
list.forEach(i => { list.forEach(i => {
const arrow = createArrowBg(tex); const arrow = createArrowBg(tex);
arrow.rotation = getArrowRotation(dir); arrow.rotation = getArrowRotation(dir);
this.conveyor.addChild(arrow); conveyorContainer.addChild(arrow);
const p = Tool.getPositionByIndex(i); const p = Tool.getPositionByIndex(i);
this.conveyorMap[i] = arrow; this.conveyorMap[i] = arrow;
arrow.x = p[0]; arrow.x = p[0];
arrow.y = p[1]; arrow.y = p[1];
}); });
} }
} }
//初始化地图格子数据,包括生成口,联通口 //初始化地图格子数据,包括生成口,联通口
...@@ -672,7 +687,6 @@ export default class MainScene extends Scene { ...@@ -672,7 +687,6 @@ export default class MainScene extends Scene {
//设置生成口, //设置生成口,
this.generateIndexs = Tool.setGenerateLats(this.lattices, genLatDatas) this.generateIndexs = Tool.setGenerateLats(this.lattices, genLatDatas)
var downMax: number = 0; var downMax: number = 0;
var upMax: number = 0; var upMax: number = 0;
var hasSmallToBig: boolean; var hasSmallToBig: boolean;
...@@ -684,7 +698,7 @@ export default class MainScene extends Scene { ...@@ -684,7 +698,7 @@ export default class MainScene extends Scene {
var connectedLat = connectedLats[i]; var connectedLat = connectedLats[i];
if (!connectedLat || !connectedLat.length) continue; if (!connectedLat || !connectedLat.length) continue;
if (!this.lattices[connectedLat[0]]) { if (!this.lattices[connectedLat[0]]) {
throw new Error('联通干了个空的@沈豪洲(牛奶) ') throw new Error('联通干了个空的@沈豪洲(牛奶) '+JSON.stringify(connectedLat))
} }
try { try {
this.lattices[connectedLat[0]].down = connectedLat[1]; this.lattices[connectedLat[0]].down = connectedLat[1];
......
...@@ -3,7 +3,7 @@ import ConveyorAni, { getConveyorAni } from "../something/conveyor/ConveyorAni"; ...@@ -3,7 +3,7 @@ import ConveyorAni, { getConveyorAni } from "../something/conveyor/ConveyorAni";
import { ARROW_DIR, fillConveyor, findTarget, getArrowDir } from "../something/conveyor/conveyorTool"; import { ARROW_DIR, fillConveyor, findTarget, getArrowDir } from "../something/conveyor/conveyorTool";
import { Tool } from "../something/Tool"; import { Tool } from "../something/Tool";
import MainScene from "./MainScene"; import MainScene from "./MainScene";
export const CONVERYOR_ANI_DUR = 200; export const CONVERYOR_ANI_DUR = 500;
const getTargetIndexs = (conveyor: number[]) => { const getTargetIndexs = (conveyor: number[]) => {
const dir = getArrowDir(conveyor); const dir = getArrowDir(conveyor);
let list = fillConveyor(conveyor); let list = fillConveyor(conveyor);
...@@ -16,9 +16,8 @@ const getTargetIndexs = (conveyor: number[]) => { ...@@ -16,9 +16,8 @@ const getTargetIndexs = (conveyor: number[]) => {
} }
export default async (thisObj: MainScene) => { export default async (thisObj: MainScene) => {
//加上传送带的动画 //移动的动画,如果是两头的需要一个带遮罩的动画,会涉及元素的复制
//移动的动画,如果是两头的需要一个带遮罩的动画 //检查与其他元素的兼容性,比如带有svga的独眼怪、果冻怪等等
//检查与其他元素的兼容性
const conveyorList = thisObj.chapterData.map.conveyor; const conveyorList = thisObj.chapterData.map.conveyor;
if (!conveyorList) return; if (!conveyorList) return;
const elementsList = []; //所有轨道元素组的列表 const elementsList = []; //所有轨道元素组的列表
......
...@@ -3,76 +3,5 @@ import { PassType } from "../enum/PassType"; ...@@ -3,76 +3,5 @@ import { PassType } from "../enum/PassType";
import { ElementType } from "../enum/ElementType"; import { ElementType } from "../enum/ElementType";
//501-525 //501-525
export const Chapters20: ChapterData[] = [ export const Chapters20: ChapterData[] = [
{ { baseElementTypes: [ 0, 1, 2, 3,4 ], bubbleProbability: 0, stepCount: 25, passTarget: { type: 1, elements: [ { type: 2, count: 88 } ] }, starScores: [ 15000, 20000, 25000 ], map: { lattices: [ 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 ], connectedLats: [ [ 31 ,49 ] ], conveyor: [ [ 24, 60 ], [ 59, 56 ], [ 47, 20 ] ], conveyorConnectedLats: [ [ 60, 59 ], [ 56, 47 ], [ 20, 24 ] ], elements: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 12, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], baseElements: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], recycles: [], generateLats: [ { index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 8, type: null }, { index: 13, type: null } ] } }
baseElementTypes: [0, 1, 2, 3, 4],
bubbleProbability: 0,
stepCount: 999,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.CHICKEN,
count: 995,
},
],
},
starScores: [1000, 5000, 10000],
map: {
lattices: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
],
conveyor: [
// [29,56],
// [51, 33],
[29,56],
[57,60],
[51, 33],
[32, 30],
],
conveyorConnectedLats: [
// [56,51],
// [33,29],
[56,57],
[60,51],
[33, 32],
[30, 29],
],
generateLats: [
{ index: 11, type: [0], cus: [] },
{ index: 15, type: [0], cus: [] },
],
// connectedLats: [[76, 11]],
elements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
],
baseElements: [
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
],
// recycles: [70, 71, 72, 73]
},
}
] ]
\ No newline at end of file
...@@ -30,16 +30,29 @@ export const Chapters20: ChapterData[] = [ ...@@ -30,16 +30,29 @@ export const Chapters20: ChapterData[] = [
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
], ],
conveyor: [ conveyor: [
// [29,56],
// [51, 33],
[29,56], [29,56],
[57,60], [57,60],
[51, 33], [51, 33],
[32, 30], [32, 30],
// [57,60],
// [32, 30],
], ],
conveyorConnectedLats: [ conveyorConnectedLats: [
// [56,51],
// [33,29],
[56,57], [56,57],
[60,51], [60,51],
[33, 32], [33, 32],
[30, 29], [30, 29],
// [60,32],
// [30,57],
], ],
generateLats: [ generateLats: [
{ index: 11, type: [0], cus: [] }, { index: 11, type: [0], cus: [] },
......
import { CONVERYOR_ANI_DUR } from "../../mainScene/doConveyorAI"; import { CONVERYOR_ANI_DUR } from "../../mainScene/doConveyorAI";
import MainScene from "../../mainScene/MainScene"; import MainScene from "../../mainScene/MainScene";
import { Tool } from "../Tool"; import { Tool } from "../Tool";
import { ARROW_DIR, fillConveyor, getArrowDir } from "./conveyorTool"; import { ARROW_DIR, fillConveyor, getArrowDir, getArrowRotation } from "./conveyorTool";
import createArrowBg from "./createArrowBg";
//单个皮带转动动效 //单个皮带转动动效
export default class ConveyorAni { export default class ConveyorAni {
protected orign: any[];
protected list: any[];
protected views: any[] = [] protected views: any[] = []
protected _dir; protected _dir;
protected thisobj;
constructor(conveyor, thisobj: MainScene) { constructor(conveyor, thisobj: MainScene) {
this.list = fillConveyor(conveyor); this.thisobj = thisobj;
this.orign = JSON.parse(JSON.stringify(this.list)); const list = fillConveyor(conveyor);
this.views = this.list.map(index => thisobj.conveyorMap[index]); this.views = list.map(index => thisobj.conveyorMap[index]);
this._dir = getArrowDir(conveyor); this._dir = getArrowDir(conveyor);
this.extendView();
} }
play() { } play() { }
extendView() { }
} }
class ConveyorDownAni extends ConveyorAni { class ConveyorDownAni extends ConveyorAni {
play() { async play() {
this.views.forEach(view => { const firstY = this.views[0].y;
egret.Tween.get(view).to({ y: view.y + Tool.height }, CONVERYOR_ANI_DUR).call(() => { await Promise.all(this.views.map(view => {
return new Promise((r) => {
egret.Tween.get(view).to({ y: view.y + Tool.height }, CONVERYOR_ANI_DUR).call(r);
})
}))
const last = this.views.pop();
last.y = firstY;
this.views.unshift(last);
}
}); extendView() { //顶部增加一个
}) const arrow = createArrowBg();
this.views[0].parent.addChild(arrow);
arrow.x = this.views[0].x;
arrow.y = this.views[0].y - Tool.width;
this.views.unshift(arrow);
arrow.rotation = getArrowRotation(this._dir);
} }
} }
class ConveyorUpAni extends ConveyorAni {
play() {
this.views.forEach(view => {
egret.Tween.get(view).to({ y: view.y - Tool.height }, CONVERYOR_ANI_DUR).call(() => {
class ConveyorUpAni extends ConveyorAni {
async play() {
const lastY = this.views[this.views.length - 1].y;
await Promise.all(this.views.map(view => {
return new Promise((r) => {
egret.Tween.get(view).to({ y: view.y - Tool.height }, CONVERYOR_ANI_DUR).call(r);
}) })
}) }))
const first = this.views.shift();
first.y = lastY;
this.views.push(first);
}
extendView() {
const arrow = createArrowBg();
this.views[0].parent.addChild(arrow);
arrow.x = this.views[0].x;
arrow.y = this.views[this.views.length - 1].y + Tool.width;
this.views.push(arrow);
arrow.rotation = getArrowRotation(this._dir);
} }
} }
class ConveyorLeftAni extends ConveyorAni { class ConveyorLeftAni extends ConveyorAni {
play() { async play() {
this.views.forEach(view => { const lastX = this.views[this.views.length - 1].x;
egret.Tween.get(view).to({ x: view.x - Tool.width }, CONVERYOR_ANI_DUR).call(() => { await Promise.all(this.views.map(view => {
return new Promise((r) => {
egret.Tween.get(view).to({ x: view.x - Tool.width }, CONVERYOR_ANI_DUR).call(r);
}) })
}) }))
const first = this.views.shift();
first.x = lastX;
this.views.push(first);
}
extendView() {
const arrow = createArrowBg();
this.views[0].parent.addChild(arrow);
arrow.x = this.views[this.views.length - 1].x + Tool.width;
arrow.y = this.views[0].y;
this.views.push(arrow);
arrow.rotation = getArrowRotation(this._dir);
} }
} }
class ConveyorRightAni extends ConveyorAni { class ConveyorRightAni extends ConveyorAni {
play() { async play() {
this.views.forEach(view => { const firstX = this.views[0].x;
egret.Tween.get(view).to({ x: view.x + Tool.width }, CONVERYOR_ANI_DUR).call(() => { await Promise.all(this.views.map(view => {
return new Promise((r) => {
egret.Tween.get(view).to({ x: view.x + Tool.width }, CONVERYOR_ANI_DUR).call(r);
}) })
}) }))
const last = this.views.pop();
last.x = firstX;
this.views.unshift(last);
}
extendView() {
const arrow = createArrowBg();
this.views[0].parent.addChild(arrow);
arrow.x = this.views[0].x - Tool.width;
arrow.y = this.views[0].y;
this.views.unshift(arrow);
arrow.rotation = getArrowRotation(this._dir);
} }
} }
......
...@@ -101,10 +101,24 @@ export const fillConveyor = (conveyor: number[]) => { ...@@ -101,10 +101,24 @@ export const fillConveyor = (conveyor: number[]) => {
export const findTarget = (start: number, conveyorConnectedLats: number[][]) => { export const findTarget = (start: number, conveyorConnectedLats: number[][]) => {
for (const c of conveyorConnectedLats) { for (const c of conveyorConnectedLats) {
const [s,e]=c; const [s, e] = c;
if(start==s) if (start == s)
return e return e
} }
throw new Error('配置错误') throw new Error('配置错误')
}
export const getOneConveyorMask = (list: number[], dir) => {
const s = new egret.Sprite();
if (dir == ARROW_DIR.LEFT || dir == ARROW_DIR.RIGHT) {
s.graphics.beginFill(0, 1);
s.graphics.drawRect(-Tool.width / 2, -Tool.width / 2, list.length * Tool.width, Tool.width);
s.graphics.endFill();
} else {
s.graphics.beginFill(0, 1);
s.graphics.drawRect(-Tool.width / 2, -Tool.width / 2, Tool.width, list.length * Tool.width);
s.graphics.endFill();
}
return s;
} }
\ No newline at end of file
export default (tex) => { export default (tex = RES.getRes('arrowbg_png')) => {
const container = new egret.Sprite(); const container = new egret.Sprite();
const arrow = new egret.Bitmap(tex); const arrow = new egret.Bitmap(tex);
arrow.anchorOffsetX = arrow.width / 2; arrow.anchorOffsetX = arrow.width / 2;
......
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