mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:48:56 +02:00
end of day
This commit is contained in:
parent
fafea94196
commit
c7ae3396eb
1 changed files with 198 additions and 193 deletions
|
@ -46,208 +46,213 @@ var blocks = [
|
||||||
];
|
];
|
||||||
|
|
||||||
var arrangements = [{
|
var arrangements = [{
|
||||||
name: 'tall',
|
name: 'greenhenge',
|
||||||
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_GREEN],
|
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_YELLOW],
|
||||||
target: "atp:/blocky/newblocks1.json"
|
target: "atp:/blocky/newblocks1.json"
|
||||||
}, {
|
},
|
||||||
name: 'ostrich',
|
{
|
||||||
blocks: [BLOCK_RED, BLOCK_RED, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_NATURAL],
|
name: 'tallstuff',
|
||||||
target: "atp:/blocky/newblocks5.json"
|
blocks: [BLOCK_RED, BLOCK_RED, BLOCK_RED],
|
||||||
}, {
|
target: "atp:/blocky/newblocks2.json"
|
||||||
name: 'froglog',
|
},
|
||||||
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_GREEN, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL],
|
{
|
||||||
target: "atp:/blocky/newblocks2.json"
|
name: 'ostrich',
|
||||||
}, {
|
blocks: [BLOCK_RED, BLOCK_RED, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_NATURAL],
|
||||||
name: 'allOneLeg',
|
target: "atp:/blocky/newblocks5.json"
|
||||||
blocks: [BLOCK_RED, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_BLUE, BLOCK_BLUE, BLOCK_NATURAL],
|
},
|
||||||
target: "atp:/blocky/newblocks3.json"
|
{
|
||||||
}, {
|
name: 'fourppl',
|
||||||
name: 'threeppl',
|
blocks: [BLOCK_BLUE, BLOCK_BLUE, BLOCK_BLUE, BLOCK_BLUE, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL],
|
||||||
blocks: [BLOCK_BLUE, BLOCK_YELLOW, BLOCK_BLUE, BLOCK_NATURAL, BLOCK_NATURAL, BLOCK_NATURAL],
|
target: "atp:/blocky/newblocks3.json"
|
||||||
target: "atp:/blocky/newblocks4.json"
|
},
|
||||||
}, {
|
{
|
||||||
name: 'dominoes',
|
name: 'frogguy',
|
||||||
blocks: [BLOCK_RED, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW],
|
blocks: [BLOCK_GREEN, BLOCK_GREEN, BLOCK_GREEN, BLOCK_YELLOW, BLOCK_RED, BLOCK_RED, BLOCK_NATURAL, BLOCK_NATURAL],
|
||||||
target: "atp:/blocky/arrangement6B.json"
|
target: "atp:/blocky/newblocks4.json"
|
||||||
}]
|
},
|
||||||
|
{
|
||||||
|
name: 'dominoes',
|
||||||
|
blocks: [BLOCK_RED, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW, BLOCK_YELLOW],
|
||||||
|
target: "atp:/blocky/arrangement6B.json"
|
||||||
|
}]
|
||||||
|
|
||||||
var PLAYABLE_BLOCKS_POSITION = {
|
var PLAYABLE_BLOCKS_POSITION = {
|
||||||
x: 1097.6,
|
x: 1097.6,
|
||||||
y: 460.5,
|
y: 460.5,
|
||||||
z: -66.22
|
z: -66.22
|
||||||
};
|
};
|
||||||
|
|
||||||
var TARGET_BLOCKS_POSITION = {
|
var TARGET_BLOCKS_POSITION = {
|
||||||
x: 1096.82,
|
x: 1096.82,
|
||||||
y: 460.5,
|
y: 460.5,
|
||||||
z: -67.689
|
z: -67.689
|
||||||
};
|
};
|
||||||
//#debug
|
//#debug
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
print('BLOCK ENTITY SCRIPT')
|
print('BLOCK ENTITY SCRIPT')
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
function Blocky() {
|
function Blocky() {
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
|
||||||
|
|
||||||
Blocky.prototype = {
|
|
||||||
debug: true,
|
|
||||||
playableBlocks: [],
|
|
||||||
targetBlocks: [],
|
|
||||||
preload: function(entityID) {
|
|
||||||
print('BLOCKY preload')
|
|
||||||
this.entityID = entityID;
|
|
||||||
},
|
|
||||||
createTargetBlocks: function(arrangement) {
|
|
||||||
var created = [];
|
|
||||||
print('BLOCKY create target blocks')
|
|
||||||
|
|
||||||
var created = [];
|
|
||||||
var success = Clipboard.importEntities(arrangement.target);
|
|
||||||
if (success === true) {
|
|
||||||
created = Clipboard.pasteEntities(TARGET_BLOCKS_POSITION)
|
|
||||||
print('created ' + created);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.targetBlocks = created;
|
Blocky.prototype = {
|
||||||
print('BLOCKY TARGET BLOCKS:: ' + this.targetBlocks);
|
debug: false,
|
||||||
},
|
playableBlocks: [],
|
||||||
createPlayableBlocks: function(arrangement) {
|
targetBlocks: [],
|
||||||
print('BLOCKY creating playable blocks' + arrangement.blocks.length);
|
preload: function(entityID) {
|
||||||
arrangement.blocks.forEach(function(block) {
|
print('BLOCKY preload')
|
||||||
print('BLOCKY in a block loop')
|
this.entityID = entityID;
|
||||||
var blockProps = {
|
},
|
||||||
name: "home_model_blocky_block",
|
createTargetBlocks: function(arrangement) {
|
||||||
type: 'Model',
|
var created = [];
|
||||||
collisionSoundURL: "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
|
print('BLOCKY create target blocks')
|
||||||
dynamic: false,
|
|
||||||
collisionless: true,
|
var created = [];
|
||||||
gravity: {
|
var success = Clipboard.importEntities(arrangement.target);
|
||||||
x: 0,
|
if (success === true) {
|
||||||
y: -9.8,
|
created = Clipboard.pasteEntities(TARGET_BLOCKS_POSITION)
|
||||||
z: 0
|
print('created ' + created);
|
||||||
},
|
}
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
this.targetBlocks = created;
|
||||||
grabbable: true
|
print('BLOCKY TARGET BLOCKS:: ' + this.targetBlocks);
|
||||||
},
|
},
|
||||||
hifiHomeKey: {
|
createPlayableBlocks: function(arrangement) {
|
||||||
reset: true
|
print('BLOCKY creating playable blocks' + arrangement.blocks.length);
|
||||||
|
arrangement.blocks.forEach(function(block) {
|
||||||
|
print('BLOCKY in a block loop')
|
||||||
|
var blockProps = {
|
||||||
|
name: "home_model_blocky_block",
|
||||||
|
type: 'Model',
|
||||||
|
collisionSoundURL: "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
|
||||||
|
dynamic: true,
|
||||||
|
collisionless: false,
|
||||||
|
gravity: {
|
||||||
|
x: 0,
|
||||||
|
y: -9.8,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: true
|
||||||
|
},
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
dimensions: block.dimensions,
|
||||||
|
modelURL: block.url,
|
||||||
|
shapeType: 'box',
|
||||||
|
velocity: {
|
||||||
|
x: 0,
|
||||||
|
y: -0.01,
|
||||||
|
z: 0,
|
||||||
|
},
|
||||||
|
position: PLAYABLE_BLOCKS_POSITION
|
||||||
}
|
}
|
||||||
}),
|
var newBlock = Entities.addEntity(blockProps);
|
||||||
dimensions: block.dimensions,
|
print('BLOCKY made a playable block' + newBlock)
|
||||||
modelURL: block.url,
|
_this.playableBlocks.push(newBlock);
|
||||||
shapeType: 'box',
|
print('BLOCKY pushing it into playable blocks');
|
||||||
velocity: {
|
})
|
||||||
x: 0,
|
|
||||||
y: -0.01,
|
|
||||||
z: 0,
|
|
||||||
},
|
|
||||||
position: PLAYABLE_BLOCKS_POSITION
|
|
||||||
}
|
|
||||||
var newBlock = Entities.addEntity(blockProps);
|
|
||||||
print('BLOCKY made a playable block' + newBlock)
|
|
||||||
_this.playableBlocks.push(newBlock);
|
|
||||||
print('BLOCKY pushing it into playable blocks');
|
|
||||||
})
|
|
||||||
|
|
||||||
print('BLOCKY after going through playable arrangement')
|
print('BLOCKY after going through playable arrangement')
|
||||||
},
|
},
|
||||||
startNearTrigger: function() {
|
startNearTrigger: function() {
|
||||||
print('BLOCKY got a near trigger');
|
print('BLOCKY got a near trigger');
|
||||||
this.advanceRound();
|
this.advanceRound();
|
||||||
},
|
},
|
||||||
advanceRound: function() {
|
advanceRound: function() {
|
||||||
print('BLOCKY advance round');
|
print('BLOCKY advance round');
|
||||||
this.cleanup();
|
this.cleanup();
|
||||||
var arrangement = arrangements[Math.floor(Math.random() * arrangements.length)];
|
var arrangement = arrangements[Math.floor(Math.random() * arrangements.length)];
|
||||||
this.createTargetBlocks(arrangement);
|
this.createTargetBlocks(arrangement);
|
||||||
|
|
||||||
if (this.debug === true) {
|
if (this.debug === true) {
|
||||||
this.debugCreatePlayableBlocks();
|
this.debugCreatePlayableBlocks();
|
||||||
} else {
|
} else {
|
||||||
this.createPlayableBlocks(arrangement);
|
this.createPlayableBlocks(arrangement);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findBlocks: function() {
|
findBlocks: function() {
|
||||||
var found = [];
|
var found = [];
|
||||||
var results = Entities.findEntities(MyAvatar.position, 10);
|
var results = Entities.findEntities(MyAvatar.position, 10);
|
||||||
results.forEach(function(result) {
|
results.forEach(function(result) {
|
||||||
var properties = Entities.getEntityProperties(result);
|
var properties = Entities.getEntityProperties(result);
|
||||||
print('got result props')
|
print('got result props')
|
||||||
if (properties.name.indexOf('blocky_block') > -1) {
|
if (properties.name.indexOf('blocky_block') > -1) {
|
||||||
found.push(result);
|
found.push(result);
|
||||||
}
|
|
||||||
});
|
|
||||||
return found;
|
|
||||||
},
|
|
||||||
|
|
||||||
cleanup: function() {
|
|
||||||
print('BLOCKY cleanup');
|
|
||||||
var blocks = this.findBlocks();
|
|
||||||
print('BLOCKY cleanup2' + blocks.length)
|
|
||||||
blocks.forEach(function(block) {
|
|
||||||
Entities.deleteEntity(block);
|
|
||||||
})
|
|
||||||
print('BLOCKY after find and delete')
|
|
||||||
this.targetBlocks.forEach(function(block) {
|
|
||||||
Entities.deleteEntity(block);
|
|
||||||
});
|
|
||||||
this.playableBlocks.forEach(function(block) {
|
|
||||||
Entities.deleteEntity(block);
|
|
||||||
});
|
|
||||||
this.targetBlocks = [];
|
|
||||||
this.playableBlocks = [];
|
|
||||||
},
|
|
||||||
debugCreatePlayableBlocks: function() {
|
|
||||||
print('BLOCKY debug create');
|
|
||||||
var howMany = 10;
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < howMany; i++) {
|
|
||||||
var block = blocks[Math.floor(Math.random() * blocks.length)];
|
|
||||||
var blockProps = {
|
|
||||||
name: "home_model_blocky_block",
|
|
||||||
type: 'Model',
|
|
||||||
collisionSoundURL: "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
|
|
||||||
dynamic: false,
|
|
||||||
collisionless: true,
|
|
||||||
// gravity: {
|
|
||||||
// x: 0,
|
|
||||||
// y: -9.8,
|
|
||||||
// z: 0
|
|
||||||
// },
|
|
||||||
userData: JSON.stringify({
|
|
||||||
grabbableKey: {
|
|
||||||
grabbable: true
|
|
||||||
},
|
|
||||||
hifiHomeKey: {
|
|
||||||
reset: true
|
|
||||||
}
|
}
|
||||||
}),
|
});
|
||||||
dimensions: block.dimensions,
|
return found;
|
||||||
modelURL: block.url,
|
},
|
||||||
shapeType: 'box',
|
|
||||||
velocity: {
|
|
||||||
x: 0,
|
|
||||||
y: -0.01,
|
|
||||||
z: 0,
|
|
||||||
},
|
|
||||||
position: PLAYABLE_BLOCKS_POSITION
|
|
||||||
}
|
|
||||||
this.playableBlocks.push(Entities.addEntity(blockProps));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unload: function() {
|
|
||||||
this.cleanup();
|
|
||||||
},
|
|
||||||
clickReleaseOnEntity: function() {
|
|
||||||
print('BLOCKY click')
|
|
||||||
this.startNearTrigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Blocky();
|
cleanup: function() {
|
||||||
})
|
print('BLOCKY cleanup');
|
||||||
|
var blocks = this.findBlocks();
|
||||||
|
print('BLOCKY cleanup2' + blocks.length)
|
||||||
|
blocks.forEach(function(block) {
|
||||||
|
Entities.deleteEntity(block);
|
||||||
|
})
|
||||||
|
print('BLOCKY after find and delete')
|
||||||
|
this.targetBlocks.forEach(function(block) {
|
||||||
|
Entities.deleteEntity(block);
|
||||||
|
});
|
||||||
|
this.playableBlocks.forEach(function(block) {
|
||||||
|
Entities.deleteEntity(block);
|
||||||
|
});
|
||||||
|
this.targetBlocks = [];
|
||||||
|
this.playableBlocks = [];
|
||||||
|
},
|
||||||
|
debugCreatePlayableBlocks: function() {
|
||||||
|
print('BLOCKY debug create');
|
||||||
|
var howMany = 10;
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < howMany; i++) {
|
||||||
|
var block = blocks[Math.floor(Math.random() * blocks.length)];
|
||||||
|
var blockProps = {
|
||||||
|
name: "home_model_blocky_block",
|
||||||
|
type: 'Model',
|
||||||
|
collisionSoundURL: "atp:/kineticObjects/blocks/ToyWoodBlock.L.wav",
|
||||||
|
dynamic: false,
|
||||||
|
collisionless: true,
|
||||||
|
// gravity: {
|
||||||
|
// x: 0,
|
||||||
|
// y: -9.8,
|
||||||
|
// z: 0
|
||||||
|
// },
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
grabbable: true
|
||||||
|
},
|
||||||
|
hifiHomeKey: {
|
||||||
|
reset: true
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
dimensions: block.dimensions,
|
||||||
|
modelURL: block.url,
|
||||||
|
shapeType: 'box',
|
||||||
|
velocity: {
|
||||||
|
x: 0,
|
||||||
|
y: -0.01,
|
||||||
|
z: 0,
|
||||||
|
},
|
||||||
|
position: PLAYABLE_BLOCKS_POSITION
|
||||||
|
}
|
||||||
|
this.playableBlocks.push(Entities.addEntity(blockProps));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unload: function() {
|
||||||
|
this.cleanup();
|
||||||
|
},
|
||||||
|
clickReleaseOnEntity: function() {
|
||||||
|
print('BLOCKY click')
|
||||||
|
this.startNearTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Blocky();
|
||||||
|
})
|
Loading…
Reference in a new issue