예제 #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);
        }
예제 #2
0
 public void UnEquipItem(EquipmentItem item)
 {
     foreach (ObjectProperty property in item.GetProperties())
     {
         if (property.SerializedType == typeof(int) || property.SerializedType == typeof(float))
         {
             SendMessage("RemoveModifiersFromSource", new object[] { property.Name, 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.OnItemUnEquip(item);
             break;
         }
     }
 }
 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;
         }
     }
 }