示例#1
0
        //Lobby methods
        #region Create Lobby()

        //Lobby Creation
        public void CreateLobby(DTO.Player host)
        {
            try
            {
                //make a playerlobby and set the hostplayer member to th playerid of the host, ist lobbyid is been generated
                //its playerid is set to the playerid of the host, isawatingforplayers is true and startgame false
                PlayerLobby pl = new PlayerLobby();
                pl.HostPlayer          = (int)host.PlayerId;
                pl.LobbyId             = getLobbyId();
                pl.PlayerId            = (int)host.PlayerId;
                pl.IsWaitingForPlayers = true;  //to determine which playerlobby is still awaiting for players
                pl.StartGame           = false; //to indicate if the game is started or not

                //make a new lobby with its name is the name of the host and its id is the same as the playerlobby's id
                Lobby alobby = new Lobby();
                alobby.LobbyName = host.PlayerName;
                alobby.LobbyId   = pl.LobbyId;

                //add the lobby to the static playerlobby list
                gamelobbies.Add(new DTO.PlayerLobby(host)
                {
                    LobbyId = new DTO.Lobby()
                    {
                        LobbyId = alobby.LobbyId, LobbyName = alobby.LobbyName
                    }, IsAwaitingForPlayers = true, StartGame = false
                });

                //save all changes
                dc.Lobbies.InsertOnSubmit(alobby);
                dc.PlayerLobbies.InsertOnSubmit(pl);
                dc.SubmitChanges();
            }
            catch (Exception)
            {
            }
        }
        public void CreateLobby(DTO.Player host)
        {
            try
            {
                PlayerLobby pl = new PlayerLobby();
                pl.HostPlayer          = (int)host.PlayerId;
                pl.LobbyId             = getLobbyId();
                pl.PlayerId            = (int)host.PlayerId;
                pl.IsWaitingForPlayers = true;

                Lobby alobby = new Lobby();
                alobby.LobbyName = host.PlayerName;
                alobby.LobbyId   = pl.LobbyId;



                dc.Lobbies.InsertOnSubmit(alobby);
                dc.PlayerLobbies.InsertOnSubmit(pl);
                dc.SubmitChanges();
            }
            catch (Exception)
            {
            }
        }
 partial void DeletePlayerLobby(PlayerLobby instance);
 partial void UpdatePlayerLobby(PlayerLobby instance);
 partial void InsertPlayerLobby(PlayerLobby instance);