Exemple #1
0
    /// <summary>
    /// Tells the client handler to send a CreateObject event to the client that just connected
    /// </summary>
    /// <param name="handler"></param>
    public void SpawnObjects(ClientHandler handler)
    {
        ConnectPlayer connectPlayer = new ConnectPlayer(handler.GetClientNetworkID());

        handler.SendPacket(connectPlayer.Serialize(), 0);

        int i        = 0;
        int prefabID = 0;

        foreach (NetworkingObject netObj in _networkingObjects)
        {
            if (i < 2)
            {
                prefabID = 1;
            }
            else
            {
                prefabID = 0;
            }
            CreateObject createObject = new CreateObject(prefabID, netObj.transform.position.x, netObj.transform.position.z, netObj.GetNetworkID(), netObj.GetPlayerNetworkID());
            i++;
            byte[] createObjectBytes = createObject.Serialize();

            handler.SendPacket(createObjectBytes, 0);
        }
    }