Beispiel #1
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            _server.Update(gameTime, istate);

            if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
            {
                byte[] binData = _server.GetLobbySyncData();
                _server.StartLobbySync(binData);
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InGame)
            {
                _doNotStop = true;
                MainGame.Inst.SetMultiplayerServerLevelScreen(Levels.LEVELS[_server.LevelID], _server.Speed, _server.MusicIndex, _server);
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
                MainGame.Inst.SetOverworldScreen();
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
                MainGame.Inst.SetOverworldScreen();
            }

            UpdateHostData();
        }
Beispiel #2
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (_isDying || !Alive)
            {
                return;
            }

            _server.Update(gameTime, istate);

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);

                Remove();
                return;
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
            {
                _doNotStop = true;
                Remove();
                Owner.HUD.AddModal(new MultiplayerClientLobbyPanel(_server), true, 0.5f);
            }
        }
Beispiel #3
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            if (_isDying || !Alive)
            {
                return;
            }

            Server.Update(gameTime, istate);

            if (Server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(Server.Error, Server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);

                switch (Server.Error)
                {
                case SAMNetworkConnection.ErrorType.SessionNotFound:
                case SAMNetworkConnection.ErrorType.AuthentificationFailed:
                case SAMNetworkConnection.ErrorType.LobbyFull:
                case SAMNetworkConnection.ErrorType.GameVersionMismatch:
                    _isDying = true;
                    AddHUDOperation(new JoinErrorOperation());
                    return;

                case SAMNetworkConnection.ErrorType.BluetoothNotEnabled:
                case SAMNetworkConnection.ErrorType.P2PConnectionFailed:
                case SAMNetworkConnection.ErrorType.P2PConnectionLost:
                case SAMNetworkConnection.ErrorType.NetworkMediumInternalError:
                case SAMNetworkConnection.ErrorType.ProxyServerTimeout:
                case SAMNetworkConnection.ErrorType.UserTimeout:
                case SAMNetworkConnection.ErrorType.ServerUserTimeout:
                case SAMNetworkConnection.ErrorType.NotInLobby:
                case SAMNetworkConnection.ErrorType.LevelNotFound:
                case SAMNetworkConnection.ErrorType.LevelVersionMismatch:
                case SAMNetworkConnection.ErrorType.UserDisconnect:
                case SAMNetworkConnection.ErrorType.ServerDisconnect:
                case SAMNetworkConnection.ErrorType.BluetoothAdapterNotFound:
                case SAMNetworkConnection.ErrorType.BluetoothAdapterNoPermission:
                case SAMNetworkConnection.ErrorType.P2PNoServerConnection:
                    Remove();
                    return;

                case SAMNetworkConnection.ErrorType.None:
                default:
                    SAMLog.Error("MJLS::EnumSwitch_DU", "value = " + Server.Error);
                    break;
                }
            }

            if (Server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
            }

            if (Server.Mode == SAMNetworkConnection.ServerMode.InLobby)
            {
                _doNotStop = true;
                Remove();
                Owner.HUD.AddModal(new MultiplayerClientLobbyPanel(Server), true, 0.5f);
            }
        }
Beispiel #4
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            _server.Update(gameTime, istate);

            _btnStart.BackgroundNormal = _btnStart.BackgroundNormal.WithColor(ColorMath.Blend(FlatColors.Emerald, FlatColors.GreenSea, FloatMath.PercSin(gameTime.TotalElapsedSeconds * 5)));


            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Remove();

                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby && _server.SessionCount == _server.SessionCapacity)
            {
                _btnStart.IsVisible = true;
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InGame)
            {
                MainGame.Inst.SetMultiplayerServerLevelScreen(Levels.LEVELS[_server.LevelID], _server.Speed, _server.MusicIndex, _server);
            }
        }
