refactoring
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { BoxGeometry, Mesh, MeshStandardMaterial, Group, EventDispatcher } from 'three';
|
||||
import { MotionEngine } from '../../lib/MotionEngine';
|
||||
import { centerOrigin } from '@/lib/MeshUtils';
|
||||
|
||||
class PuzzleGame1 extends EventDispatcher {
|
||||
@@ -9,7 +8,7 @@ class PuzzleGame1 extends EventDispatcher {
|
||||
return new Promise(async (resolve, reject)=>{
|
||||
let w = data.w, h = data.h, wh = w*h;
|
||||
let container = new Group();
|
||||
const aq = new MotionEngine();
|
||||
const aq = engine.motionQueue;
|
||||
const pr = [[0, 2], [0, -1], [0, 1], [1, 0], [-1, 0], [0, 0]];
|
||||
let d = 1.2;
|
||||
|
||||
@@ -76,7 +75,8 @@ class PuzzleGame1 extends EventDispatcher {
|
||||
aq.add({
|
||||
o: i.object,
|
||||
a: { rotation: { x: pr[i.object._ri][0] * Math.PI / 2, y: pr[i.object._ri][1] * Math.PI / 2 } },
|
||||
t: .5
|
||||
t: .5,
|
||||
s: 'PG2'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -86,8 +86,7 @@ class PuzzleGame1 extends EventDispatcher {
|
||||
});
|
||||
|
||||
this.update = () => {
|
||||
aq.update();
|
||||
if (aq.isIdle() && !this.done && check()) {
|
||||
if (aq.isIdle('PG2') && !this.done && check()) {
|
||||
this.done = true;
|
||||
container.children.forEach((c, i) => {
|
||||
aq.add({
|
||||
@@ -96,7 +95,8 @@ class PuzzleGame1 extends EventDispatcher {
|
||||
t: 1,
|
||||
f: i == 0 ? ()=>{
|
||||
this.dispatchEvent({type:'finish'})
|
||||
} : undefined
|
||||
} : undefined,
|
||||
s: 'PG2'
|
||||
});
|
||||
});
|
||||
//engine.dashboard.addPoints(10);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { BoxGeometry, Mesh, MeshBasicMaterial, Group, EventDispatcher } from 'three';
|
||||
import { MotionEngine } from '../../lib/MotionEngine';
|
||||
import { centerOrigin } from '@/lib/MeshUtils';
|
||||
|
||||
class PuzzleGame2 extends EventDispatcher {
|
||||
@@ -12,7 +11,7 @@ class PuzzleGame2 extends EventDispatcher {
|
||||
const material = new MeshBasicMaterial({
|
||||
map: texture
|
||||
});
|
||||
const aq = new MotionEngine();
|
||||
const aq = engine.motionQueue;
|
||||
const m2 = new MeshBasicMaterial({
|
||||
map: texture,
|
||||
transparent: true,
|
||||
@@ -113,12 +112,14 @@ class PuzzleGame2 extends EventDispatcher {
|
||||
o: i.object,
|
||||
a: { position: { x: (xl - xc) * d, y: (yl - yc) * d } },
|
||||
t: .3,
|
||||
m: 'offset'
|
||||
m: 'offset',
|
||||
s: 'PG2'
|
||||
},{
|
||||
o: last,
|
||||
a: { position: { x: (xc - xl) * d, y: (yc - yl) * d } },
|
||||
t: .3,
|
||||
m: 'offset'
|
||||
m: 'offset',
|
||||
s: 'PG2'
|
||||
}]);
|
||||
xch(idx, lidx);
|
||||
}
|
||||
@@ -130,8 +131,7 @@ class PuzzleGame2 extends EventDispatcher {
|
||||
});
|
||||
|
||||
this.update = () => {
|
||||
aq.update();
|
||||
if (aq.isIdle() && !this.done && check()) {
|
||||
if (aq.isIdle('PG2') && !this.done && check()) {
|
||||
this.done = true;
|
||||
container.children.forEach((c, i) => {
|
||||
last.material = material;
|
||||
@@ -141,7 +141,8 @@ class PuzzleGame2 extends EventDispatcher {
|
||||
t: 1,
|
||||
f: i == 0 ? ()=>{
|
||||
this.dispatchEvent({type:'finish'})
|
||||
} : undefined
|
||||
} : undefined,
|
||||
s: 'PG2'
|
||||
});
|
||||
});
|
||||
//engine.dashboard.addPoints(10);
|
||||
|
||||
Reference in New Issue
Block a user