Exemple #1
0
        private GameListing GSListing;  // The Stores the Game server list used by list view
        //////////////////////////////////////////////////

        ///// STRUCTORS //////////////////////////////////
        public WindowPortal(App app)
        {
            InitializeComponent();
            Parent      = app;
            GSSelection = null;
            GSListing   = null;

            this.btnJoinServer.IsEnabled = false;
        }
Exemple #2
0
 public GameBase(int gameId, Player player, GameListing currentGame, int minPlayers, int maxPlayers)
 {
     if (player == null)
     {
         throw new ArgumentException();
     }
     this.GameId = gameId;
     players.Add(player);
     _minPlayers = minPlayers;
     _maxPlayers = maxPlayers;
     CurrentGame = currentGame;
 }
Exemple #3
0
 /// <summary>
 /// Gets game server list from portal
 /// </summary>
 private void LoadGameServerListing()
 {
     try
     {
         GSListing = Parent.UPSConnection.QueryGameServers(Parent.Token);
         this.lvServerListing.ItemsSource = GSListing.GameServerDetailList;
     } catch (ServerConnectionException) {
         MessageBox.Show("Problem connecting to portal server, attempting to reconnect",
                         "Error Loading Game Server List!");
         Parent.UPSConnection.Reconnect();
     } catch (PortalServerException) {
         MessageBox.Show("The portal server could not process your request at this time",
                         "Error Loading Game Server List!");
     }
 }
        public GameListing QueryGameServers(string token, out ECode ec)
        {
            ec = ECode.None;
            GameListing gsl = null;

            if (UserRegistry.IsClientRegistered(token))
            {
                gsl = GenerateGameServerListing();
            }
            else
            {
                ec = ECode.AuthenticationFail;
            }

            return(gsl);
        }
        internal GameListing GenerateGameServerListing()
        {
            GameListing       gsl  = null;
            List <GameDetail> list = new List <GameDetail>();

            foreach (KeyValuePair <string, ClientSession> kvp in GameRegistry)
            {
                string        name    = kvp.Value.PUID;
                string        address = kvp.Value.ClientAddress;
                List <string> registeredUsernames
                    = new List <string>(((GameSession)kvp.Value).PlayerList.Keys);

                list.Add(new GameDetail(name, address, registeredUsernames));
            }

            gsl = new GameListing(list);
            return(gsl);
        }
Exemple #6
0
    public void PopulateGames()
    {
        foreach (GameObject entry in entries)
        {
            Destroy(entry, 0);
        }
        entries.Clear();
        scrollArea.sizeDelta = new Vector2(scrollArea.sizeDelta.x, (lobbyStorage.Length * 35) + 40);
        int i = 0;

        foreach (GameMatchmakingInfo info in lobbyStorage)
        {
            GameObject newListing = GameObject.Instantiate(GameEntryPrefab, scrollArea) as GameObject;
            entries.Add(newListing);
            RectTransform rt = newListing.GetComponent <RectTransform>();
            rt.anchoredPosition = new Vector2(0, -5 - (35 * i));
            GameListing gl = newListing.GetComponent <GameListing>();
            gl.info = info;
            gl.UpdateLabel();
            i++;
        }
    }
        public GameListing QueryGameServers(string token)
        {
            ECode       ec    = ECode.None;
            GameListing value = null;

            try
            {
                value = Server.QueryGameServers(token, out ec);
            } catch (ArgumentNullException ex) {
                throw new ServerConnectionException(ECode.ConnectionError, null, ERRMSG_CONNECTION, ex);
            } catch (CommunicationException ex) {
                throw new ServerConnectionException(ECode.ConnectionError, null, ERRMSG_CONNECTION, ex);
            } catch (TimeoutException ex) {
                throw new ServerConnectionException(ECode.ConnectionError, null, ERRMSG_CONNECTION, ex);
            }

            if (ec != ECode.None)
            {
                throw new PortalServerException(ec, "Internal error occurred at: QueryGameServers()");
            }

            return(value);
        }
Exemple #8
0
 public void SetMatch(GameListing desc)
 {
     nameText.text = desc.name;
     playersText.text = desc.count.ToString();
     this.desc = desc;
 }
Exemple #9
0
 public void DeselectMatch()
 {
     selected = null;
     detailsDisableObject.SetActive(false);
 }
Exemple #10
0
    public void SelectMatch(GameListing desc)
    {
        selected = desc;
        detailsDisableObject.SetActive(true);
        worldDescription.text = desc.name;

        passwordObject.SetActive(desc.match != null && desc.match.isPrivate);
        passwordInput.text = "";
    }
Exemple #11
0
    private IEnumerator RefreshList()
    {
        testLAN.Initialize();
        //testLAN.StopBroadcast();
        testLAN.StartAsClient();
        bool test = false;
        testLAN.OnReceive += (ip, data) =>
        {
            var listing = new GameListing
            {
                address = ip,
            };

            lanGames[ip] = listing;

            ParseName(data,
                      out listing.name,
                      out listing.version,
                      out listing.count);

            listing.name = "(LOCAL) " + listing.name;
        };

        while (hostID == -1)
        {
            testLAN.broadcastData = hostedname + "!" + (int)version + "?" + clients.Count;

            var request = new ListMatchRequest();
            request.nameFilter = "";
            request.pageSize = 32;

            match.ListMatches(request, matches =>
            {
                matchGames.Clear();

                if (!matches.success)
                {
                    newerVersionDisableObject.SetActive(false);
                    noWorldsDisableObject.SetActive(false);
                    cantConnectDisableObject.SetActive(true);

                    RefreshListing();

                    return;
                }

                var list = matches.matches;

                var valid = list.Where(m => GetVersion(m) == (int)version);
                var newer = list.Where(m => GetVersion(m) >  (int)version);

                newerVersionDisableObject.SetActive(newer.Any());
                noWorldsDisableObject.SetActive(!newer.Any() && !valid.Any());
                cantConnectDisableObject.SetActive(false);
                worlds.SetActive(valid.Select(m => ConvertListing(m)));

                matchGames.Clear();
                matchGames.AddRange(valid.Select(m => ConvertListing(m)));

                if (selected != null
                 && selected.match != null
                 && !list.Any(m => m.networkId == selected.match.networkId))
                {
                    DeselectMatch();
                }

                RefreshListing();
            });

            yield return new WaitForSeconds(5);
        }
    }
Exemple #12
0
    private GameListing ConvertListing(MatchDesc desc)
    {
        var listing = new GameListing();

        ParseName(desc.name,
                  out listing.name,
                  out listing.version,
                  out listing.count);

        listing.count = desc.currentSize;
        listing.match = desc;

        return listing;
    }
Exemple #13
0
 private void InitialiseWorld(GameListing desc, WorldPanel panel)
 {
     panel.SetMatch(desc);
 }