Example #1
0
        public static void LoadArenaComplete(int _fromClient, Packet _packet)
        {
            int _clientIdCheck = _packet.ReadInt();

            if (_fromClient == _clientIdCheck)
            {
                Server.clients[_fromClient].player.isLoadComplete = true;

                if (Server.isEveryoneLoadComplete())
                {
                    ServerSend.StartGame();
                }
            }
            else
            {
                Console.WriteLine($"Player \"{Server.clients[_fromClient].player.username}\" (ID : {_fromClient}) has assumed the wrong client ID ({_clientIdCheck})");
            }
        }
Example #2
0
        public static void SendRoleIDRequest(int _fromClient, Packet _packet)
        {
            int _clientIDCheck = _packet.ReadInt();

            if (_fromClient == _clientIDCheck)
            {
                ServerSend.SendRoleToPlayer(_fromClient);
                Server.clients[_fromClient].player.isRoleReveal = true;

                if (Server.isEveryoneRevealTheirRole())
                {
                    ServerSend.EveryoneKnowTheirRole();

                    for (int i = 1; i <= Server.MaxPlayers; i++)
                    {
                        ServerSend.SendPlayerCardInHand(i);
                    }
                }
            }
        }
Example #3
0
        public static void WelcomeReceived(int _fromClient, Packet _packet)
        {
            int    _clientIdCheck = _packet.ReadInt();
            string _username      = _packet.ReadString();

            Console.WriteLine($"{Server.clients[_fromClient].tcp.socket.Client.RemoteEndPoint} | {_username} connected successfully and is now player {_fromClient}");
            if (_fromClient != _clientIdCheck)
            {
                Console.WriteLine($"Player \"{_username}\" (ID : {_fromClient}) has assumed the wrong client ID ({_clientIdCheck})");
            }
            Server.clients[_fromClient].SendIntoGame(_username);

            int _length = Server.clients.Count;

            for (int i = 1; i <= _length; i++)
            {
                if (Server.clients[i] != null)
                {
                    ServerSend.SpawnPlayerInLobby(i);
                }
            }
        }
        public void SendIntoGame(string _playerName)
        {
            player = new Player(id, _playerName);

            foreach (Client _client in Server.clients.Values)
            {
                if (_client.player != null)
                {
                    if (_client.id != id)
                    {
                        ServerSend.SpawnPlayer(id, _client.player);
                    }
                }
            }

            foreach (Client _client in Server.clients.Values)
            {
                if (_client.player != null)
                {
                    ServerSend.SpawnPlayer(_client.id, player);
                }
            }
        }