mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 12:41:40 +00:00
add blast support to replay, fix mega bugs
This commit is contained in:
parent
50ae6803dc
commit
7b00b995d1
6 changed files with 61 additions and 36 deletions
|
|
@ -1579,7 +1579,7 @@ class Marble extends GameObject {
|
||||||
move.d = new Vector(this.level.replay.currentPlaybackFrame.marbleX, this.level.replay.currentPlaybackFrame.marbleY, 0);
|
move.d = new Vector(this.level.replay.currentPlaybackFrame.marbleX, this.level.replay.currentPlaybackFrame.marbleY, 0);
|
||||||
} else {
|
} else {
|
||||||
if (this.level.isRecording) {
|
if (this.level.isRecording) {
|
||||||
this.level.replay.recordMarbleStateFlags(move.jump, move.powerup, false);
|
this.level.replay.recordMarbleStateFlags(move.jump, move.powerup, false, false);
|
||||||
this.level.replay.recordMarbleInput(move.d.x, move.d.y);
|
this.level.replay.recordMarbleInput(move.d.x, move.d.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,7 @@ class MarbleWorld extends Scheduler {
|
||||||
"shapes/pads/green.jpg",
|
"shapes/pads/green.jpg",
|
||||||
"shapes/items/gem.dts", // Ew ew
|
"shapes/items/gem.dts", // Ew ew
|
||||||
"shapes/items/gemshine.png",
|
"shapes/items/gemshine.png",
|
||||||
|
"shapes/items/enviro1.jpg",
|
||||||
];
|
];
|
||||||
if (this.game == "ultra") {
|
if (this.game == "ultra") {
|
||||||
marblefiles.push("shapes/balls/pack1/marble20.normal.png");
|
marblefiles.push("shapes/balls/pack1/marble20.normal.png");
|
||||||
|
|
@ -1102,6 +1103,24 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function performRestart() {
|
||||||
|
this.respawnPressedTime = timeState.timeSinceLoad;
|
||||||
|
this.restart();
|
||||||
|
if (!this.isWatching) {
|
||||||
|
Settings.playStatistics.respawns++;
|
||||||
|
|
||||||
|
if (!Settings.levelStatistics.exists(mission.path)) {
|
||||||
|
Settings.levelStatistics.set(mission.path, {
|
||||||
|
oobs: 0,
|
||||||
|
respawns: 1,
|
||||||
|
totalTime: 0,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Settings.levelStatistics[mission.path].respawns++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function update(dt:Float) {
|
public function update(dt:Float) {
|
||||||
if (!_ready) {
|
if (!_ready) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1131,23 +1150,8 @@ class MarbleWorld extends Scheduler {
|
||||||
ProfilerUI.measure("updateTimer");
|
ProfilerUI.measure("updateTimer");
|
||||||
this.updateTimer(dt);
|
this.updateTimer(dt);
|
||||||
|
|
||||||
if ((Key.isPressed(Settings.controlsSettings.respawn) || MarbleGame.instance.touchInput.restartButton.pressed)
|
if ((Key.isPressed(Settings.controlsSettings.respawn)) && this.finishTime == null) {
|
||||||
&& this.finishTime == null) {
|
performRestart();
|
||||||
this.respawnPressedTime = timeState.timeSinceLoad;
|
|
||||||
this.restart();
|
|
||||||
if (!this.isWatching) {
|
|
||||||
Settings.playStatistics.respawns++;
|
|
||||||
|
|
||||||
if (!Settings.levelStatistics.exists(mission.path)) {
|
|
||||||
Settings.levelStatistics.set(mission.path, {
|
|
||||||
oobs: 0,
|
|
||||||
respawns: 1,
|
|
||||||
totalTime: 0,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Settings.levelStatistics[mission.path].respawns++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1168,8 +1172,14 @@ class MarbleWorld extends Scheduler {
|
||||||
&& !this.isWatching
|
&& !this.isWatching
|
||||||
&& this.game == "ultra") {
|
&& this.game == "ultra") {
|
||||||
this.marble.useBlast();
|
this.marble.useBlast();
|
||||||
|
if (this.isRecording) {
|
||||||
|
this.replay.recordMarbleStateFlags(false, false, false, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isWatching && this.replay.currentPlaybackFrame.marbleStateFlags.has(UsedBlast))
|
||||||
|
this.marble.useBlast();
|
||||||
|
|
||||||
// Replay gravity
|
// Replay gravity
|
||||||
if (this.isWatching) {
|
if (this.isWatching) {
|
||||||
if (this.replay.currentPlaybackFrame.gravityChange) {
|
if (this.replay.currentPlaybackFrame.gravityChange) {
|
||||||
|
|
@ -1769,12 +1779,16 @@ class MarbleWorld extends Scheduler {
|
||||||
this.marble.camera.nextCameraYaw = this.marble.camera.CameraYaw;
|
this.marble.camera.nextCameraYaw = this.marble.camera.CameraYaw;
|
||||||
this.marble.camera.nextCameraPitch = this.marble.camera.CameraPitch;
|
this.marble.camera.nextCameraPitch = this.marble.camera.CameraPitch;
|
||||||
this.marble.camera.oob = false;
|
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;
|
this.blastAmount = this.cheeckpointBlast;
|
||||||
if (this.isRecording) {
|
if (this.isRecording) {
|
||||||
this.replay.recordCameraState(this.marble.camera.CameraYaw, this.marble.camera.CameraPitch);
|
this.replay.recordCameraState(this.marble.camera.CameraYaw, this.marble.camera.CameraPitch);
|
||||||
this.replay.recordMarbleInput(0, 0);
|
this.replay.recordMarbleInput(0, 0);
|
||||||
this.replay.recordMarbleState(mpos, marble.velocity, marble.getRotationQuat(), marble.omega);
|
this.replay.recordMarbleState(mpos, marble.velocity, marble.getRotationQuat(), marble.omega);
|
||||||
this.replay.recordMarbleStateFlags(false, false, true);
|
this.replay.recordMarbleStateFlags(false, false, true, false);
|
||||||
}
|
}
|
||||||
var gravityField = ""; // (this.currentCheckpoint.srcElement as any) ?.gravity || this.currentCheckpointTrigger?.element.gravity;
|
var gravityField = ""; // (this.currentCheckpoint.srcElement as any) ?.gravity || this.currentCheckpointTrigger?.element.gravity;
|
||||||
if (this.currentCheckpoint.elem.fields.exists('gravity')) {
|
if (this.currentCheckpoint.elem.fields.exists('gravity')) {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ enum ReplayMarbleState {
|
||||||
UsedPowerup;
|
UsedPowerup;
|
||||||
Jumped;
|
Jumped;
|
||||||
InstantTeleport;
|
InstantTeleport;
|
||||||
|
UsedBlast;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:publicFields
|
@:publicFields
|
||||||
|
|
@ -99,6 +100,8 @@ class ReplayFrame {
|
||||||
interpFrame.marbleStateFlags.set(UsedPowerup);
|
interpFrame.marbleStateFlags.set(UsedPowerup);
|
||||||
if (this.marbleStateFlags.has(Jumped))
|
if (this.marbleStateFlags.has(Jumped))
|
||||||
interpFrame.marbleStateFlags.set(Jumped);
|
interpFrame.marbleStateFlags.set(Jumped);
|
||||||
|
if (this.marbleStateFlags.has(UsedBlast))
|
||||||
|
interpFrame.marbleStateFlags.set(UsedBlast);
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
interpFrame.marbleX = this.marbleX;
|
interpFrame.marbleX = this.marbleX;
|
||||||
|
|
@ -246,7 +249,7 @@ class Replay {
|
||||||
var currentPlaybackFrameIdx:Int;
|
var currentPlaybackFrameIdx:Int;
|
||||||
var currentPlaybackTime:Float;
|
var currentPlaybackTime:Float;
|
||||||
|
|
||||||
var version:Int = 3;
|
var version:Int = 4;
|
||||||
|
|
||||||
public function new(mission:String) {
|
public function new(mission:String) {
|
||||||
this.mission = mission;
|
this.mission = mission;
|
||||||
|
|
@ -276,13 +279,15 @@ class Replay {
|
||||||
currentRecordFrame.marbleAngularVelocity = angularVelocity.clone();
|
currentRecordFrame.marbleAngularVelocity = angularVelocity.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recordMarbleStateFlags(jumped:Bool, usedPowerup:Bool, instantTeleport:Bool) {
|
public function recordMarbleStateFlags(jumped:Bool, usedPowerup:Bool, instantTeleport:Bool, usedBlast:Bool) {
|
||||||
if (jumped)
|
if (jumped)
|
||||||
currentRecordFrame.marbleStateFlags.set(Jumped);
|
currentRecordFrame.marbleStateFlags.set(Jumped);
|
||||||
if (usedPowerup)
|
if (usedPowerup)
|
||||||
currentRecordFrame.marbleStateFlags.set(UsedPowerup);
|
currentRecordFrame.marbleStateFlags.set(UsedPowerup);
|
||||||
if (instantTeleport)
|
if (instantTeleport)
|
||||||
currentRecordFrame.marbleStateFlags.set(InstantTeleport);
|
currentRecordFrame.marbleStateFlags.set(InstantTeleport);
|
||||||
|
if (usedBlast)
|
||||||
|
currentRecordFrame.marbleStateFlags.set(UsedBlast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recordPowerupPickup(powerup:PowerUp) {
|
public function recordPowerupPickup(powerup:PowerUp) {
|
||||||
|
|
|
||||||
|
|
@ -309,23 +309,25 @@ class PlayGui {
|
||||||
// gemImageObject.matNameOverride.set("base.gem", "base.gem.");
|
// gemImageObject.matNameOverride.set("base.gem", "base.gem.");
|
||||||
gemImageObject.ambientSpinFactor /= -2;
|
gemImageObject.ambientSpinFactor /= -2;
|
||||||
// ["base.gem"] = color + ".gem";
|
// ["base.gem"] = color + ".gem";
|
||||||
ResourceLoader.load("shapes/items/" + gemColor + ".gem.png").entry.load(() -> {
|
ResourceLoader.load("shapes/items/gem.dts").entry.load(() -> {
|
||||||
gemImageObject.init(null, () -> {
|
ResourceLoader.load("shapes/items/" + gemColor + ".gem.png").entry.load(() -> {
|
||||||
for (mat in gemImageObject.materials) {
|
gemImageObject.init(null, () -> {
|
||||||
mat.mainPass.enableLights = false;
|
for (mat in gemImageObject.materials) {
|
||||||
|
mat.mainPass.enableLights = false;
|
||||||
|
|
||||||
// Huge hacks
|
// Huge hacks
|
||||||
if (mat.blendMode != Add) {
|
if (mat.blendMode != Add) {
|
||||||
var alphaShader = new h3d.shader.AlphaChannel();
|
var alphaShader = new h3d.shader.AlphaChannel();
|
||||||
mat.mainPass.addShader(alphaShader);
|
mat.mainPass.addShader(alphaShader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
gemImageScene.addChild(gemImageObject);
|
||||||
gemImageScene.addChild(gemImageObject);
|
var gemImageCenter = gemImageObject.getBounds().getCenter();
|
||||||
var gemImageCenter = gemImageObject.getBounds().getCenter();
|
|
||||||
|
|
||||||
gemImageScene.camera.pos = new Vector(0, 3, gemImageCenter.z);
|
gemImageScene.camera.pos = new Vector(0, 3, gemImageCenter.z);
|
||||||
gemImageScene.camera.target = new Vector(gemImageCenter.x, gemImageCenter.y, gemImageCenter.z);
|
gemImageScene.camera.target = new Vector(gemImageCenter.x, gemImageCenter.y, gemImageCenter.z);
|
||||||
onFinish();
|
onFinish();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,9 @@ class RestartButton extends TouchButton {
|
||||||
super(ResourceLoader.getImage("data/ui/touch/refresh.png").resource, new Vector(135, 55 + offset), 35);
|
super(ResourceLoader.getImage("data/ui/touch/refresh.png").resource, new Vector(135, 55 + offset), 35);
|
||||||
this.guiElement.horizSizing = Right;
|
this.guiElement.horizSizing = Right;
|
||||||
this.guiElement.vertSizing = Bottom;
|
this.guiElement.vertSizing = Bottom;
|
||||||
|
this.onClick = () -> {
|
||||||
|
if (MarbleGame.instance.world.finishTime == null)
|
||||||
|
MarbleGame.instance.world.performRestart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class TeleportTrigger extends Trigger {
|
||||||
this.level.marble.prevPos.load(position);
|
this.level.marble.prevPos.load(position);
|
||||||
this.level.marble.setPosition(position.x, position.y, position.z);
|
this.level.marble.setPosition(position.x, position.y, position.z);
|
||||||
if (this.level.isRecording) {
|
if (this.level.isRecording) {
|
||||||
this.level.replay.recordMarbleStateFlags(false, false, true);
|
this.level.replay.recordMarbleStateFlags(false, false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MisParser.parseBoolean(chooseNonNull(this.element.keepvelocity, destination.element.keepvelocity)))
|
if (!MisParser.parseBoolean(chooseNonNull(this.element.keepvelocity, destination.element.keepvelocity)))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue