fix more restart and add platform indicators
|
Before Width: | Height: | Size: 516 B After Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 275 B |
BIN
data/ui/xbox/platform_mac.png
Normal file
|
After Width: | Height: | Size: 256 B |
BIN
data/ui/xbox/platform_unknown.png
Normal file
|
After Width: | Height: | Size: 349 B |
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 388 B |
|
|
@ -521,6 +521,7 @@ class MarbleWorld extends Scheduler {
|
|||
public function restartMultiplayerState() {
|
||||
if (this.isMultiplayer) {
|
||||
serverStartTicks = 0;
|
||||
startTime = 1e8;
|
||||
lastMoves = new MarbleUpdateQueue();
|
||||
predictions = new MarblePredictionStore();
|
||||
powerupPredictions = new PowerupPredictionStore();
|
||||
|
|
@ -1188,21 +1189,21 @@ class MarbleWorld extends Scheduler {
|
|||
advanceTimeState.dt = 0.032;
|
||||
advanceTimeState.ticks = ourLastMoveTime;
|
||||
|
||||
if (marbleNeedsPrediction & (1 << Net.clientId) > 0) { // Only for our clients pls
|
||||
// if (qm != null) {
|
||||
// var mvs = qm.powerupStates.copy();
|
||||
for (pw in marble.level.powerUps) {
|
||||
// var val = mvs.shift();
|
||||
// if (pw.lastPickUpTime != val)
|
||||
// Console.log('Revert powerup pickup: ${pw.lastPickUpTime} -> ${val}');
|
||||
pw.lastPickUpTime = powerupPredictions.getState(pw.netIndex);
|
||||
}
|
||||
var huntMode:HuntMode = cast this.gameMode;
|
||||
for (activeGem in @:privateAccess huntMode.activeGemSpawnGroup) {
|
||||
huntMode.setGemHiddenStatus(activeGem, gemPredictions.getState(activeGem));
|
||||
}
|
||||
// }
|
||||
// if (marbleNeedsPrediction & (1 << Net.clientId) > 0) { // Only for our clients pls
|
||||
// if (qm != null) {
|
||||
// var mvs = qm.powerupStates.copy();
|
||||
for (pw in marble.level.powerUps) {
|
||||
// var val = mvs.shift();
|
||||
// if (pw.lastPickUpTime != val)
|
||||
// Console.log('Revert powerup pickup: ${pw.lastPickUpTime} -> ${val}');
|
||||
pw.lastPickUpTime = powerupPredictions.getState(pw.netIndex);
|
||||
}
|
||||
var huntMode:HuntMode = cast this.gameMode;
|
||||
for (activeGem in @:privateAccess huntMode.activeGemSpawnGroup) {
|
||||
huntMode.setGemHiddenStatus(activeGem, gemPredictions.getState(activeGem));
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
ackLag = ourQueuedMoves.length;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package gui;
|
||||
|
||||
import net.ClientConnection.NetPlatform;
|
||||
import net.Net;
|
||||
import net.NetCommands;
|
||||
import modes.GameMode.ScoreType;
|
||||
|
|
@ -152,18 +153,21 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
if (Net.isHost) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.lobbyHostReady
|
||||
state: Net.lobbyHostReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
}
|
||||
if (Net.isClient) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.clientConnection.lobbyReady
|
||||
state: Net.clientConnection.lobbyReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
for (c => v in Net.clientIdMap) {
|
||||
playerListArr.push({
|
||||
name: v.name,
|
||||
state: v.lobbyReady
|
||||
state: v.lobbyReady,
|
||||
platform: v.platform
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -174,12 +178,22 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
return ResourceLoader.getResource("data/ui/xbox/Ready.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "notready":
|
||||
return ResourceLoader.getResource("data/ui/xbox/NotReady.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "pc":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_desktop.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "mac":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_mac.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "web":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_web.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "android":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_android.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
case "unknown":
|
||||
return ResourceLoader.getResource("data/ui/xbox/platform_unknown.png", ResourceLoader.getImage, this.imageResources).toTile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
playerList = new GuiMLTextListCtrl(arial14, playerListArr.map(player -> {
|
||||
return '<img src="${player.state ? "ready" : "notready"}"></img>${player.name}';
|
||||
return '<img src="${player.state ? "ready" : "notready"}"></img><img src="${platformToString(player.platform)}"></img>${player.name}';
|
||||
}), imgLoader);
|
||||
playerList.selectedColor = 0xF29515;
|
||||
playerList.selectedFillColor = 0xEBEBEB;
|
||||
|
|
@ -327,29 +341,42 @@ class MultiplayerLevelSelectGui extends GuiImage {
|
|||
super.onResize(width, height);
|
||||
}
|
||||
|
||||
inline function platformToString(platform:NetPlatform) {
|
||||
return switch (platform) {
|
||||
case Unknown: return "unknown";
|
||||
case Android: return "android";
|
||||
case MacOS: return "mac";
|
||||
case PC: return "pc";
|
||||
case Web: return "web";
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLobbyNames() {
|
||||
var playerListArr = [];
|
||||
if (Net.isHost) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.lobbyHostReady
|
||||
state: Net.lobbyHostReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
}
|
||||
if (Net.isClient) {
|
||||
playerListArr.push({
|
||||
name: Settings.highscoreName,
|
||||
state: Net.lobbyClientReady
|
||||
state: Net.lobbyClientReady,
|
||||
platform: Net.getPlatform()
|
||||
});
|
||||
}
|
||||
for (c => v in Net.clientIdMap) {
|
||||
playerListArr.push({
|
||||
name: v.name,
|
||||
state: v.lobbyReady
|
||||
state: v.lobbyReady,
|
||||
platform: v.platform
|
||||
});
|
||||
}
|
||||
|
||||
playerList.setTexts(playerListArr.map(player -> {
|
||||
return '<img src="${player.state ? "ready" : "notready"}"></img>${player.name}';
|
||||
return '<img src="${player.state ? "ready" : "notready"}"></img><img src="${platformToString(player.platform)}"></img>${player.name}';
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -463,6 +463,18 @@ class HuntMode extends NullMode {
|
|||
}
|
||||
|
||||
public function setActiveSpawnSphere(spawnGroup:Array<Int>) {
|
||||
Console.log("Got new gem spawn from server!");
|
||||
if (activeGemSpawnGroup != null) {
|
||||
for (agem in activeGemSpawnGroup) {
|
||||
var gemSpawn = gemSpawnPoints[agem];
|
||||
if (gemSpawn.gem != null) {
|
||||
gemSpawn.gem.pickedUp = true;
|
||||
gemSpawn.gem.setHide(true);
|
||||
gemSpawn.gemBeam.setHide(true);
|
||||
activeGems.remove(gemSpawn.gem);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (sphereId in spawnGroup) {
|
||||
var gemSpawn = gemSpawnPoints[sphereId];
|
||||
if (gemSpawn.gem != null) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ enum abstract GameplayState(Int) from Int to Int {
|
|||
var GAME;
|
||||
}
|
||||
|
||||
enum abstract NetPlatform(Int) from Int to Int {
|
||||
var Unknown;
|
||||
var PC;
|
||||
var MacOS;
|
||||
var Web;
|
||||
var Android;
|
||||
}
|
||||
|
||||
@:publicFields
|
||||
class ClientConnection extends GameConnection {
|
||||
var socket:RTCPeerConnection;
|
||||
|
|
@ -50,8 +58,9 @@ abstract class GameConnection {
|
|||
var moveManager:MoveManager;
|
||||
var name:String;
|
||||
var lobbyReady:Bool;
|
||||
var platform:NetPlatform;
|
||||
|
||||
public function new(id:Int) {
|
||||
function new(id:Int) {
|
||||
this.id = id;
|
||||
this.moveManager = new MoveManager(this);
|
||||
this.lobbyReady = false;
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ class ServerInfo {
|
|||
var privateServer:Bool;
|
||||
var inviteCode:Int;
|
||||
var state:String;
|
||||
var platform:String;
|
||||
var platform:NetPlatform;
|
||||
|
||||
public function new(name:String, players:Int, maxPlayers:Int, privateSlots:Int, privateServer:Bool, inviteCode:Int, state:String, platform:String) {
|
||||
public function new(name:String, players:Int, maxPlayers:Int, privateSlots:Int, privateServer:Bool, inviteCode:Int, state:String, platform:NetPlatform) {
|
||||
this.name = name;
|
||||
this.players = players;
|
||||
this.maxPlayers = maxPlayers;
|
||||
|
|
@ -298,6 +298,7 @@ class Net {
|
|||
for (c => v in clientIdMap) {
|
||||
b.writeByte(c);
|
||||
b.writeByte(v.lobbyReady ? 1 : 0);
|
||||
b.writeByte(v.platform);
|
||||
var name = v.getName();
|
||||
b.writeByte(name.length);
|
||||
for (i in 0...name.length) {
|
||||
|
|
@ -307,6 +308,7 @@ class Net {
|
|||
// Write host data
|
||||
b.writeByte(0);
|
||||
b.writeByte(Net.lobbyHostReady ? 1 : 0);
|
||||
b.writeByte(getPlatform());
|
||||
var name = Settings.highscoreName;
|
||||
b.writeByte(name.length);
|
||||
for (i in 0...name.length) {
|
||||
|
|
@ -327,6 +329,7 @@ class Net {
|
|||
clientId = input.readByte(); // 8 bit client id, hopefully we don't exceed this
|
||||
Console.log('Client ID set to ${clientId}');
|
||||
NetCommands.setPlayerName(clientId, Settings.highscoreName); // Send our player name to the server
|
||||
NetCommands.transmitPlatform(clientId, getPlatform()); // send our platform too
|
||||
|
||||
case Ping:
|
||||
var pingLeft = input.readByte();
|
||||
|
|
@ -407,6 +410,7 @@ class Net {
|
|||
for (i in 0...count) {
|
||||
var id = input.readByte();
|
||||
var cready = input.readByte() == 1;
|
||||
var platform = input.readByte();
|
||||
if (id != 0 && id != Net.clientId && !clientIdMap.exists(id)) {
|
||||
Console.log('Adding ghost connection ${id}');
|
||||
addGhost(id);
|
||||
|
|
@ -420,6 +424,7 @@ class Net {
|
|||
if (clientIdMap.exists(id)) {
|
||||
clientIdMap[id].setName(name);
|
||||
clientIdMap[id].lobbyReady = cready;
|
||||
clientIdMap[id].platform = platform;
|
||||
}
|
||||
if (Net.clientId == id) {
|
||||
Net.lobbyClientReady = cready;
|
||||
|
|
@ -457,15 +462,19 @@ class Net {
|
|||
}
|
||||
}
|
||||
|
||||
public static function getPlatform() {
|
||||
public static inline function getPlatform() {
|
||||
#if js
|
||||
return "Browser";
|
||||
return NetPlatform.Web;
|
||||
#end
|
||||
#if hl
|
||||
#if MACOS_BUNDLE
|
||||
return "MacOS";
|
||||
return NetPlatform.MacOS;
|
||||
#else
|
||||
return "Windows";
|
||||
#if android
|
||||
return NetPlatform.Android;
|
||||
#else
|
||||
return NetPlatform.PC;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package net;
|
||||
|
||||
import net.ClientConnection.NetPlatform;
|
||||
import gui.EndGameGui;
|
||||
import modes.HuntMode;
|
||||
import net.ClientConnection.GameplayState;
|
||||
|
|
@ -128,6 +129,15 @@ class NetCommands {
|
|||
}
|
||||
}
|
||||
|
||||
@:rpc(client) public static function transmitPlatform(clientId:Int, platform:Int) {
|
||||
if (Net.isHost) {
|
||||
Net.clientIdMap[clientId].platform = platform;
|
||||
if (MarbleGame.canvas.content is MultiplayerLevelSelectGui) {
|
||||
cast(MarbleGame.canvas.content, MultiplayerLevelSelectGui).updateLobbyNames();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@:rpc(server) public static function endGame() {
|
||||
if (Net.isClient) {
|
||||
if (MarbleGame.instance.world != null) {
|
||||
|
|
@ -146,10 +156,8 @@ class NetCommands {
|
|||
@:rpc(server) public static function restartGame() {
|
||||
var world = MarbleGame.instance.world;
|
||||
if (Net.isHost) {
|
||||
world.schedule(1, () -> {
|
||||
world.allClientsReady();
|
||||
return null;
|
||||
});
|
||||
world.startTime = 1e8;
|
||||
haxe.Timer.delay(() -> world.allClientsReady(), 1500);
|
||||
}
|
||||
if (Net.isClient) {
|
||||
var gui = MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1];
|
||||
|
|
|
|||