Пример #1
0
    public void Detach_test()
    {
        Attachment attachment = new Attachment();

        attachment.Attach(GameObject.CreatePrimitive(PrimitiveType.Cube).transform, GetEquipmentFixture());
        Equipment equipment = attachment.Detach();

        Assert.That(equipment != null);
        Assert.That(equipment.Amount == 1);
        Assert.That(equipment.EquipmentData.ID == "leather_boots");
        Assert.That(!attachment.IsAttached);
    }
Пример #2
0
 void Start()
 {
     mouse = GetComponent <ClingyMouse>();
     mouse.events.OnMouse0Down.AddListener(info => {
         Collider2D coll = Physics2D.OverlapPoint(transform.position);
         if (!coll)
         {
             return;
         }
         attachment = Clingy.AttachOneToOne(dragStrategy, gameObject, coll.gameObject);
     });
     mouse.events.OnMouse0Up.AddListener(info => {
         if (attachment != null)
         {
             attachment.Detach();
             attachment = null;
         }
     });
 }
Пример #3
0
            /// <summary>
            /// Unequip method that detach the equipment from the body.
            /// </summary>
            /// <param name="attachment">The attachment</param>
            /// <param name="equipment">The equipment that is attached, if successful.</param>
            /// <returns>Return true, if there is an equipment attached.</returns>
            private bool Unequip(Attachment attachment, out Equipment equipment)
            {
                if (!attachment.IsAttached)
                {
                    equipment = null;
                    return(false);
                }

                equipment = attachment.Detach();

                if (!ReferenceEquals(equipment, null) && equipment.EquipmentData.HideBodyPart)
                {
                    _actor.Body.DisplayBodyParts(equipment.EquipmentData.SlotType, true);
                }

                _actor.Statistics.UpdateStatistics(equipment.EquipmentData.EquipmentStats.Statistics, false);

                OnEquipmentRemovedEvent?.Invoke(equipment);

                return(true);
            }