Пример #1
0
        public static void PlayerAttack(int _fromClient, Packet _packet)
        {
            int _id = _packet.ReadInt();

            if (Server.clients[_fromClient].player != null)
            {
                ServerSend.PlayerAttacked(Server.clients[_fromClient].player, Server.clients[_id].player);

                Server.clients[_id].player.hp -= 1;

                if (Server.clients[_id].player.hp <= 0)
                {
                    ServerSend.PlayerDown(Server.clients[_id].player);

                    int    i      = 0;
                    Player winner = null;
                    foreach (Client _client in Server.clients.Values)
                    {
                        if (_client.player != null && _client.player.hp > 0)
                        {
                            i++;
                            winner = _client.player;
                        }
                    }
                    if (i == 1)
                    {
                        ServerSend.EndGame(winner);
                        // ELIMINATE ALL PLAYER DATA, RESET GAME, fix camera on victory.
                        // lesch olle jusa!
                        foreach (Client _client in Server.clients.Values)
                        {
                            _client.Disconnect();
                        }
                        Server.clients = new Dictionary <int, Client>();
                        Server.InitializeServerData();
                    }
                }
            }
        }