Example #1
0
 protected virtual void InitilizeItemSlots()
 {
     for (int i = 0; i < Capacity; i++)
     {
         var itemSlotData = new ItemSlotData
         {
             ParentNetId = AttachedNetworkIdentity.netId,
             SlotIndex   = i,
             SlotType    = ItemSlotType.Any
         };
         InventorySlotData.Add(i, itemSlotData);
     }
 }
Example #2
0
 public Slot(Transform slotTransform, ItemSlotData slotData, int slotIndex)
 {
     SlotTransform = slotTransform;
     SlotData      = slotData;
     SlotIndex     = slotIndex;
     if (!SlotData.Occupant())
     {
         return;
     }
     GameManager.ItemDictionary.TryGetValue(SlotData.OccupantItemData.ItemId, out var itemObject);
     if (itemObject == null)
     {
         return;
     }
     ItemReference = itemObject.GetComponent <Item>();
 }
Example #3
0
        protected override void InitilizeItemSlots()
        {
            base.InitilizeItemSlots();
            var count = 0;

            foreach (var equipmentSlot in SlotReferences)
            {
                var itemslotData = new ItemSlotData
                {
                    ParentNetId = AttachedNetworkIdentity.netId,
                    SlotIndex   = InventorySlotData.Count + count,
                    SlotType    = equipmentSlot.Key
                };
                InventorySlotData.Add(count + Capacity, itemslotData);
                count++;
            }
        }
Example #4
0
        private void EquipmentSlotChanged(ItemSlotData itemData, SlotEquipable equipableSlot)
        {
            // destroy localEquip if Exists
            if (equipableSlot.CurrentEquip)
            {
                Destroy(equipableSlot.CurrentEquip.gameObject);
                equipableSlot.CurrentEquip = null;
            }
            var equipableItem = equipableSlot.ItemReference as ItemEquipable;

            if (equipableItem == null)
            {
                return;
            }
            equipableSlot.CurrentEquip = Instantiate(equipableItem.EquipItem, equipableSlot.SlotTransform);
            equipableSlot.CurrentEquip.transform.localPosition = Vector3.zero;
        }
Example #5
0
        protected override void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int key, ItemSlotData itemSlotData)
        {
            base.OnSlotChanged(op, key, itemSlotData);
            if (itemSlotData.SlotType == ItemSlotType.Any)
            {
                return;
            }
            SlotReferences.TryGetValue(itemSlotData.SlotType, out var equipmentSlotReference);
            InventorySlots.TryGetValue(key, out var itemSlot);
            var equipableSlot = itemSlot as SlotEquipable;

            switch (op)
            {
            case SyncDictionaryItemSlot.Operation.OP_ADD:
                InventorySlots.Add(key, new SlotEquipable(equipmentSlotReference.SlotTransform, itemSlotData, key));
                return;

            case SyncDictionaryItemSlot.Operation.OP_REMOVE:
                InventorySlots.Remove(key);
                return;
            }
            if (equipableSlot == null)
            {
                return;
            }
            equipableSlot.SlotData = itemSlotData;
            equipableSlot.OnSlotChange();

            EquipmentSlotChanged(itemSlotData, equipableSlot);
        }
Example #6
0
        protected virtual void OnSlotChanged(SyncDictionaryItemSlot.Operation op, int key, ItemSlotData itemSlotData)
        {
            if (itemSlotData.SlotType != ItemSlotType.Any)
            {
                return;
            }
            InventorySlots.TryGetValue(key, out var itemSlot);
            switch (op)
            {
            case SyncDictionaryItemSlot.Operation.OP_ADD:
                InventorySlots.Add(key, new Slot(_inventoryTransform, itemSlotData, key));
                return;

            case SyncDictionaryItemSlot.Operation.OP_REMOVE:
                InventorySlots.Remove(key);
                return;
            }
            if (itemSlot == null)
            {
                return;
            }
            itemSlot.SlotData = itemSlotData;
            itemSlot.OnSlotChange();
        }
Example #7
0
 public SlotEquipable(Transform slotTransform, ItemSlotData slotData, int slotIndex) : base(slotTransform, slotData, slotIndex)
 {
 }