Noah Petherbridge
837960c477
* The crumbly floor doodad was made 50% larger. * New doodad: Small Key and Small Key Door. These work like the colored doors and locks except each Small Key is consumed when it unlocks a door. The door's appearance is of iron bars. * The inventory HUD displays a small quantity label in the lower-right corner of items that have a quantity, such as the Small Key. This is done as a Canvas.CornerLabel string attribute on uix.Canvas. * The "give all keys" cheat adds 99 Small Keys to your inventory.
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
// Crumbly Floor.
|
|
function main() {
|
|
Self.SetHitbox(0, 0, 98, 11);
|
|
|
|
Self.AddAnimation("shake", 100, ["shake1", "shake2", "floor", "shake1", "shake2", "floor"]);
|
|
Self.AddAnimation("fall", 100, ["fall1", "fall2", "fall3", "fall4"]);
|
|
|
|
// Recover time for the floor to respawn.
|
|
var recover = 5000;
|
|
|
|
// States of the floor.
|
|
var stateSolid = 0;
|
|
var stateShaking = 1;
|
|
var stateFalling = 2;
|
|
var stateFallen = 3;
|
|
var state = stateSolid;
|
|
|
|
// Started the animation?
|
|
var startedAnimation = false;
|
|
|
|
Events.OnCollide(function(e) {
|
|
|
|
// If the floor is falling, the player passes right thru.
|
|
if (state === stateFalling || state === stateFallen) {
|
|
return;
|
|
}
|
|
|
|
// Floor is solid until it begins to fall.
|
|
if (e.InHitbox && (state === stateSolid || state === stateShaking)) {
|
|
// Only activate when touched from the top.
|
|
if (e.Overlap.Y > 0) {
|
|
return false;
|
|
}
|
|
|
|
// If movement is not settled, be solid.
|
|
if (!e.Settled) {
|
|
return false;
|
|
}
|
|
|
|
// Begin the animation sequence if we're in the solid state.
|
|
if (state === stateSolid) {
|
|
state = stateShaking;
|
|
Self.PlayAnimation("shake", function() {
|
|
state = stateFalling;
|
|
Self.PlayAnimation("fall", function() {
|
|
Sound.Play("crumbly-break.wav")
|
|
state = stateFallen;
|
|
Self.ShowLayerNamed("fallen");
|
|
|
|
// Recover after a while.
|
|
setTimeout(function() {
|
|
Self.ShowLayer(0);
|
|
state = stateSolid;
|
|
}, recover);
|
|
});
|
|
})
|
|
}
|
|
|
|
return false;
|
|
}
|
|
});
|
|
}
|