mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-23 00:29:16 +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";
|
var TEXTURE_NAME = "tex.health1";
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
Script.include("block.js");
|
||||||
DestructibleBlock = function() {
|
DestructibleBlock = function() {
|
||||||
}
|
}
|
||||||
DestructibleBlock.prototype = {
|
DestructibleBlock.prototype = {
|
||||||
|
@ -138,6 +139,24 @@ var TEXTURE_NAME = "tex.health1";
|
||||||
Entities.editEntity(this.entityID, { textures: newTexturesJSON });
|
Entities.editEntity(this.entityID, { textures: newTexturesJSON });
|
||||||
print("tdBlock.js | Setting texture to: ", 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 () {
|
(function () {
|
||||||
|
|
||||||
|
Script.include("block.js");
|
||||||
|
|
||||||
var BLOCK_MODEL_URL = Script.resolvePath("assets/block.fbx");
|
var BLOCK_MODEL_URL = Script.resolvePath("assets/block.fbx");
|
||||||
var BLOCK_DIMENSIONS = {
|
var BLOCK_DIMENSIONS = {
|
||||||
x: 1,
|
x: 1,
|
||||||
|
@ -44,22 +46,12 @@
|
||||||
muzzleVelocity = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0), muzzleVelocity);
|
muzzleVelocity = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0), muzzleVelocity);
|
||||||
muzzleVelocity = Vec3.multiplyQbyV(cylinder.rotation, muzzleVelocity);
|
muzzleVelocity = Vec3.multiplyQbyV(cylinder.rotation, muzzleVelocity);
|
||||||
|
|
||||||
Entities.addEntity({
|
var blockProperties = getBlockProperties();
|
||||||
type: "Model",
|
blockProperties.position = muzzlePosition;
|
||||||
name: "TD.block",
|
blockProperties.velocity = muzzleVelocity;
|
||||||
modelURL: BLOCK_MODEL_URL,
|
blockProperties.rotation = Quat.multiply(cylinder.rotation, Quat.fromPitchYawRollDegrees(0.0, Math.random() * 360.0, 0.0));
|
||||||
shapeType: "compound",
|
|
||||||
//compoundShapeURL: BLOCK_COMPOUND_SHAPE_URL,
|
Entities.addEntity(blockProperties);
|
||||||
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")
|
|
||||||
});
|
|
||||||
|
|
||||||
Audio.playSound(muzzleSound, {
|
Audio.playSound(muzzleSound, {
|
||||||
position: cylinder.muzzlePosition,
|
position: cylinder.muzzlePosition,
|
||||||
|
|
|
@ -158,9 +158,11 @@ function cleanup() {
|
||||||
var t = teamEntities[i];
|
var t = teamEntities[i];
|
||||||
Entities.deleteEntity(t.targetID);
|
Entities.deleteEntity(t.targetID);
|
||||||
Entities.deleteEntity(t.spawnerID);
|
Entities.deleteEntity(t.spawnerID);
|
||||||
|
if (t.bowIDs !== undefined) {
|
||||||
for (var j = 0; j < t.bowIDs.length; ++j) {
|
for (var j = 0; j < t.bowIDs.length; ++j) {
|
||||||
Entities.deleteEntity(t.bowIDs[j]);
|
Entities.deleteEntity(t.bowIDs[j]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Entities.deleteEntity(t.roofID);
|
Entities.deleteEntity(t.roofID);
|
||||||
Entities.deleteEntity(t.arenaID);
|
Entities.deleteEntity(t.arenaID);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue