コード例 #1
0
    private GameObject InstantiateItem(int itemType)
    {
        var prefab   = _gameManager.GetItemPrefab(itemType);
        var position = RandomPosition();
        var ret      = GameObject.Instantiate(prefab, position, Quaternion.identity);
        var item     = ret.GetComponent <ItemScript>();

        item.NetworkId = _itemNetworkId;
        WSServer.SpawnItem(new SerDeSpawnItem
        {
            ItemType  = itemType,
            Position  = position,
            NetworkId = _itemNetworkId,
        });

        item.DestroyCallback += networkId =>
                                WSServer.DestroyItem(networkId);

        ++_itemNetworkId;
        return(ret);
    }