/// <summary> /// 购买物品的按钮事件 /// </summary> private void buyItem() { if (Playerattribute.getInstance().GoldCoin < int.Parse(m_goldText.text)) { return; } if (m_playSlotQueue.Count != 0) { foreach (var item in m_playSlotQueue) { item.GetComponent <playerSlot>().setplayerSlot(-1, null); Destroy(item.transform.GetChild(0).gameObject); } m_playSlotQueue.Clear(); } if (PlayerSlotManager.instace.getNullSolt() == null) { return; } GameObject temp = Instantiate(m_itemImage).transform.gameObject; temp.transform.parent = PlayerSlotManager.instace.getNullSolt().transform; temp.transform.localPosition = Vector3.zero; temp.transform.localScale = Vector3.one; //CreatPlayerSlot.instace.getNullSolt().GetComponent<playerSlot>().isNull = 0; //CreatPlayerSlot.instace.getNullSolt().GetComponent<playerSlot>().item=item; PlayerSlotManager.instace.getNullSolt().GetComponent <playerSlot>().setplayerSlot(0, m_item); Playerattribute.getInstance().GoldCoin -= int.Parse(m_goldText.text); hideTool(); }
public static Playerattribute getInstance() { if (instance == null) { instance = new Playerattribute(); } return(instance); }
/// <summary> /// 操作按钮的事件 /// </summary> private void Caozuo() { //点击预购按钮执行的事件 if (m_caozuo.GetComponentInChildren <Text>().text == "预购") { InventroyManager.instance.setPrepurchase(m_fatherItem); itemObjectpoolManager.instance.setCompositechildslotpool(); itemObjectpoolManager.instance.setLinepool(); hideTool(); } //点击出售按钮执行的事件 else { Playerattribute.getInstance().GoldCoin += m_item.SellPrice; m_sellItem.GetComponent <playerSlot>().isNull = -1; Destroy(m_sellItem.transform.GetChild(0).gameObject); hideTool(); } }
// Start is called before the first frame update void Start() { _playerattribute = Playerattribute.getInstance(); _GoldText = GetComponent <Text>(); }
public void addGold() { Playerattribute.getInstance().GoldCoin += 1000; }