private void InitClient(tk.TcpClient client)
    {
        if (spawnCarswClients)
        {
            CarSpawner spawner = GameObject.FindObjectOfType <CarSpawner>();

            if (spawner)
            {
                if (_server.debug)
                {
                    Debug.Log("spawning car.");
                }

                spawner.Spawn(client.gameObject.GetComponent <tk.JsonTcpClient>());
            }
        }
        else
        {
            //we are in the front end.
            tk.TcpMenuHandler handler = GameObject.FindObjectOfType <TcpMenuHandler>();

            if (handler)
            {
                if (_server.debug)
                {
                    Debug.Log("init menu handler.");
                }

                handler.Init(client.gameObject.GetComponent <tk.JsonTcpClient>());
            }
        }
    }
    private void InitClient(tk.TcpClient client)
    {
        if (privateAPI) // private API client server
        {
            PrivateAPI privateAPIHandler = GameObject.FindObjectOfType <PrivateAPI>();
            if (privateAPIHandler != null)
            {
                if (_server.debug)
                {
                    Debug.Log("init private API handler.");
                }

                privateAPIHandler.Init(client.gameObject.GetComponent <tk.JsonTcpClient>());
            }
        }

        else // normal client server
        {
            if (spawnCarswClients) // we are on in a track scene
            {
                CarSpawner spawner = GameObject.FindObjectOfType <CarSpawner>();
                if (spawner != null)
                {
                    if (_server.debug)
                    {
                        Debug.Log("spawning car.");
                    }

                    spawner.Spawn(client.gameObject.GetComponent <tk.JsonTcpClient>(), false);
                }
            }
            else //we are in the menu
            {
                tk.TcpMenuHandler handler = GameObject.FindObjectOfType <TcpMenuHandler>();
                if (handler != null)
                {
                    if (_server.debug)
                    {
                        Debug.Log("init menu handler.");
                    }

                    handler.Init(client.gameObject.GetComponent <tk.JsonTcpClient>());
                }
            }
        }
    }
Exemple #3
0
    private void InitClient(tk.TcpClient client)
    {
        //Is there a race manager active?
        RaceManager raceMan = GameObject.FindObjectOfType <RaceManager>();

        if (raceMan != null)
        {
            if (_server.debug)
            {
                Debug.Log("client joined race.");
            }

            raceMan.OnClientJoined(client.gameObject.GetComponent <tk.JsonTcpClient>());
        }
        else if (spawnCarswClients)
        {
            CarSpawner spawner = GameObject.FindObjectOfType <CarSpawner>();

            if (spawner)
            {
                if (_server.debug)
                {
                    Debug.Log("spawning car.");
                }

                spawner.Spawn(client.gameObject.GetComponent <tk.JsonTcpClient>());
            }
        }
        else
        {
            //we are in the front end.
            tk.TcpMenuHandler handler = GameObject.FindObjectOfType <TcpMenuHandler>();

            if (handler)
            {
                if (_server.debug)
                {
                    Debug.Log("init menu handler.");
                }

                handler.Init(client.gameObject.GetComponent <tk.JsonTcpClient>());
            }
        }
    }