refactoring
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -25,7 +25,7 @@
|
||||
<!-- <v-list-item prepend-icon="mdi-cogs" :title="l.gameRules"></v-list-item> -->
|
||||
<v-divider></v-divider>
|
||||
<v-list-item prepend-icon="mdi-controller" :title="l.games" to="/games/list"></v-list-item>
|
||||
<v-list-item prepend-icon="mdi-cog-play" :title="l.play" to="/play/list"></v-list-item>
|
||||
<v-list-item prepend-icon="mdi-cog-play" :title="l.preview" to="/preview/list"></v-list-item>
|
||||
|
||||
</v-list>
|
||||
<v-divider></v-divider>
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ export default {
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
env: 'GamePlaying',
|
||||
env: 'GamePreview',
|
||||
scenesList: [],
|
||||
objectsList: [],
|
||||
mode: 'translate',
|
||||
@@ -2,6 +2,7 @@ import { getBoundingBox, getBoundingBoxCenterPoint, getBoundingBoxMaxLength, cen
|
||||
import { EventDispatcher, SphereGeometry, Mesh, MeshStandardMaterial, BackSide } from "three";
|
||||
|
||||
class GenericObject extends EventDispatcher{
|
||||
emits = ['finish']
|
||||
constructor(engine, data){
|
||||
super();
|
||||
return new Promise(async(resolve, reject)=>{
|
||||
|
||||
@@ -37,6 +37,7 @@ const defaults = {
|
||||
const tl = 4;
|
||||
|
||||
class MazeQuizGame extends EventDispatcher {
|
||||
emits = ['finish']
|
||||
constructor(engine, data) {
|
||||
super();
|
||||
data.noPhysics = true;
|
||||
@@ -48,7 +49,7 @@ class MazeQuizGame extends EventDispatcher {
|
||||
let ud1 = engine.physics.world.getCollider(e.handle1)?.parent()?.userData,
|
||||
ud2 = engine.physics.world.getCollider(e.handle2)?.parent()?.userData;
|
||||
let ud = {...ud1, ...ud2}
|
||||
console.log('collision', ud)
|
||||
//console.log('collision', ud)
|
||||
if (ud.finish){
|
||||
if (e.started){
|
||||
engine.dashboard.levelProgress.update(1)
|
||||
|
||||
@@ -3,6 +3,7 @@ import { MotionEngine } from '../../lib/MotionEngine';
|
||||
import { centerOrigin } from '@/lib/MeshUtils';
|
||||
|
||||
class PuzzleGame1 extends EventDispatcher {
|
||||
emits = ['finish']
|
||||
constructor(engine, data) {
|
||||
super();
|
||||
return new Promise(async (resolve, reject)=>{
|
||||
|
||||
@@ -3,6 +3,7 @@ import { MotionEngine } from '../../lib/MotionEngine';
|
||||
import { centerOrigin } from '@/lib/MeshUtils';
|
||||
|
||||
class PuzzleGame2 extends EventDispatcher {
|
||||
emits = ['finish']
|
||||
constructor(engine, data) {
|
||||
super();
|
||||
return new Promise(async (resolve, reject)=>{
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {
|
||||
PlaneGeometry, MeshStandardMaterial, SRGBColorSpace,
|
||||
PlaneGeometry, MeshBasicMaterial, SRGBColorSpace,
|
||||
VideoTexture, DoubleSide, Mesh, EventDispatcher
|
||||
} from 'three';
|
||||
|
||||
class VideoPlayer extends EventDispatcher {
|
||||
emits = ['finish']
|
||||
constructor(engine, data){
|
||||
super();
|
||||
let vi, plane;
|
||||
@@ -15,7 +16,7 @@ class VideoPlayer extends EventDispatcher {
|
||||
let geometry = new PlaneGeometry( this.aspect, 1 );
|
||||
let map = new VideoTexture( vi );
|
||||
map.colorSpace = SRGBColorSpace;
|
||||
let material = new MeshStandardMaterial( {
|
||||
let material = new MeshBasicMaterial( {
|
||||
color: 0xffffff,
|
||||
map,
|
||||
transparent: true,
|
||||
|
||||
@@ -109,7 +109,7 @@ class DashBoard {
|
||||
text:``, fontSize: 0.044, font: '/static/fonts/Montserrat-Bold.ttf',
|
||||
outlineColor: 0x113377, outlineWidth: '3%', anchorX: 'center',
|
||||
})
|
||||
pointsText.position.set(0.86 * engine.aspect/2, 0.47, 0);
|
||||
pointsText.position.set(0.86 * engine.aspect/2, 0.47, -0.001);
|
||||
dash.add(pointsText);
|
||||
|
||||
engine.addEventListener('beforeRender', ()=>{
|
||||
|
||||
@@ -143,19 +143,23 @@ export default {
|
||||
}
|
||||
gameEngine.activeObjects.add(env.scene);
|
||||
}
|
||||
let expectToFinish = 0, finished = 0;;
|
||||
if (this.scene.data.items){
|
||||
let loaded = 0;
|
||||
for (let i of this.scene.data.items) {
|
||||
if (this.env == 'GamePlaying'){
|
||||
if (this.env != 'GameDesigner'){
|
||||
if (i.data.activationTriggers?.length || i.data.activationScore){
|
||||
i.data.shouldBeLocked = true;
|
||||
}
|
||||
}
|
||||
let io = await new InteractiveObject(gameEngine, i.data)
|
||||
i.__io = io;
|
||||
if (io.emits?.includes('finish')){
|
||||
expectToFinish++;
|
||||
}
|
||||
this.setObjectAttributes(l, i.data, io.object, io.source, 1);
|
||||
gameEngine.activeObjects.add(io.object);
|
||||
if (this.env == 'GamePlaying'){
|
||||
if (this.env != 'GameDesigner'){
|
||||
if (i.data.$go?.type == 'player3d'){
|
||||
let hero = new Hero(io.source, i.data.$go);
|
||||
hero.init(gameEngine);
|
||||
@@ -173,6 +177,7 @@ export default {
|
||||
}
|
||||
}
|
||||
io.addEventListener('finish', ()=>{
|
||||
finished ++;
|
||||
if (!i.data.pointsGiven){
|
||||
gameEngine.dashboard?.addPoints(i.data.points)
|
||||
}
|
||||
@@ -186,7 +191,11 @@ export default {
|
||||
gameEngine.dashboard.points > di.data.activationScore){
|
||||
di.__io.locker.unlock();
|
||||
}
|
||||
})
|
||||
});
|
||||
if (finished == expectToFinish){
|
||||
//GO TO NEXT LEVEL
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
loaded += 1/this.scene.data.items.length
|
||||
@@ -194,7 +203,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.scene.data.$intro && this.env == 'GamePlaying'){
|
||||
if (this.scene.data.$intro && this.env != 'GameDesigner'){
|
||||
let intro = await new VideoPlayer(gameEngine, {$go: this.scene.data.$intro, skipTransition: true, playInHud: true});
|
||||
gameEngine.activeObjects.add(intro.object);
|
||||
intro.video.addEventListener('pause',()=>{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-container max-width="1400">
|
||||
<GamePlaying v-model="object"></GamePlaying>
|
||||
<GamePreview v-model="object"></GamePreview>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col v-for="(v, i) in items" :key="i" cols="12" xs="6" sm="4" md="3" xl="2" class="position-relative">
|
||||
<router-link :to="`/play/${v.id}`">
|
||||
<router-link :to="`/preview/${v.id}`">
|
||||
<v-img :src="`/asset/thumb/${v.thumb}.webp`"></v-img>
|
||||
</router-link>
|
||||
<div class="d-flex">
|
||||
Reference in New Issue
Block a user