mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
remove some non-mbu features
This commit is contained in:
parent
b7f2a70f37
commit
a270c9e41d
15 changed files with 1 additions and 854 deletions
|
|
@ -62,9 +62,7 @@ class MarbleWorldMacros {
|
|||
shape = new EndPad();
|
||||
if (element is MissionElementStaticShape && cast(element, MissionElementStaticShape) == endPadElement)
|
||||
endPad = cast shape;
|
||||
} else if (dataBlockLowerCase == "signfinish")
|
||||
shape = new SignFinish();
|
||||
else if (StringTools.startsWith(dataBlockLowerCase, "signplain"))
|
||||
} else if (StringTools.startsWith(dataBlockLowerCase, "signplain"))
|
||||
shape = new SignPlain(cast element);
|
||||
else if (StringTools.startsWith(dataBlockLowerCase, "gemitem")) {
|
||||
shape = new Gem(cast element);
|
||||
|
|
@ -74,12 +72,8 @@ class MarbleWorldMacros {
|
|||
shape = new SuperJump(cast element);
|
||||
else if (StringTools.startsWith(dataBlockLowerCase, "signcaution"))
|
||||
shape = new SignCaution(cast element);
|
||||
else if (dataBlockLowerCase == "superbounceitem")
|
||||
shape = new SuperBounce(cast element);
|
||||
else if (dataBlockLowerCase == "roundbumper")
|
||||
shape = new RoundBumper();
|
||||
else if (dataBlockLowerCase == "trianglebumper")
|
||||
shape = new TriangleBumper();
|
||||
else if (dataBlockLowerCase == "helicopteritem")
|
||||
shape = new Helicopter(cast element);
|
||||
else if (dataBlockLowerCase == "easteregg")
|
||||
|
|
@ -90,36 +84,20 @@ class MarbleWorldMacros {
|
|||
shape = new DuctFan();
|
||||
else if (dataBlockLowerCase == "smallductfan")
|
||||
shape = new SmallDuctFan();
|
||||
else if (dataBlockLowerCase == "magnet")
|
||||
shape = new Magnet();
|
||||
else if (dataBlockLowerCase == "antigravityitem")
|
||||
shape = new AntiGravity(cast element);
|
||||
else if (dataBlockLowerCase == "norespawnantigravityitem")
|
||||
shape = new AntiGravity(cast element, true);
|
||||
else if (dataBlockLowerCase == "landmine")
|
||||
shape = new LandMine();
|
||||
else if (dataBlockLowerCase == "nuke")
|
||||
shape = new Nuke();
|
||||
else if (dataBlockLowerCase == "shockabsorberitem")
|
||||
shape = new ShockAbsorber(cast element);
|
||||
else if (dataBlockLowerCase == "superspeeditem")
|
||||
shape = new SuperSpeed(cast element);
|
||||
else if (dataBlockLowerCase == "timetravelitem" || dataBlockLowerCase == "timepenaltyitem")
|
||||
shape = new TimeTravel(cast element);
|
||||
else if (dataBlockLowerCase == "randompowerupitem")
|
||||
shape = new RandomPowerup(cast element);
|
||||
else if (dataBlockLowerCase == "blastitem")
|
||||
shape = new Blast(cast element);
|
||||
else if (dataBlockLowerCase == "megamarbleitem")
|
||||
shape = new MegaMarble(cast element);
|
||||
else if (dataBlockLowerCase == "tornado")
|
||||
shape = new Tornado();
|
||||
else if (dataBlockLowerCase == "trapdoor")
|
||||
shape = new Trapdoor();
|
||||
else if (dataBlockLowerCase == "pushbutton")
|
||||
shape = new PushButton();
|
||||
else if (dataBlockLowerCase == "oilslick")
|
||||
shape = new Oilslick();
|
||||
else if (dataBlockLowerCase == "arrow" || StringTools.startsWith(dataBlockLowerCase, "sign"))
|
||||
shape = new Sign(cast element);
|
||||
else if ([
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import collision.gjk.ConvexHull;
|
|||
import hxd.snd.effect.Pitch;
|
||||
import hxd.snd.effect.Spatialization;
|
||||
import hxd.snd.Channel;
|
||||
import shapes.TriangleBumper;
|
||||
import shapes.RoundBumper;
|
||||
import src.Util;
|
||||
import src.AudioManager;
|
||||
|
|
@ -519,12 +518,6 @@ class Marble extends GameObject {
|
|||
playedSounds.push("data/sound/bumperding1.wav");
|
||||
}
|
||||
}
|
||||
if (contact.otherObject is TriangleBumper) {
|
||||
if (!playedSounds.contains("data/sound/bumper1.wav")) {
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/bumper1.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
playedSounds.push("data/sound/bumper1.wav");
|
||||
}
|
||||
}
|
||||
forceObjectCount++;
|
||||
contactNormal = contactNormal.add(contact.normal);
|
||||
contactForce += contact.force;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package src;
|
|||
|
||||
import rewind.RewindManager;
|
||||
import Macros.MarbleWorldMacros;
|
||||
import shapes.PushButton;
|
||||
#if js
|
||||
import gui.MainMenuGui;
|
||||
#else
|
||||
|
|
@ -21,8 +20,6 @@ import shapes.EasterEgg;
|
|||
import shapes.Sign;
|
||||
import triggers.TeleportTrigger;
|
||||
import triggers.DestinationTrigger;
|
||||
import shapes.Nuke;
|
||||
import shapes.Magnet;
|
||||
import src.Replay;
|
||||
import gui.Canvas;
|
||||
import hxd.snd.Channel;
|
||||
|
|
@ -47,25 +44,17 @@ import triggers.HelpTrigger;
|
|||
import triggers.InBoundsTrigger;
|
||||
import triggers.OutOfBoundsTrigger;
|
||||
import shapes.Trapdoor;
|
||||
import shapes.Oilslick;
|
||||
import shapes.Tornado;
|
||||
import shapes.TimeTravel;
|
||||
import shapes.SuperSpeed;
|
||||
import shapes.ShockAbsorber;
|
||||
import shapes.LandMine;
|
||||
import shapes.AntiGravity;
|
||||
import shapes.SmallDuctFan;
|
||||
import shapes.DuctFan;
|
||||
import shapes.Helicopter;
|
||||
import shapes.TriangleBumper;
|
||||
import shapes.RoundBumper;
|
||||
import shapes.SuperBounce;
|
||||
import shapes.RandomPowerup;
|
||||
import shapes.SignCaution;
|
||||
import shapes.SuperJump;
|
||||
import shapes.Gem;
|
||||
import shapes.SignPlain;
|
||||
import shapes.SignFinish;
|
||||
import shapes.EndPad;
|
||||
import shapes.StartPad;
|
||||
import h3d.Matrix;
|
||||
|
|
@ -505,24 +494,6 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
tidx++;
|
||||
}
|
||||
if (dtss is LandMine) {
|
||||
var landmine:LandMine = cast dtss;
|
||||
if (!this.isWatching) {
|
||||
this.replay.recordLandMineState(landmine.disappearTime - this.timeState.timeSinceLoad);
|
||||
} else {
|
||||
landmine.disappearTime = this.replay.getLandMineState(lidx) + this.timeState.timeSinceLoad;
|
||||
}
|
||||
lidx++;
|
||||
}
|
||||
if (dtss is PushButton) {
|
||||
var pushbutton:PushButton = cast dtss;
|
||||
if (!this.isWatching) {
|
||||
this.replay.recordPushButtonState(pushbutton.lastContactTime - this.timeState.timeSinceLoad);
|
||||
} else {
|
||||
pushbutton.lastContactTime = this.replay.getPushButtonState(pidx) + this.timeState.timeSinceLoad;
|
||||
}
|
||||
pidx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@ package rewind;
|
|||
|
||||
import shapes.AbstractBumper;
|
||||
import shapes.PowerUp;
|
||||
import shapes.LandMine;
|
||||
import src.MarbleWorld;
|
||||
import shapes.Trapdoor;
|
||||
import shapes.PushButton;
|
||||
import src.Util;
|
||||
import shapes.Nuke;
|
||||
|
||||
class RewindManager {
|
||||
var frames:Array<RewindFrame> = [];
|
||||
|
|
@ -57,18 +54,6 @@ class RewindManager {
|
|||
var pow:PowerUp = cast dts;
|
||||
rf.powerupStates.push(pow.lastPickUpTime);
|
||||
}
|
||||
if (dts is PushButton) {
|
||||
var pow:PushButton = cast dts;
|
||||
rf.powerupStates.push(pow.lastContactTime);
|
||||
}
|
||||
if (dts is LandMine) {
|
||||
var lm:LandMine = cast dts;
|
||||
rf.landMineStates.push(lm.disappearTime);
|
||||
}
|
||||
if (dts is Nuke) {
|
||||
var lm:Nuke = cast dts;
|
||||
rf.landMineStates.push(lm.disappearTime);
|
||||
}
|
||||
if (dts is Trapdoor) {
|
||||
var td:Trapdoor = cast dts;
|
||||
rf.trapdoorStates.push({
|
||||
|
|
@ -161,18 +146,6 @@ class RewindManager {
|
|||
var pow:PowerUp = cast dts;
|
||||
pow.lastPickUpTime = pstates.shift();
|
||||
}
|
||||
if (dts is PushButton) {
|
||||
var pow:PushButton = cast dts;
|
||||
pow.lastContactTime = pstates.shift();
|
||||
}
|
||||
if (dts is LandMine) {
|
||||
var lm:LandMine = cast dts;
|
||||
lm.disappearTime = lmstates.shift();
|
||||
}
|
||||
if (dts is Nuke) {
|
||||
var lm:Nuke = cast dts;
|
||||
lm.disappearTime = lmstates.shift();
|
||||
}
|
||||
if (dts is Trapdoor) {
|
||||
var td:Trapdoor = cast dts;
|
||||
var tdState = tstates.shift();
|
||||
|
|
|
|||
|
|
@ -1,180 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.AudioManager;
|
||||
import src.TimeState;
|
||||
import collision.CollisionHull;
|
||||
import collision.CollisionInfo;
|
||||
import src.DtsObject;
|
||||
import src.Util;
|
||||
import src.ParticleSystem.ParticleEmitterOptions;
|
||||
import src.ParticleSystem.ParticleData;
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
import src.MarbleWorld;
|
||||
|
||||
final landMineParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 2,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 3,
|
||||
velocityVariance: 1,
|
||||
emitterLifetime: 50,
|
||||
inheritedVelFactor: 0.2,
|
||||
particleOptions: {
|
||||
texture: 'particles/smoke.png',
|
||||
blending: Add,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 1000,
|
||||
lifetimeVariance: 150,
|
||||
dragCoefficient: 2,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(0.56, 0.36, 0.26, 1), new Vector(0.56, 0.36, 0.26, 0)],
|
||||
sizes: [0.5, 1],
|
||||
times: [0, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final landMineSmokeParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 2,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 4,
|
||||
velocityVariance: 0.5,
|
||||
emitterLifetime: 250,
|
||||
inheritedVelFactor: 0.25,
|
||||
particleOptions: {
|
||||
texture: 'particles/smoke.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 1200,
|
||||
lifetimeVariance: 300,
|
||||
dragCoefficient: 10,
|
||||
acceleration: -8,
|
||||
colors: [
|
||||
new Vector(0.56, 0.36, 0.26, 1),
|
||||
new Vector(0.2, 0.2, 0.2, 1),
|
||||
new Vector(0, 0, 0, 0)
|
||||
],
|
||||
sizes: [1.5, 2, 3],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final landMineSparksParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 3,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 13,
|
||||
velocityVariance: 6.75,
|
||||
emitterLifetime: 100,
|
||||
inheritedVelFactor: 0.2,
|
||||
particleOptions: {
|
||||
texture: 'particles/spark.png',
|
||||
blending: Add,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 500,
|
||||
lifetimeVariance: 350,
|
||||
dragCoefficient: 1,
|
||||
acceleration: 0,
|
||||
colors: [
|
||||
new Vector(0.6, 0.4, 0.3, 1),
|
||||
new Vector(0.6, 0.4, 0.3, 1),
|
||||
new Vector(1, 0.4, 0.3, 0)
|
||||
],
|
||||
sizes: [0.5, 0.25, 0.25],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
class LandMine extends DtsObject {
|
||||
var disappearTime = -1e8;
|
||||
|
||||
var landMineParticleData:ParticleData;
|
||||
var landMineSmokeParticleData:ParticleData;
|
||||
var landMineSparkParticleData:ParticleData;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
dtsPath = "data/shapes/hazards/landmine.dts";
|
||||
this.identifier = "LandMine";
|
||||
this.isCollideable = true;
|
||||
|
||||
landMineParticleData = new ParticleData();
|
||||
landMineParticleData.identifier = "landMineParticle";
|
||||
landMineParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
landMineSmokeParticleData = new ParticleData();
|
||||
landMineSmokeParticleData.identifier = "landMineSmokeParticle";
|
||||
landMineSmokeParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
landMineSparkParticleData = new ParticleData();
|
||||
landMineSparkParticleData.identifier = "landMineSparkParticle";
|
||||
landMineSparkParticleData.texture = ResourceLoader.getResource("data/particles/spark.png", ResourceLoader.getTexture, this.textureResources);
|
||||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/explode1.wav").entry.load(onFinish);
|
||||
});
|
||||
}
|
||||
|
||||
override function onMarbleContact(timeState:TimeState, ?contact:CollisionInfo) {
|
||||
if (this.isCollideable && !this.level.rewinding) {
|
||||
// marble.velocity = marble.velocity.add(vec);
|
||||
this.disappearTime = timeState.timeSinceLoad;
|
||||
this.setCollisionEnabled(false);
|
||||
|
||||
if (!this.level.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/explode1.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.particleManager.createEmitter(landMineParticle, landMineParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSmokeParticle, landMineSmokeParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(landMineSparksParticle, landMineSparkParticleData, this.getAbsPos().getPosition());
|
||||
|
||||
var marble = this.level.marble;
|
||||
var minePos = this.getAbsPos().getPosition();
|
||||
var off = marble.getAbsPos().getPosition().sub(minePos);
|
||||
|
||||
var strength = computeExplosionStrength(off.length());
|
||||
|
||||
var impulse = off.normalized().multiply(strength);
|
||||
marble.applyImpulse(impulse);
|
||||
|
||||
// for (collider in this.colliders) {
|
||||
// var hull:CollisionHull = cast collider;
|
||||
// hull.force = strength;
|
||||
// }
|
||||
}
|
||||
// Normally, we would add a light here, but that's too expensive for THREE, apparently.
|
||||
|
||||
// this.level.replay.recordMarbleContact(this);
|
||||
}
|
||||
|
||||
function computeExplosionStrength(r:Float) {
|
||||
// Figured out through testing by RandomityGuy
|
||||
if (r >= 10.25)
|
||||
return 0.0;
|
||||
if (r >= 10)
|
||||
return Util.lerp(30.0087, 30.7555, r - 10);
|
||||
|
||||
// The explosion first becomes stronger the further you are away from it, then becomes weaker again (parabolic).
|
||||
var a = 0.071436222;
|
||||
var v = (Math.pow((r - 5), 2)) / (-4 * a) + 87.5;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
override function update(timeState:TimeState) {
|
||||
super.update(timeState);
|
||||
if (timeState.timeSinceLoad >= this.disappearTime + 5 || timeState.timeSinceLoad < this.disappearTime) {
|
||||
this.setHide(false);
|
||||
} else {
|
||||
this.setHide(true);
|
||||
}
|
||||
|
||||
var opacity = Util.clamp((timeState.timeSinceLoad - (this.disappearTime + 5)), 0, 1);
|
||||
this.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import hxd.snd.effect.Spatialization;
|
||||
import src.ResourceLoader;
|
||||
import src.AudioManager;
|
||||
import hxd.snd.Channel;
|
||||
import h3d.Vector;
|
||||
import src.ForceObject;
|
||||
|
||||
class Magnet extends ForceObject {
|
||||
var soundChannel:Channel;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/hazards/magnet/magnet.dts";
|
||||
this.isCollideable = true;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "Magnet";
|
||||
this.useInstancing = true;
|
||||
this.forceDatas = [
|
||||
{
|
||||
forceType: ForceCone,
|
||||
forceNode: 0,
|
||||
forceStrength: -90,
|
||||
forceRadius: 10,
|
||||
forceArc: 0.7,
|
||||
forceVector: new Vector()
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public override function init(level:src.MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/magnet.wav").entry.load(() -> {
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/magnet.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
new Vector(1e8, 1e8, 1e8), true);
|
||||
this.soundChannel.pause = true;
|
||||
onFinish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override function reset() {
|
||||
super.reset();
|
||||
|
||||
if (this.soundChannel != null) {
|
||||
var seffect = this.soundChannel.getEffect(Spatialization);
|
||||
seffect.position = this.getAbsPos().getPosition();
|
||||
seffect.fadeDistance = 15;
|
||||
// seffect.maxDistance = 5;
|
||||
|
||||
if (this.soundChannel.pause)
|
||||
this.soundChannel.pause = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.AudioManager;
|
||||
import src.TimeState;
|
||||
import collision.CollisionHull;
|
||||
import collision.CollisionInfo;
|
||||
import src.DtsObject;
|
||||
import src.Util;
|
||||
import src.ParticleSystem.ParticleEmitterOptions;
|
||||
import src.ParticleSystem.ParticleData;
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
import src.MarbleWorld;
|
||||
|
||||
final nukeParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 0.2,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 2,
|
||||
velocityVariance: 1,
|
||||
emitterLifetime: 50,
|
||||
inheritedVelFactor: 0.2,
|
||||
particleOptions: {
|
||||
texture: 'particles/smoke.png',
|
||||
blending: Add,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 1000,
|
||||
lifetimeVariance: 150,
|
||||
dragCoefficient: 0.8,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(0.56, 0.36, 0.26, 1), new Vector(0.56, 0.36, 0.26, 0)],
|
||||
sizes: [0.5, 1],
|
||||
times: [0, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final nukeSmokeParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 0.5,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 1.3,
|
||||
velocityVariance: 0.5,
|
||||
emitterLifetime: 50,
|
||||
inheritedVelFactor: 0.25,
|
||||
particleOptions: {
|
||||
texture: 'particles/smoke.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 2500,
|
||||
lifetimeVariance: 300,
|
||||
dragCoefficient: 0.7,
|
||||
acceleration: -8,
|
||||
colors: [
|
||||
new Vector(0.56, 0.36, 0.26, 1),
|
||||
new Vector(0.2, 0.2, 0.2, 1),
|
||||
new Vector(0, 0, 0, 0)
|
||||
],
|
||||
sizes: [1, 1.5, 2],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final nukeSparksParticle:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 1.7,
|
||||
ambientVelocity: new Vector(0, -0.5, 0),
|
||||
ejectionVelocity: 13 / 1.5,
|
||||
velocityVariance: 5,
|
||||
emitterLifetime: 5000,
|
||||
inheritedVelFactor: 0.2,
|
||||
particleOptions: {
|
||||
texture: 'particles/spark.png',
|
||||
blending: Add,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 4500,
|
||||
lifetimeVariance: 2500,
|
||||
dragCoefficient: 0.5,
|
||||
acceleration: 0,
|
||||
colors: [
|
||||
new Vector(0.6, 0.4, 0.3, 1),
|
||||
new Vector(0.6, 0.4, 0.3, 1),
|
||||
new Vector(1, 0.4, 0.3, 0)
|
||||
],
|
||||
sizes: [0.5, 0.4, 0.2],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
class Nuke extends DtsObject {
|
||||
var disappearTime = -1e8;
|
||||
|
||||
var nukeParticleData:ParticleData;
|
||||
var nukeSmokeParticleData:ParticleData;
|
||||
var nukeSparkParticleData:ParticleData;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
dtsPath = "data/shapes/hazards/nuke/nuke.dts";
|
||||
this.identifier = "Nuke";
|
||||
this.isCollideable = true;
|
||||
|
||||
nukeParticleData = new ParticleData();
|
||||
nukeParticleData.identifier = "nukeParticle";
|
||||
nukeParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
nukeSmokeParticleData = new ParticleData();
|
||||
nukeSmokeParticleData.identifier = "nukeSmokeParticle";
|
||||
nukeSmokeParticleData.texture = ResourceLoader.getResource("data/particles/smoke.png", ResourceLoader.getTexture, this.textureResources);
|
||||
|
||||
nukeSparkParticleData = new ParticleData();
|
||||
nukeSparkParticleData.identifier = "nukeSparkParticle";
|
||||
nukeSparkParticleData.texture = ResourceLoader.getResource("data/particles/spark.png", ResourceLoader.getTexture, this.textureResources);
|
||||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/nukeexplode.wav").entry.load(onFinish);
|
||||
});
|
||||
}
|
||||
|
||||
override function onMarbleContact(timeState:TimeState, ?contact:CollisionInfo) {
|
||||
if (this.isCollideable && !this.level.rewinding) {
|
||||
// marble.velocity = marble.velocity.add(vec);
|
||||
this.disappearTime = timeState.timeSinceLoad;
|
||||
this.setCollisionEnabled(false);
|
||||
|
||||
// if (!this.level.rewinding)
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/nukeexplode.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
this.level.particleManager.createEmitter(nukeParticle, nukeParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(nukeSmokeParticle, nukeSmokeParticleData, this.getAbsPos().getPosition());
|
||||
this.level.particleManager.createEmitter(nukeSparksParticle, nukeSparkParticleData, this.getAbsPos().getPosition());
|
||||
|
||||
var marble = this.level.marble;
|
||||
var minePos = this.getAbsPos().getPosition();
|
||||
var dtsCenter = this.dts.bounds.center();
|
||||
// dtsCenter.x = -dtsCenter.x;
|
||||
// minePos.x += dtsCenter.x;
|
||||
// minePos.y += dtsCenter.y;
|
||||
// minePos.z += dtsCenter.z;
|
||||
var off = marble.getAbsPos().getPosition().sub(minePos);
|
||||
|
||||
var force = computeExplosionForce(off);
|
||||
marble.applyImpulse(force, true);
|
||||
|
||||
// for (collider in this.colliders) {
|
||||
// var hull:CollisionHull = cast collider;
|
||||
// hull.force = strength;
|
||||
// }
|
||||
}
|
||||
// Normally, we would add a light here, but that's too expensive for THREE, apparently.
|
||||
|
||||
// this.level.replay.recordMarbleContact(this);
|
||||
}
|
||||
|
||||
function computeExplosionForce(distVec:Vector) {
|
||||
var range = 10;
|
||||
var power = 100;
|
||||
|
||||
var dist = distVec.length();
|
||||
if (dist < range) {
|
||||
var scalar = (1 - dist / range) * power;
|
||||
distVec = distVec.multiply(scalar);
|
||||
}
|
||||
|
||||
return distVec;
|
||||
}
|
||||
|
||||
override function update(timeState:TimeState) {
|
||||
super.update(timeState);
|
||||
if (timeState.timeSinceLoad >= this.disappearTime + 15 || timeState.timeSinceLoad < this.disappearTime) {
|
||||
this.setHide(false);
|
||||
} else {
|
||||
this.setHide(true);
|
||||
}
|
||||
|
||||
var opacity = Util.clamp((timeState.timeSinceLoad - (this.disappearTime + 15)), 0, 1);
|
||||
this.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.DtsObject;
|
||||
|
||||
class Oilslick extends DtsObject {
|
||||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/hazards/oilslick.dts";
|
||||
this.identifier = "Oilslick";
|
||||
this.useInstancing = true;
|
||||
this.isCollideable = true;
|
||||
this.isTSStatic = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import hxd.snd.effect.Spatialization;
|
||||
import src.TimeState;
|
||||
import collision.CollisionInfo;
|
||||
import src.Util;
|
||||
import src.DtsObject;
|
||||
import h3d.Vector;
|
||||
import src.ForceObject;
|
||||
import src.ResourceLoader;
|
||||
import src.AudioManager;
|
||||
import src.MarbleWorld;
|
||||
|
||||
class PushButton extends DtsObject {
|
||||
var lastContactTime = -1e8;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/buttons/pushbutton.dts";
|
||||
this.isCollideable = true;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "PushButton";
|
||||
this.hasNonVisualSequences = true;
|
||||
this.enableCollideCallbacks = true;
|
||||
}
|
||||
|
||||
public override function update(timeState:TimeState) {
|
||||
var currentCompletion = this.getCurrentCompletion(timeState);
|
||||
|
||||
// Override the keyframe
|
||||
this.sequenceKeyframeOverride.set(this.dts.sequences[0], currentCompletion * (this.dts.sequences[0].numKeyFrames - 1));
|
||||
super.update(timeState);
|
||||
}
|
||||
|
||||
function getCurrentCompletion(timeState:TimeState) {
|
||||
var elapsed = timeState.timeSinceLoad - this.lastContactTime;
|
||||
var completion = Util.clamp(elapsed / this.dts.sequences[0].duration, 0, 1);
|
||||
if (elapsed > 5)
|
||||
completion = Util.clamp(1 - (elapsed - 5) / this.dts.sequences[0].duration, 0, 1);
|
||||
return completion;
|
||||
}
|
||||
|
||||
override function onMarbleContact(time:TimeState, ?contact:CollisionInfo) {
|
||||
super.onMarbleContact(time, contact);
|
||||
if (time.timeSinceLoad - this.lastContactTime <= 0)
|
||||
return; // The trapdoor is queued to open, so don't do anything.
|
||||
var currentCompletion = this.getCurrentCompletion(time);
|
||||
|
||||
if (currentCompletion == 0)
|
||||
this.lastContactTime = time.timeSinceLoad;
|
||||
|
||||
// this.level.replay.recordMarbleContact(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.ResourceLoaderWorker;
|
||||
import src.ResourceLoader;
|
||||
import mis.MissionElement.MissionElementItem;
|
||||
import src.TimeState;
|
||||
import mis.MisParser;
|
||||
import src.MarbleWorld;
|
||||
|
||||
class RandomPowerup extends PowerUp {
|
||||
var wasTimeTravel:Bool;
|
||||
|
||||
public function new(element:MissionElementItem) {
|
||||
super(element);
|
||||
this.dtsPath = "data/shapes/items/random.dts";
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "RandomPowerup";
|
||||
this.useInstancing = true;
|
||||
this.autoUse = true;
|
||||
this.wasTimeTravel = false;
|
||||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
var sounds = [
|
||||
"sound/pugyrocoptervoice.wav",
|
||||
"sound/pushockabsorbervoice.wav",
|
||||
"sound/pusuperbouncevoice.wav",
|
||||
"sound/pusuperjumpvoice.wav",
|
||||
"sound/pusuperspeedvoice.wav",
|
||||
"sound/dosuperspeed.wav",
|
||||
"sound/dosuperjump.wav",
|
||||
"sound/putimetravelvoice.wav",
|
||||
"sound/timetravelactive.wav"
|
||||
];
|
||||
#if js
|
||||
// Load all the resources of the other powerups
|
||||
sounds = sounds.concat([
|
||||
"shapes/items/powerup-bounce.png",
|
||||
"shapes/items/rocket.jpg",
|
||||
"shapes/items/shockabsorber.dts",
|
||||
"shapes/items/shockabsorber.png",
|
||||
"shapes/items/sji_shinysteel.png",
|
||||
"shapes/items/superbounce.dts",
|
||||
"shapes/items/superjump.dts",
|
||||
"shapes/items/superspeed.dts",
|
||||
"shapes/items/itemarrow.jpg",
|
||||
"shapes/items/enviro1.jpg",
|
||||
"shapes/images/helicopter.dts",
|
||||
"shapes/images/helicopter.jpg"
|
||||
]);
|
||||
#end
|
||||
var rlw = new ResourceLoaderWorker(onFinish);
|
||||
for (sound in sounds) {
|
||||
rlw.loadFile(sound);
|
||||
}
|
||||
rlw.run();
|
||||
});
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
while (true) {
|
||||
var r = Std.random(6);
|
||||
if (this.level.isWatching)
|
||||
r = this.level.replay.getRandomGenState();
|
||||
var pow:PowerUp = null;
|
||||
switch (r) {
|
||||
case 0:
|
||||
pow = new TimeTravel(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/putimetravelvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
wasTimeTravel = true;
|
||||
case 1:
|
||||
pow = new SuperJump(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperjumpvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
case 2:
|
||||
pow = new SuperSpeed(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperspeedvoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
case 3:
|
||||
pow = new ShockAbsorber(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pushockabsorbervoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
case 4:
|
||||
pow = new SuperBounce(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperbouncevoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
case 5:
|
||||
pow = new Helicopter(this.element);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pugyrocoptervoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
}
|
||||
pow.level = this.level;
|
||||
|
||||
if (pow.pickUp()) {
|
||||
this.cooldownDuration = pow.cooldownDuration;
|
||||
this.pickUpName = pow.pickUpName;
|
||||
if (this.level.isRecording)
|
||||
this.level.replay.recordRandomGenState(r);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function use(time:TimeState) {
|
||||
if (this.wasTimeTravel)
|
||||
this.level.addBonusTime(5);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.ResourceLoader;
|
||||
import mis.MissionElement.MissionElementItem;
|
||||
import src.TimeState;
|
||||
import src.DtsObject;
|
||||
import src.MarbleWorld;
|
||||
|
||||
class ShockAbsorber extends PowerUp {
|
||||
public function new(element:MissionElementItem) {
|
||||
super(element);
|
||||
this.dtsPath = "data/shapes/items/shockabsorber.dts";
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "ShockAbsorber";
|
||||
this.pickUpName = "Anti-Recoil PowerUp";
|
||||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/pushockabsorbervoice.wav").entry.load(() -> {
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pushockabsorbervoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
onFinish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
return this.level.pickUpPowerUp(this);
|
||||
}
|
||||
|
||||
public function use(timeState:TimeState) {
|
||||
var marble = this.level.marble;
|
||||
marble.enableShockAbsorber(timeState.currentAttemptTime);
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.DtsObject;
|
||||
|
||||
class SignFinish extends DtsObject {
|
||||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/signs/finishlinesign.dts";
|
||||
this.isCollideable = true;
|
||||
this.identifier = "SignFinish";
|
||||
this.useInstancing = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.ResourceLoader;
|
||||
import mis.MissionElement.MissionElementItem;
|
||||
import src.TimeState;
|
||||
import src.DtsObject;
|
||||
import src.MarbleWorld;
|
||||
|
||||
class SuperBounce extends PowerUp {
|
||||
public function new(element:MissionElementItem) {
|
||||
super(element);
|
||||
this.dtsPath = "data/shapes/items/superbounce.dts";
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "SuperBounce";
|
||||
this.pickUpName = "Marble Recoil PowerUp";
|
||||
}
|
||||
|
||||
public function pickUp():Bool {
|
||||
return this.level.pickUpPowerUp(this);
|
||||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/pusuperbouncevoice.wav").entry.load(() -> {
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pusuperbouncevoice.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
onFinish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function use(timeState:TimeState) {
|
||||
var marble = this.level.marble;
|
||||
marble.enableSuperBounce(timeState.currentAttemptTime);
|
||||
// marble.body.addLinearVelocity(this.level.currentUp.scale(20)); // Simply add to vertical velocity
|
||||
// if (!this.level.rewinding)
|
||||
// AudioManager.play(this.sounds[1]);
|
||||
// this.level.particles.createEmitter(superJumpParticleOptions, null, () => Util.vecOimoToThree(marble.body.getPosition()));
|
||||
this.level.deselectPowerUp();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import hxd.snd.effect.Spatialization;
|
||||
import hxd.snd.Channel;
|
||||
import h3d.Vector;
|
||||
import src.ForceObject;
|
||||
import src.ResourceLoader;
|
||||
import src.AudioManager;
|
||||
import src.MarbleWorld;
|
||||
|
||||
class Tornado extends ForceObject {
|
||||
var soundChannel:Channel;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
this.dtsPath = "data/shapes/hazards/tornado.dts";
|
||||
this.isCollideable = false;
|
||||
this.isTSStatic = false;
|
||||
this.identifier = "Tornado";
|
||||
this.forceDatas = [
|
||||
{
|
||||
forceType: ForceSpherical,
|
||||
forceNode: 0,
|
||||
forceStrength: -60,
|
||||
forceRadius: 8,
|
||||
forceArc: 0,
|
||||
forceVector: new Vector()
|
||||
},
|
||||
{
|
||||
forceType: ForceSpherical,
|
||||
forceNode: 0,
|
||||
forceStrength: 60,
|
||||
forceRadius: 3,
|
||||
forceArc: 0,
|
||||
forceVector: new Vector()
|
||||
},
|
||||
{
|
||||
forceType: ForceField,
|
||||
forceNode: 0,
|
||||
forceStrength: 250,
|
||||
forceRadius: 3,
|
||||
forceArc: 0,
|
||||
forceVector: new Vector(0, 0, 1)
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public override function init(level:src.MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/tornado.wav").entry.load(() -> {
|
||||
this.soundChannel = AudioManager.playSound(ResourceLoader.getResource("data/sound/tornado.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
new Vector(1e8, 1e8, 1e8), true);
|
||||
this.soundChannel.pause = true;
|
||||
for (material in this.materials) {
|
||||
material.blendMode = Alpha;
|
||||
material.mainPass.culling = h3d.mat.Data.Face.None;
|
||||
material.mainPass.depthWrite = false;
|
||||
}
|
||||
onFinish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override function reset() {
|
||||
super.reset();
|
||||
|
||||
var seffect = this.soundChannel.getEffect(Spatialization);
|
||||
seffect.position = this.getAbsPos().getPosition();
|
||||
|
||||
if (this.soundChannel.pause)
|
||||
this.soundChannel.pause = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
package shapes;
|
||||
|
||||
import src.DtsObject;
|
||||
|
||||
class TriangleBumper extends AbstractBumper {
|
||||
public function new() {
|
||||
super();
|
||||
dtsPath = "data/shapes/bumpers/pball_tri.dts";
|
||||
identifier = "TriangleBumper";
|
||||
isCollideable = true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue