protected const float kListenForGroupsSecs = 2.0f; // TODO: belongs here? public override void Start(object param = null) { base.Start(); announcedGroups = new Dictionary <string, ApianGroupInfo>(); settings = appl.frontend.GetUserSettings(); _ParseGameAndGroup(); appl.GameCreatedEvt += OnGameCreatedEvt; appl.PeerJoinedGameEvt += OnPeerJoinedGameEvt; appl.AddAppCore(null); // Setup/connect fake network appl.ConnectToNetwork(settings.p2pConnectionString); if (gameId == null) { _SetState(kCreatingGame, new BeamGameNet.GameCreationData()); } else { _SetState(kJoiningGame, gameId); } appl.frontend?.OnStartMode(ModeId(), null); }
public override void Start(object param = null) { base.Start(); game = appl.mainGameInst; /// game.GameCreatedEvt += OnGameCreatedEvt; /// game.PeerJoinedGameEvt += OnPeerJoinedGameEvt; /// game.PeerLeftGameEvt += OnPeerLeftGameEvt; game.UnknownBikeEvt += OnUnknownBikeEvt; game.NewBikeEvt += OnNewBikeEvt; settings = game.frontend.GetUserSettings(); game.ClearPlayers(); game.ClearBikes(); game.ClearPlaces(); // need to "connect"first in order to have a p2pId appl.ConnectToNetwork(settings.p2pConnectionString); /// game.AddLocalPeer(core.LocalPeer); if (!settings.tempSettings.ContainsKey("gameId")) { _SetState(kCreatingGame, new BeamGameNet.GameCreationData()); } else { _SetState(kJoiningGame, settings.tempSettings["gameId"]); } game.frontend?.OnStartMode(ModeId(), null); }
public static void Save(BeamUserSettings settings) { System.IO.Directory.CreateDirectory(path); string filePath = path + Path.DirectorySeparatorChar + fileBaseName + ".json"; BeamUserSettings saveSettings = new BeamUserSettings(settings); saveSettings.tempSettings = new Dictionary <string, string>(); // Don't persist temp settings File.WriteAllText(filePath, JsonConvert.SerializeObject(saveSettings, Formatting.Indented)); }
public BeamUserSettings(BeamUserSettings source) { if (version != source.version) { throw(new Exception($"Invalid settings version: {source.version}")); } startMode = source.startMode; screenName = source.screenName; p2pConnectionString = source.p2pConnectionString; ethNodeUrl = source.ethNodeUrl; ethAcct = source.ethAcct; localPlayerCtrlType = source.localPlayerCtrlType; aiBikeCount = source.aiBikeCount; regenerateAiBikes = source.regenerateAiBikes; defaultLogLevel = source.defaultLogLevel; logLevels = source.logLevels ?? new Dictionary <string, string>(); tempSettings = source.tempSettings ?? new Dictionary <string, string>(); }
public static BeamUserSettings Load(string baseName = defaultBaseName) { fileBaseName = baseName; BeamUserSettings settings; string filePath = path + Path.DirectorySeparatorChar + fileBaseName + ".json"; try { settings = JsonConvert.DeserializeObject <BeamUserSettings>(File.ReadAllText(filePath)); } catch (Exception) { settings = BeamUserSettings.CreateDefault(); } // TODO: in real life this should do at least 1 version's worth of updating. if (settings.version != currentVersion) { // settings = BeamUserSettings.CreateDefault(); throw(new Exception($"Invalid settings version: {settings.version}")); } return(settings); }
private void _UpdateLocalPeer() { BeamUserSettings settings = frontend.GetUserSettings(); LocalPeer = new BeamNetworkPeer(gameNet.LocalP2pId(), settings.screenName); }