Ejemplo n.º 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();
        }
 private void OnClickStart(HUDTextButton sender, HUDButtonEventArgs e)
 {
     if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby && _server.SessionCount == _server.SessionCapacity)
     {
         byte[] binData = _server.GetLobbySyncData();
         _server.StartLobbySync(binData);
     }
 }
Ejemplo n.º 3
0
        public override void Update(SAMTime gameTime, InputState istate)
        {
            base.Update(gameTime, istate);

            if (_server.Mode == SAMNetworkConnection.ServerMode.Stopped || _server.Mode == SAMNetworkConnection.ServerMode.Error)
            {
                bool dc = false;

                if (_btnNext != null && _btnNext.IsEnabled)
                {
                    _btnNext.BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnNext.BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnNext.IsEnabled         = false;
                    dc = true;
                }
                if (_btnRand != null && _btnRand.IsEnabled)
                {
                    _btnRand.BackgroundNormal  = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnRand.BackgroundPressed = HUDBackgroundDefinition.CreateRounded(FlatColors.Asbestos, 16);
                    _btnRand.IsEnabled         = false;
                    dc = true;
                }

                if (_server.ConnType == MultiplayerConnectionType.P2P && dc && _server.Mode == SAMNetworkConnection.ServerMode.Stopped)
                {
                    Owner.HUD.ShowToast("HMSP:ConnStop", L10N.TF(L10NImpl.STR_MP_TIMEOUT_USER, (_server.SessionUserID == 0) ? "1" : "0"), 32, FlatColors.Flamingo, FlatColors.Foreground, 7f);
                }
            }

            if (_server.Mode == SAMNetworkConnection.ServerMode.BroadcastNewGame ||
                _server.Mode == SAMNetworkConnection.ServerMode.BeforeNewGame ||
                _server.Mode == SAMNetworkConnection.ServerMode.CreatingNewGame)
            {
                _loadingCog.IsVisible = true;
            }

            if (_server.SessionUserID == 0 && _nextLevelRandom)
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
                {
                    byte[] binData = _serverHost.GetLobbySyncData();
                    _server.StartLobbySync(binData);
                }

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

            if (_server.SessionUserID == 0)
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.CreatingNewGame)
                {
                    if (_nextLevelRandom)
                    {
                        SetLevelDataRandom();

                        _server.Mode = SAMNetworkConnection.ServerMode.InLobby;

                        byte[] binData = _serverHost.GetLobbySyncData();
                        _serverHost.StartLobbySync(binData);
                    }
                    else
                    {
                        _preventStopOnRem();
                        Remove();

                        HUD.AddModal(new MultiplayerRehostPanel(_server as GDMultiplayerServer), false, 0.5f, 0.5f);
                    }
                }
            }
            else
            {
                if (_server.Mode == SAMNetworkConnection.ServerMode.InLobby)
                {
                    _preventStopOnRem();

                    Remove();
                    HUD.AddModal(new MultiplayerClientLobbyPanel(_server as GDMultiplayerClient), false, 0.5f, 0.5f);
                }
            }
        }