public ItemIconPickUpImplementor CreateIIPUImplementor(int transferableQuantity, int itemQuantity, int pickUpStepQuantity, out IItemIcon ii, out IItemIconTransactionManager iiTAM, out IPickUpSystemUIElementFactory uieFactory)
    {
        IItemIcon thisII = Substitute.For <IItemIcon>();

        thisII.GetUIImage().Returns(Substitute.For <IUIImage>());
        IItemTemplate itemTemp = Substitute.For <IItemTemplate>();

        itemTemp.GetPickUpStepQuantity().Returns(pickUpStepQuantity);
        // thisII.GetItemTemplate().Returns(itemTemp);
        IUIItem item = Substitute.For <IUIItem>();

        item.GetItemTemplate().Returns(itemTemp);
        thisII.GetUIItem().Returns(item);
        thisII.GetTransferableQuantity().Returns(transferableQuantity);
        thisII.GetItemQuantity().Returns(itemQuantity);
        thisII.GetIconGroup().Returns(Substitute.For <IIconGroup>());
        IItemIconTransactionManager   thisIITAM      = Substitute.For <IItemIconTransactionManager>();
        IPickUpSystemUIElementFactory thisUIEFactory = Substitute.For <IPickUpSystemUIElementFactory>();
        ItemIconPickUpImplementor     implementor    = new ItemIconPickUpImplementor(thisIITAM, thisUIEFactory);

        implementor.SetItemIcon(thisII);
        ii         = thisII;
        iiTAM      = thisIITAM;
        uieFactory = thisUIEFactory;
        return(implementor);
    }
示例#2
0
 public bool IsSameAs(IUIItem other)
 {
     /*  Ghost is treated as same, sharing the same item instance with picked
      */
     if (thisItemTemp.IsStackable())
     {
         return(thisItemTemp == other.GetItemTemplate());
     }
     else            /* non stackable */
     {
         return(thisItemID == other.GetItemID());
     }
 }
 protected override bool IsEligibleForHover(IItemIcon pickedII)
 {
     if (pickedII is IEquippableItemIcon)
     {
         IEquippableItemIcon pickedEqpII    = pickedII as IEquippableItemIcon;
         IUIItem             pickedItem     = pickedEqpII.GetUIItem();
         IItemTemplate       pickedItemTemp = pickedItem.GetItemTemplate();
         if (pickedEqpII.IsBowOrWearItemIcon())               // always swapped
         {
             return(true);
         }
         else
         {
             if (pickedEqpII.IsInEqpIG())
             {
                 return(true);                 //always revertable
             }
             else                              // pickd from pool
             {
                 if (pickedEqpII.IsEquipped()) //always has the same partially picked item
                 {
                     return(true);
                 }
                 else
                 {
                     IEquipToolIG relevantEqpIG = thisEqpIITAM.GetRelevantEquipIG(pickedEqpII);
                     if (relevantEqpIG.GetSize() == 1)                            //swap target is deduced
                     {
                         return(true);
                     }
                     else
                     {
                         if (relevantEqpIG.HasSlotSpace())                               //add target is deduced
                         {
                             return(true);
                         }
                         else
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         throw new System.ArgumentException("pickedII must be of type IEquippableItemIcon");
     }
 }
示例#4
0
    public void IsSameAs_ThisItemTempIsStackable_ThisItemTempNotRefEqualsToOtherItemTemp_ReturnsFalse()
    {
        IUIItemConstArg arg;
        TestItem        item         = CreateTestItem(1, 0, out arg);
        IItemTemplate   thisItemTemp = arg.itemTemp;

        thisItemTemp.IsStackable().Returns(true);
        IUIItem otherItem = Substitute.For <IUIItem>();

        otherItem.GetItemTemplate().Returns(Substitute.For <IItemTemplate>());

        bool actualBool = item.IsSameAs(otherItem);

        Assert.That(actualBool, Is.False);
    }
    public List <IItemIcon> CreateStubItemIconsWithItemTempsMatchingAt(int[] quantities, int[] sameAt, IItemTemplate sourceItemTemp)
    {
        List <IItemIcon> result = new List <IItemIcon>();
        int index = -1;

        foreach (int i in quantities)
        {
            index++;
            IItemIcon ii      = Substitute.For <IItemIcon>();
            IUIItem   tarItem = Substitute.For <IUIItem>();
            if (i == -1)
            {
                ii.IsEmpty().Returns(true);
                ii.GetUIItem().Returns((IUIItem)null);
                ii.GetItemTemplate().Returns((IItemTemplate)null);
            }
            else
            {
                ii.IsEmpty().Returns(false);
                tarItem.GetQuantity().Returns(i);
                IItemTemplate tarItemTemp = Substitute.For <IItemTemplate>();
                tarItem.GetItemTemplate().Returns(tarItemTemp);
                bool contained = false;
                foreach (int j in sameAt)
                {
                    if (j == index)
                    {
                        contained = true;
                    }
                }
                if (contained)
                {
                    tarItemTemp.IsSameAs(sourceItemTemp).Returns(true);
                }
                else
                {
                    tarItemTemp.IsSameAs(sourceItemTemp).Returns(false);
                }
                ii.GetUIItem().Returns(tarItem);
                ii.GetItemTemplate().Returns(tarItemTemp);
            }
            result.Add(ii);
        }
        return(result);
    }