Add headers to shortbow scripts and add minor cleanup

This commit is contained in:
Ryan Huffman 2017-02-02 11:37:51 -08:00
parent f412e4cdea
commit 69abdf7dd2
10 changed files with 86 additions and 20 deletions

View file

@ -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
});

View file

@ -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');

View file

@ -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);

View file

@ -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.
//

View file

@ -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');
// +--------+ +-----------+ +-----------------+

View file

@ -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));
}
}

View file

@ -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,

View file

@ -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) {

View file

@ -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');

View file

@ -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') {