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