Пример #1
0
        public void EquipItem(EquipmentItem item)
        {
            foreach (ObjectProperty property in item.GetProperties())
            {
                if (property.SerializedType == typeof(int) || property.SerializedType == typeof(float))
                {
                    float value = System.Convert.ToSingle(property.GetValue());
                    SendMessage("AddModifier", new object[] { property.Name, value, (value <= 1f && value >= -1f) ? 1 : 0, item }, SendMessageOptions.DontRequireReceiver);
                }
            }

            for (int i = 0; i < this.m_VisibleItems.Count; i++)
            {
                VisibleItem visibleItem = this.m_VisibleItems[i];
                if (visibleItem.item.Id == item.Id)
                {
                    visibleItem.OnItemEquip(item);
                    return;
                }
            }

            StaticItem staticItem = gameObject.AddComponent <StaticItem>();

            staticItem.item = InventoryManager.Database.items.Find(x => x.Id == item.Id);
            VisibleItem.Attachment attachment = new VisibleItem.Attachment();
            attachment.prefab      = item.EquipPrefab;
            attachment.region      = item.Region[0];
            staticItem.attachments = new VisibleItem.Attachment[1] {
                attachment
            };
            staticItem.OnItemEquip(item);
        }
 public void EquipItem(EquipmentItem item)
 {
     foreach (ObjectProperty property in item.GetProperties())
     {
         if (property.SerializedType == typeof(int) || property.SerializedType == typeof(float))
         {
             float value = System.Convert.ToSingle(property.GetValue());
             SendMessage("AddModifier", new object[] { property.Name, value, (value <= 1f && value >= -1f) ? 1 : 0, item }, SendMessageOptions.DontRequireReceiver);
         }
     }
     for (int i = 0; i < this.m_VisibleItems.Count; i++)
     {
         VisibleItem visibleItem = this.m_VisibleItems[i];
         if (visibleItem.item.Id == item.Id)
         {
             visibleItem.OnItemEquip(item);
             break;
         }
     }
 }