mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
tweaks
This commit is contained in:
parent
d79c7a90e9
commit
2b33aa3284
53 changed files with 13 additions and 565 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -60,7 +60,7 @@ class AudioManager {
|
|||
|
||||
public static function playShell() {
|
||||
AudioManager.manager.stopByName("music");
|
||||
var sndres = ResourceLoader.getAudio("data/sound/music/Pianoforte.ogg");
|
||||
var sndres = ResourceLoader.getAudio("data/sound/music/Tim Trance.ogg");
|
||||
if (sndres == null)
|
||||
return;
|
||||
sndres.acquire();
|
||||
|
|
|
|||
|
|
@ -237,11 +237,8 @@ class Marble extends GameObject {
|
|||
public var heldPowerup:PowerUp;
|
||||
public var lastContactNormal:Vector;
|
||||
|
||||
var forcefield:DtsObject;
|
||||
var helicopter:HelicopterImage;
|
||||
var blastWave:BlastWave;
|
||||
var superBounceEnableTime:Float = -1e8;
|
||||
var shockAbsorberEnableTime:Float = -1e8;
|
||||
var helicopterEnableTime:Float = -1e8;
|
||||
var megaMarbleEnableTime:Float = -1e8;
|
||||
var blastUseTime:Float = -1e8;
|
||||
|
|
@ -260,8 +257,6 @@ class Marble extends GameObject {
|
|||
var rollMegaSound:Channel;
|
||||
var slipSound:Channel;
|
||||
|
||||
var superbounceSound:Channel;
|
||||
var shockabsorberSound:Channel;
|
||||
var helicopterSound:Channel;
|
||||
var playedSounds = [];
|
||||
|
||||
|
|
@ -311,12 +306,6 @@ class Marble extends GameObject {
|
|||
this.getAbsPos().getPosition(), true);
|
||||
this.rollSound.volume = 0;
|
||||
this.slipSound.volume = 0;
|
||||
this.shockabsorberSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/superbounceactive.wav", ResourceLoader.getAudio,
|
||||
this.soundResources), null, true);
|
||||
this.shockabsorberSound.pause = true;
|
||||
this.superbounceSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/forcefield.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
null, true);
|
||||
this.superbounceSound.pause = true;
|
||||
this.helicopterSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/use_gyrocopter.wav", ResourceLoader.getAudio,
|
||||
this.soundResources), null, true);
|
||||
this.helicopterSound.pause = true;
|
||||
|
|
@ -458,17 +447,6 @@ class Marble extends GameObject {
|
|||
this.blastWave.z = 1e8;
|
||||
this.blastWave.isBoundingBoxCollideable = false;
|
||||
|
||||
this.forcefield = new DtsObject();
|
||||
this.forcefield.dtsPath = "data/shapes/images/glow_bounce.dts";
|
||||
this.forcefield.useInstancing = true;
|
||||
this.forcefield.identifier = "GlowBounce";
|
||||
this.forcefield.showSequences = false;
|
||||
this.addChild(this.forcefield);
|
||||
this.forcefield.x = 1e8;
|
||||
this.forcefield.y = 1e8;
|
||||
this.forcefield.z = 1e8;
|
||||
this.forcefield.isBoundingBoxCollideable = false;
|
||||
|
||||
this.helicopter = new HelicopterImage();
|
||||
this.helicopter.isBoundingBoxCollideable = false;
|
||||
// this.addChild(this.helicopter);
|
||||
|
|
@ -478,7 +456,6 @@ class Marble extends GameObject {
|
|||
this.helicopter.scale(0.3 / 0.2);
|
||||
|
||||
var worker = new ResourceLoaderWorker(onFinish);
|
||||
worker.addTask(fwd -> level.addDtsObject(this.forcefield, fwd));
|
||||
worker.addTask(fwd -> level.addDtsObject(this.helicopter, fwd));
|
||||
worker.addTask(fwd -> level.addDtsObject(this.blastWave, fwd));
|
||||
worker.run();
|
||||
|
|
@ -661,12 +638,6 @@ class Marble extends GameObject {
|
|||
this.velocity = this.velocity.sub(surfaceVel);
|
||||
} else {
|
||||
var restitution = this._bounceRestitution;
|
||||
if (currentTime - this.superBounceEnableTime < 5) {
|
||||
restitution = 0.9;
|
||||
}
|
||||
if (currentTime - this.shockAbsorberEnableTime < 5) {
|
||||
restitution = 0.01;
|
||||
}
|
||||
restitution *= contacts[i].restitution;
|
||||
|
||||
var velocityAdd = surfaceVel.multiply(-(1 + restitution));
|
||||
|
|
@ -1826,6 +1797,7 @@ class Marble extends GameObject {
|
|||
this._radius = this._prevRadius;
|
||||
this.collider.radius = this._radius;
|
||||
this._marbleScale = this._defaultScale;
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/MegaShrink.wav", ResourceLoader.getAudio, this.soundResources), null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1921,26 +1893,6 @@ class Marble extends GameObject {
|
|||
}
|
||||
|
||||
public function updatePowerupStates(currentTime:Float, dt:Float) {
|
||||
if (currentTime - this.shockAbsorberEnableTime < 5) {
|
||||
this.shockabsorberSound.pause = false;
|
||||
} else {
|
||||
this.shockabsorberSound.pause = true;
|
||||
}
|
||||
if (currentTime - this.superBounceEnableTime < 5) {
|
||||
this.superbounceSound.pause = false;
|
||||
} else {
|
||||
this.superbounceSound.pause = true;
|
||||
}
|
||||
|
||||
if (currentTime - this.shockAbsorberEnableTime < 5) {
|
||||
this.forcefield.setPosition(0, 0, 0);
|
||||
} else if (currentTime - this.superBounceEnableTime < 5) {
|
||||
this.forcefield.setPosition(0, 0, 0);
|
||||
} else {
|
||||
this.forcefield.x = 1e8;
|
||||
this.forcefield.y = 1e8;
|
||||
this.forcefield.z = 1e8;
|
||||
}
|
||||
if (currentTime - this.helicopterEnableTime < 5) {
|
||||
this.helicopter.setPosition(x, y, z);
|
||||
this.helicopter.setRotationQuat(this.level.getOrientationQuat(currentTime));
|
||||
|
|
@ -1980,14 +1932,6 @@ class Marble extends GameObject {
|
|||
this.appliedImpulses.push({impulse: impulse, contactImpulse: contactImpulse});
|
||||
}
|
||||
|
||||
public function enableSuperBounce(time:Float) {
|
||||
this.superBounceEnableTime = time;
|
||||
}
|
||||
|
||||
public function enableShockAbsorber(time:Float) {
|
||||
this.shockAbsorberEnableTime = time;
|
||||
}
|
||||
|
||||
public function enableHelicopter(time:Float) {
|
||||
this.helicopterEnableTime = time;
|
||||
}
|
||||
|
|
@ -2048,8 +1992,6 @@ class Marble extends GameObject {
|
|||
this.velocity = new Vector();
|
||||
this.collider.velocity = new Vector();
|
||||
this.omega = new Vector();
|
||||
this.superBounceEnableTime = Math.NEGATIVE_INFINITY;
|
||||
this.shockAbsorberEnableTime = Math.NEGATIVE_INFINITY;
|
||||
this.helicopterEnableTime = Math.NEGATIVE_INFINITY;
|
||||
this.megaMarbleEnableTime = Math.NEGATIVE_INFINITY;
|
||||
this.blastUseTime = Math.NEGATIVE_INFINITY;
|
||||
|
|
|
|||
|
|
@ -260,28 +260,16 @@ class MarbleWorld extends Scheduler {
|
|||
this._loadingLength = resourceLoadFuncs.length;
|
||||
fwd();
|
||||
});
|
||||
this.resourceLoadFuncs.push(fwd -> this.loadMusic(fwd));
|
||||
this._loadingLength = resourceLoadFuncs.length;
|
||||
}
|
||||
|
||||
public function loadMusic(onFinish:Void->Void) {
|
||||
if (this.mission.missionInfo.music != null) {
|
||||
var musicFileName = 'sound/music/' + this.mission.missionInfo.music;
|
||||
ResourceLoader.load(musicFileName).entry.load(onFinish);
|
||||
} else {
|
||||
onFinish();
|
||||
}
|
||||
}
|
||||
|
||||
public function postInit() {
|
||||
// Add the sky at the last so that cubemap reflections work
|
||||
this.playGui.init(this.scene2d, this.mission.game.toLowerCase());
|
||||
this.scene.addChild(this.sky); // TODO FIX ANDROID
|
||||
this.scene.addChild(this.sky);
|
||||
this._ready = true;
|
||||
var musicFileName = 'data/sound/music/' + this.mission.missionInfo.music;
|
||||
AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources), this.mission.missionInfo.music);
|
||||
AudioManager.playShell();
|
||||
MarbleGame.canvas.clearContent();
|
||||
if (this.endPad != null)
|
||||
this.endPad.generateCollider();
|
||||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||
Console.log("MISSION LOADED");
|
||||
|
|
@ -375,11 +363,8 @@ class MarbleWorld extends Scheduler {
|
|||
"particles/smoke.png",
|
||||
"sound/rolling_hard.wav",
|
||||
"sound/sliding.wav",
|
||||
"sound/superbounceactive.wav",
|
||||
"sound/forcefield.wav",
|
||||
"sound/use_gyrocopter.wav",
|
||||
"sound/bumperding1.wav",
|
||||
"sound/bumper1.wav",
|
||||
"sound/jump.wav",
|
||||
"sound/mega_roll.wav",
|
||||
"sound/bouncehard1.wav",
|
||||
|
|
@ -388,8 +373,6 @@ class MarbleWorld extends Scheduler {
|
|||
"sound/bouncehard4.wav",
|
||||
"sound/spawn_alternate.wav",
|
||||
"sound/missinggems.wav",
|
||||
"shapes/images/glow_bounce.dts",
|
||||
"shapes/images/glow_bounce.png",
|
||||
"shapes/images/helicopter.dts",
|
||||
"shapes/images/helicopter.jpg", // These irk us a lot because ifl shit
|
||||
"shapes/items/gem.dts", // Ew ew
|
||||
|
|
@ -400,7 +383,7 @@ class MarbleWorld extends Scheduler {
|
|||
marblefiles.push("shapes/balls/pack1/marble20.normal.png");
|
||||
marblefiles.push("shapes/balls/pack1/marble18.normal.png");
|
||||
marblefiles.push("shapes/balls/pack1/marble01.normal.png");
|
||||
marblefiles.push("sound/blast.wav");
|
||||
marblefiles.push("sound/use_blast.wav");
|
||||
}
|
||||
// Hacky
|
||||
marblefiles.push(StringTools.replace(Settings.optionsSettings.marbleModel, "data/", ""));
|
||||
|
|
@ -1407,7 +1390,7 @@ class MarbleWorld extends Scheduler {
|
|||
AudioManager.playSound(ResourceLoader.getResource('data/sound/missinggems.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
displayAlert("You can't finish without all the gems!");
|
||||
} else {
|
||||
this.endPad.spawnFirework(this.timeState);
|
||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/finish.wav', ResourceLoader.getAudio, this.soundResources));
|
||||
this.finishTime = this.timeState.clone();
|
||||
this.marble.setMode(Finish);
|
||||
this.marble.camera.finish = true;
|
||||
|
|
@ -1684,8 +1667,6 @@ class MarbleWorld extends Scheduler {
|
|||
this.marble.camera.nextCameraYaw = this.marble.camera.CameraYaw;
|
||||
this.marble.camera.nextCameraPitch = this.marble.camera.CameraPitch;
|
||||
this.marble.camera.oob = false;
|
||||
@:privateAccess this.marble.superBounceEnableTime = -1e8;
|
||||
@:privateAccess this.marble.shockAbsorberEnableTime = -1e8;
|
||||
@:privateAccess this.marble.helicopterEnableTime = -1e8;
|
||||
@:privateAccess this.marble.megaMarbleEnableTime = -1e8;
|
||||
this.blastAmount = this.cheeckpointBlast;
|
||||
|
|
|
|||
|
|
@ -66,16 +66,5 @@ class ExitGameDlg extends GuiControl {
|
|||
dialogImg.addChild(restartButton);
|
||||
|
||||
this.addChild(dialogImg);
|
||||
|
||||
var jukeboxButton = new GuiButton(loadButtonImages("data/ui/jukebox/jb_pausemenu"));
|
||||
jukeboxButton.vertSizing = Top;
|
||||
jukeboxButton.horizSizing = Left;
|
||||
jukeboxButton.position = new Vector(439, 403);
|
||||
jukeboxButton.extent = new Vector(187, 65);
|
||||
jukeboxButton.pressedAction = (e) -> {
|
||||
MarbleGame.canvas.pushDialog(new JukeboxDlg());
|
||||
}
|
||||
|
||||
this.addChild(jukeboxButton);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,165 +0,0 @@
|
|||
package gui;
|
||||
|
||||
import h2d.filter.DropShadow;
|
||||
import hxd.res.BitmapFont;
|
||||
import h3d.Vector;
|
||||
import src.ResourceLoader;
|
||||
import src.MarbleGame;
|
||||
import src.Settings;
|
||||
import src.AudioManager;
|
||||
|
||||
class JukeboxDlg extends GuiImage {
|
||||
public function new() {
|
||||
var img = ResourceLoader.getImage("data/ui/jukebox/window.png");
|
||||
super(img.resource.toTile());
|
||||
|
||||
this.horizSizing = Center;
|
||||
this.vertSizing = Center;
|
||||
this.position = new Vector(39, 35);
|
||||
this.extent = new Vector(541, 409);
|
||||
|
||||
function loadButtonImages(path:String) {
|
||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
||||
return [normal, hover, pressed];
|
||||
}
|
||||
|
||||
var markerFelt32fontdata = ResourceLoader.getFileEntry("data/font/MarkerFelt.fnt");
|
||||
var markerFelt32b = new BitmapFont(markerFelt32fontdata.entry);
|
||||
@:privateAccess markerFelt32b.loader = ResourceLoader.loader;
|
||||
var markerFelt32 = markerFelt32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
||||
var markerFelt24 = markerFelt32b.toSdfFont(cast 18 * Settings.uiScale, MultiChannel);
|
||||
var markerFelt18 = markerFelt32b.toSdfFont(cast 14 * Settings.uiScale, MultiChannel);
|
||||
|
||||
#if hl
|
||||
var songPath = "data/sound/music";
|
||||
#end
|
||||
#if js
|
||||
var songPath = "sound/music";
|
||||
#end
|
||||
var songFiles = ResourceLoader.fileSystem.dir(songPath);
|
||||
var songList = songFiles.map(x -> StringTools.replace(x.name, ".ogg", ""));
|
||||
|
||||
var playing:Bool = !AudioManager.currentMusicPaused;
|
||||
var selectedIdx:Int = 0;
|
||||
|
||||
var currentPlayingSong = StringTools.replace(AudioManager.currentMusicName, ".ogg", "");
|
||||
selectedIdx = songList.indexOf(currentPlayingSong);
|
||||
|
||||
var songTitle = new GuiMLText(markerFelt24, null);
|
||||
songTitle.position = new Vector(61, 262);
|
||||
songTitle.extent = new Vector(416, 22);
|
||||
songTitle.text.filter = new DropShadow(1.414, 0.785, 0x0000007F, 1, 0, 0.4, 1, true);
|
||||
songTitle.text.textColor = 0xFFFFFF;
|
||||
songTitle.text.text = '<p align="center">Title: ${songList[selectedIdx]}</p>';
|
||||
this.addChild(songTitle);
|
||||
|
||||
var songStatus = new GuiMLText(markerFelt24, null);
|
||||
songStatus.position = new Vector(56, 283);
|
||||
songStatus.extent = new Vector(421, 22);
|
||||
songStatus.text.filter = new DropShadow(1.414, 0.785, 0x0000007F, 1, 0, 0.4, 1, true);
|
||||
songStatus.text.textColor = 0xFFFFFF;
|
||||
songStatus.text.text = '<p align="center">${playing ? "Playing" : "Stopped"}</p>';
|
||||
this.addChild(songStatus);
|
||||
|
||||
var scroll = new GuiScrollCtrl(ResourceLoader.getResource("data/ui/common/philscroll.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||
scroll.position = new Vector(51, 39);
|
||||
scroll.extent = new Vector(439, 216);
|
||||
this.addChild(scroll);
|
||||
|
||||
var songCtrl = new GuiTextListCtrl(markerFelt24, songList);
|
||||
songCtrl.position = new Vector(0, 0);
|
||||
songCtrl.extent = new Vector(423, 456);
|
||||
songCtrl.scrollable = true;
|
||||
songCtrl.textYOffset = -6;
|
||||
songCtrl.selectedColor = 0;
|
||||
songCtrl._prevSelected = selectedIdx;
|
||||
scroll.addChild(songCtrl);
|
||||
scroll.setScrollMax(songCtrl.calculateFullHeight());
|
||||
|
||||
function setCurrentSong(idx:Int) {
|
||||
selectedIdx = idx;
|
||||
songCtrl._prevSelected = idx;
|
||||
songTitle.text.text = '<p align="center">Title: ${songList[idx]}</p>';
|
||||
songCtrl.redrawSelectionRect(songCtrl.getHitTestRect());
|
||||
|
||||
if (playing) {
|
||||
songFiles[idx].load(() -> {
|
||||
var audiores = ResourceLoader.getAudio(songFiles[idx].path).resource;
|
||||
AudioManager.playMusic(audiores, songList[idx]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
songCtrl.onSelectedFunc = (idx) -> {
|
||||
setCurrentSong(idx);
|
||||
};
|
||||
|
||||
var stopBtn = new GuiButton(loadButtonImages("data/ui/jukebox/stop"));
|
||||
stopBtn.position = new Vector(219, 306);
|
||||
stopBtn.extent = new Vector(96, 45);
|
||||
this.addChild(stopBtn);
|
||||
|
||||
var playBtn = new GuiButton(loadButtonImages("data/ui/jukebox/play"));
|
||||
playBtn.position = new Vector(219, 306);
|
||||
playBtn.extent = new Vector(96, 45);
|
||||
|
||||
stopBtn.pressedAction = (e) -> {
|
||||
this.removeChild(stopBtn);
|
||||
this.addChild(playBtn);
|
||||
playBtn.render(MarbleGame.canvas.scene2d);
|
||||
playing = false;
|
||||
songStatus.text.text = '<p align="center">${playing ? "Playing" : "Stopped"}</p>';
|
||||
AudioManager.pauseMusic(true);
|
||||
};
|
||||
|
||||
playBtn.pressedAction = (e) -> {
|
||||
this.removeChild(playBtn);
|
||||
this.addChild(stopBtn);
|
||||
stopBtn.render(MarbleGame.canvas.scene2d);
|
||||
playing = true;
|
||||
songStatus.text.text = '<p align="center">${playing ? "Playing" : "Stopped"}</p>';
|
||||
if (AudioManager.currentMusicName != songList[selectedIdx]) {
|
||||
songFiles[selectedIdx].load(() -> {
|
||||
var audiores = ResourceLoader.getAudio(songFiles[selectedIdx].path).resource;
|
||||
AudioManager.playMusic(audiores, songList[selectedIdx]);
|
||||
});
|
||||
} else {
|
||||
AudioManager.pauseMusic(false);
|
||||
}
|
||||
};
|
||||
|
||||
var prevBtn = new GuiButton(loadButtonImages("data/ui/play/prev"));
|
||||
prevBtn.position = new Vector(145, 307);
|
||||
prevBtn.extent = new Vector(72, 43);
|
||||
prevBtn.pressedAction = (e) -> {
|
||||
if (selectedIdx >= 1) {
|
||||
setCurrentSong(selectedIdx - 1);
|
||||
} else {
|
||||
setCurrentSong(songList.length - 1);
|
||||
}
|
||||
}
|
||||
this.addChild(prevBtn);
|
||||
|
||||
var nextBtn = new GuiButton(loadButtonImages("data/ui/play/next"));
|
||||
nextBtn.position = new Vector(317, 307);
|
||||
nextBtn.extent = new Vector(72, 43);
|
||||
nextBtn.pressedAction = (e) -> {
|
||||
if (selectedIdx < songList.length - 1) {
|
||||
setCurrentSong(selectedIdx + 1);
|
||||
} else {
|
||||
setCurrentSong(0);
|
||||
}
|
||||
}
|
||||
this.addChild(nextBtn);
|
||||
|
||||
var closeBtn = new GuiButton(loadButtonImages("data/ui/jukebox/close"));
|
||||
closeBtn.position = new Vector(47, 307);
|
||||
closeBtn.extent = new Vector(94, 45);
|
||||
closeBtn.pressedAction = (e) -> {
|
||||
MarbleGame.canvas.popDialog(this);
|
||||
}
|
||||
this.addChild(closeBtn);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,12 +27,7 @@ class RewindManager {
|
|||
rf.bonusTime = level.bonusTime;
|
||||
rf.gemCount = level.gemCount;
|
||||
rf.gemStates = level.gems.map(x -> x.pickedUp);
|
||||
rf.activePowerupStates = [@:privateAccess
|
||||
level.marble.superBounceEnableTime, @:privateAccess
|
||||
level.marble.shockAbsorberEnableTime, @:privateAccess
|
||||
level.marble.helicopterEnableTime, @:privateAccess
|
||||
level.marble.megaMarbleEnableTime
|
||||
];
|
||||
rf.activePowerupStates = [@:privateAccess level.marble.helicopterEnableTime, @:privateAccess level.marble.megaMarbleEnableTime];
|
||||
rf.currentUp = level.currentUp.clone();
|
||||
rf.lastContactNormal = level.marble.lastContactNormal.clone();
|
||||
rf.mpStates = level.pathedInteriors.map(x -> {
|
||||
|
|
@ -108,10 +103,8 @@ class RewindManager {
|
|||
for (i in 0...rf.gemStates.length) {
|
||||
level.gems[i].setHide(rf.gemStates[i]);
|
||||
}
|
||||
@:privateAccess level.marble.superBounceEnableTime = rf.activePowerupStates[0];
|
||||
@:privateAccess level.marble.shockAbsorberEnableTime = rf.activePowerupStates[1];
|
||||
@:privateAccess level.marble.helicopterEnableTime = rf.activePowerupStates[2];
|
||||
@:privateAccess level.marble.megaMarbleEnableTime = rf.activePowerupStates[3];
|
||||
@:privateAccess level.marble.helicopterEnableTime = rf.activePowerupStates[0];
|
||||
@:privateAccess level.marble.megaMarbleEnableTime = rf.activePowerupStates[1];
|
||||
|
||||
if (level.currentUp.x != rf.currentUp.x || level.currentUp.y != rf.currentUp.y || level.currentUp.z != rf.currentUp.z) {
|
||||
level.setUp(rf.currentUp, level.timeState);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class EasterEgg extends PowerUp {
|
|||
this.pickupSound = ResourceLoader.getResource("data/sound/easter_egg.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
this.customPickupMessage = "You picked up an Easter Egg!";
|
||||
} else {
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/easterfound.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
this.pickupSound = ResourceLoader.getResource("data/sound/pu_easter.wav", ResourceLoader.getAudio, this.soundResources);
|
||||
this.customPickupMessage = "You picked up an Easter Egg!.";
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class EasterEgg extends PowerUp {
|
|||
public override function init(level:src.MarbleWorld, onFinish:() -> Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/easter_egg.wav").entry.load(() -> {
|
||||
ResourceLoader.load("sound/easterfound.wav").entry.load(onFinish);
|
||||
ResourceLoader.load("sound/pu_easter.wav").entry.load(onFinish);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import src.Resource;
|
|||
import h3d.mat.Texture;
|
||||
|
||||
class EndPad extends DtsObject {
|
||||
var fireworks:Array<Firework> = [];
|
||||
|
||||
var finishCollider:ConvexHull;
|
||||
var finishBounds:Bounds;
|
||||
var inFinish:Bool = false;
|
||||
|
|
@ -40,24 +38,7 @@ class EndPad extends DtsObject {
|
|||
}
|
||||
|
||||
public override function init(level:MarbleWorld, onFinish:Void->Void) {
|
||||
super.init(level, () -> {
|
||||
ResourceLoader.load("sound/firewrks.wav").entry.load(onFinish);
|
||||
});
|
||||
}
|
||||
|
||||
// override function onMarbleContact(timeState:TimeState, ?contact:CollisionInfo) {
|
||||
// if (!isEntered) {
|
||||
// isEntered = true;
|
||||
// spawnFirework(timeState);
|
||||
// }
|
||||
// }
|
||||
|
||||
function spawnFirework(time:TimeState) {
|
||||
var firework = new Firework(this.getAbsPos().getPosition(), time.timeSinceLoad, this.level);
|
||||
this.fireworks.push(firework);
|
||||
AudioManager.playSound(ResourceLoader.getResource("data/sound/firewrks.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
this.getAbsPos().getPosition());
|
||||
// AudioManager.play(this.sounds[0], 1, AudioManager.soundGain, this.worldPosition);
|
||||
super.init(level, onFinish);
|
||||
}
|
||||
|
||||
function generateCollider() {
|
||||
|
|
@ -112,13 +93,6 @@ class EndPad extends DtsObject {
|
|||
|
||||
override function update(timeState:TimeState) {
|
||||
super.update(timeState);
|
||||
|
||||
for (firework in this.fireworks) {
|
||||
firework.tick(timeState.timeSinceLoad);
|
||||
if (timeState.timeSinceLoad - firework.spawnTime >= 10)
|
||||
this.fireworks.remove(firework);
|
||||
// We can safely remove the firework
|
||||
}
|
||||
}
|
||||
|
||||
override function postProcessMaterial(matName:String, material:h3d.mat.Material) {
|
||||
|
|
@ -201,269 +175,3 @@ class EndPad extends DtsObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
final fireworkSmoke:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 100,
|
||||
ambientVelocity: new Vector(0, 0, 1),
|
||||
ejectionVelocity: 0,
|
||||
velocityVariance: 0,
|
||||
emitterLifetime: 4000,
|
||||
spawnOffset: () -> {
|
||||
var r = Math.sqrt(Math.random());
|
||||
var theta = Math.random() * Math.PI * 2;
|
||||
var randomPointInCircle = new Vector(r * Math.cos(theta), r * Math.sin(theta));
|
||||
return new Vector(randomPointInCircle.x * 1.6, randomPointInCircle.y * 1.6, Math.random() * 0.4 - 0.5);
|
||||
},
|
||||
inheritedVelFactor: 0,
|
||||
particleOptions: {
|
||||
texture: 'particles/saturn.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 0,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 2000,
|
||||
lifetimeVariance: 200,
|
||||
dragCoefficient: 0.5,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(1, 1, 0, 0), new Vector(1, 0, 0, 1), new Vector(1, 0, 0, 0)],
|
||||
sizes: [0.1, 0.2, 0.3],
|
||||
times: [0, 0.2, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final redTrail:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 30,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 0,
|
||||
velocityVariance: 0,
|
||||
emitterLifetime: 10000,
|
||||
inheritedVelFactor: 0,
|
||||
particleOptions: {
|
||||
texture: 'particles/spark.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 0,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 600,
|
||||
lifetimeVariance: 100,
|
||||
dragCoefficient: 0,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(1, 1, 0, 1), new Vector(1, 0, 0, 1), new Vector(1, 0, 0, 0)],
|
||||
sizes: [0.1, 0.05, 0.01],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final blueTrail:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 30,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 0,
|
||||
velocityVariance: 0,
|
||||
emitterLifetime: 10000,
|
||||
inheritedVelFactor: 0,
|
||||
particleOptions: {
|
||||
texture: 'particles/spark.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 0,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 600,
|
||||
lifetimeVariance: 100,
|
||||
dragCoefficient: 0,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(0, 0, 1, 1), new Vector(0.5, 0.5, 1, 1), new Vector(1, 1, 1, 0)],
|
||||
sizes: [0.1, 0.05, 0.01],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final redSpark:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 1,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 0.8,
|
||||
velocityVariance: 0.25,
|
||||
emitterLifetime: 10,
|
||||
inheritedVelFactor: 0,
|
||||
particleOptions: {
|
||||
texture: 'particles/star.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 500,
|
||||
lifetimeVariance: 50,
|
||||
dragCoefficient: 0.5,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(1, 1, 0, 1), new Vector(1, 1, 0, 1), new Vector(1, 0, 0, 0)],
|
||||
sizes: [0.2, 0.2, 0.2],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
final blueSpark:ParticleEmitterOptions = {
|
||||
ejectionPeriod: 1,
|
||||
ambientVelocity: new Vector(0, 0, 0),
|
||||
ejectionVelocity: 0.5,
|
||||
velocityVariance: 0.25,
|
||||
emitterLifetime: 10,
|
||||
inheritedVelFactor: 0,
|
||||
particleOptions: {
|
||||
texture: 'particles/bubble.png',
|
||||
blending: Alpha,
|
||||
spinSpeed: 40,
|
||||
spinRandomMin: -90,
|
||||
spinRandomMax: 90,
|
||||
lifetime: 2000,
|
||||
lifetimeVariance: 200,
|
||||
dragCoefficient: 0,
|
||||
acceleration: 0,
|
||||
colors: [new Vector(0, 0, 1, 1), new Vector(0.5, 0.5, 1, 1), new Vector(1, 1, 1, 0)],
|
||||
sizes: [0.2, 0.2, 0.2],
|
||||
times: [0, 0.5, 1]
|
||||
}
|
||||
};
|
||||
|
||||
typedef Trail = {
|
||||
var type:String;
|
||||
var smokeEmitter:ParticleEmitter;
|
||||
var targetPos:Vector;
|
||||
var spawnTime:Float;
|
||||
var lifetime:Float;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
class Firework extends Scheduler {
|
||||
var pos:Vector;
|
||||
var spawnTime:Float;
|
||||
var trails:Array<Trail> = [];
|
||||
|
||||
/** The fireworks are spawned in waves, this controls how many are left. */
|
||||
var wavesLeft = 4;
|
||||
|
||||
var level:MarbleWorld;
|
||||
|
||||
var fireworkSmokeData:ParticleData;
|
||||
var fireworkRedTrailData:ParticleData;
|
||||
var fireworkBlueTrailData:ParticleData;
|
||||
var fireworkRedSparkData:ParticleData;
|
||||
var fireworkBlueSparkData:ParticleData;
|
||||
|
||||
var textureResources:Array<Resource<Texture>> = [];
|
||||
|
||||
public function new(pos:Vector, spawnTime:Float, level:MarbleWorld) {
|
||||
this.pos = pos;
|
||||
this.spawnTime = spawnTime;
|
||||
this.level = level;
|
||||
|
||||
fireworkSmokeData = new ParticleData();
|
||||
fireworkSmokeData.identifier = "fireworkSmoke";
|
||||
var res1 = ResourceLoader.getTexture("data/particles/saturn.png");
|
||||
res1.acquire();
|
||||
if (!this.textureResources.contains(res1))
|
||||
this.textureResources.push(res1);
|
||||
fireworkSmokeData.texture = res1.resource;
|
||||
|
||||
fireworkRedTrailData = new ParticleData();
|
||||
fireworkRedTrailData.identifier = "fireworkRedTrail";
|
||||
var res2 = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
res2.acquire();
|
||||
if (!this.textureResources.contains(res2))
|
||||
this.textureResources.push(res2);
|
||||
fireworkRedTrailData.texture = res2.resource;
|
||||
|
||||
fireworkBlueTrailData = new ParticleData();
|
||||
fireworkBlueTrailData.identifier = "fireworkBlueTrail";
|
||||
var res3 = ResourceLoader.getTexture("data/particles/spark.png");
|
||||
res3.acquire();
|
||||
if (!this.textureResources.contains(res3))
|
||||
this.textureResources.push(res3);
|
||||
fireworkBlueTrailData.texture = res3.resource;
|
||||
|
||||
fireworkRedSparkData = new ParticleData();
|
||||
fireworkRedSparkData.identifier = "fireworkRedSpark";
|
||||
var res4 = ResourceLoader.getTexture("data/particles/star.png");
|
||||
res4.acquire();
|
||||
if (!this.textureResources.contains(res4))
|
||||
this.textureResources.push(res4);
|
||||
fireworkRedSparkData.texture = res4.resource;
|
||||
|
||||
fireworkBlueSparkData = new ParticleData();
|
||||
fireworkBlueSparkData.identifier = "fireworkBlueSpark";
|
||||
var res5 = ResourceLoader.getTexture("data/particles/bubble.png");
|
||||
res5.acquire();
|
||||
if (!this.textureResources.contains(res5))
|
||||
this.textureResources.push(res5);
|
||||
fireworkBlueSparkData.texture = res5.resource;
|
||||
|
||||
level.particleManager.createEmitter(fireworkSmoke, fireworkSmokeData, this.pos); // Start the smoke
|
||||
this.doWave(this.spawnTime); // Start the first wave
|
||||
}
|
||||
|
||||
public function tick(time:Float) {
|
||||
this.tickSchedule(time);
|
||||
|
||||
// Update the trails
|
||||
for (trail in this.trails) {
|
||||
var completion = Util.clamp((time - trail.spawnTime) / trail.lifetime, 0, 1);
|
||||
completion = 1 - Math.pow((1 - completion), 2); // ease-out
|
||||
|
||||
// Make the trail travel along an arc (parabola, whatever)
|
||||
var pos = this.pos.clone().multiply(1 - completion).add(trail.targetPos.clone().multiply(completion));
|
||||
pos = pos.sub(new Vector(0, 0, 1).multiply(Math.pow(completion, 2)));
|
||||
trail.smokeEmitter.setPos(pos, time);
|
||||
|
||||
if (completion == 1) {
|
||||
// The trail has reached its end, remove the emitter and spawn the explosion.
|
||||
level.particleManager.removeEmitter(trail.smokeEmitter);
|
||||
this.trails.remove(trail);
|
||||
|
||||
if (trail.type == 'red') {
|
||||
level.particleManager.createEmitter(redSpark, fireworkRedSparkData, pos);
|
||||
} else {
|
||||
level.particleManager.createEmitter(blueSpark, fireworkBlueSparkData, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Spawns a bunch of trails going in random directions. */
|
||||
function doWave(time:Float) {
|
||||
var count = Math.floor(17 + Math.random() * 10);
|
||||
for (i in 0...count)
|
||||
this.spawnTrail(time);
|
||||
this.wavesLeft--;
|
||||
if (this.wavesLeft > 0) {
|
||||
var nextWaveTime = time + 0.5 + 1 * Math.random();
|
||||
this.schedule(nextWaveTime, () -> this.doWave(nextWaveTime));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function spawnTrail(time:Float) {
|
||||
var type = (Math.random() < 0.5) ? 'red' : 'blue';
|
||||
var lifetime = 0.25 + Math.random() * 2;
|
||||
var distanceFac = 0.5 + lifetime / 5; // Make sure the firework doesn't travel a great distance way too quickly
|
||||
var emitter = level.particleManager.createEmitter((type == 'red') ? redTrail : blueTrail,
|
||||
(type == 'red') ? fireworkRedTrailData : fireworkBlueTrailData, this.pos);
|
||||
|
||||
var r = Math.sqrt(Math.random());
|
||||
var theta = Math.random() * Math.PI * 2;
|
||||
|
||||
var randomPointInCircle = new Vector(r * Math.cos(theta), r * Math.sin(theta));
|
||||
var targetPos = new Vector(randomPointInCircle.x * 3, randomPointInCircle.y * 3, 1 + Math.sqrt(Math.random()) * 3).multiply(distanceFac).add(this.pos);
|
||||
var trail:Trail = {
|
||||
type: type,
|
||||
smokeEmitter: emitter,
|
||||
targetPos: targetPos,
|
||||
spawnTime: time,
|
||||
lifetime: lifetime
|
||||
};
|
||||
this.trails.push(trail);
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
for (textureResource in this.textureResources) {
|
||||
textureResource.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue