mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-03 05:42:25 +00:00
fix various ui bugs
This commit is contained in:
parent
c033bb17e7
commit
7d60ec59f7
4 changed files with 82 additions and 12 deletions
|
|
@ -590,6 +590,14 @@ class MarbleWorld extends Scheduler {
|
|||
MarbleGame.canvas.pushDialog(new MPPreGameDlg());
|
||||
this.setCursorLock(false);
|
||||
this.marble.camera.startOverview();
|
||||
|
||||
// Hide all gems
|
||||
for (gem in this.gems) {
|
||||
gem.setHide(true);
|
||||
gem.pickedUp = true;
|
||||
gem.setHide(true);
|
||||
this.collisionWorld.removeEntity(gem.boundingCollider); // remove from octree to make it easy
|
||||
}
|
||||
}
|
||||
|
||||
public function addJoiningClient(cc:GameConnection, onAdded:() -> Void) {
|
||||
|
|
@ -661,6 +669,8 @@ class MarbleWorld extends Scheduler {
|
|||
|
||||
this.rewindManager.clear();
|
||||
|
||||
setCursorLock(true);
|
||||
|
||||
this.timeState.currentAttemptTime = 0;
|
||||
this.timeState.gameplayClock = this.gameMode.getStartTime();
|
||||
this.timeState.ticks = 0;
|
||||
|
|
@ -2014,7 +2024,7 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
if (_instancesNeedsUpdate) {
|
||||
if (this.radar != null)
|
||||
this.radar.render();
|
||||
this.radar.render(this.serverStartTicks != 0);
|
||||
_instancesNeedsUpdate = false;
|
||||
this.instanceManager.render();
|
||||
}
|
||||
|
|
@ -2057,22 +2067,37 @@ class MarbleWorld extends Scheduler {
|
|||
function determineClockColor(timeToDisplay:Float) {
|
||||
if (this.finishTime != null)
|
||||
return 1;
|
||||
if (this.timeState.currentAttemptTime < 3.5 || this.bonusTime > 0)
|
||||
return 1;
|
||||
if (timeToDisplay >= this.mission.qualifyTime)
|
||||
return 2;
|
||||
if (this.isMultiplayer) {
|
||||
if (!this.multiplayerStarted)
|
||||
return 1;
|
||||
|
||||
if (this.timeState.currentAttemptTime >= 3.5 && !Net.isMP) {
|
||||
// Create the flashing effect
|
||||
var alarmStart = this.mission.computeAlarmStartTime();
|
||||
var elapsed = timeToDisplay - alarmStart;
|
||||
if (elapsed < 0)
|
||||
if (alarmStart < timeToDisplay)
|
||||
return 0;
|
||||
if (Math.floor(elapsed) % 2 == 0)
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0; // Default yellow
|
||||
return 0;
|
||||
} else {
|
||||
if (this.timeState.currentAttemptTime < 3.5 || this.bonusTime > 0)
|
||||
return 1;
|
||||
if (timeToDisplay >= this.mission.qualifyTime)
|
||||
return 2;
|
||||
|
||||
if (this.timeState.currentAttemptTime >= 3.5 && !Net.isMP) {
|
||||
// Create the flashing effect
|
||||
var alarmStart = this.mission.computeAlarmStartTime();
|
||||
var elapsed = timeToDisplay - alarmStart;
|
||||
if (elapsed < 0)
|
||||
return 0;
|
||||
if (Math.floor(elapsed) % 2 == 0)
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0; // Default yellow
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTimer(dt:Float) {
|
||||
|
|
@ -2121,14 +2146,17 @@ class MarbleWorld extends Scheduler {
|
|||
var clockTicks = Math.floor((ourStartTime - this.timeState.gameplayClock) / 0.032);
|
||||
var clockTickTime = ourStartTime - clockTicks * 0.032;
|
||||
var delta = clockTickTime - this.timeState.gameplayClock;
|
||||
this.timeState.gameplayClock = gameplayHigh - delta;
|
||||
this.timeState.gameplayClock = Math.max(0, gameplayHigh - delta);
|
||||
}
|
||||
}
|
||||
|
||||
this.timeState.gameplayClock += dt * timeMultiplier;
|
||||
this.timeState.gameplayClock = Math.max(0, this.timeState.gameplayClock);
|
||||
}
|
||||
if (this.timeState.gameplayClock < 0 && !Net.isClient)
|
||||
if (this.timeState.gameplayClock <= 0 && !Net.isClient) {
|
||||
this.gameMode.onTimeExpire();
|
||||
this.timeState.gameplayClock = 0;
|
||||
}
|
||||
}
|
||||
this.timeState.currentAttemptTime += dt;
|
||||
} else {
|
||||
|
|
@ -2170,6 +2198,24 @@ class MarbleWorld extends Scheduler {
|
|||
AudioManager.playSound(ResourceLoader.getResource("data/sound/alarm_timeout.wav", ResourceLoader.getAudio, this.soundResources));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.multiplayerStarted) {
|
||||
var alarmStart = this.mission.computeAlarmStartTime();
|
||||
|
||||
if (prevGameplayClock > alarmStart && this.timeState.gameplayClock <= alarmStart) {
|
||||
// Start the alarm
|
||||
this.alarmSound = AudioManager.playSound(ResourceLoader.getResource("data/sound/alarm.wav", ResourceLoader.getAudio, this.soundResources),
|
||||
null, true); // AudioManager.createAudioSource('alarm.wav');
|
||||
this.displayHelp('You have ${alarmStart} seconds remaining.');
|
||||
}
|
||||
if (prevGameplayClock > 0 && this.timeState.gameplayClock <= 0) {
|
||||
// Stop the alarm
|
||||
if (this.alarmSound != null) {
|
||||
this.alarmSound.stop();
|
||||
this.alarmSound = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finishTime != null)
|
||||
this.timeState.gameplayClock = finishTime.gameplayClock;
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ class Mission {
|
|||
mission.type = missionInfo.type.toLowerCase();
|
||||
mission.missionInfo = missionInfo;
|
||||
mission.gameMode = missionInfo.gamemode;
|
||||
if (mission.gameMode != null) {
|
||||
mission.gameMode = StringTools.trim(mission.gameMode).toLowerCase();
|
||||
}
|
||||
return mission;
|
||||
}
|
||||
|
||||
|
|
@ -239,11 +242,19 @@ class Mission {
|
|||
/** Computes the clock time in MBP when the user should be warned that they're about to exceed the par time. */
|
||||
public function computeAlarmStartTime() {
|
||||
var alarmStart = this.qualifyTime;
|
||||
if (this.gameMode != null && this.gameMode == 'hunt') {
|
||||
alarmStart = 15;
|
||||
if (this.missionInfo.alarmstarttime != null)
|
||||
alarmStart = MisParser.parseNumber(this.missionInfo.alarmstarttime);
|
||||
return alarmStart;
|
||||
}
|
||||
alarmStart = 0;
|
||||
if (this.missionInfo.alarmstarttime != null)
|
||||
alarmStart -= MisParser.parseNumber(this.missionInfo.alarmstarttime);
|
||||
else {
|
||||
alarmStart -= 15;
|
||||
}
|
||||
|
||||
alarmStart = Math.max(0, alarmStart);
|
||||
|
||||
return alarmStart;
|
||||
|
|
|
|||
|
|
@ -64,10 +64,17 @@ class Radar {
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
public function render(doRender) {
|
||||
if (!_dirty)
|
||||
return;
|
||||
g.clear();
|
||||
if (!doRender) {
|
||||
for (marble => marbleName in marbleNameTexts) {
|
||||
if (marbleName != null)
|
||||
marbleName.alpha = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var gemCount = 0;
|
||||
for (gem in level.gems) {
|
||||
if (!gem.pickedUp) {
|
||||
|
|
|
|||
|
|
@ -266,6 +266,12 @@ class MPPreGameDlg extends GuiControl {
|
|||
|
||||
playBtn.disabled = !allReady;
|
||||
|
||||
if (playerListArr.length > 1) {
|
||||
spectateBtn.anim.visible = true;
|
||||
} else {
|
||||
spectateBtn.anim.visible = false;
|
||||
}
|
||||
|
||||
var playerListCompiled = playerListArr.map(player -> player.spectate ? '[S] ${player.name}' : player.name);
|
||||
var playerListStateCompiled = playerListArr.map(player -> player.ready ? "[Ready]" : "[Waiting]");
|
||||
playerListLeft.setTexts(playerListCompiled);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue