diff --git a/unpublishedScripts/marketplace/gameTable/createGameTable.js b/unpublishedScripts/marketplace/gameTable/createGameTable.js index 0141020655..7ce084f413 100644 --- a/unpublishedScripts/marketplace/gameTable/createGameTable.js +++ b/unpublishedScripts/marketplace/gameTable/createGameTable.js @@ -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 TABLE_MODEL_URL = Script.resolvePath('assets/table/gameTable.fbx') + CLEARCACHE; var MODEL_URL = Script.resolvePath('assets/table/finalFrame.fbx') + CLEARCACHE; var TABLE_SCRIPT_URL = Script.resolvePath('table.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 RESET_BUTTON_SCRIPT_URL = Script.resolvePath('resetGameButton.js') + CLEARCACHE; var TABLE_PICTURE_URL = Script.resolvePath('assets/mats/Table-default.jpg') + CLEARCACHE; @@ -152,7 +160,6 @@ function createMat() { Picture: TABLE_PICTURE_URL }), parentID: table, - script: MAT_SCRIPT_URL, position: getOffsetFromTable(matOffset.forward, matOffset.vertical, matOffset.right), userData: JSON.stringify({ grabbableKey: { @@ -240,7 +247,6 @@ function makeTable() { createEntitySpawner(); createResetGameButton(); createNextGameButton(); - } function cleanup() { diff --git a/unpublishedScripts/marketplace/gameTable/entitySpawner.js b/unpublishedScripts/marketplace/gameTable/entitySpawner.js index ab7b37ad6a..19b1efbb0f 100644 --- a/unpublishedScripts/marketplace/gameTable/entitySpawner.js +++ b/unpublishedScripts/marketplace/gameTable/entitySpawner.js @@ -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() { var _this; @@ -198,8 +206,6 @@ _this.entityID = id; }, createSingleEntity: function(url, spawnLocation, spawnRotation) { - // print('creating a single entity: ' + url) - // print('creating a single entity at : ' + JSON.stringify(spawnLocation)) if (url === 'empty') { return null; } @@ -217,10 +223,8 @@ }) }, spawnEntities: function(id, params) { - print('spawn entities called!!'); this.items = []; var dimensions = Entities.getEntityProperties(params[1]).dimensions; - print('and it has params: ' + params.length); _this.game = JSON.parse(params[0]); _this.matDimensions = dimensions; _this.matCenter = Entities.getEntityProperties(params[1]).position; @@ -242,12 +246,8 @@ }, spawnByPile: function() { - print('should spawn by pile'); var props = Entities.getEntityProperties(_this.entityID); - - var i; - for (i = 0; i < _this.game.howMany; i++) { - print('spawning entity from pile:: ' + i); + for (var i = 0; i < _this.game.howMany; i++) { var spawnLocation = { x: props.position.x, y: props.position.y - 0.25, @@ -264,8 +264,7 @@ } }, 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(); }, @@ -294,11 +293,9 @@ setupGrid: function() { _this.tiles = []; - var i; - var j; - for (i = 0; i < _this.game.startingArrangement.length; i++) { - for (j = 0; j < _this.game.startingArrangement[i].length; j++) { + for (var i = 0; i < _this.game.startingArrangement.length; i++) { + for (var j = 0; j < _this.game.startingArrangement[i].length; j++) { // print('jbp there is a tile at:: ' + i + "::" + j) var tile = new Tile(i, j); var item = _this.createSingleEntity(tile.url, tile.middle, _this.tableRotation); diff --git a/unpublishedScripts/marketplace/gameTable/mat.js b/unpublishedScripts/marketplace/gameTable/mat.js deleted file mode 100644 index 56da38db67..0000000000 --- a/unpublishedScripts/marketplace/gameTable/mat.js +++ /dev/null @@ -1,9 +0,0 @@ -(function() { - var _this - - function Mat() { - _this = this; - }; - Mat.prototype = {} - return new Mat(); -}); diff --git a/unpublishedScripts/marketplace/gameTable/nextGameButton.js b/unpublishedScripts/marketplace/gameTable/nextGameButton.js index 7ffa4be9dc..473e3c196c 100644 --- a/unpublishedScripts/marketplace/gameTable/nextGameButton.js +++ b/unpublishedScripts/marketplace/gameTable/nextGameButton.js @@ -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() { var _this; var CLICK_SOUND_URL = Script.resolvePath('assets/sfx/woodenTapClick.wav'); @@ -18,7 +28,6 @@ var props = Entities.getEntityProperties(_this.entityID); var results = Entities.findEntities(props.position, 7.5); var found = false; - print('results? ' + results.length); results.forEach(function(item) { var itemProps = Entities.getEntityProperties(item); var descriptionSplit = itemProps.description.split(":"); @@ -37,9 +46,7 @@ startFarTrigger: function() {}, nextGame: function() { Audio.playSound(CLICK_SOUND_URL, { loop: false, position: myLocation, volume: 0.4 }); - print('next game button calling nextGame'); var table = _this.getEntityFromGroup('gameTable', 'table'); - print('has table?' + table); var tableString = table.substr(1, table.length - 2); Entities.callEntityMethod(tableString, 'nextGame'); } diff --git a/unpublishedScripts/marketplace/gameTable/snapToGrid.js b/unpublishedScripts/marketplace/gameTable/snapToGrid.js index 06bd59a9cc..a0405a9206 100644 --- a/unpublishedScripts/marketplace/gameTable/snapToGrid.js +++ b/unpublishedScripts/marketplace/gameTable/snapToGrid.js @@ -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() { var _this; var DONT_SNAP_WHEN_FARTHER_THAN_THIS = 0.25; diff --git a/unpublishedScripts/marketplace/gameTable/table.js b/unpublishedScripts/marketplace/gameTable/table.js index 28eb702a76..f618fe4f88 100644 --- a/unpublishedScripts/marketplace/gameTable/table.js +++ b/unpublishedScripts/marketplace/gameTable/table.js @@ -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() { var CLEARCACHE = "?"+Math.random().toString(36).substring(7); var GAMES_LIST_ENDPOINT = Script.resolvePath('games/gamesDirectory.svo.json') + CLEARCACHE; @@ -12,7 +22,6 @@ GameTable.prototype = { matCorner: null, currentGameIndex: 0, - count: 0, preload: function(entityID) { _this.entityID = entityID; Script.setTimeout(function() { @@ -50,27 +59,21 @@ var userData = _this.getCurrentUserData(); if (!(userData.gameTableData !== undefined && userData.gameTableData.currentGame !== undefined)) { _this.currentGameIndex = -1; - print("no userdata found, setting game index to -1.") return; } var foundIndex = -1; _this.gamesList.forEach(function(game, index) { if (game.gameName === userData.gameTableData.currentGame) { foundIndex = index; - print("found " + game.gameName + " at index " + index); } - }) + }); _this.currentGameIndex = foundIndex; }, setInitialGameIfNone: function() { _this.getCurrentGame(); if (_this.currentGameIndex === -1) { - print('userdata has no gameTableData or no currentGame'); _this.setCurrentGame(); _this.cleanupGameEntities(); - print('i set the game and reset the game') - } else { - print('already has game') } }, resetGame: function() { @@ -81,11 +84,8 @@ nextGame: function() { // always check the current game before switching _this.getCurrentGame(); - print("got current game " + _this.currentGameIndex); _this.currentGameIndex = (_this.currentGameIndex + 1) % _this.gamesList.length; - print("it is now " + _this.currentGameIndex); _this.cleanupGameEntities(); - print("and now it is " + _this.currentGameIndex); }, cleanupGameEntities: function() { var props = Entities.getEntityProperties(_this.entityID); @@ -108,9 +108,7 @@ _this.spawnEntitiesForGame(); }, setCurrentGamesList: function() { - var gamesList = getGamesList(); - _this.gamesList = gamesList; - print('set gamesList to: ' + JSON.stringify(gamesList)); + _this.gamesList = getGamesList(); _this.setInitialGameIfNone(); }, setCurrentGame: function() { @@ -155,19 +153,14 @@ result = item; } }); - print('result returned ought to be: ' + result); return result }, spawnEntitiesForGame: function() { - print('jbp should spawn entities for game. count: ' + this.count); var entitySpawner = _this.getEntityFromGroup('gameTable', 'entitySpawner'); - - var props = Entities.getEntityProperties(_this.entityID); var mat = _this.getEntityFromGroup('gameTable', 'mat'); - - Entities.callEntityMethod(entitySpawner, 'spawnEntities', [JSON.stringify(_this.currentGameFull), mat, _this.entityID]); - this.count++; + Entities.callEntityMethod(entitySpawner, 'spawnEntities', [JSON.stringify(_this.currentGameFull),mat, + _this.entityID]); } }; @@ -175,10 +168,7 @@ var request = new XMLHttpRequest(); request.open("GET", GAMES_LIST_ENDPOINT, false); request.send(); - - var response = JSON.parse(request.responseText); - print('got gamesList' + request.responseText); - return response; + return JSON.parse(request.responseText); } return new GameTable();