Exemple #1
0
    // Find the car for the given JsonTcpClient and remove it from the scene.
    public bool RemoveCar(tk.JsonTcpClient client)
    {
        GameObject toRemove = null;

        foreach (GameObject go in cars)
        {
            GameObject TcpClientObj = getChildGameObject(go, "TCPClient");

            if (TcpClientObj)
            {
                tk.TcpCarHandler handler = TcpClientObj.GetComponent <tk.TcpCarHandler>();

                if (handler != null && handler.GetClient() == client)
                {
                    toRemove = go;
                }
            }
        }

        if (toRemove != null)
        {
            cars.Remove(toRemove);
            GameObject.Destroy(toRemove);

            if (cars.Count < 2)
            {
                DeactivateSplitScreen();
            }

            return(true);
        }


        return(false);
    }
Exemple #2
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.name != target)
        {
            return;
        }
        float time = Time.fixedTime;

        Transform parent = col.transform.parent.parent;

        if (parent == null)
        {
            return;
        }

        string carName = parent.name;

        tk.TcpCarHandler client = parent.GetComponentInChildren <tk.TcpCarHandler>();

        if (client != null)
        {
            UnityMainThreadDispatcher.Instance().Enqueue(client.SendCollisionWithStartingLine(index, time));
        }

        if (privateAPI != null)
        {
            privateAPI.CollisionWithStatingLine(carName, index, time);
        }
    }
    // Find the car for the given JsonTcpClient and remove it from the scene.
    public bool RemoveCar(tk.JsonTcpClient client)
    {
        GameObject toRemove = null;

        foreach (GameObject go in cars)
        {
            GameObject TcpClientObj = getChildGameObject(go, "TCPClient");

            if (TcpClientObj != null)
            {
                tk.TcpCarHandler handler = TcpClientObj.GetComponent <tk.TcpCarHandler>();

                if (handler != null && handler.GetClient() == client)
                {
                    toRemove = go;
                }
            }
        }

        if (toRemove != null)
        {
            int iSplitScreenCam = cars.IndexOf(toRemove);
            if (GlobalState.overheadCamera)
            {
                iSplitScreenCam += 1;
            }

            if (raceCameras != null)
            {
                int carID = toRemove.GetInstanceID() - 4;
                if (raceCameras.carProgress.ContainsKey(carID))
                {
                    raceCameras.carProgress.Remove(carID);
                }
            }

            RemoveTimer(toRemove);
            cars.Remove(toRemove);

            if (cameras.Count > iSplitScreenCam)
            {
                GameObject SplitScreenCamGo = cameras[iSplitScreenCam];
                RemoveSplitScreenCam(SplitScreenCamGo);
            }
            GameObject.Destroy(toRemove);

            Debug.Log("Removed car");
            return(true);
        }
        else
        {
            Debug.LogError("failed to remove car");
            return(false);
        }
    }
 public void RemoveGhostCars()
 {
     foreach (GameObject car in cars)
     {
         tk.TcpCarHandler tcpCarHandler = car.GetComponentInChildren <tk.TcpCarHandler>();
         if (tcpCarHandler != null && tcpCarHandler.IsGhostCar())
         {
             tcpCarHandler.Boot();
         }
     }
 }
Exemple #5
0
    // Find the car for the given JsonTcpClient and remove it from the scene.
    public bool RemoveCar(tk.JsonTcpClient client)
    {
        GameObject toRemove = null;

        foreach (GameObject go in cars)
        {
            GameObject TcpClientObj = getChildGameObject(go, "TCPClient");

            if (TcpClientObj != null)
            {
                tk.TcpCarHandler handler = TcpClientObj.GetComponent <tk.TcpCarHandler>();

                if (handler != null && handler.GetClient() == client)
                {
                    toRemove = go;
                }
            }
        }

        if (toRemove != null)
        {
            int        iSplitScreenCam  = cars.IndexOf(toRemove);
            GameObject SplitScreenCamGo = cameras[iSplitScreenCam];

            RemoveTimer(toRemove);
            cars.Remove(toRemove);
            RemoveSplitScreenCam(SplitScreenCamGo);
            GameObject.Destroy(toRemove);

            Debug.Log("Removed car");
            return(true);
        }
        else
        {
            Debug.LogError("failed to remove car");
            return(false);
        }
    }