public XElement ToXML() { return(new XElement("Equipment", new XElement("OccupiesSlots", from a in OccupiesSlots select a.ToXML()), new XElement("CoversSlots", from a in CoversSlots select a.ToXML()), new XElement("OnEquip", OnEquip.ToXML()), new XElement("OnUnequip", OnUnequip.ToXML()), new XElement("OnMove", OnMove.ToXML()))); }
public void Equip(InventoryItem inventoryItem) { string equipmentType = inventoryItem.definition.GetStaticProperty("equipmentType").AsString(); if (items.IsSlotSet(equipmentType)) { UnEquip(items.Get(equipmentType)); } items.Set(equipmentType, inventoryItem); OnEquip?.Invoke(inventoryItem); }
public void EquipItem(NPCSlots slot, ItemInst item) { if (item.BaseInst.Slot == (int)slot) { return; } BaseInst.EquipItem((int)slot, item.BaseInst); OnEquip?.Invoke(item); }
public void EquipItem(NPCSlots slot, ItemInst item) { if (item.BaseInst.Slot == (int)slot) { return; } pBeforeEquip(slot, item); this.BaseInst.EquipItem((int)slot, item.BaseInst); pAfterEquip(slot, item); OnEquip?.Invoke(item); }
public void Equip(GameObject prefab) { GameObject clone = Instantiate(prefab); clone.name = clone.name.Replace("(Clone)", string.Empty); clone.transform.SetParent(transform); EquipmentData equipmentData = clone.GetComponent <EquipmentData>(); if (equipmentData == null) { Destroy(clone); throw new Exception("Invalid object"); } //Unequip old Unequip(equipmentData.Slots); //Equip if (Application.isPlaying) { Destroy(clone.transform.GetChild(0).gameObject); } else { DestroyImmediate(clone.transform.GetChild(0).gameObject); } List <SkinnedMeshRenderer> childrenRenderers = new List <SkinnedMeshRenderer>(clone.GetComponentsInChildren <SkinnedMeshRenderer>()); foreach (SkinnedMeshRenderer skinnedMeshRenderer in childrenRenderers) { var skinBones = skinnedMeshRenderer.bones; skinnedMeshRenderer.rootBone = bonesIndex[skinnedMeshRenderer.rootBone.name]; List <Transform> nBones = new List <Transform>(); foreach (Transform skinBone in skinBones) { nBones.Add(bonesIndex[skinBone.name]); } skinnedMeshRenderer.bones = nBones.ToArray(); } foreach (EquipmentSlot dataSlot in equipmentData.Slots) { slotToGameobjectDictionary.Add(dataSlot, clone); OnEquip?.Invoke(dataSlot, equipmentData); } equipment.Add(clone); }
public virtual void Equip(EntityEquipable eq) { if (eq == null) { return; } if (GetEquipped(eq.Type) != null) { Unequip(eq.Type); } SetEquipped(eq.Type, eq); OnEquip.Invoke(master, eq); }
public void Equip(WeaponData weaponData) { GameObject go = Instantiate(weaponData.gameObject); weaponData = go.GetComponent <WeaponData>(); if (_dictionary.ContainsKey(weaponData.equipmentSlot)) { Unequip(weaponData.equipmentSlot); } _dictionary.Add(weaponData.equipmentSlot, weaponData); go.transform.SetParent(GetTransformFromEquipmentSlot(weaponData)); go.transform.localRotation = Quaternion.identity; go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; OnEquip?.Invoke(weaponData); }
internal void InvokeOnEquip(int slot) { OnEquip?.Invoke(slot); }
private void UnsubscribeToEquipEvents() { OnEquip.Unsubscribe(OnEquipNet); OnUnequip.Unsubscribe(OnUnequipNet); }
private void SubscribeToEquipEvents() { OnEquip.SafeSubscribe(OnEquipNet); OnUnequip.SafeSubscribe(OnUnequipNet); }
void Start() { OnEquip.Invoke(); gun = player.GetComponent <GunManager>(); }