Пример #1
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        var count_players = NetworkServer.connections.Count;

        if (count_players <= startPositions.Count)
        {
            if (count_players == 2)
            {
                canvas.createBall();
                NetworkServer.Spawn(canvas.GetBall());
            }
            string player_tag = "racket_up";
            if (count_players == 1)
            {
                player_tag = "racket_down";
            }
            GameObject player = Instantiate(playerPrefab, startPositions[count_players - 1].position, Quaternion.identity);
            player.tag = player_tag;
            platform platform = player.GetComponent <platform>();
            platform.canvas = canvas;
            NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
        }
        else
        {
            conn.Disconnect();
        }
    }
Пример #2
0
 private void OnDestroy()
 {
     if (canvas != null)
     {
         Destroy(canvas.GetBall());
     }
 }