Exemplo n.º 1
0
 public Channel this[GPlayer player] => LobbyList.GetLobby(player.Lobby);
Exemplo n.º 2
0
        public void PlayerSelectLobby(GPlayer player, Packet packet, bool RequestJoinGameList = false)
        {
            var lp = player.Lobby;

            //Lê Id do Lobby
            if (!packet.ReadByte(out byte lobbyId))
            {
                return;
            }

            var lobby = LobbyList.GetLobby(lobbyId);

            if (lp != null)
            {
                lobby.RemovePlayer(player);
            }

            //Caso o lobby não existir
            if (lobby == null)
            {
                player.SendResponse(new byte[] { 0x95, 0x00, 0x02, 0x01, 0x00 });
                throw new Exception("Player Select Invalid Lobby");
            }
            //Se estiver lotado
            if (lobby.IsFull)
            {
                player.SendResponse(new byte[] { 0x4E, 0x00, 0x02 });
                throw new Exception("Player Selected Lobby Full");
            }
            // ## add player
            if (lobby.AddPlayer(player))
            {
                try
                {
                    if (RequestJoinGameList == false)
                    {
                        // player.SendResponse(new byte[] { 0x95, 0x00, 0x02, 0x01, 0x00 });

                        player.SendResponse(ShowEnterLobby(1));

                        player.SendResponse(new byte[] { 0xF6, 0x01, 0x00, 0x00, 0x00, 0x00 });
                    }
                    if (lp == null)
                    {
                        int Year     = DateTime.Now.Year;
                        int Month    = DateTime.Now.Month;
                        int Day      = DateTime.Now.Day;
                        var _db      = new PangyaEntities();
                        var LoginReg = _db.Pangya_Item_Daily_Log.FirstOrDefault(c => c.UID == player.GetUID);

                        if (LoginReg == null)
                        {
                            new LoginDailyRewardSystem().PlayerDailyLoginCheck(player, 0);
                        }
                        else
                        {
                            if (LoginReg.RegDate.Year == Year && LoginReg.RegDate.Month == Month && Day == LoginReg.RegDate.Day)
                            {
                                new LoginDailyRewardSystem().PlayerDailyLoginCheck(player, 1);
                            }
                            else
                            {
                                new LoginDailyRewardSystem().PlayerDailyLoginCheck(player, 0);
                            }
                        }
                    }
                    // ## if request join lobby
                    if (RequestJoinGameList)
                    {
                        //player.SendResponse(new byte[] { 0x95, 0x00, 0x02, 0x01, 0x00 });

                        player.SendResponse(ShowEnterLobby(1));

                        player.SendResponse(new byte[] { 0xF6, 0x01, 0x00, 0x00, 0x00, 0x00 });

                        lobby.JoinMultiplayerGamesList(player);
                    }
                }
                finally
                {
                }
            }
        }