Example #1
0
 public HostedGameViewModel(HostedGameData data)
 {
     Data = data;
     var game = GameManager.Get().GetById(data.GameGuid);
     this.Id = data.Id;
     this.GameId = data.GameGuid;
     this.GameVersion = data.GameVersion;
     this.Name = data.Name;
     this.User = data.Username;
     this.Port = data.Port;
     this.Status = data.GameStatus;
     this.StartTime = data.TimeStarted;
     this.GameName = data.GameName;
     this.HasPassword = data.HasPassword;
     this.Visible = true;
     UpdateVisibility();
     switch (data.Source)
     {
         case HostedGameSource.Online:
             GameSource = "Online";
             break;
         case HostedGameSource.Lan:
             GameSource = "Lan";
             break;
     }
     if (game == null) return;
     this.CanPlay = true;
     this.GameName = game.Name;
     this.IPAddress = data.IpAddress;
 }
Example #2
0
 public HostedGameViewModel(HostedGameData data)
 {
     var game = Program.GamesRepository.Games.FirstOrDefault(x => x.Id == data.GameGuid);
     this.GameId = data.GameGuid;
     this.GameVersion = data.GameVersion;
     this.Name = data.Name;
     this.User = data.UserHosting;
     this.Port = data.Port;
     this.Status = data.GameStatus;
     this.StartTime = data.TimeStarted;
     this.GameName = "{Unknown Game}";
     if (game == null) return;
     this.CanPlay = true;
     this.GameName = game.Name;
 }
Example #3
0
 public HostedGameViewModel(HostedGameData data)
 {
     var game = GameManager.Get().GetById(data.GameGuid);
     this.GameId = data.GameGuid;
     this.GameVersion = data.GameVersion;
     this.Name = data.Name;
     this.User = data.UserHosting;
     this.Port = data.Port;
     this.Status = data.GameStatus;
     this.StartTime = data.TimeStarted;
     this.GameName = "{Unknown Game}";
     if (game == null) return;
     this.CanPlay = true;
     this.GameName = game.Name;
 }
 public HostedGameListItem(HostedGameData g)
 {
     InitializeComponent();
     Game = g;
 }
Example #5
0
 public void SendGameReady(HostedGameData game)
 {
     var m = new Message(game.Username + "@of.octgn.net", MessageType.normal, "", "gameready");
     m.GenerateId();
     m.AddChild(game);
     Xmpp.Send(m);
 }
Example #6
0
        public void OnGameHostResponse(HostedGameData data)
        {
            if (_waitingRequestId != data.Id)
                return;
            lock (_users)
            {
				Log.InfoFormat("[{0}] Got Hosted Game Data {1}",this,data);
                if (State != MatchmakingQueueState.WaitingForHostedGame)
                {
                    // Actually this can happen if someone cancels out of the queue
                    //Log.Fatal("Timeed out before hosted game could be returned. Need to increase timeout.");
                    //this._hostGameTimeout.When = new TimeSpan(0,0,(int)_hostGameTimeout.When.TotalSeconds + 5);
                    return;
                }
                // Send all users a message telling them the info they need to connect to game server
                // Kick all the users from the queue.
                var message = new Message(new Jid("*****@*****.**"), MessageType.normal, "", "gameready");
                message.ChildNodes.Add(data);
				Log.InfoFormat("[{0}] Sending users game data",this);
                foreach (var u in _users.Where(x => x.IsInReadyQueue).ToArray())
                {
                    message.To = u.JidUser;
                    message.GenerateId();
                    this.Bot.Xmpp.Send(message);
                    _users.Remove(u);
                }
                // set time to game
                AverageTime.Cycle();
                State = MatchmakingQueueState.WaitingForUsers;
            }
        }
        private void OnGameReady(HostedGameData obj)
        {
            try
            {
                Log.InfoFormat("Game is ready {0}",obj);
                _lastMatchmakingMessage = DateTime.Now;
                Log.Info("Getting game...");
                var game = GameManager.Get().GetById(obj.GameGuid);
                Program.LobbyClient.CurrentHostedGamePort = (int)obj.Port;
                //Program.GameSettings.UseTwoSidedTable = true;
                Log.Info("Creating game engine");
                Program.GameEngine = new GameEngine(game, Program.LobbyClient.Me.UserName, false, this._currentQueue.ToString().ToLower());
                Program.IsHost = false;
                Program.IsMatchmaking = true;
                Program.GameMode = this._mode;

                var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

                // Should use gameData.IpAddress sometime.
                Program.Client = new ClientSocket(hostAddress, (int)obj.Port);
                Log.Info("Connecting...");
                Program.Client.Connect();
                this._dispatcher.Invoke(new Action(() =>
                {
                    Log.Info("Launching play window");
                    WindowManager.PlayWindow = new PlayWindow();
                    WindowManager.PlayWindow.Show();
                    Log.Info("Finished launching play window");
                }));

            }
            catch (Exception e)
            {
                Log.Warn("Error joining matchmaking game", e);
                TopMostMessageBox.Show("Can't join matchmaking game, there is a problem with your connection.", "Error",MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ResetToBeginning();
        }