mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:03:11 +02:00
removal of debug prints, style fixes, added headers
This commit is contained in:
parent
4c09fbfe74
commit
b8e7be087d
6 changed files with 54 additions and 55 deletions
|
@ -1,10 +1,18 @@
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 3/31/2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Revision of James B. Pollack's work on GamesTable in 2016
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
var CLEARCACHE = "?"+Math.random().toString(36).substring(7);
|
var CLEARCACHE = "?"+Math.random().toString(36).substring(7);
|
||||||
var TABLE_MODEL_URL = Script.resolvePath('assets/table/gameTable.fbx') + CLEARCACHE;
|
var TABLE_MODEL_URL = Script.resolvePath('assets/table/gameTable.fbx') + CLEARCACHE;
|
||||||
var MODEL_URL = Script.resolvePath('assets/table/finalFrame.fbx') + CLEARCACHE;
|
var MODEL_URL = Script.resolvePath('assets/table/finalFrame.fbx') + CLEARCACHE;
|
||||||
var TABLE_SCRIPT_URL = Script.resolvePath('table.js') + CLEARCACHE;
|
var TABLE_SCRIPT_URL = Script.resolvePath('table.js') + CLEARCACHE;
|
||||||
var ENTITY_SPAWNER_SCRIPT_URL = Script.resolvePath('entitySpawner.js') + CLEARCACHE;
|
var ENTITY_SPAWNER_SCRIPT_URL = Script.resolvePath('entitySpawner.js') + CLEARCACHE;
|
||||||
var MAT_SCRIPT_URL = Script.resolvePath('mat.js') + CLEARCACHE;
|
|
||||||
var NEXT_GAME_BUTTON_SCRIPT_URL = Script.resolvePath('nextGameButton.js') + CLEARCACHE;
|
var NEXT_GAME_BUTTON_SCRIPT_URL = Script.resolvePath('nextGameButton.js') + CLEARCACHE;
|
||||||
var RESET_BUTTON_SCRIPT_URL = Script.resolvePath('resetGameButton.js') + CLEARCACHE;
|
var RESET_BUTTON_SCRIPT_URL = Script.resolvePath('resetGameButton.js') + CLEARCACHE;
|
||||||
var TABLE_PICTURE_URL = Script.resolvePath('assets/mats/Table-default.jpg') + CLEARCACHE;
|
var TABLE_PICTURE_URL = Script.resolvePath('assets/mats/Table-default.jpg') + CLEARCACHE;
|
||||||
|
@ -152,7 +160,6 @@ function createMat() {
|
||||||
Picture: TABLE_PICTURE_URL
|
Picture: TABLE_PICTURE_URL
|
||||||
}),
|
}),
|
||||||
parentID: table,
|
parentID: table,
|
||||||
script: MAT_SCRIPT_URL,
|
|
||||||
position: getOffsetFromTable(matOffset.forward, matOffset.vertical, matOffset.right),
|
position: getOffsetFromTable(matOffset.forward, matOffset.vertical, matOffset.right),
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
|
@ -240,7 +247,6 @@ function makeTable() {
|
||||||
createEntitySpawner();
|
createEntitySpawner();
|
||||||
createResetGameButton();
|
createResetGameButton();
|
||||||
createNextGameButton();
|
createNextGameButton();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 3/31/2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
|
@ -198,8 +206,6 @@
|
||||||
_this.entityID = id;
|
_this.entityID = id;
|
||||||
},
|
},
|
||||||
createSingleEntity: function(url, spawnLocation, spawnRotation) {
|
createSingleEntity: function(url, spawnLocation, spawnRotation) {
|
||||||
// print('creating a single entity: ' + url)
|
|
||||||
// print('creating a single entity at : ' + JSON.stringify(spawnLocation))
|
|
||||||
if (url === 'empty') {
|
if (url === 'empty') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -217,10 +223,8 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
spawnEntities: function(id, params) {
|
spawnEntities: function(id, params) {
|
||||||
print('spawn entities called!!');
|
|
||||||
this.items = [];
|
this.items = [];
|
||||||
var dimensions = Entities.getEntityProperties(params[1]).dimensions;
|
var dimensions = Entities.getEntityProperties(params[1]).dimensions;
|
||||||
print('and it has params: ' + params.length);
|
|
||||||
_this.game = JSON.parse(params[0]);
|
_this.game = JSON.parse(params[0]);
|
||||||
_this.matDimensions = dimensions;
|
_this.matDimensions = dimensions;
|
||||||
_this.matCenter = Entities.getEntityProperties(params[1]).position;
|
_this.matCenter = Entities.getEntityProperties(params[1]).position;
|
||||||
|
@ -242,12 +246,8 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
spawnByPile: function() {
|
spawnByPile: function() {
|
||||||
print('should spawn by pile');
|
|
||||||
var props = Entities.getEntityProperties(_this.entityID);
|
var props = Entities.getEntityProperties(_this.entityID);
|
||||||
|
for (var i = 0; i < _this.game.howMany; i++) {
|
||||||
var i;
|
|
||||||
for (i = 0; i < _this.game.howMany; i++) {
|
|
||||||
print('spawning entity from pile:: ' + i);
|
|
||||||
var spawnLocation = {
|
var spawnLocation = {
|
||||||
x: props.position.x,
|
x: props.position.x,
|
||||||
y: props.position.y - 0.25,
|
y: props.position.y - 0.25,
|
||||||
|
@ -264,7 +264,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
spawnByArranged: function() {
|
spawnByArranged: function() {
|
||||||
print('should spawn by arranged');
|
|
||||||
// make sure to set userData.gameTable.attachedTo appropriately
|
// make sure to set userData.gameTable.attachedTo appropriately
|
||||||
_this.setupGrid();
|
_this.setupGrid();
|
||||||
|
|
||||||
|
@ -294,11 +293,9 @@
|
||||||
|
|
||||||
setupGrid: function() {
|
setupGrid: function() {
|
||||||
_this.tiles = [];
|
_this.tiles = [];
|
||||||
var i;
|
|
||||||
var j;
|
|
||||||
|
|
||||||
for (i = 0; i < _this.game.startingArrangement.length; i++) {
|
for (var i = 0; i < _this.game.startingArrangement.length; i++) {
|
||||||
for (j = 0; j < _this.game.startingArrangement[i].length; j++) {
|
for (var j = 0; j < _this.game.startingArrangement[i].length; j++) {
|
||||||
// print('jbp there is a tile at:: ' + i + "::" + j)
|
// print('jbp there is a tile at:: ' + i + "::" + j)
|
||||||
var tile = new Tile(i, j);
|
var tile = new Tile(i, j);
|
||||||
var item = _this.createSingleEntity(tile.url, tile.middle, _this.tableRotation);
|
var item = _this.createSingleEntity(tile.url, tile.middle, _this.tableRotation);
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
(function() {
|
|
||||||
var _this
|
|
||||||
|
|
||||||
function Mat() {
|
|
||||||
_this = this;
|
|
||||||
};
|
|
||||||
Mat.prototype = {}
|
|
||||||
return new Mat();
|
|
||||||
});
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 3/31/2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Revision of James B. Pollack's work on GamesTable in 2016
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var _this;
|
var _this;
|
||||||
var CLICK_SOUND_URL = Script.resolvePath('assets/sfx/woodenTapClick.wav');
|
var CLICK_SOUND_URL = Script.resolvePath('assets/sfx/woodenTapClick.wav');
|
||||||
|
@ -18,7 +28,6 @@
|
||||||
var props = Entities.getEntityProperties(_this.entityID);
|
var props = Entities.getEntityProperties(_this.entityID);
|
||||||
var results = Entities.findEntities(props.position, 7.5);
|
var results = Entities.findEntities(props.position, 7.5);
|
||||||
var found = false;
|
var found = false;
|
||||||
print('results? ' + results.length);
|
|
||||||
results.forEach(function(item) {
|
results.forEach(function(item) {
|
||||||
var itemProps = Entities.getEntityProperties(item);
|
var itemProps = Entities.getEntityProperties(item);
|
||||||
var descriptionSplit = itemProps.description.split(":");
|
var descriptionSplit = itemProps.description.split(":");
|
||||||
|
@ -37,9 +46,7 @@
|
||||||
startFarTrigger: function() {},
|
startFarTrigger: function() {},
|
||||||
nextGame: function() {
|
nextGame: function() {
|
||||||
Audio.playSound(CLICK_SOUND_URL, { loop: false, position: myLocation, volume: 0.4 });
|
Audio.playSound(CLICK_SOUND_URL, { loop: false, position: myLocation, volume: 0.4 });
|
||||||
print('next game button calling nextGame');
|
|
||||||
var table = _this.getEntityFromGroup('gameTable', 'table');
|
var table = _this.getEntityFromGroup('gameTable', 'table');
|
||||||
print('has table?' + table);
|
|
||||||
var tableString = table.substr(1, table.length - 2);
|
var tableString = table.substr(1, table.length - 2);
|
||||||
Entities.callEntityMethod(tableString, 'nextGame');
|
Entities.callEntityMethod(tableString, 'nextGame');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 3/31/2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var _this;
|
var _this;
|
||||||
var DONT_SNAP_WHEN_FARTHER_THAN_THIS = 0.25;
|
var DONT_SNAP_WHEN_FARTHER_THAN_THIS = 0.25;
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 3/31/2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Revision of James B. Pollack's work on GamesTable in 2016
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var CLEARCACHE = "?"+Math.random().toString(36).substring(7);
|
var CLEARCACHE = "?"+Math.random().toString(36).substring(7);
|
||||||
var GAMES_LIST_ENDPOINT = Script.resolvePath('games/gamesDirectory.svo.json') + CLEARCACHE;
|
var GAMES_LIST_ENDPOINT = Script.resolvePath('games/gamesDirectory.svo.json') + CLEARCACHE;
|
||||||
|
@ -12,7 +22,6 @@
|
||||||
GameTable.prototype = {
|
GameTable.prototype = {
|
||||||
matCorner: null,
|
matCorner: null,
|
||||||
currentGameIndex: 0,
|
currentGameIndex: 0,
|
||||||
count: 0,
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
|
@ -50,27 +59,21 @@
|
||||||
var userData = _this.getCurrentUserData();
|
var userData = _this.getCurrentUserData();
|
||||||
if (!(userData.gameTableData !== undefined && userData.gameTableData.currentGame !== undefined)) {
|
if (!(userData.gameTableData !== undefined && userData.gameTableData.currentGame !== undefined)) {
|
||||||
_this.currentGameIndex = -1;
|
_this.currentGameIndex = -1;
|
||||||
print("no userdata found, setting game index to -1.")
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var foundIndex = -1;
|
var foundIndex = -1;
|
||||||
_this.gamesList.forEach(function(game, index) {
|
_this.gamesList.forEach(function(game, index) {
|
||||||
if (game.gameName === userData.gameTableData.currentGame) {
|
if (game.gameName === userData.gameTableData.currentGame) {
|
||||||
foundIndex = index;
|
foundIndex = index;
|
||||||
print("found " + game.gameName + " at index " + index);
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
_this.currentGameIndex = foundIndex;
|
_this.currentGameIndex = foundIndex;
|
||||||
},
|
},
|
||||||
setInitialGameIfNone: function() {
|
setInitialGameIfNone: function() {
|
||||||
_this.getCurrentGame();
|
_this.getCurrentGame();
|
||||||
if (_this.currentGameIndex === -1) {
|
if (_this.currentGameIndex === -1) {
|
||||||
print('userdata has no gameTableData or no currentGame');
|
|
||||||
_this.setCurrentGame();
|
_this.setCurrentGame();
|
||||||
_this.cleanupGameEntities();
|
_this.cleanupGameEntities();
|
||||||
print('i set the game and reset the game')
|
|
||||||
} else {
|
|
||||||
print('already has game')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resetGame: function() {
|
resetGame: function() {
|
||||||
|
@ -81,11 +84,8 @@
|
||||||
nextGame: function() {
|
nextGame: function() {
|
||||||
// always check the current game before switching
|
// always check the current game before switching
|
||||||
_this.getCurrentGame();
|
_this.getCurrentGame();
|
||||||
print("got current game " + _this.currentGameIndex);
|
|
||||||
_this.currentGameIndex = (_this.currentGameIndex + 1) % _this.gamesList.length;
|
_this.currentGameIndex = (_this.currentGameIndex + 1) % _this.gamesList.length;
|
||||||
print("it is now " + _this.currentGameIndex);
|
|
||||||
_this.cleanupGameEntities();
|
_this.cleanupGameEntities();
|
||||||
print("and now it is " + _this.currentGameIndex);
|
|
||||||
},
|
},
|
||||||
cleanupGameEntities: function() {
|
cleanupGameEntities: function() {
|
||||||
var props = Entities.getEntityProperties(_this.entityID);
|
var props = Entities.getEntityProperties(_this.entityID);
|
||||||
|
@ -108,9 +108,7 @@
|
||||||
_this.spawnEntitiesForGame();
|
_this.spawnEntitiesForGame();
|
||||||
},
|
},
|
||||||
setCurrentGamesList: function() {
|
setCurrentGamesList: function() {
|
||||||
var gamesList = getGamesList();
|
_this.gamesList = getGamesList();
|
||||||
_this.gamesList = gamesList;
|
|
||||||
print('set gamesList to: ' + JSON.stringify(gamesList));
|
|
||||||
_this.setInitialGameIfNone();
|
_this.setInitialGameIfNone();
|
||||||
},
|
},
|
||||||
setCurrentGame: function() {
|
setCurrentGame: function() {
|
||||||
|
@ -155,19 +153,14 @@
|
||||||
result = item;
|
result = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
print('result returned ought to be: ' + result);
|
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
spawnEntitiesForGame: function() {
|
spawnEntitiesForGame: function() {
|
||||||
print('jbp should spawn entities for game. count: ' + this.count);
|
|
||||||
var entitySpawner = _this.getEntityFromGroup('gameTable', 'entitySpawner');
|
var entitySpawner = _this.getEntityFromGroup('gameTable', 'entitySpawner');
|
||||||
|
|
||||||
var props = Entities.getEntityProperties(_this.entityID);
|
|
||||||
var mat = _this.getEntityFromGroup('gameTable', 'mat');
|
var mat = _this.getEntityFromGroup('gameTable', 'mat');
|
||||||
|
|
||||||
|
Entities.callEntityMethod(entitySpawner, 'spawnEntities', [JSON.stringify(_this.currentGameFull),mat,
|
||||||
Entities.callEntityMethod(entitySpawner, 'spawnEntities', [JSON.stringify(_this.currentGameFull), mat, _this.entityID]);
|
_this.entityID]);
|
||||||
this.count++;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,10 +168,7 @@
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
request.open("GET", GAMES_LIST_ENDPOINT, false);
|
request.open("GET", GAMES_LIST_ENDPOINT, false);
|
||||||
request.send();
|
request.send();
|
||||||
|
return JSON.parse(request.responseText);
|
||||||
var response = JSON.parse(request.responseText);
|
|
||||||
print('got gamesList' + request.responseText);
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GameTable();
|
return new GameTable();
|
||||||
|
|
Loading…
Reference in a new issue