Пример #1
0
        private void LeftClickItemIcon(object[] eventParams)
        {
            Debug.Assert(eventParams.Length == 1 && eventParams[0] is ItemIcon);
            ItemIcon     itemIcon     = (ItemIcon)eventParams[0];
            SlotPosition slotPosition = itemIcon.Position;
            IPickupable  pickupable   = itemIcon.Item as IPickupable;
            IEquipable   equipable    = itemIcon.Item as IEquipable;

            if (_airItem.IsEmpty)
            {
                if (itemIcon.IsEquipmentIcon)
                {
                    equipable.OnUnequip(_equipment, _stats);
                }
                else if (itemIcon.Item is IStackable)
                {
                    EventManager.TriggerEvent(EventName.OPEN_SPLIT_SCREEN, eventParams);
                    return;
                }
                else
                {
                    pickupable.OnRemoveFromInventory(_inventory, slotPosition);
                }
                pickupable.OnPutInAir(_airItem, slotPosition);
            }
            else
            {
                IPickupable pickupableAir = _airItem.Item as IPickupable;
                if (slotPosition.RowIndex == EquipmentSlot.EQUIPMENT_SLOT_ROW_INDEX)
                {
                    IEquipable equipableAir = _airItem.Item as IEquipable;
                    if (equipableAir == null)
                    {
                        Debug.Log("Not equipable");
                        return;
                    }
                    if ((Equipment.EquipmentType)slotPosition.SlotIndex != equipableAir.EquipmentType)
                    {
                        Debug.Log("Not the same equipment type");
                        return;
                    }
                    if (equipable.IsDurable == false)
                    {
                        Debug.Log("Not durable");
                    }
                    equipable.OnUnequip(_equipment, _stats);
                    pickupableAir.OnRemoveFromAir(_airItem);
                    equipableAir.OnEquip(_equipment, _stats);
                    pickupable.OnPutInAir(_airItem, slotPosition);
                }
                else
                {
                    pickupable.OnRemoveFromInventory(_inventory, slotPosition);
                    pickupableAir.OnRemoveFromAir(_airItem);
                    pickupableAir.OnPutInInventory(_inventory, slotPosition);
                    pickupable.OnPutInAir(_airItem, slotPosition);
                }
            }
        }
Пример #2
0
        private void LeftClickWorld(object[] eventParams)
        {
            if (_airItem.IsEmpty)
            {
                return;
            }

            IPickupable pickupableAir = _airItem.Item as IPickupable;

            pickupableAir.OnRemoveFromAir(_airItem);
            pickupableAir.OnPutOnGround(transform.position);
        }
Пример #3
0
        private void LeftClickItemSlot(object[] eventParams)
        {
            Debug.Assert(eventParams.Length == 1 && eventParams[0] is SlotPosition);
            SlotPosition slotPosition = (SlotPosition)eventParams[0];

            if (_airItem.IsEmpty)
            {
                return;
            }

            IPickupable pickupable = _airItem.Item as IPickupable;

            if (slotPosition.RowIndex == EquipmentSlot.EQUIPMENT_SLOT_ROW_INDEX)
            {
                IEquipable equipable = _airItem.Item as IEquipable;
                if (equipable == null)
                {
                    Debug.Log("Not equipable");
                    return;
                }
                if ((Equipment.EquipmentType)slotPosition.SlotIndex != equipable.EquipmentType)
                {
                    Debug.Log("Not the same equipment type");
                    return;
                }
                if (equipable.IsDurable == false)
                {
                    Debug.Log("Not durable");
                }
                pickupable.OnRemoveFromAir(_airItem);
                equipable.OnEquip(_equipment, _stats);
            }
            else
            {
                pickupable.OnRemoveFromAir(_airItem);
                pickupable.OnPutInInventory(_inventory, slotPosition);
            }
        }
Пример #4
0
        private void ReturnAirItem(object[] eventParams)
        {
            if (_airItem.IsEmpty)
            {
                return;
            }

            SlotPosition originalPosition = _airItem.OriginalPosition;
            Item         itemAir          = _airItem.Item;
            IPickupable  pickupableAir    = itemAir as IPickupable;
            IEquipable   equipableAir     = itemAir as IEquipable;
            IStackable   stackableAir     = itemAir as IStackable;

            pickupableAir.OnRemoveFromAir(_airItem);

            if (originalPosition.RowIndex == EquipmentSlot.EQUIPMENT_SLOT_ROW_INDEX)
            {
                Equipment.EquipmentType equipmentType = (Equipment.EquipmentType)originalPosition.SlotIndex;

                if (_equipment.EquipmentTable[equipmentType].IsEmpty)
                {
                    equipableAir.OnEquip(_equipment, _stats);
                }
                else
                {
                    pickupableAir.OnPutInInventory(_inventory);
                }
            }
            else
            {
                if (stackableAir != null)
                {
                    stackableAir.OnStack(_inventory, originalPosition);
                }
                else if (_inventory.IsItemEmpty(originalPosition))
                {
                    pickupableAir.OnPutInInventory(_inventory, originalPosition);
                }
                else
                {
                    pickupableAir.OnPutInInventory(_inventory);
                }
            }
        }