Ejemplo n.º 1
0
        public static PUN2ClientEquipmentCollection <IEquippableItemInstance> CreateClientEquipmentCollection(
            string collectionName,
            System.Guid collectionGuid,
            PhotonView owner,
            PUN2ActionsBridge playerBridge,
            EquipmentCollectionSlot <IEquippableItemInstance>[] slots,
            IEquippableCharacter <IEquippableItemInstance> character)
        {
            var collection = new PUN2ClientEquipmentCollection <IEquippableItemInstance>(owner, playerBridge, 0, character)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.slots = slots;
            for (int i = 0; i < collection.slots.Length; i++)
            {
                collection.slots[i].collection = collection;
                collection.slots[i].index      = i;
            }

            collection.Register();

            // The server's owner object always has read/write permission.
            PUN2PermissionsRegistry.collections.SetPermission(collection, owner, ReadWritePermission.None);

            _logger.Log($"[Client] Created and registered equipment collection with name '{collection.collectionName}' and guid '{collection.ID}' for ViewID: {owner.ViewID}", collection);

            return(collection);
        }
Ejemplo n.º 2
0
        protected override void Awake()
        {
            base.Awake();

            bridge = GetComponent <PUN2ActionsBridge>();

            // Register to collection events. First is for when we are a client and the later one is for the master.
            if (PhotonNetwork.IsMasterClient)
            {
                ServerCollectionRegistry.byName.OnAddedItem += CollectionRegistry_OnItemAdded;
            }
            else
            {
                CollectionRegistry.byName.OnAddedItem += CollectionRegistry_OnItemAdded;
            }
        }
Ejemplo n.º 3
0
        private PUN2CollectionBase <IItemInstance> GetCollection(PUN2ActionsBridge bridge)
        {
            // The collection belongs to this identity
            var cols = PUN2PermissionsRegistry.collections.GetAllWithPermission(this.photonView);
            var triggerCollection = cols.FirstOrDefault(o => o.obj.collectionName == _collectionName);

            if (triggerCollection.obj != null)
            {
                // NOTE: The collection belongs to this object's network identity.
                // NOTE: We're handling the lifetime of the object and handle registration of the collection on clients.
                return(triggerCollection.obj as PUN2CollectionBase <IItemInstance>);
            }

            // The collection belongs to the player using this trigger
            var cols2            = PUN2PermissionsRegistry.collections.GetAllWithPermission(bridge.photonView);
            var playerCollection = cols2.FirstOrDefault(o => o.obj.collectionName == _collectionName);

            return(playerCollection.obj as PUN2CollectionBase <IItemInstance>);
        }
Ejemplo n.º 4
0
 public PUN2VendorReplicator(PUN2ActionsBridge bridge, ILogger logger = null)
 {
     this.bridge = bridge;
     this.logger = logger ?? new UnityLogger("[PUN2] ");
 }
 public PUN2ClientCurrencyCollection(PhotonView owner, PUN2ActionsBridge actionsBridge, ILogger logger = null)
     : base(owner, logger)
 {
     this.actionsBridge = actionsBridge;
 }
Ejemplo n.º 6
0
 public PUN2ClientCollection(PhotonView owner, PUN2ActionsBridge actionBridge, int slotCount, ILogger logger = null)
     : base(owner, slotCount, logger)
 {
     this.actionBridge = actionBridge;
 }
Ejemplo n.º 7
0
        //private static PUN2EquipmentInputValidator inputValidator;
        //static PUN2EquipmentReplicator()
        //{
        //    inputValidator = new PUN2EquipmentInputValidator(new UnityLogger("[PUN2][Validation] "));
        //}

        public PUN2EquipmentReplicator(PUN2ActionsBridge bridge, ILogger logger = null)
        {
            this.bridge = bridge;
            //this.logger = logger ?? new UnityLogger("[PUN2] ");
        }
 public PUN2ClientEquipmentCollection(PhotonView owner, PUN2ActionsBridge actionBridge, int slotCount, IEquippableCharacter <TEquippableType> character, ILogger logger = null)
     : base(slotCount, character, logger)
 {
     this.actionBridge = actionBridge;
     this.owner        = owner;
 }
        public static PUN2ClientCurrencyCollection CreateClientCurrencyCollection(string collectionName, System.Guid collectionGuid, PhotonView owner, PUN2ActionsBridge playerBridge)
        {
            var collection = new PUN2ClientCurrencyCollection(owner, playerBridge, _logger)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.Register();

            // Set permission for this client; If we own it it will be added to the registry list.
            PUN2PermissionsRegistry.collections.SetPermission(collection, playerBridge.photonView, ReadWritePermission.None);

            _logger.Log($"[Client] Created and registered currency collection with name {collection.collectionName} and guid {collection.ID} for ViewID: {owner.ViewID}", collection);
            return(collection);
        }
Ejemplo n.º 10
0
        public static PUN2ClientCollection <IItemInstance> CreateClientItemCollection(int slotCount, string collectionName, System.Guid collectionGuid, PhotonView owner, PUN2ActionsBridge playerBridge)
        {
            var collection = new PUN2ClientCollection <IItemInstance>(owner, playerBridge, slotCount)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.Register();

            // Set permission for this client; If we own it it will be added to the registry list.
            PUN2PermissionsRegistry.collections.SetPermission(collection, playerBridge.photonView, ReadWritePermission.None);

            _logger.Log($"[Client] Created and registered collection with name '{collection.collectionName}' and guid '{collection.ID}' for ViewID: {owner.ViewID}", collection);
            return(collection);
        }
Ejemplo n.º 11
0
        public static PUN2ClientCollection <IVendorProduct <IItemInstance> > CreateClientVendorItemCollection(int slotCount, string collectionName, System.Guid collectionGuid, PhotonView owner, PUN2ActionsBridge playerBridge)
        {
            var collection = new PUN2ClientCollection <IVendorProduct <IItemInstance> >(owner, playerBridge, slotCount)
            {
                collectionName = collectionName,
                ID             = collectionGuid
            };

            collection.Register();

            // NOTE: Do not give the player read+write access to the vendor collection; That way the client could set items directly into the vendor collection.
            PUN2PermissionsRegistry.collections.SetPermission(collection, owner, ReadWritePermission.Read);

            _logger.Log($"[Client] Created and registered vendor item collection with name '{collectionName}' and guid '{collectionGuid}' for ViewID: {owner.ViewID}", collection);
            return(collection);
        }