Example #1
0
    private void DropItem(string toDrop, byte[] item, Vector3 pos)
    {
        if (PhotonNetwork.IsMasterClient)
        {
            ItemPrefab insItem = PhotonNetwork.InstantiateSceneObject(toDrop, pos, Quaternion.identity).GetComponent <ItemPrefab>();
            insItem.Drop(item);

            //int id = insItem.GetComponent<PhotonView>().ViewID;
            //photonView.RPC("RI", RpcTarget.AllBuffered, item, id);
        }
    }
    public override void OnPlayerEnteredRoom(Player newPlayer)
    {
        if (!PhotonNetwork.IsMasterClient)
        {
            return;
        }

        ByteObjectConverter boc = new ByteObjectConverter();

        foreach (KeyValuePair <int, Item> droppedItem in droppedItems)
        {
            byte[] itemToDrop = boc.ObjectToByteArray(droppedItem.Value);

            ItemPrefab ip = PhotonView.Find(droppedItem.Key).GetComponent <ItemPrefab>();
            ip.Drop(itemToDrop);
        }
    }