mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-01 04:23:00 +02:00
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
//
|
|
// 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('shortbow.js?' + Date.now());
|
|
Script.include('shortbowGameManager.js?' + Date.now());
|
|
|
|
TEMPLATES = SHORTBOW_ENTITIES.Entities;
|
|
|
|
this.entityID = null;
|
|
var gameManager = null;
|
|
this.preload = function(entityID) {
|
|
this.entityID = entityID;
|
|
|
|
var props = Entities.getEntityProperties(entityID, ['position', 'userData']);
|
|
var data = utils.parseJSON(props.userData);
|
|
if (data === undefined) {
|
|
print("Error parsing shortbow entity userData, returning");
|
|
return;
|
|
}
|
|
|
|
var rootPosition = props.position;
|
|
|
|
var bowPositions = [];
|
|
var spawnPositions = [];
|
|
for (var i = 0; i < TEMPLATES.length; ++i) {
|
|
var template = TEMPLATES[i];
|
|
if (template.name === "SB.BowSpawn") {
|
|
bowPositions.push(template.localPosition);
|
|
} else if (template.name === "SB.EnemySpawn") {
|
|
spawnPositions.push(template.localPosition);
|
|
}
|
|
}
|
|
|
|
gameManager = new ShortbowGameManager(this.entityID, bowPositions, spawnPositions);
|
|
};
|
|
this.unload = function() {
|
|
if (gameManager) {
|
|
gameManager.cleanup();
|
|
gameManager = null;
|
|
}
|
|
};
|
|
});
|