public void EquipArmor(ArmorEquipment newItem) { Equipment oldItem = null; // Find out what slot the item fits in // and put it there. int slotIndex = (int)newItem.equipSlot; // If there was already an item in the slot // make sure to put it back in the inventory if (currentArmor != null) { oldItem = currentArmor; inventory.Add(oldItem); } // An item has been equipped so we trigger the callback if (onEquipmentChanged != null) { onEquipmentChanged.Invoke(newItem, oldItem); } currentArmor = newItem; Debug.Log(newItem.name + " equipped!"); InitializeArmor(newItem); }
public void SandMake() { GameObject btn = Instantiate(m_BtnObj); GameObject btn_2 = Instantiate(m_BtnObj); if (m_DicBtnType[m_BtnObj] == 1) { WeaponEquipment weanponEquipment = btn.GetComponent <WeaponEquipment>(); //btn_2를 주는 이유는 장착시 스크린에서도 없애기 위한 부분 weanponEquipment.Init(m_Inventory, btn_2); btn_2.AddComponent <ReturnItem>().Init(this, weanponEquipment.m_nMoney, btn); btn.transform.SetParent(m_Inventory.m_AttackScreen.transform); btn_2.transform.SetParent(m_InventoryShow.m_AttackScreenObj.transform); m_InventoryShow.AttackBtn(); } else if (m_DicBtnType[m_BtnObj] == 2) { ArmorEquipment armorEquipment = btn.GetComponent <ArmorEquipment>(); armorEquipment.Init(m_Inventory, btn_2); btn_2.AddComponent <ReturnItem>().Init(this, armorEquipment.m_nMoney, btn); btn.transform.SetParent(m_Inventory.m_DefenseScreen.transform); btn_2.transform.SetParent(m_InventoryShow.m_DefenseScreenObj.transform); m_InventoryShow.DefenseBtn(); } btn.transform.localScale = new Vector3(0.14f, 0.15f, 0.14f); btn.GetComponent <RectTransform>().pivot = new Vector2(0, 0.79f); btn_2.transform.localScale = new Vector3(0.14f, 0.20f, 0.14f); btn_2.transform.GetChild(0).localScale = new Vector3(1.1f, 0.8f, 0.14f); btn_2.GetComponent <RectTransform>().pivot = new Vector2(0, 1.35f); m_Inventory.SetMoney(m_Inventory.m_Money - m_nPrice); m_InventoryShow.m_MoneyTxt.text = m_Inventory.m_Money.ToString(); m_Inventory.SetMoney(); m_PortionMenu.OtherMoney(); m_AskBuy.SetActive(false); AudioManager.Instance.PlayEffect(0); }
void InitializeArmor(ArmorEquipment item) { PlayerAnimationController.Instance.SetArmorLayerWeight(item.skinLayer); }
private void GetEquipment() { currentWeapon = EquipmentManager.Instance.GetWeapon(); currentArmor = EquipmentManager.Instance.GetArmor(); }