mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-06 18:13:54 +02:00
Update tower defense blocks to grow
This commit is contained in:
parent
ef62e6feb1
commit
5022cdd2a7
4 changed files with 54 additions and 18 deletions
|
@ -0,0 +1,23 @@
|
|||
var BLOCK_MODEL_URL = Script.resolvePath("assets/block.fbx");
|
||||
var BLOCK_DIMENSIONS = {
|
||||
x: 1,
|
||||
y: 1,
|
||||
z: 1
|
||||
};
|
||||
var BLOCK_LIFETIME = 120;
|
||||
|
||||
getBlockProperties = function() {
|
||||
return {
|
||||
type: "Model",
|
||||
name: "TD.block",
|
||||
modelURL: BLOCK_MODEL_URL,
|
||||
shapeType: "compound",
|
||||
//compoundShapeURL: BLOCK_COMPOUND_SHAPE_URL,
|
||||
dimensions: BLOCK_DIMENSIONS,
|
||||
dynamic: 1,
|
||||
gravity: { x: 0.0, y: -9.8, z: 0.0 },
|
||||
collisionsWillMove: 1,
|
||||
lifetime: BLOCK_LIFETIME,
|
||||
script: Script.resolvePath("destructibleEntity.js")
|
||||
};
|
||||
}
|
|
@ -53,6 +53,7 @@ function parseJSON(json) {
|
|||
var TEXTURE_NAME = "tex.health1";
|
||||
|
||||
(function() {
|
||||
Script.include("block.js");
|
||||
DestructibleBlock = function() {
|
||||
}
|
||||
DestructibleBlock.prototype = {
|
||||
|
@ -138,6 +139,24 @@ var TEXTURE_NAME = "tex.health1";
|
|||
Entities.editEntity(this.entityID, { textures: newTexturesJSON });
|
||||
print("tdBlock.js | Setting texture to: ", newTexturesJSON);
|
||||
}
|
||||
},
|
||||
growBlock: function() {
|
||||
var props = getBlockProperties();
|
||||
props.position = Entities.getEntityProperties(this.entityID, 'position').position;
|
||||
props.position.y += props.dimensions.y;
|
||||
Entities.addEntity(props);
|
||||
},
|
||||
startNearTrigger: function () {
|
||||
print("launch.js | got start near trigger");
|
||||
this.growBlock();
|
||||
},
|
||||
startFarTrigger: function () {
|
||||
print("launch.js | got start far trigger");
|
||||
this.growBlock();
|
||||
},
|
||||
clickDownOnEntity: function () {
|
||||
print("launch.js | got click down");
|
||||
this.growBlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
(function () {
|
||||
|
||||
Script.include("block.js");
|
||||
|
||||
var BLOCK_MODEL_URL = Script.resolvePath("assets/block.fbx");
|
||||
var BLOCK_DIMENSIONS = {
|
||||
x: 1,
|
||||
|
@ -44,22 +46,12 @@
|
|||
muzzleVelocity = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0), muzzleVelocity);
|
||||
muzzleVelocity = Vec3.multiplyQbyV(cylinder.rotation, muzzleVelocity);
|
||||
|
||||
Entities.addEntity({
|
||||
type: "Model",
|
||||
name: "TD.block",
|
||||
modelURL: BLOCK_MODEL_URL,
|
||||
shapeType: "compound",
|
||||
//compoundShapeURL: BLOCK_COMPOUND_SHAPE_URL,
|
||||
dimensions: BLOCK_DIMENSIONS,
|
||||
dynamic: 1,
|
||||
gravity: { x: 0.0, y: -9.8, z: 0.0 },
|
||||
collisionsWillMove: 1,
|
||||
position: muzzlePosition,
|
||||
rotation: Quat.multiply(cylinder.rotation, Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0)),
|
||||
velocity: muzzleVelocity,
|
||||
lifetime: BLOCK_LIFETIME,
|
||||
script: Script.resolvePath("destructibleEntity.js")
|
||||
});
|
||||
var blockProperties = getBlockProperties();
|
||||
blockProperties.position = muzzlePosition;
|
||||
blockProperties.velocity = muzzleVelocity;
|
||||
blockProperties.rotation = Quat.multiply(cylinder.rotation, Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0));
|
||||
|
||||
Entities.addEntity(blockProperties);
|
||||
|
||||
Audio.playSound(muzzleSound, {
|
||||
position: cylinder.muzzlePosition,
|
||||
|
|
|
@ -158,8 +158,10 @@ function cleanup() {
|
|||
var t = teamEntities[i];
|
||||
Entities.deleteEntity(t.targetID);
|
||||
Entities.deleteEntity(t.spawnerID);
|
||||
for (var j = 0; j < t.bowIDs.length; ++j) {
|
||||
Entities.deleteEntity(t.bowIDs[j]);
|
||||
if (t.bowIDs !== undefined) {
|
||||
for (var j = 0; j < t.bowIDs.length; ++j) {
|
||||
Entities.deleteEntity(t.bowIDs[j]);
|
||||
}
|
||||
}
|
||||
Entities.deleteEntity(t.roofID);
|
||||
Entities.deleteEntity(t.arenaID);
|
||||
|
|
Loading…
Reference in a new issue