コード例 #1
0
        private void Server_CreateCollection()
        {
            if (!PhotonNetwork.LocalPlayer.IsMasterClient)
            {
                return;
            }

            _logger.Log($"UNetItemCollectionCreator - Server_CreateCollection viewId: {this.photonView.ViewID}, _isPlayerCollection: {_isPlayerCollection}", this);

            if (_isPlayerCollection)
            {
                var bridge = GetComponent <PUN2ActionsBridge>();
                if (bridge == null)
                {
                    _logger.Error($"Trying to sync collection to client, but no {nameof(PUN2ActionsBridge)} found on object!", this);
                    return;
                }

                var guid = System.Guid.NewGuid();

                collection = bridge.Server_AddCollectionToServerAndClient(collectionName: _collectionName, collectionGuid: guid, slotCount: slotCount);
                bridge.Server_SetCollectionPermissionOnServerAndClient(collectionGuid: guid, permission: _permission);
            }
            else
            {
                collection = PUN2CollectionUtility.CreateServerItemCollection(_slotCount, _collectionName, System.Guid.NewGuid(), this.photonView);
            }
        }
コード例 #2
0
        public void TargetRpc_AddCollection(PhotonView owner, string collectionName, Guid collectionGuid, int slotCount)
        {
            var collection = PUN2ActionsBridge.collectionFinder.GetClientCollection(collectionGuid);

            if (collection == null)
            {
                collection = PUN2CollectionUtility.CreateClientItemCollection(slotCount, collectionName, collectionGuid, owner, bridge);
            }
        }
コード例 #3
0
        private void Server_CreateCollection()
        {
            if (!PhotonNetwork.LocalPlayer.IsMasterClient)
            {
                return;
            }

            _logger.Log($"PUN2EquipmentCollectionCreator - Server_CreateCollection ViewId: {this.photonView.ViewID}, _isPlayerCollection: {_isPlayerCollection}", this);
            if (_isPlayerCollection)
            {
                var bridge = GetComponent <PUN2ActionsBridge>();
                if (bridge == null)
                {
                    _logger.Error($"Trying to sync collection to client, but no {nameof(PUN2ActionsBridge)} found on object!", this);
                    return;
                }

                var guid = System.Guid.NewGuid();

                collection = bridge.Server_AddEquipmentCollectionToServerAndClient(
                    //owner: this.photonView,
                    collectionName: _collectionName,
                    collectionGuid: guid,
                    slots: _slots//.Select(o => string.Join(":", o.equipmentTypes.Select(j => j.ID.ToString() )) ).ToArray()
                    );

                bridge.Server_SetCollectionPermissionOnServerAndClient(
                    collectionGuid: guid,
                    permission: _permission
                    );
            }
            else
            {
                var equippableCharacter = GetComponent <IEquippableCharacter <IEquippableItemInstance> >();
                collection = PUN2CollectionUtility.CreateServerEquipmentCollection(_collectionName, System.Guid.NewGuid(), this.photonView, _slots.Select(o => o.ToSlotInstance(equippableCharacter)).ToArray(), equippableCharacter);
            }
        }