mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-01-02 13:22:23 +00:00
various fixes: platinum gem on end game, fix spawn chances, fix weird states regarding player leaves
This commit is contained in:
parent
17d76eeea0
commit
120b9bdf0e
8 changed files with 99 additions and 52 deletions
|
|
@ -375,9 +375,9 @@ class DifBuilder {
|
|||
'pq_ray_wall_combo.normal.png', 'pq_ray_wall_combo.spec.png'),
|
||||
'multiplayer/interiors/platinumquest/pq_ray_wall_combo_2' => (onFinish) -> createPQMaterial(onFinish, 'pq_ray_wall_combo_2.png',
|
||||
'pq_ray_wall_combo_2.normal.png', 'pq_ray_wall_combo_2.spec.png'),
|
||||
'multiplayer/interiors/platinumquest/pq_ray_wall_combo_2_medium' => (onFinish) -> createPQMaterial(onFinish, 'pq_ray_wall_combo_2.png',
|
||||
'multiplayer/interiors/platinumquest/pq_ray_wall_combo_2_medium' => (onFinish) -> createPQMaterial(onFinish, 'pq_ray_wall_combo_2_medium.png',
|
||||
'pq_ray_wall_combo_2.normal.png', 'pq_ray_wall_combo_2.spec.png'),
|
||||
'multiplayer/interiors/platinumquest/pq_ray_wall_combo_small' => (onFinish) -> createPQMaterial(onFinish, 'pq_ray_wall_combo.png',
|
||||
'multiplayer/interiors/platinumquest/pq_ray_wall_combo_small' => (onFinish) -> createPQMaterial(onFinish, 'pq_ray_wall_combo_small.png',
|
||||
'pq_ray_wall_combo.normal.png', 'pq_ray_wall_combo.spec.png'),
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -2071,10 +2071,17 @@ class MarbleWorld extends Scheduler {
|
|||
#if js
|
||||
lock = true;
|
||||
|
||||
var loadPerTick = 500; // Stack limits???
|
||||
var loadedFuncs = 0;
|
||||
var func = this.resourceLoadFuncs.shift();
|
||||
|
||||
var consumeFn;
|
||||
consumeFn = () -> {
|
||||
if (loadedFuncs >= loadPerTick) {
|
||||
lock = false;
|
||||
return;
|
||||
}
|
||||
loadedFuncs += 1;
|
||||
this._resourcesLoaded++;
|
||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
||||
if (this.resourceLoadFuncs.length != 0) {
|
||||
|
|
|
|||
|
|
@ -141,15 +141,23 @@ class MPEndGameGui extends GuiImage {
|
|||
middleCtrl.extent = new Vector(800, 480);
|
||||
this.addChild(middleCtrl);
|
||||
|
||||
var hasPlatinum = false;
|
||||
var scores = @:privateAccess MarbleGame.instance.world.playGui.playerList;
|
||||
for (player in scores) {
|
||||
if (player.p > 0) {
|
||||
hasPlatinum = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var headerML = new GuiText(domcasual36);
|
||||
headerML.position = new Vector(25, 83);
|
||||
headerML.extent = new Vector(750, 14);
|
||||
headerML.horizSizing = Width;
|
||||
headerML.text.textColor = 0xFFFFFF;
|
||||
headerML.text.text = " Name Score Marble";
|
||||
headerML.text.text = ' Name Score ${hasPlatinum ? " " : ""} Marble';
|
||||
middleCtrl.addChild(headerML);
|
||||
|
||||
var scores = @:privateAccess MarbleGame.instance.world.playGui.playerList;
|
||||
var ourRank = scores.indexOf(scores.filter(x -> x.us == true)[0]) + 1;
|
||||
var rankSuffix = ourRank == 1 ? "st" : (ourRank == 2 ? "nd" : (ourRank == 3 ? "rd" : "th"));
|
||||
|
||||
|
|
@ -181,6 +189,10 @@ class MPEndGameGui extends GuiImage {
|
|||
middleCtrl.addChild(yellowGem);
|
||||
var blueGem = buildObjectShow("data/shapes/items/gem.dts", new Vector(469, 65), new Vector(64, 64), 2.5, 0, ["base.gem" => "blue.gem"]);
|
||||
middleCtrl.addChild(blueGem);
|
||||
if (hasPlatinum) {
|
||||
var platinumGem = buildObjectShow("data/shapes/items/gem.dts", new Vector(521, 65), new Vector(64, 64), 2.5, 0, ["base.gem" => "platinum.gem"]);
|
||||
middleCtrl.addChild(platinumGem);
|
||||
}
|
||||
|
||||
var playerContainer = new GuiControl();
|
||||
playerContainer.horizSizing = Center;
|
||||
|
|
@ -191,7 +203,7 @@ class MPEndGameGui extends GuiImage {
|
|||
|
||||
var idx = 0;
|
||||
|
||||
function addPlayer(rank:Int, playerName:String, score:Int, r:Int, y:Int, b:Int, marbleCat:Int, marbleSel:Int) {
|
||||
function addPlayer(rank:Int, playerName:String, score:Int, r:Int, y:Int, b:Int, p:Int, marbleCat:Int, marbleSel:Int) {
|
||||
var container = new GuiControl();
|
||||
container.position = new Vector(0, 44 * idx);
|
||||
container.extent = new Vector(750, 44);
|
||||
|
|
@ -227,16 +239,27 @@ class MPEndGameGui extends GuiImage {
|
|||
container.addChild(playerY);
|
||||
|
||||
var playerB = new GuiText(domcasual36);
|
||||
playerB.text.textColor = 0x0000FF;
|
||||
playerB.text.textColor = 0x4040FF;
|
||||
playerB.text.text = '${b}';
|
||||
playerB.justify = Center;
|
||||
playerB.position = new Vector(452, 3);
|
||||
playerB.extent = new Vector(52, 14);
|
||||
container.addChild(playerB);
|
||||
|
||||
var marble = buildObjectShow(MarbleSelectGui.marbleData[marbleCat][marbleSel].dts, new Vector(524, -10), new Vector(64, 64), 2.4, 0, [
|
||||
"base.marble" => MarbleSelectGui.marbleData[marbleCat][marbleSel].skin + ".marble"
|
||||
]);
|
||||
if (hasPlatinum) {
|
||||
var playerB = new GuiText(domcasual36);
|
||||
playerB.text.textColor = 0xCCCCCC;
|
||||
playerB.text.text = '${p}';
|
||||
playerB.justify = Center;
|
||||
playerB.position = new Vector(504, 3);
|
||||
playerB.extent = new Vector(52, 14);
|
||||
container.addChild(playerB);
|
||||
}
|
||||
|
||||
var marble = buildObjectShow(MarbleSelectGui.marbleData[marbleCat][marbleSel].dts, new Vector((hasPlatinum ? 52 : 0) + 524, -10),
|
||||
new Vector(64, 64), 2.4, 0, [
|
||||
"base.marble" => MarbleSelectGui.marbleData[marbleCat][marbleSel].skin + ".marble"
|
||||
]);
|
||||
|
||||
container.addChild(marble);
|
||||
|
||||
|
|
@ -255,7 +278,7 @@ class MPEndGameGui extends GuiImage {
|
|||
marb = c.marbleId;
|
||||
}
|
||||
|
||||
addPlayer(r, player.name, player.score, player.r, player.y, player.b, cat, marb);
|
||||
addPlayer(r, player.name, player.score, player.r, player.y, player.b, player.p, cat, marb);
|
||||
r += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ class MPPreGameDlg extends GuiControl {
|
|||
leaveBtn.extent = new Vector(94, 45);
|
||||
leaveBtn.pressedAction = (e) -> {
|
||||
MarbleGame.instance.quitMission(true);
|
||||
if (Net.isMP && Net.isClient) {
|
||||
Net.disconnect();
|
||||
MarbleGame.canvas.setContent(new JoinServerGui());
|
||||
}
|
||||
}
|
||||
dialogImg.addChild(leaveBtn);
|
||||
|
||||
|
|
@ -240,6 +244,8 @@ class MPPreGameDlg extends GuiControl {
|
|||
ready: Net.lobbyHostReady,
|
||||
spectate: Net.hostSpectate
|
||||
});
|
||||
spectateBtn.pressed = Net.hostSpectate;
|
||||
readyBtn.pressed = Net.lobbyHostReady;
|
||||
}
|
||||
if (Net.isClient) {
|
||||
playerListArr.push({
|
||||
|
|
@ -247,6 +253,8 @@ class MPPreGameDlg extends GuiControl {
|
|||
ready: Net.lobbyClientReady,
|
||||
spectate: Net.clientSpectate
|
||||
});
|
||||
spectateBtn.pressed = Net.clientSpectate;
|
||||
readyBtn.pressed = Net.lobbyClientReady;
|
||||
}
|
||||
if (Net.clientIdMap != null) {
|
||||
for (c => v in Net.clientIdMap) {
|
||||
|
|
@ -279,6 +287,12 @@ class MPPreGameDlg extends GuiControl {
|
|||
playerListLeft.setTexts(playerListCompiled);
|
||||
playerListRight.setTexts(playerListStateCompiled);
|
||||
|
||||
if (playerListArr.length == 1) {
|
||||
// Disable spectating
|
||||
Net.hostSpectate = false;
|
||||
Net.clientSpectate = false;
|
||||
}
|
||||
|
||||
// if (!showingCustoms)
|
||||
// playerList.setTexts(playerListArr.map(player -> {
|
||||
// return '<img src="${player.state ? "ready" : "notready"}"></img><img src="${platformToString(player.platform)}"></img>${player.name}';
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class PlayerInfo {
|
|||
var r:Int;
|
||||
var y:Int;
|
||||
var b:Int;
|
||||
var p:Int;
|
||||
}
|
||||
|
||||
class PlayGui {
|
||||
|
|
@ -720,7 +721,8 @@ class PlayGui {
|
|||
score: 0,
|
||||
r: 0,
|
||||
y: 0,
|
||||
b: 0
|
||||
b: 0,
|
||||
p: 0
|
||||
});
|
||||
redrawPlayerList();
|
||||
}
|
||||
|
|
@ -748,6 +750,9 @@ class PlayGui {
|
|||
if (score == 5) {
|
||||
f[0].b += 1;
|
||||
}
|
||||
if (score == 10) {
|
||||
f[0].p += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (id == Net.clientId) {
|
||||
|
|
@ -765,6 +770,7 @@ class PlayGui {
|
|||
player.r = scoreboardPacket.rBoard.exists(player.id) ? scoreboardPacket.rBoard.get(player.id) : 0;
|
||||
player.y = scoreboardPacket.yBoard.exists(player.id) ? scoreboardPacket.yBoard.get(player.id) : 0;
|
||||
player.b = scoreboardPacket.bBoard.exists(player.id) ? scoreboardPacket.bBoard.get(player.id) : 0;
|
||||
player.p = scoreboardPacket.pBoard.exists(player.id) ? scoreboardPacket.pBoard.get(player.id) : 0;
|
||||
}
|
||||
redrawPlayerList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class HuntMode extends NullMode {
|
|||
}
|
||||
|
||||
override function getPreloadFiles() {
|
||||
return ['data/sound/opponentdiamond.wav'];
|
||||
return ['data/sound/opponentdiamond.wav', 'data/sound/firewrks.wav'];
|
||||
}
|
||||
|
||||
function setupGems() {
|
||||
|
|
@ -285,33 +285,36 @@ class HuntMode extends NullMode {
|
|||
var pos = furthest.gem.getAbsPos().getPosition();
|
||||
|
||||
var results = [];
|
||||
var search = gemOctree.radiusSearch(pos, gemGroupRadius);
|
||||
for (elem in search) {
|
||||
var gemElem:GemSpawnPoint = cast elem;
|
||||
var gemPos = gemElem.gem.getAbsPos().getPosition();
|
||||
while (results.length == 0) {
|
||||
var search = gemOctree.radiusSearch(pos, gemGroupRadius);
|
||||
for (elem in search) {
|
||||
var gemElem:GemSpawnPoint = cast elem;
|
||||
var gemPos = gemElem.gem.getAbsPos().getPosition();
|
||||
|
||||
if (level.mission.missionInfo.game == "PlatinumQuest") {
|
||||
// Spawn chances!
|
||||
var chance = switch (gemElem.gem.gemColor) {
|
||||
case "red":
|
||||
level.mission.missionInfo.spawnchancered != null ? Std.parseFloat(level.mission.missionInfo.spawnchancered) : 0.9;
|
||||
case "yellow":
|
||||
level.mission.missionInfo.spawnchanceyellow != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceyellow) : 0.65;
|
||||
case "blue":
|
||||
level.mission.missionInfo.spawnchanceblue != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceblue) : 0.35;
|
||||
case "platinum":
|
||||
level.mission.missionInfo.spawnchanceplatinum != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceplatinum) : 0.18;
|
||||
default:
|
||||
1.0;
|
||||
};
|
||||
if (Math.random() > chance)
|
||||
continue; // Don't spawn!
|
||||
if (level.mission.missionInfo.game == "PlatinumQuest") {
|
||||
// Spawn chances!
|
||||
var chance = switch (gemElem.gem.gemColor.toLowerCase()) {
|
||||
case "red.gem":
|
||||
level.mission.missionInfo.spawnchancered != null ? Std.parseFloat(level.mission.missionInfo.spawnchancered) : 0.9;
|
||||
case "yellow.gem":
|
||||
level.mission.missionInfo.spawnchanceyellow != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceyellow) : 0.65;
|
||||
case "blue.gem":
|
||||
level.mission.missionInfo.spawnchanceblue != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceblue) : 0.35;
|
||||
case "platinum.gem":
|
||||
level.mission.missionInfo.spawnchanceplatinum != null ? Std.parseFloat(level.mission.missionInfo.spawnchanceplatinum) : 0.18;
|
||||
default:
|
||||
1.0;
|
||||
};
|
||||
var choice = Math.random();
|
||||
if (choice > chance)
|
||||
continue; // Don't spawn!
|
||||
}
|
||||
|
||||
results.push({
|
||||
gem: gemElem.netIndex,
|
||||
weight: this.gemGroupRadius - gemPos.distance(pos) + rng.randRange(0, getGemWeight(gemElem.gem) + 3)
|
||||
});
|
||||
}
|
||||
|
||||
results.push({
|
||||
gem: gemElem.netIndex,
|
||||
weight: this.gemGroupRadius - gemPos.distance(pos) + rng.randRange(0, getGemWeight(gemElem.gem) + 3)
|
||||
});
|
||||
}
|
||||
results.sort((a, b) -> {
|
||||
if (a.weight > b.weight)
|
||||
|
|
@ -437,13 +440,14 @@ class HuntMode extends NullMode {
|
|||
}
|
||||
|
||||
function getGemWeight(gem:Gem) {
|
||||
if (gem.gemColor == "red")
|
||||
var col = gem.gemColor.toLowerCase();
|
||||
if (col == "red.gem")
|
||||
return 0;
|
||||
if (gem.gemColor == "yellow")
|
||||
if (col == "yellow.gem")
|
||||
return 1;
|
||||
if (gem.gemColor == "blue")
|
||||
if (col == "blue.gem")
|
||||
return 4;
|
||||
if (gem.gemColor == "platinum")
|
||||
if (col == "platinum.gem")
|
||||
return 9;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,17 +284,6 @@ class NetCommands {
|
|||
var conn = Net.clientIdMap.get(clientId);
|
||||
if (MarbleGame.instance.world != null) {
|
||||
MarbleGame.instance.world.removePlayer(conn);
|
||||
|
||||
var allReady = true;
|
||||
for (id => client in Net.clientIdMap) {
|
||||
if (client.state != GameplayState.GAME && client != conn) {
|
||||
allReady = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allReady && MarbleGame.instance.world.serverStartTicks == 0) {
|
||||
MarbleGame.instance.world.allClientsReady();
|
||||
}
|
||||
}
|
||||
Net.clientIdMap.remove(clientId);
|
||||
if (MarbleGame.canvas.content is MPPlayMissionGui) {
|
||||
|
|
|
|||
|
|
@ -317,12 +317,14 @@ class ScoreboardPacket implements NetPacket {
|
|||
var rBoard:Map<Int, Int>;
|
||||
var yBoard:Map<Int, Int>;
|
||||
var bBoard:Map<Int, Int>;
|
||||
var pBoard:Map<Int, Int>;
|
||||
|
||||
public function new() {
|
||||
scoreBoard = new Map();
|
||||
rBoard = new Map();
|
||||
yBoard = new Map();
|
||||
bBoard = new Map();
|
||||
pBoard = new Map();
|
||||
}
|
||||
|
||||
public inline function deserialize(b:InputBitStream) {
|
||||
|
|
@ -333,6 +335,7 @@ class ScoreboardPacket implements NetPacket {
|
|||
rBoard[id] = b.readInt(10);
|
||||
yBoard[id] = b.readInt(10);
|
||||
bBoard[id] = b.readInt(10);
|
||||
pBoard[id] = b.readInt(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,6 +350,7 @@ class ScoreboardPacket implements NetPacket {
|
|||
b.writeInt(rBoard[key], 10);
|
||||
b.writeInt(yBoard[key], 10);
|
||||
b.writeInt(bBoard[key], 10);
|
||||
b.writeInt(pBoard[key], 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue