コード例 #1
0
    public override IEnumerator Process()
    {
        yield return(WaitFor(SentBy));

        GameObject player = NetworkObject;

        if (ValidRequest(HeadsetItem))
        {
            Headset    headset       = HeadsetItem.GetComponent <Headset>();
            GameObject encryptionKey = Object.Instantiate(Resources.Load("Encryptionkey", typeof(GameObject)),
                                                          HeadsetItem.transform.parent) as GameObject;
            encryptionKey.GetComponent <EncryptionKey>().Type = headset.EncryptionKey;

            PlayerNetworkActions pna = player.GetComponent <PlayerNetworkActions>();
            string slot = UIManager.FindEmptySlotForItem(encryptionKey);
            if (pna.AddItem(encryptionKey, slot))
            {
                NetworkServer.Spawn(encryptionKey);
                headset.EncryptionKey = EncryptionKeyType.None;
                pna.PlaceInSlot(encryptionKey, slot);
            }
            else
            {
                Object.Destroy(encryptionKey);
                Debug.LogError("Could not add Encryptionkey item to player.");
            }
        }
    }
コード例 #2
0
        private IEnumerator SetItemPatiently(string slotName, GameObject obj)
        {
            //Waiting for hier name resolve
            yield return(new WaitForSeconds(0.2f));

            playerNetworkActions.AddItem(obj, slotName, true);
        }