From 69abdf7dd2fb5d693981e4a78d2efca2df719a3a Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 2 Feb 2017 11:37:51 -0800 Subject: [PATCH] Add headers to shortbow scripts and add minor cleanup --- .../shortbow/displayServerEntity.js | 18 ++++++++++++------ .../marketplace/shortbow/enemyClientEntity.js | 8 ++++++++ .../marketplace/shortbow/enemyServerEntity.js | 9 ++++++++- .../marketplace/shortbow/shortbow.js | 8 ++++++++ .../shortbow/shortbowGameManager.js | 8 ++++++++ .../shortbow/shortbowServerEntity.js | 12 ++++++++---- .../marketplace/shortbow/spawnShortbow.js | 14 ++++++++++---- .../shortbow/startGameButtonClientEntity.js | 13 ++++++++----- .../shortbow/startGameButtonServerEntity.js | 8 ++++++++ .../marketplace/shortbow/utils.js | 8 ++++++++ 10 files changed, 86 insertions(+), 20 deletions(-) diff --git a/unpublishedScripts/marketplace/shortbow/displayServerEntity.js b/unpublishedScripts/marketplace/shortbow/displayServerEntity.js index ea4c006491..85de03d78b 100644 --- a/unpublishedScripts/marketplace/shortbow/displayServerEntity.js +++ b/unpublishedScripts/marketplace/shortbow/displayServerEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js'); @@ -7,25 +15,23 @@ preload: function(entityID) { this.entityID = entityID; - this.entityIDsThatHaveCollidedWithMe = []; - var props = Entities.getEntityProperties(this.entityID, ['userData', 'parentID']); var data = utils.parseJSON(props.userData); if (data !== undefined && data.displayType !== undefined) { - this.gameChannel = data.displayType + "-" + props.parentID; + this.commChannel = data.displayType + "-" + props.parentID; } else { print("scoreboardEntity.js | ERROR: userData does not contain a game channel and/or team number"); } - Messages.subscribe(this.gameChannel); + Messages.subscribe(this.commChannel); Messages.messageReceived.connect(this, this.onReceivedMessage); }, unload: function() { - Messages.unsubscribe(this.gameChannel); + Messages.unsubscribe(this.commChannel); Messages.messageReceived.disconnect(this, this.onReceivedMessage); }, onReceivedMessage: function(channel, message, senderID) { - if (channel === this.gameChannel) { + if (channel === this.commChannel) { Entities.editEntity(this.entityID, { text: message }); diff --git a/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js b/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js index ad300f93d8..86978a724b 100644 --- a/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js +++ b/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js'); diff --git a/unpublishedScripts/marketplace/shortbow/enemyServerEntity.js b/unpublishedScripts/marketplace/shortbow/enemyServerEntity.js index 53003f2175..322e440b27 100644 --- a/unpublishedScripts/marketplace/shortbow/enemyServerEntity.js +++ b/unpublishedScripts/marketplace/shortbow/enemyServerEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js'); @@ -5,7 +13,6 @@ }; Enemy.prototype = { preload: function(entityID) { - print("Loaded enemy entity"); this.entityID = entityID; var userData = Entities.getEntityProperties(this.entityID, 'userData').userData; var data = utils.parseJSON(userData); diff --git a/unpublishedScripts/marketplace/shortbow/shortbow.js b/unpublishedScripts/marketplace/shortbow/shortbow.js index 4124872998..5534e31aae 100644 --- a/unpublishedScripts/marketplace/shortbow/shortbow.js +++ b/unpublishedScripts/marketplace/shortbow/shortbow.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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 +// + // This is a copy of the data in shortbow.json, which is an export of the shortbow // scene. // diff --git a/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js b/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js index 257bf4005e..ab2269f737 100644 --- a/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js +++ b/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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 +// + Script.include('utils.js'); // +--------+ +-----------+ +-----------------+ diff --git a/unpublishedScripts/marketplace/shortbow/shortbowServerEntity.js b/unpublishedScripts/marketplace/shortbow/shortbowServerEntity.js index 85e41e5383..db1485399f 100644 --- a/unpublishedScripts/marketplace/shortbow/shortbowServerEntity.js +++ b/unpublishedScripts/marketplace/shortbow/shortbowServerEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js?' + Date.now()); Script.include('spawnShortbow.js?' + Date.now()); @@ -22,13 +30,9 @@ for (var i = 0; i < TEMPLATES.length; ++i) { var template = TEMPLATES[i]; if (template.name === "SB.BowSpawn") { - //bowPositions.push(Vec3.sum(rootPosition, template.localPosition)); bowPositions.push(template.localPosition); - //Vec3.print("Pushing bow position", Vec3.sum(rootPosition, template.localPosition)); } else if (template.name === "SB.EnemySpawn") { - //spawnPositions.push(Vec3.sum(rootPosition, template.localPosition)); spawnPositions.push(template.localPosition); - //Vec3.print("Pushing spawnposition", template.localPosition)); } } diff --git a/unpublishedScripts/marketplace/shortbow/spawnShortbow.js b/unpublishedScripts/marketplace/shortbow/spawnShortbow.js index d8ca561df2..615f256eab 100644 --- a/unpublishedScripts/marketplace/shortbow/spawnShortbow.js +++ b/unpublishedScripts/marketplace/shortbow/spawnShortbow.js @@ -1,8 +1,14 @@ -print("============= Script Starting ============="); +// +// Created by Ryan Huffman on 1/10/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 +// -Script.include('utils.js?' + Date.now()); -Script.include('shortbow.js?' + Date.now()); -Script.include('shortbowGameManager.js?' + Date.now()); +Script.include('utils.js'); +Script.include('shortbow.js'); +Script.include('shortbowGameManager.js'); TEMPLATES = SHORTBOW_ENTITIES.Entities; // Merge two objects into a new object. If a key name appears in both a and b, diff --git a/unpublishedScripts/marketplace/shortbow/startGameButtonClientEntity.js b/unpublishedScripts/marketplace/shortbow/startGameButtonClientEntity.js index aae6b4ad86..0aea5a7c96 100644 --- a/unpublishedScripts/marketplace/shortbow/startGameButtonClientEntity.js +++ b/unpublishedScripts/marketplace/shortbow/startGameButtonClientEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js'); @@ -5,21 +13,16 @@ }; StartButton.prototype = { preload: function(entityID) { - print("Preloading start button"); this.entityID = entityID; this.commChannel = "shortbow-" + Entities.getEntityProperties(entityID, 'parentID').parentID; Script.addEventHandler(entityID, "collisionWithEntity", this.onCollide.bind(this)); }, signalAC: function() { - print("Button pressed"); - print("Sending message to: ", this.commChannel); Messages.sendMessage(this.commChannel, JSON.stringify({ type: 'start-game' })); }, onCollide: function(entityA, entityB, collision) { - print("Collided with: ", entityB); - var colliderName = Entities.getEntityProperties(entityB, 'name').name; if (colliderName.indexOf("projectile") > -1) { diff --git a/unpublishedScripts/marketplace/shortbow/startGameButtonServerEntity.js b/unpublishedScripts/marketplace/shortbow/startGameButtonServerEntity.js index 60b89a04a5..a6f98b13d7 100644 --- a/unpublishedScripts/marketplace/shortbow/startGameButtonServerEntity.js +++ b/unpublishedScripts/marketplace/shortbow/startGameButtonServerEntity.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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() { Script.include('utils.js'); diff --git a/unpublishedScripts/marketplace/shortbow/utils.js b/unpublishedScripts/marketplace/shortbow/utils.js index 53b3fc7655..80391bd120 100644 --- a/unpublishedScripts/marketplace/shortbow/utils.js +++ b/unpublishedScripts/marketplace/shortbow/utils.js @@ -1,3 +1,11 @@ +// +// Created by Ryan Huffman on 1/10/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 +// + if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== 'function') {