Beispiel #5
0
        public MainGame() : base()
        {
            Backend = new GDServerAPI(GDBridge);
            //Backend = new DummyGDServerAPI();

            if (GDConstants.FLAVOR == GDFlavor.IAB)
            {
                GDBridge.IAB.Connect(GDConstants.IABList);
            }

            Profile = new PlayerProfile();

            var sdata = FileHelper.Inst.ReadDataOrNull(GDConstants.PROFILE_FILENAME);             // %LOCALAPPDATA%\IsolatedStorage\...

            if (sdata != null)
            {
                try
                {
#if DEBUG
                    var starttime = Environment.TickCount;
#endif
                    Profile.DeserializeFromString(sdata);
#if DEBUG
                    SAMLog.Debug($"Deserialized profile in {Environment.TickCount - starttime}ms");
#endif
                }
                catch (Exception e)
                {
                    SAMLog.Error("Deserialization", e);

                    Profile = new PlayerProfile();
                    SaveProfile();
                }
            }
            else
            {
                SaveProfile();
            }

            SAMLog.LogEvent += SAMLogOnLogEvent;
            SAMLog.AdditionalLogInfo.Add(GetLogInfo);

            for (int i = 0; i < MAX_LOG_SEND_COUNT; i++)
            {
                LastSendLogTimes[i] = float.MinValue;
            }

            L10NImpl.Init(Profile.Language);

            AddAgent(new HighscoreAgent());

            Inst = this;
        }
Beispiel #6
0
        public MainGame() : base()
        {
            Backend = new SGServerAPI(SGBridge);
            //Backend = new DummySGServerAPI();

            SGBridge.IAB.Connect(SGConstants.IABList);

            Settings = new UserSettings();

            var sdata = FileHelper.Inst.ReadDataOrNull(SGConstants.PROFILE_FILENAME);             // %LOCALAPPDATA%\IsolatedStorage\...

            if (sdata != null)
            {
                try
                {
#if DEBUG
                    var starttime = Environment.TickCount;
#endif
                    Settings.DeserializeFromString(sdata);
#if DEBUG
                    SAMLog.Debug($"Deserialized settings in {Environment.TickCount - starttime}ms");
#endif
                }
                catch (Exception e)
                {
                    SAMLog.Error("Deserialization", e);

                    Settings = new UserSettings();
                    SaveUserConfig();
                }
            }
            else
            {
                SaveUserConfig();
            }

            SAMLog.LogEvent += SAMLogOnLogEvent;
            SAMLog.AdditionalLogInfo.Add(GetLogInfo);

            for (int i = 0; i < MAX_LOG_SEND_COUNT; i++)
            {
                LastSendLogTimes[i] = float.MinValue;
            }

            L10NImpl.Init(Settings.Language);

            Inst = this;
        }
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            base.OnUpdate(gameTime, istate);

#if DEBUG
            DebugUtils.TIMING_NETWORK.Start();
            _server.Update(gameTime, istate);
            DebugUtils.TIMING_NETWORK.Stop();
#else
            _server.Update(gameTime, istate);
#endif

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                HUD.ShowToast("SCRNSC::ERR", L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);

                MainGame.Inst.SetOverworldScreen();
            }
        }
Beispiel #8
0
        protected override void DoUpdate(SAMTime gameTime, InputState istate)
        {
            _server.Update(gameTime, istate);

            if (skipUpdate)
            {
                return;
            }

            if (_server.LevelID != null && _server.LevelID.Value != _lastLevelID)
            {
                _lastLevelID = _server.LevelID.Value;

                LevelBlueprint bp;
                if (Levels.LEVELS.TryGetValue(_server.LevelID.Value, out bp))
                {
                    var d = GetFractionColorByID(bp, _server.SessionUserID + 1);
                    fracName = d.Item1;
                    _lblFraction.TextColor = d.Item2;
                }
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                Remove();

                Owner.HUD.ShowToast(null, L10NImpl.FormatNetworkErrorMessage(_server.Error, _server.ErrorData), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
                skipUpdate = true;
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped)
            {
                Remove();
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.InGame)
            {
                MainGame.Inst.SetMultiplayerClientLevelScreen(Levels.LEVELS[_server.LevelID.Value], _server.Speed.Value, _server.MusicIndex.Value, _server);
                skipUpdate = true;
            }
        }